Fix: honor send timeout on unix socket connect
[lttng-ust.git] / liblttng-ust-comm / lttng-ust-comm.c
index cee1b694333c8a264955c079692908ff6b49d792..d065499a246320f9dc2e00c7403471d3a35123e1 100644 (file)
@@ -86,7 +86,7 @@ const char *lttng_ust_strerror(int code)
  *
  * Connect to unix socket using the path name.
  */
-int ustcomm_connect_unix_sock(const char *pathname)
+int ustcomm_connect_unix_sock(const char *pathname, long timeout)
 {
        struct sockaddr_un sun;
        int fd, ret;
@@ -101,6 +101,15 @@ int ustcomm_connect_unix_sock(const char *pathname)
                ret = -errno;
                goto error;
        }
+       if (timeout >= 0) {
+               /* Give at least 10ms. */
+               if (timeout < 10)
+                       timeout = 10;
+               ret = ustcomm_setsockopt_snd_timeout(fd, timeout);
+               if (ret < 0) {
+                       WARN("Error setting connect socket send timeout");
+               }
+       }
        ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
        if (ret < 0) {
                PERROR("fcntl");
This page took 0.0235 seconds and 4 git commands to generate.