<p>Max <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/12760">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Stream client: fix disconnection logic<br><br>Previously closing the client did not alter its state, so we might<br>end-up with a client without any file descriptors, but being in state<br>STREAM_CLI_STATE_CONNECTED. Fix this inconsistency by setting<br>appropriate state.<br><br>Related issue is that reconnect function, which is always (at least in<br>the library and examples) called when some problem with the connection<br>is detected, closed the connection only after checking whether<br>reconnection is enabled. This might result in another inconsistency<br>fixed in this patch by moving the check below connection cleanup.<br><br>While at it, also move connection close logging to appropriate place:<br>it's confusing to see logs about connection being closed while in<br>reality it wasn't even established.<br><br>Change-Id: If41ed60bd625488c283d1e8a2b078e640f04c78e<br>---<br>M src/stream.c<br>1 file changed, 8 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/stream.c b/src/stream.c</span><br><span>index 7cc77c9..7b97d2a 100644</span><br><span>--- a/src/stream.c</span><br><span>+++ b/src/stream.c</span><br><span>@@ -169,12 +169,13 @@</span><br><span>  *  connection (if any) and schedule a re-connect timer */</span><br><span> void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+       osmo_stream_cli_close(cli);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        if (cli->reconnect_timeout < 0) {</span><br><span>              LOGSCLI(cli, LOGL_DEBUG, "not reconnecting, disabled.\n");</span><br><span>                 return;</span><br><span>      }</span><br><span style="color: hsl(0, 100%, 40%);">-       LOGSCLI(cli, LOGL_DEBUG, "connection closed\n");</span><br><span style="color: hsl(0, 100%, 40%);">-      osmo_stream_cli_close(cli);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        LOGSCLI(cli, LOGL_DEBUG, "retrying in %d seconds...\n",</span><br><span>            cli->reconnect_timeout);</span><br><span>  osmo_timer_schedule(&cli->timer, cli->reconnect_timeout, 0);</span><br><span>@@ -192,6 +193,11 @@</span><br><span>        osmo_fd_unregister(&cli->ofd);</span><br><span>        close(cli->ofd.fd);</span><br><span>       cli->ofd.fd = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if (cli->state == STREAM_CLI_STATE_CONNECTED)</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGSCLI(cli, LOGL_DEBUG, "connection closed\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  cli->state = STREAM_CLI_STATE_NONE;</span><br><span> }</span><br><span> </span><br><span> static void osmo_stream_cli_read(struct osmo_stream_cli *cli)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12760">change 12760</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12760"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-netif </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: If41ed60bd625488c283d1e8a2b078e640f04c78e </div>
<div style="display:none"> Gerrit-Change-Number: 12760 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pablo Neira Ayuso <pablo@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>