From: Jonathan Rajotte Date: Wed, 21 Feb 2018 03:06:31 +0000 (-0500) Subject: Fix: set errno with value from SO_ERROR on error. X-Git-Tag: v2.10.3~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dfe758f3f476a983f277ebda23cf7ce41b0daa69;p=lttng-tools.git Fix: set errno with value from SO_ERROR on error. Debugging output at the same time in case of asynchronous handling. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index 25dbd2195..ed7f5dc16 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -176,6 +176,8 @@ int connect_with_timeout(struct lttcomm_sock *sock) goto success; } + DBG("Asynchronous connect for sock %d, performing polling with" + " timeout: %lums", sock->fd, timeout); /* * Perform poll loop following EINPROGRESS recommendation from * connect(2) man page. @@ -202,12 +204,15 @@ int connect_with_timeout(struct lttcomm_sock *sock) ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &optval, &optval_len); if (ret) { + PERROR("getsockopt"); goto error; } if (!optval) { connect_ret = 0; goto success; } else { + /* Get actual connect() errno from opt_val */ + errno = optval; goto error; } } diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c index 0b0383cdd..1fd18a962 100644 --- a/src/common/sessiond-comm/inet6.c +++ b/src/common/sessiond-comm/inet6.c @@ -174,6 +174,9 @@ int connect_with_timeout(struct lttcomm_sock *sock) goto success; } + DBG("Asynchronous connect for sock %d, performing polling with" + " timeout: %lums", sock->fd, timeout); + /* * Perform poll loop following EINPROGRESS recommendation from * connect(2) man page. @@ -200,12 +203,15 @@ int connect_with_timeout(struct lttcomm_sock *sock) ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &optval, &optval_len); if (ret) { + PERROR("getsockopt"); goto error; } if (!optval) { connect_ret = 0; goto success; } else { + /* Get actual connect() errno from opt_val */ + errno = optval; goto error; } }