rotate pending on the relay working
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 15 Sep 2017 21:39:57 +0000 (17:39 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Fri, 15 Sep 2017 21:52:58 +0000 (17:52 -0400)
just need to find a default value

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 f97537377d6ca5c25f1521852501a14561d57b3a..a86e4db0b34a8621a3a2fec70a690d1b7a82a493 100644 (file)
@@ -4177,37 +4177,11 @@ int cmd_rotate_session(struct ltt_session *session,
                goto error;
        }
 
-       if (session->rotate_pending) {
+       if (session->rotate_pending || session->rotate_pending_relay) {
                ret = -LTTNG_ERR_ROTATE_PENDING;
                goto error;
        }
 
-       /*
-        * If the user did not wait for the previous rotation to complete
-        * (--no-wait), we have to ensure now that the relay had time to
-        * receive all the data pending from the previous rotation.
-        */
-       if (session->rotate_pending_relay) {
-               ret = relay_rotate_pending(session,
-                               session->rotate_count - 1);
-               if (ret == 0) {
-                       DBG("Previous rotation completed on the relay for session %s"
-                                       ", rotate_id %" PRIu64,
-                                       session->name,
-                                       session->rotate_count);
-                       session->rotate_pending_relay = 0;
-               } else if (ret == 1) {
-                       DBG("Session %s, rotate_id %" PRIu64 " still pending "
-                                       "on the relay",
-                                       session->name, session->rotate_count);
-                       ret = -LTTNG_ERR_ROTATE_PENDING;
-                       goto error;
-               } else {
-                       ERR("Failed to check rotate pending on the relay");
-                       ret = -LTTNG_ERR_UNK;
-               }
-       }
-
        /* Special case for the first rotation. */
        if (session->rotate_count == 0) {
                const char *base_path = NULL;
@@ -4333,43 +4307,9 @@ int cmd_rotate_pending(struct ltt_session *session,
                (*pending_return)->status = LTTNG_ROTATE_EMPTY;
        /* Rotate with a relay */
        } else if (session->rotate_pending_relay) {
-               /* The consumer has not finished the rotation. */
-               if (session->rotate_pending) {
-                       DBG("Session %s, rotate_id %" PRIu64 " still pending",
-                                       session->name, session->rotate_count);
-                       (*pending_return)->status = LTTNG_ROTATE_STARTED;
-               } else {
-                       /*
-                        * The consumer finished the rotation, but we don't
-                        * know if the relay still has data pending. We need to
-                        * find one consumer_output to talk to the relay and
-                        * ask it.
-                        *
-                        * (rotate_count - 1) is the chunk id that we want to
-                        * make sure is completely flushed to disk on the
-                        * relay.
-                        */
-                       ret = relay_rotate_pending(session,
-                                       session->rotate_count - 1);
-                       if (ret == 0) {
-                               DBG("Rotate completed on the relay for session %s"
-                                               ", rotate_id %" PRIu64,
-                                               session->name,
-                                               session->rotate_count);
-                               session->rotate_pending_relay = 0;
-                               (*pending_return)->status = LTTNG_ROTATE_COMPLETED;
-                               snprintf((*pending_return)->output_path, PATH_MAX, "%s",
-                                               session->rotation_chunk.current_rotate_path);
-                       } else if (ret == 1) {
-                               DBG("Session %s, rotate_id %" PRIu64 " still pending "
-                                               "on the relay",
-                                               session->name, session->rotate_count);
-                               (*pending_return)->status = LTTNG_ROTATE_STARTED;
-                       } else {
-                               ERR("Failed to check rotate pending on the relay");
-                               (*pending_return)->status = LTTNG_ROTATE_ERROR;
-                       }
-               }
+               DBG("Session %s, rotate_id %" PRIu64 " still pending",
+                               session->name, session->rotate_count);
+               (*pending_return)->status = LTTNG_ROTATE_STARTED;
        } else if (session->rotate_pending) {
                DBG("Session %s, rotate_id %" PRIu64 " still pending",
                                session->name, session->rotate_count);
index c00cbfc509c1ff1ae7e75734d23a5cff3353ac36..352feaf9a24b103dc9fcb5ab323ae2f802327a95 100644 (file)
@@ -5726,6 +5726,7 @@ int main(int argc, char **argv)
        struct lttng_pipe *ust32_channel_rotate_pipe = NULL,
                        *ust64_channel_rotate_pipe = NULL,
                        *kernel_channel_rotate_pipe = NULL;
+       struct timer_thread_parameters timer_thread_ctx;
 
        init_kernel_workarounds();
 
@@ -6054,6 +6055,11 @@ int main(int argc, char **argv)
                retval = -1;
                goto exit_init_data;
        }
+       /*
+        * The write-side of the pipe is used by the timer thread to wakeup
+        * the rotation thread when needed.
+        */
+       timer_thread_ctx.rotate_timer_pipe = rotate_timer_pipe[1];
 
        /* 64 bits consumerd path setup */
        ret = snprintf(ustconsumer64_data.err_unix_sock_path, PATH_MAX,
@@ -6308,7 +6314,7 @@ int main(int argc, char **argv)
 
        /* Create timer thread. */
        ret = pthread_create(&timer_thread, default_pthread_attr(),
-                       sessiond_timer_thread, NULL);
+                       sessiond_timer_thread, &timer_thread_ctx);
        if (ret) {
                errno = ret;
                PERROR("pthread_create timer");
index 6159359e01c886c2de0ee9d15afa66ce7645612b..4431a9494988a0c69f8279e5d19721f74696ba74 100644 (file)
@@ -398,7 +398,8 @@ int handle_rotate_timer_pipe(int fd, uint32_t revents,
        if (ret == 0) {
                DBG("[rotation-thread] Rotation completed on the relay for "
                                "session %" PRIu64, session_id);
-               /* TODO: delete timer */
+               session->rotate_pending_relay = 0;
+               sessiond_timer_rotate_pending_stop(session);
        } else if (ret == 1) {
                DBG("[rotation-thread] Rotation still pending on the relay for "
                                "session %" PRIu64, session_id);
index 92d1d7a8f202ae8a3b51d344f2803dd429d350dd..1c6bc70baadb052ea552c292ae3255b63e08b7c8 100644 (file)
@@ -236,6 +236,21 @@ int sessiond_timer_signal_init(void)
        return 0;
 }
 
+static
+void relay_rotation_pending_timer(struct timer_thread_parameters *ctx,
+               int sig, siginfo_t *si)
+{
+       int ret;
+       struct ltt_session *session = si->si_value.sival_ptr;
+       assert(session);
+
+       ret = lttng_write(ctx->rotate_timer_pipe, &session->id,
+                       sizeof(session->id));
+       if (ret < sizeof(session->id)) {
+               PERROR("wakeup rotate pipe");
+       }
+}
+
 /*
  * This thread is the sighandler for the timer signals.
  */
@@ -244,6 +259,7 @@ void *sessiond_timer_thread(void *data)
        int signr;
        sigset_t mask;
        siginfo_t info;
+       struct timer_thread_parameters *ctx = data;
 
        rcu_register_thread();
        rcu_thread_online();
@@ -283,7 +299,8 @@ void *sessiond_timer_thread(void *data)
                        fprintf(stderr, "KILL\n");
                        goto end;
                } else if (signr == LTTNG_SESSIOND_SIG_ROTATE_PENDING) {
-                       fprintf(stderr, "ALLO TIMER\n");
+                       fprintf(stderr, "PENDING TIMER\n");
+                       relay_rotation_pending_timer(ctx, info.si_signo, &info);
                } else {
                        ERR("Unexpected signal %d\n", info.si_signo);
                }
index e4f379c86bcefedfcf0f7957540d150da2cb4307..1c74f7cc1e67707fb60e4a4547cdb57794576c30 100644 (file)
@@ -41,6 +41,10 @@ struct timer_signal_data {
        pthread_mutex_t lock;
 };
 
+struct timer_thread_parameters {
+       int rotate_timer_pipe;
+};
+
 void *sessiond_timer_thread(void *data);
 int sessiond_timer_signal_init(void);
 
This page took 0.03375 seconds and 5 git commands to generate.