session CHANGE make all the communication non-blocking
For all the timeouts to make sense.
diff --git a/src/session_client.c b/src/session_client.c
index fbb270b..614779e 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -376,7 +376,7 @@
int
nc_sock_connect(const char* host, uint16_t port)
{
- int i, sock = -1;
+ int i, sock = -1, flags;
struct addrinfo hints, *res_list, *res;
char port_s[6]; /* length of string representation of short int */
@@ -409,6 +409,12 @@
goto errloop;
}
+ /* make the socket non-blocking */
+ if (((flags = fcntl(sock, F_GETFL)) == -1) || (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1)) {
+ ERR("Fcntl failed (%s).", strerror(errno));
+ return -1;
+ }
+
/* we're done, network connection established */
break;
errloop:
@@ -976,12 +982,12 @@
#ifdef NC_ENABLED_SSH
if (client_opts.ch_binds[idx].ti == NC_TI_LIBSSH) {
- *session = nc_accept_callhome_ssh_sock(sock, host, port, ctx);
+ *session = nc_accept_callhome_ssh_sock(sock, host, port, ctx, NC_TRANSPORT_TIMEOUT);
} else
#endif
#ifdef NC_ENABLED_TLS
if (client_opts.ch_binds[idx].ti == NC_TI_OPENSSL) {
- *session = nc_accept_callhome_tls_sock(sock, host, port, ctx);
+ *session = nc_accept_callhome_tls_sock(sock, host, port, ctx, NC_TRANSPORT_TIMEOUT);
} else
#endif
{