From 781e7b38f87b1a8a4ddf65a040935750aabc2b6e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 17 Mar 2017 00:14:38 +0100 Subject: stream_client: Actually use/honor the reconect parameter The reconnect behavior was likely broken in commit de3f57a8293a5b39435d6f283da23e0172bad8bb If the user requests a re-connect, we should start it. Not only in case the connection drops later, but also if the initial connection itself fails. Change-Id: I817e026404cbd9145cae2ce90bc57a1db1d2e12b --- src/stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index a30fd04..d72d800 100644 --- a/src/stream.c +++ b/src/stream.c @@ -308,8 +308,11 @@ int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect) ret = osmo_sock_init(AF_INET, SOCK_STREAM, cli->proto, cli->addr, cli->port, OSMO_SOCK_F_CONNECT); - if (ret < 0) + if (ret < 0) { + if (reconnect && errno == ECONNREFUSED) + osmo_stream_cli_reconnect(cli); return ret; + } cli->ofd.fd = ret; if (osmo_fd_register(&cli->ofd) < 0) { -- cgit v1.2.3