X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-comm.c;h=86af682b110024c5b1c6f73bb4b34d4ccc29d648;hb=a0a3bef9e447a220a36fb7cb4c3f60e4eafdec4d;hp=1f60f86dcb4c4287b9690b7fcfd974fb960e5ab1;hpb=ff51799104d4b7255b7e00c839260fd4650e5113;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 1f60f86d..86af682b 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -178,10 +178,14 @@ static const char *str_timeout; static int got_timeout_env; extern void lttng_ring_buffer_client_overwrite_init(void); +extern void lttng_ring_buffer_client_overwrite_rt_init(void); extern void lttng_ring_buffer_client_discard_init(void); +extern void lttng_ring_buffer_client_discard_rt_init(void); extern void lttng_ring_buffer_metadata_client_init(void); extern void lttng_ring_buffer_client_overwrite_exit(void); +extern void lttng_ring_buffer_client_overwrite_rt_exit(void); extern void lttng_ring_buffer_client_discard_exit(void); +extern void lttng_ring_buffer_client_discard_rt_exit(void); extern void lttng_ring_buffer_metadata_client_exit(void); /* @@ -393,7 +397,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 +471,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 +500,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 +639,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"); } @@ -926,7 +933,6 @@ restart: } /* Register */ - timeout = get_notify_sock_timeout(); for (i = 0; i < 2; i++) { ret = ustcomm_connect_unix_sock(sock_info->sock_path); if (ret < 0) { @@ -942,33 +948,33 @@ restart: goto restart; } open_sock[i] = ret; - if (timeout > 0) { - ret = ustcomm_setsockopt_rcv_timeout(open_sock[i], - timeout); - if (ret < 0) { - WARN("Error setting socket receive timeout"); - } - ret = ustcomm_setsockopt_snd_timeout(open_sock[i], - timeout); - if (ret < 0) { - WARN("Error setting socket send timeout"); - } - } else if (timeout == -1) { - ret = fcntl(open_sock[i], F_SETFL, O_NONBLOCK); - if (ret < 0) { - WARN("Error setting socket to non-blocking"); - } - } else { - if (timeout != 0) { - WARN("Unsuppoorted timeout value %ld", - timeout); - } - } } sock_info->socket = open_sock[0]; sock_info->notify_socket = open_sock[1]; + timeout = get_notify_sock_timeout(); + 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) { + WARN("Error setting socket receive timeout"); + } + ret = ustcomm_setsockopt_snd_timeout(sock_info->notify_socket, + timeout); + if (ret < 0) { + WARN("Error setting socket send timeout"); + } + } else if (timeout < -1) { + WARN("Unsuppoorted timeout value %ld", timeout); + } + /* * Create only one root handle per listener thread for the whole * process lifetime, so we ensure we get ID which is statically @@ -1114,7 +1120,10 @@ void __attribute__((constructor)) lttng_ust_init(void) init_tracepoint(); lttng_ring_buffer_metadata_client_init(); lttng_ring_buffer_client_overwrite_init(); + lttng_ring_buffer_client_overwrite_rt_init(); lttng_ring_buffer_client_discard_init(); + lttng_ring_buffer_client_discard_rt_init(); + lttng_context_init(); timeout_mode = get_constructor_timeout(&constructor_timeout); @@ -1217,7 +1226,10 @@ void lttng_ust_cleanup(int exiting) */ lttng_ust_abi_exit(); lttng_ust_events_exit(); + lttng_context_exit(); + lttng_ring_buffer_client_discard_rt_exit(); lttng_ring_buffer_client_discard_exit(); + lttng_ring_buffer_client_overwrite_rt_exit(); lttng_ring_buffer_client_overwrite_exit(); lttng_ring_buffer_metadata_client_exit(); exit_tracepoint();