Fix: streaming and snapshot backward compat for relayd < 2.11
[lttng-tools.git] / src / bin / lttng-sessiond / session.c
index 6e187f2ff51df9c17fb162f0096e7e6a92d7a372..7fba07bb438c0cfcfbe3ae1d1bfdd7a3a9f95ce8 100644 (file)
@@ -565,25 +565,6 @@ error:
        goto end_no_move;
 }
 
-bool session_output_supports_trace_chunks(const struct ltt_session *session)
-{
-       const struct consumer_output *output = session->kernel_session ?
-                       session->kernel_session->consumer :
-                       session->ust_session->consumer;
-
-       if (output->type == CONSUMER_DST_LOCAL) {
-               return true;
-       } else {
-               if (output->relay_major_version > 2) {
-                       return true;
-               } else if (output->relay_major_version == 2 &&
-                               output->relay_minor_version >= 11) {
-                       return true;
-               }
-       }
-       return false;
-}
-
 struct lttng_trace_chunk *session_create_new_trace_chunk(
                const struct ltt_session *session,
                const struct consumer_output *consumer_output_override,
@@ -802,11 +783,10 @@ void session_release(struct urcu_ref *ref)
        usess = session->ust_session;
        ksess = session->kernel_session;
 
-        /* Clean kernel session teardown */
+        /* Clean kernel session teardown, keeping data for destroy notifier. */
        kernel_destroy_session(ksess);
-       session->kernel_session = NULL;
 
-       /* UST session teardown */
+       /* UST session teardown, keeping data for destroy notifier. */
        if (usess) {
                /* Close any relayd session */
                consumer_output_send_destroy_relayd(usess->consumer);
@@ -817,9 +797,8 @@ void session_release(struct urcu_ref *ref)
                        ERR("Error in ust_app_destroy_trace_all");
                }
 
-               /* Clean up the rest. */
+               /* Clean up the rest, keeping destroy notifier data. */
                trace_ust_destroy_session(usess);
-               session->ust_session = NULL;
        }
 
        /*
@@ -844,8 +823,16 @@ void session_release(struct urcu_ref *ref)
                del_session_ht(session);
        }
        session_notify_destruction(session);
+
+       kernel_free_session(ksess);
+       session->kernel_session = NULL;
+       if (usess) {
+               trace_ust_free_session(usess);
+               session->ust_session = NULL;
+       }
        lttng_dynamic_array_reset(&session->destroy_notifiers);
        free(session->last_archived_chunk_name);
+       free(session->base_path);
        free(session);
        if (session_published) {
                /*
@@ -976,7 +963,7 @@ end:
  * Session list lock must be held by the caller.
  */
 enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
-               struct ltt_session **out_session)
+               const char *base_path, struct ltt_session **out_session)
 {
        int ret;
        enum lttng_error_code ret_code;
@@ -1059,6 +1046,7 @@ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
                                                DEFAULT_SESSION_NAME, i,
                                                datetime);
                        }
+                       new_session->name_contains_creation_time = true;
                        if (ret == -1 || ret >= sizeof(new_session->name)) {
                                /*
                                 * Null-terminate in case the name is used
@@ -1099,6 +1087,16 @@ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
                }
        }
 
+       if (base_path) {
+               new_session->base_path = strdup(base_path);
+               if (!new_session->base_path) {
+                       ERR("Failed to allocate base path of session \"%s\"",
+                                       name);
+                       ret_code = LTTNG_ERR_SESSION_FAIL;
+                       goto error;
+               }
+       }
+
        new_session->uid = uid;
        new_session->gid = gid;
 
This page took 0.02522 seconds and 4 git commands to generate.