X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=70c194b226cc2c90dff6f5fee045b036178f2cf3;hp=153b215c08c0277f31930afbe86ad95193689665;hb=050349bbb362ea993533591532643022efeab864;hpb=283046e084c1461001c8584c5b4adada02265496 diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 153b215c0..70c194b22 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -753,6 +753,25 @@ static void *thread_manage_kconsumerd(void *data) goto error; } + /* Kconsumerd err socket */ + pollfd[1].fd = sock; + pollfd[1].events = POLLIN; + + /* Inifinite blocking call, waiting for transmission */ + ret = poll(pollfd, 2, -1); + if (ret < 0) { + perror("poll kconsumerd thread"); + goto error; + } + + /* Thread quit pipe has been closed. Killing thread. */ + if (pollfd[0].revents == POLLNVAL) { + goto error; + } else if (pollfd[1].revents == POLLERR) { + ERR("Kconsumerd err socket second poll error"); + goto error; + } + /* Wait for any kconsumerd error */ ret = lttcomm_recv_unix_sock(sock, &code, sizeof(enum lttcomm_return_code)); if (ret <= 0) { @@ -840,10 +859,10 @@ static void *thread_manage_apps(void *data) } /* - * Basic recv here to handle the very simple data - * that the libust send to register (reg_msg). + * Using message-based transmissions to ensure we don't + * have to deal with partially received messages. */ - ret = recv(sock, ®_msg, sizeof(reg_msg), 0); + ret = lttcomm_recv_unix_sock(sock, ®_msg, sizeof(reg_msg)); if (ret < 0) { perror("recv"); continue; @@ -852,6 +871,11 @@ static void *thread_manage_apps(void *data) /* Add application to the global traceable list */ if (reg_msg.reg == 1) { /* Registering */ + /* + * TODO: socket should be either passed to a + * listener thread (for more messages) or + * closed. It currently leaks. + */ ret = register_traceable_app(reg_msg.pid, reg_msg.uid); if (ret < 0) { /* register_traceable_app only return an error with