From 0d2ff20ef219ec2e407fbc82097346515016290b Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Fri, 15 Sep 2017 15:37:57 -0400 Subject: [PATCH] stop timer thread Signed-off-by: Julien Desfossez --- src/bin/lttng-sessiond/cmd.c | 5 +++++ src/bin/lttng-sessiond/main.c | 9 ++++++--- src/bin/lttng-sessiond/rotation-thread.c | 10 ++++++++++ src/bin/lttng-sessiond/sessiond-timer.c | 24 +++++++++++++++++++++++- src/bin/lttng-sessiond/sessiond-timer.h | 3 ++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index cb32f7f7f..f97537377 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -53,6 +53,7 @@ #include "notification-thread-commands.h" #include "rotate.h" #include "rotation-thread.h" +#include "sessiond-timer.h" #include "cmd.h" @@ -2766,6 +2767,10 @@ int cmd_destroy_session(struct ltt_session *session, int wpipe) } } + if (session->rotate_relay_pending_timer_enabled) { + sessiond_timer_rotate_pending_stop(session); + } + /* Clean kernel session teardown */ kernel_destroy_session(ksess); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index b2c36fc1d..c00cbfc50 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -510,9 +510,6 @@ static void stop_threads(void) /* Dispatch thread */ CMM_STORE_SHARED(dispatch_thread_exit, 1); futex_nto1_wake(&ust_cmd_queue.futex); - - /* timer thread */ - kill(getpid(), LTTNG_SESSIOND_SIG_EXIT); } /* @@ -5739,6 +5736,11 @@ int main(int argc, char **argv) goto exit_set_signal_handler; } + if (sessiond_timer_signal_init()) { + retval = -1; + goto exit_set_signal_handler; + } + setup_consumerd_path(); page_size = sysconf(_SC_PAGESIZE); @@ -6565,6 +6567,7 @@ exit_init_data: } if (timer_thread_running) { + kill(getpid(), LTTNG_SESSIOND_SIG_EXIT); ret = pthread_join(timer_thread, &status); if (ret) { errno = ret; diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index 118326dae..6159359e0 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -37,6 +37,7 @@ #include "health-sessiond.h" #include "rotate.h" #include "cmd.h" +#include "sessiond-timer.h" #include #include @@ -332,6 +333,15 @@ int handle_channel_rotation_pipe(int fd, uint32_t revents, goto end; } channel_info->session->rotate_pending = false; + if (channel_info->session->rotate_pending_relay) { + ret = sessiond_timer_rotate_pending_start( + channel_info->session, 100000); + if (ret) { + ERR("Enabling rotate pending timer"); + ret = -1; + goto end; + } + } } channel_rotation_info_destroy(channel_info); diff --git a/src/bin/lttng-sessiond/sessiond-timer.c b/src/bin/lttng-sessiond/sessiond-timer.c index bf27a9ee6..92d1d7a8f 100644 --- a/src/bin/lttng-sessiond/sessiond-timer.c +++ b/src/bin/lttng-sessiond/sessiond-timer.c @@ -185,7 +185,7 @@ end: return ret; } -int rotate_pending_timer_start(struct ltt_session *session, unsigned int +int sessiond_timer_rotate_pending_start(struct ltt_session *session, unsigned int interval_us) { int ret; @@ -198,6 +198,24 @@ int rotate_pending_timer_start(struct ltt_session *session, unsigned int return ret; } +/* + * Stop and delete the channel's live timer. + */ +void sessiond_timer_rotate_pending_stop(struct ltt_session *session) +{ + int ret; + + assert(session); + + ret = session_timer_stop(&session->rotate_relay_pending_timer, + LTTNG_SESSIOND_SIG_ROTATE_PENDING); + if (ret == -1) { + ERR("Failed to stop live timer"); + } + + session->rotate_relay_pending_timer_enabled = 0; +} + /* * Block the RT signals for the entire process. It must be called from the * sessiond main before creating the threads @@ -256,12 +274,16 @@ void *sessiond_timer_thread(void *data) } continue; } else if (signr == LTTNG_SESSIOND_SIG_TEARDOWN) { + fprintf(stderr, "TEARDOWN\n"); cmm_smp_mb(); CMM_STORE_SHARED(timer_signal.qs_done, 1); cmm_smp_mb(); DBG("Signal timer metadata thread teardown"); } else if (signr == LTTNG_SESSIOND_SIG_EXIT) { + fprintf(stderr, "KILL\n"); goto end; + } else if (signr == LTTNG_SESSIOND_SIG_ROTATE_PENDING) { + fprintf(stderr, "ALLO TIMER\n"); } else { ERR("Unexpected signal %d\n", info.si_signo); } diff --git a/src/bin/lttng-sessiond/sessiond-timer.h b/src/bin/lttng-sessiond/sessiond-timer.h index 681e154f3..e4f379c86 100644 --- a/src/bin/lttng-sessiond/sessiond-timer.h +++ b/src/bin/lttng-sessiond/sessiond-timer.h @@ -44,7 +44,8 @@ struct timer_signal_data { void *sessiond_timer_thread(void *data); int sessiond_timer_signal_init(void); -int rotate_pending_timer_start(struct ltt_session *session, unsigned int +int sessiond_timer_rotate_pending_start(struct ltt_session *session, unsigned int interval_us); +void sessiond_timer_rotate_pending_stop(struct ltt_session *session); #endif /* SESSIOND_TIMER_H */ -- 2.34.1