pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38893?usp=email )
Change subject: stream_cli: Announce failed connect() if reconnect is disabled ......................................................................
stream_cli: Announce failed connect() if reconnect is disabled
One of the use cases of disabling reconnect in osmo_stream_cli is because the user of the stream wants to control the reconnect based on upper layer contexts. In this case, though, if there's a failure during connect() time, the user won't get any notification and hence stay disconnected forever. Instead, inform the user through the disconnect_cb().
Change-Id: I69a5f7c3c7cea97d31e2fa03e8c32ce806285eb6 --- M src/stream_cli.c 1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/93/38893/1
diff --git a/src/stream_cli.c b/src/stream_cli.c index 25dda4f..807f062 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -207,7 +207,10 @@
cli->state = STREAM_CLI_STATE_CLOSED;
- if (old_state == STREAM_CLI_STATE_CONNECTED) { + /* If conn was established, notify the disconnection to the user: + * Also, if reconnect is disabled by user, notify the user that connect() failed: */ + if (old_state == STREAM_CLI_STATE_CONNECTED || + (old_state == STREAM_CLI_STATE_CONNECTING && cli->reconnect_timeout < 0)) { LOGSCLI(cli, LOGL_DEBUG, "connection closed\n"); if (cli->disconnect_cb) cli->disconnect_cb(cli);