+ /*
+ * Tearing down the metadata timer thread in a
+ * non-fully-symmetric fashion compared to its creation in case
+ * lttng_consumer_cleanup() ends up tearing down timers (which
+ * requires the timer thread to be alive).
+ */
+ if (metadata_timer_thread_online) {
+ /*
+ * Ensure the metadata timer thread exits only after all other
+ * threads are gone, because it is required to perform timer
+ * teardown synchronization.
+ */
+ kill(getpid(), LTTNG_CONSUMER_SIG_EXIT);
+ ret = pthread_join(metadata_timer_thread, &status);
+ if (ret) {
+ errno = ret;
+ PERROR("pthread_join metadata_timer_thread");
+ retval = -1;
+ }
+ ret = consumer_timer_thread_get_channel_monitor_pipe();
+ if (ret >= 0) {
+ ret = close(ret);
+ if (ret) {
+ PERROR("close channel monitor pipe");
+ }
+ }
+ metadata_timer_thread_online = false;
+ }
+ tmp_ctx = ctx;
+ ctx = NULL;
+ cmm_barrier(); /* Clear ctx for signal handler. */
+ lttng_consumer_destroy(tmp_ctx);