Add lttng_trace_format::sptr to ltt_session
[deliverable/lttng-tools.git] / src / bin / lttng-sessiond / session.cpp
index 1846024fcc60670d505a740db81125c7ec1e0aec..75e976e0a14e7886430ccf3476698aa3e34e47cb 100644 (file)
@@ -876,7 +876,7 @@ enum lttng_error_code session_kernel_open_packets(struct ltt_session *session)
 
        cds_lfht_first(session->kernel_session->consumer->socks->ht, &iter.iter);
        node = cds_lfht_iter_get_node(&iter.iter);
-       socket = container_of(node, typeof(*socket), node.node);
+       socket = caa_container_of(node, typeof(*socket), node.node);
 
        cds_list_for_each_entry(chan,
                        &session->kernel_session->channel_list.head, list) {
@@ -979,7 +979,7 @@ void session_release(struct urcu_ref *ref)
        int ret;
        struct ltt_ust_session *usess;
        struct ltt_kernel_session *ksess;
-       struct ltt_session *session = container_of(ref, typeof(*session), ref);
+       struct ltt_session *session = lttng::utils::container_of(ref, &ltt_session::ref);
        const bool session_published = session->published;
 
        LTTNG_ASSERT(!session->chunk_being_archived);
@@ -1036,10 +1036,11 @@ void session_release(struct urcu_ref *ref)
        }
        lttng_dynamic_array_reset(&session->destroy_notifiers);
        lttng_dynamic_array_reset(&session->clear_notifiers);
+
        free(session->last_archived_chunk_name);
        free(session->base_path);
        lttng_trigger_put(session->rotate_trigger);
-       free(session);
+       delete (session);
        if (session_published) {
                /*
                 * Broadcast after free-ing to ensure the memory is
@@ -1183,7 +1184,7 @@ struct ltt_session *session_find_by_id(uint64_t id)
        if (node == NULL) {
                goto end;
        }
-       ls = caa_container_of(node, struct ltt_session, node);
+       ls = lttng::utils::container_of(node, &ltt_session::node);
 
        DBG3("Session %" PRIu64 " found by id.", id);
        return session_get(ls) ? ls : NULL;
@@ -1197,7 +1198,10 @@ end:
  * Create a new session and add it to the session list.
  * Session list lock must be held by the caller.
  */
-enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
+enum lttng_error_code session_create(const char *name,
+               uid_t uid,
+               gid_t gid,
+               lttng::trace_format_descriptor::uptr& trace_format,
                struct ltt_session **out_session)
 {
        int ret;
@@ -1215,9 +1219,11 @@ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
                        goto error;
                }
        }
-       new_session = zmalloc<ltt_session>();
-       if (!new_session) {
-               PERROR("Failed to allocate an ltt_session structure");
+
+       try {
+               new_session = new ltt_session();
+       } catch (const std::exception& ex) {
+               ERR("Failed to create ltt_session: %s", ex.what());
                ret_code = LTTNG_ERR_NOMEM;
                goto error;
        }
@@ -1231,6 +1237,8 @@ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
        urcu_ref_init(&new_session->ref);
        pthread_mutex_init(&new_session->lock, NULL);
 
+       new_session->trace_format = std::move(trace_format);
+
        new_session->creation_time = time(NULL);
        if (new_session->creation_time == (time_t) -1) {
                PERROR("Failed to sample session creation time");
@@ -1456,7 +1464,7 @@ bool sample_session_id_by_name(const char *name, uint64_t *id)
                goto end;
        }
 
-       ls = caa_container_of(node, struct ltt_session, node_by_name);
+       ls = lttng::utils::container_of(node, &ltt_session::node_by_name);
        *id = ls->id;
        found = true;
 
This page took 0.02779 seconds and 5 git commands to generate.