<p>Max has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12760">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Stream client: fix disconnection logic<br><br>Previously closing the client did not alter it's state so might end-up<br>with a client without any file descriptors but in<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>Change-Id: If41ed60bd625488c283d1e8a2b078e640f04c78e<br>---<br>M src/stream.c<br>1 file changed, 5 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/60/12760/1</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 902e688..af457dd 100644</span><br><span>--- a/src/stream.c</span><br><span>+++ b/src/stream.c</span><br><span>@@ -159,12 +159,14 @@</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%);">+       LOGP(DLINP, LOGL_DEBUG, "connection closed\n");</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>              LOGP(DLINP, LOGL_DEBUG, "not reconnecting, disabled.\n");</span><br><span>          return;</span><br><span>      }</span><br><span style="color: hsl(0, 100%, 40%);">-       LOGP(DLINP, 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>        LOGP(DLINP, 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>@@ -182,6 +184,7 @@</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%);">+  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: newchange </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: 1 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>