stop timer thread
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 15 Sep 2017 19:37:57 +0000 (15:37 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Fri, 15 Sep 2017 19:37:57 +0000 (15:37 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/rotation-thread.c
src/bin/lttng-sessiond/sessiond-timer.c
src/bin/lttng-sessiond/sessiond-timer.h

index cb32f7f7fb63419373af1be65635576a13cfc49a..f97537377d6ca5c25f1521852501a14561d57b3a 100644 (file)
@@ -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);
 
index b2c36fc1d23ea92292816d7982d711ff8f415053..c00cbfc509c1ff1ae7e75734d23a5cff3353ac36 100644 (file)
@@ -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;
index 118326dae99c80d745845733c602d6d601a59e33..6159359e01c886c2de0ee9d15afa66ce7645612b 100644 (file)
@@ -37,6 +37,7 @@
 #include "health-sessiond.h"
 #include "rotate.h"
 #include "cmd.h"
+#include "sessiond-timer.h"
 
 #include <urcu.h>
 #include <urcu/list.h>
@@ -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);
index bf27a9ee6eba0614ea89fa677e3821bc05504a57..92d1d7a8f202ae8a3b51d344f2803dd429d350dd 100644 (file)
@@ -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);
                }
index 681e154f3c484c04c755ae87f823dd489c27da94..e4f379c86bcefedfcf0f7957540d150da2cb4307 100644 (file)
@@ -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 */
This page took 0.034024 seconds and 5 git commands to generate.