Fix: set errno with value from SO_ERROR on error.
[lttng-tools.git] / src / common / sessiond-comm / inet.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;
                        }
                }
This page took 0.022989 seconds and 4 git commands to generate.