Fix: set errno with value from SO_ERROR on error.
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 21 Feb 2018 03:06:31 +0000 (22:06 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 27 Feb 2018 15:09:15 +0000 (10:09 -0500)
Debugging output at the same time in case of asynchronous handling.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/sessiond-comm/inet.c
src/common/sessiond-comm/inet6.c

index 25dbd2195a9f936721fc158a7c94d29234d9206c..ed7f5dc165e1b3961a2f53ef3107a0f54db85472 100644 (file)
@@ -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;
                        }
                }
index 0b0383cdd524f77c7749d93aad2c5643937009ae..1fd18a96258382e408df8c30fe8e250b456cd11d 100644 (file)
@@ -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;
                        }
                }
This page took 0.027759 seconds and 4 git commands to generate.