X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmain.c;h=2ace82b966f9bb692e80591a38d28f6b22f28798;hb=9c9107228280bcffde8eb79cf8bb34c8208e04a4;hp=638f9a49020d847f536e2423679923c230290739;hpb=ceff174b5c719baf827b15d1f7082ea1a4fc0a9f;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 638f9a490..2ace82b96 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2027,6 +2027,22 @@ error: free(wait_node); } + /* Empty command queue. */ + for (;;) { + /* Dequeue command for registration */ + node = cds_wfcq_dequeue_blocking(&ust_cmd_queue.head, &ust_cmd_queue.tail); + if (node == NULL) { + break; + } + ust_cmd = caa_container_of(node, struct ust_command, node); + ret = close(ust_cmd->sock); + if (ret < 0) { + PERROR("close ust sock exit dispatch %d", ust_cmd->sock); + } + lttng_fd_put(LTTNG_FD_APPS, 1); + free(ust_cmd); + } + error_testpoint: DBG("Dispatch thread dying"); if (err) { @@ -5943,6 +5959,10 @@ exit_apps: } exit_reg_apps: + /* + * Join dispatch thread after joining reg_apps_thread to ensure + * we don't leak applications in the queue. + */ ret = pthread_join(dispatch_thread, &status); if (ret) { errno = ret; @@ -6008,6 +6028,9 @@ exit_options: sessiond_cleanup_options(); exit_set_signal_handler: + /* Ensure all prior call_rcu are done. */ + rcu_barrier(); + if (!retval) { exit(EXIT_SUCCESS); } else {