fix rotate pending notif with session id
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 28 Sep 2017 17:47:05 +0000 (13:47 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Thu, 28 Sep 2017 17:47:05 +0000 (13:47 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/bin/lttng-sessiond/rotate.c
src/bin/lttng-sessiond/rotation-thread.c
src/bin/lttng-sessiond/rotation-thread.h

index 9ce6f7e07229543c0fabc3b9126452571d4feb61..c8b6bc64806b7c58ccf6fda7bea41ff08702f145 100644 (file)
@@ -64,7 +64,7 @@ int rotate_add_channel_pending(uint64_t key, enum lttng_domain_type domain,
 
        new_info->channel_key.key = key;
        new_info->channel_key.domain = domain;
-       new_info->session = session;
+       new_info->session_id = session->id;
        cds_lfht_node_init(&new_info->rotate_channels_ht_node);
 
        session->nr_chan_rotate_pending++;
index 2fa886aa9f24cdbe73ba6139347256cab1d68f0b..58d70510fe52b17a647df5502bf3da5efeda1d2d 100644 (file)
@@ -37,6 +37,7 @@
 #include "health-sessiond.h"
 #include "rotate.h"
 #include "cmd.h"
+#include "session.h"
 #include "sessiond-timer.h"
 
 #include <urcu.h>
@@ -277,6 +278,7 @@ int handle_channel_rotation_pipe(int fd, uint32_t revents,
        int ret = 0;
        enum lttng_domain_type domain;
        struct rotation_channel_info *channel_info;
+       struct ltt_session *session = NULL;
        uint64_t key;
 
        if (fd == handle->ust32_consumer ||
@@ -317,38 +319,54 @@ int handle_channel_rotation_pipe(int fd, uint32_t revents,
                ret = -1;
                goto end;
        }
+       rcu_read_lock();
+       session_lock_list();
+       session = session_find_by_id(channel_info->session_id);
+       if (!session) {
+               ERR("[rotation-thread] Session %" PRIu64 " not found",
+                               channel_info->session_id);
+               ret = -1;
+               goto end_unlock;
+       }
 
-       if (--channel_info->session->nr_chan_rotate_pending == 0) {
+       if (--session->nr_chan_rotate_pending == 0) {
                time_t now = time(NULL);
 
                if (now == (time_t) -1) {
-                       channel_info->session->rotate_status = LTTNG_ROTATE_ERROR;
+                       session->rotate_status = LTTNG_ROTATE_ERROR;
                        ret = LTTNG_ERR_ROTATE_NOT_AVAILABLE;
                        goto end;
                }
+               session_lock(session);
 
-               ret = rename_complete_chunk(channel_info->session, now);
+               ret = rename_complete_chunk(session, now);
                if (ret < 0) {
                        ERR("Failed to rename completed rotation chunk");
+                       session_unlock(session);
                        goto end;
                }
-               channel_info->session->rotate_pending = false;
-               if (channel_info->session->rotate_pending_relay) {
+               session->rotate_pending = false;
+               if (session->rotate_pending_relay) {
                        ret = sessiond_timer_rotate_pending_start(
-                                       channel_info->session,
+                                       session,
                                        DEFAULT_ROTATE_PENDING_RELAY_TIMER);
                        if (ret) {
                                ERR("Enabling rotate pending timer");
                                ret = -1;
+                               session_unlock(session);
                                goto end;
                        }
                }
+               session_unlock(session);
        }
 
        channel_rotation_info_destroy(channel_info);
 
        ret = 0;
 
+end_unlock:
+       session_unlock_list();
+       rcu_read_unlock();
 end:
        return ret;
 }
index 762ef0c0de1705b5412f6cfc7e36bfba37344044..71931a73ab3c2e7c1436b029e083cc65d0256d41 100644 (file)
@@ -26,6 +26,7 @@
 #include <common/compat/poll.h>
 #include <common/hashtable/hashtable.h>
 #include <pthread.h>
+#include "session.h"
 
 struct rotation_channel_key {
        uint64_t key;
@@ -33,11 +34,7 @@ struct rotation_channel_key {
 };
 
 struct rotation_channel_info {
-       union {
-               struct ltt_kernel_channel *kchan;
-               struct ltt_ust_channel *uchan;
-       } chan;
-       struct ltt_session *session;
+       uint64_t session_id;
        struct rotation_channel_key channel_key;
        struct cds_lfht_node rotate_channels_ht_node;
 };
This page took 0.029748 seconds and 5 git commands to generate.