Add channel wakeup fd to monitor close
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index e2f94cfdd56de8fa2231e854d291c3c6f3d1c24d..d91f4bd255a993fc1f8699a3deed4f1cf8a6dba9 100644 (file)
@@ -393,7 +393,7 @@ int handle_message(struct sock_info *sock_info,
                if (lum->handle == LTTNG_UST_ROOT_HANDLE)
                        ret = -EPERM;
                else
-                       ret = lttng_ust_objd_unref(lum->handle);
+                       ret = lttng_ust_objd_unref(lum->handle, 1);
                break;
        case LTTNG_UST_FILTER:
        {
@@ -467,9 +467,11 @@ int handle_message(struct sock_info *sock_info,
        case LTTNG_UST_CHANNEL:
        {
                void *chan_data;
+               int wakeup_fd;
 
                len = ustcomm_recv_channel_from_sessiond(sock,
-                               &chan_data, lum->u.channel.len);
+                               &chan_data, lum->u.channel.len,
+                               &wakeup_fd);
                switch (len) {
                case 0: /* orderly shutdown */
                        ret = 0;
@@ -494,6 +496,7 @@ int handle_message(struct sock_info *sock_info,
                        }
                }
                args.channel.chan_data = chan_data;
+               args.channel.wakeup_fd = wakeup_fd;
                if (ops->cmd)
                        ret = ops->cmd(lum->handle, lum->cmd,
                                        (unsigned long) &lum->u,
@@ -632,7 +635,7 @@ void cleanup_sock_info(struct sock_info *sock_info, int exiting)
                sock_info->notify_socket = -1;
        }
        if (sock_info->root_handle != -1) {
-               ret = lttng_ust_objd_unref(sock_info->root_handle);
+               ret = lttng_ust_objd_unref(sock_info->root_handle, 1);
                if (ret) {
                        ERR("Error unref root handle");
                }
@@ -947,7 +950,13 @@ restart:
        sock_info->notify_socket = open_sock[1];
 
        timeout = get_notify_sock_timeout();
-       if (timeout > 0) {
+       if (timeout >= 0) {
+               /*
+                * Give at least 10ms to sessiond to reply to
+                * notifications.
+                */
+               if (timeout < 10)
+                       timeout = 10;
                ret = ustcomm_setsockopt_rcv_timeout(sock_info->notify_socket,
                                timeout);
                if (ret < 0) {
@@ -958,15 +967,8 @@ restart:
                if (ret < 0) {
                        WARN("Error setting socket send timeout");
                }
-       } else if (timeout == -1) {
-               ret = fcntl(sock_info->notify_socket, F_SETFL, O_NONBLOCK);
-               if (ret < 0) {
-                       WARN("Error setting socket to non-blocking");
-               }
-       } else {
-               if (timeout != 0) {
-                       WARN("Unsuppoorted timeout value %ld", timeout);
-               }
+       } else if (timeout < -1) {
+               WARN("Unsuppoorted timeout value %ld", timeout);
        }
 
        /*
This page took 0.024884 seconds and 4 git commands to generate.