Fix: lttng-sessiond: null pointer used to log session name
[lttng-tools.git] / src / bin / lttng-sessiond / rotation-thread.c
index 89a148a74c2bdd1393bb274afb4ae9f0f545caa1..590b95dd224b0cc0f6e5351b4cd85f147a66d8ac 100644 (file)
@@ -24,6 +24,8 @@
 #include <common/kernel-ctl/kernel-ctl.h>
 #include <lttng/notification/channel-internal.h>
 #include <lttng/rotate-internal.h>
+#include <lttng/location-internal.h>
+#include <lttng/condition/condition-internal.h>
 
 #include "rotation-thread.h"
 #include "lttng-sessiond.h"
@@ -477,7 +479,6 @@ int check_session_rotation_pending(struct ltt_session *session,
 
        if (!session->quiet_rotation) {
                location = session_get_trace_archive_location(session);
-               /* Ownership of location is transferred. */
                ret = notification_thread_command_session_rotation_completed(
                                notification_thread_handle,
                                session->name,
@@ -485,6 +486,7 @@ int check_session_rotation_pending(struct ltt_session *session,
                                session->gid,
                                session->last_archived_chunk_id.value,
                                location);
+               lttng_trace_archive_location_put(location);
                if (ret != LTTNG_OK) {
                        ERR("Failed to notify notification thread of completed rotation for session %s",
                                        session->name);
@@ -582,8 +584,6 @@ int handle_job_queue(struct rotation_thread_handle *handle,
                session_lock_list();
                session = job->session;
                if (!session) {
-                       DBG("Session \"%s\" not found",
-                                       session->name);
                        /*
                         * This is a non-fatal error, and we cannot report it to
                         * the user (timer), so just print the error and
@@ -658,10 +658,15 @@ int handle_condition(const struct lttng_condition *condition,
        session_lock_list();
        session = session_find_by_name(condition_session_name);
        if (!session) {
-               ret = -1;
-               session_unlock_list();
-               ERR("Session \"%s\" not found",
+               DBG("Failed to find session while handling notification: notification type = %s, session name = `%s`",
+                               lttng_condition_type_str(condition_type),
                                condition_session_name);
+               /*
+                * Not a fatal error: a session can be destroyed before we get
+                * the chance to handle the notification.
+                */
+               ret = 0;
+               session_unlock_list();
                goto end;
        }
        session_lock(session);
This page took 0.024763 seconds and 4 git commands to generate.