fix locking for rotate timer vs session destroy
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 27 Sep 2017 19:58:26 +0000 (15:58 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Wed, 27 Sep 2017 19:58:26 +0000 (15:58 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/rotation-thread.c
src/bin/lttng-sessiond/sessiond-timer.c

index 3878a14dca12fad81f217ca9dbb7b716b0ed8505..5d0704d1d0817c18b4400a510c6bae97ea5bd0fc 100644 (file)
@@ -4174,6 +4174,7 @@ const char *get_base_path(struct ltt_session *session,
  * Command LTTNG_ROTATE_SESSION from the lttng-ctl library.
  *
  * Ask the consumer to rotate the session output directory.
+ * The session lock must be held.
  *
  * Return 0 on success or else a LTTNG_ERR code.
  */
index d219ca918b48c902c3cb0827fce2fe297aa0f13e..2fa886aa9f24cdbe73ba6139347256cab1d68f0b 100644 (file)
@@ -405,13 +405,13 @@ int rotate_timer(struct ltt_session *session)
        /*
         * If the session is stopped, we need to cancel this timer.
         */
-       pthread_mutex_lock(&session->lock);
+       session_lock(session);
        if (!session->active && session->rotate_timer_enabled) {
                sessiond_rotate_timer_stop(session);
        }
-       pthread_mutex_unlock(&session->lock);
 
        ret = cmd_rotate_session(session, NULL);
+       session_unlock(session);
        fprintf(stderr, "RET ROTATE TIMER: %d\n", ret);
        if (ret == -LTTNG_ERR_ROTATE_PENDING) {
                ret = 0;
@@ -458,12 +458,14 @@ int handle_rotate_timer_pipe(int fd, uint32_t revents,
                goto end;
        }
 
+       rcu_read_lock();
+       session_lock_list();
        session = session_find_by_id(timer_data.session_id);
        if (!session) {
                ERR("[rotation-thread] Session %" PRIu64 " not found",
                                timer_data.session_id);
                ret = -1;
-               goto end;
+               goto end_unlock;
        }
 
        if (timer_data.signal == LTTNG_SESSIOND_SIG_ROTATE_PENDING) {
@@ -475,6 +477,9 @@ int handle_rotate_timer_pipe(int fd, uint32_t revents,
                ret = -1;
        }
 
+end_unlock:
+       session_unlock_list();
+       rcu_read_unlock();
 end:
        return ret;
 }
index 1d257bf046d4f013e3e139fdf4943f519a0adebf..62d701e8e0c74ab07bd65ce647cb0b2149c8c309 100644 (file)
@@ -303,7 +303,8 @@ void rotate_timer(struct timer_thread_parameters *ctx, int sig, siginfo_t *si)
 
        /*
         * No rate limiting here, so if the timer fires too quickly, there will
-        * be a backlog of timers queued up and we will try to catch up.
+        * be a backlog of timers queued up and the sessiond will try to catch
+        * up.
         */
        memset(&timer_data, 0, sizeof(struct sessiond_rotation_timer));
        timer_data.session_id = session->id;
This page took 0.030343 seconds and 5 git commands to generate.