X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=5dc1d92b40685598e1c841b8d3128073aeed65ba;hp=ef0d4b7bb3f2edaf073b2215843cf7fc17d9a6e3;hb=d96f09c69037dc2437ff85d8311257b87aee38d3;hpb=79d4ffb7115aa6bd499caeadc3e6c58c36d86864 diff --git a/src/common/consumer.c b/src/common/consumer.c index ef0d4b7bb..5dc1d92b4 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -2454,7 +2454,7 @@ end: */ void *consumer_thread_sessiond_poll(void *data) { - int sock, client_socket, ret; + int sock = -1, client_socket, ret; /* * structure to poll for incoming data on communication socket avoids * making blocking sockets. @@ -2514,6 +2514,13 @@ void *consumer_thread_sessiond_poll(void *data) goto end; } + /* This socket is not useful anymore. */ + ret = close(client_socket); + if (ret < 0) { + PERROR("close client_socket"); + } + client_socket = -1; + /* update the polling structure to poll on the established socket */ consumer_sockpoll[1].fd = sock; consumer_sockpoll[1].events = POLLIN | POLLPRI; @@ -2557,6 +2564,20 @@ end: */ notify_thread_pipe(ctx->consumer_data_pipe[1]); + /* Cleaning up possibly open sockets. */ + if (sock >= 0) { + ret = close(sock); + if (ret < 0) { + PERROR("close sock sessiond poll"); + } + } + if (client_socket >= 0) { + ret = close(sock); + if (ret < 0) { + PERROR("close client_socket sessiond poll"); + } + } + rcu_unregister_thread(); return NULL; }