Send ust and kernel domain directory handle to consumer
[lttng-tools.git] / src / bin / lttng-sessiond / session.c
index 2e39c43174ed21720090268e73882849555622d0..ee71533f9ff790e60e11fac522ac2c82c2f4e3c6 100644 (file)
@@ -302,7 +302,7 @@ end:
  *
  * The session list lock must be held.
  */
-int ltt_sessions_ht_alloc(void)
+static int ltt_sessions_ht_alloc(void)
 {
        int ret = 0;
 
@@ -423,7 +423,7 @@ int _session_set_trace_chunk_no_lock_check(struct ltt_session *session,
                struct lttng_trace_chunk *new_trace_chunk,
                struct lttng_trace_chunk **_current_trace_chunk)
 {
-       int ret;
+       int ret = 0;
        unsigned int i, refs_to_acquire = 0, refs_acquired = 0, refs_to_release = 0;
        struct cds_lfht_iter iter;
        struct consumer_socket *socket;
@@ -491,7 +491,8 @@ int _session_set_trace_chunk_no_lock_check(struct ltt_session *session,
                        pthread_mutex_lock(socket->lock);
                        ret = consumer_create_trace_chunk(socket,
                                        relayd_id,
-                                       session->id, new_trace_chunk);
+                                       session->id, new_trace_chunk,
+                                       DEFAULT_UST_TRACE_DIR);
                        pthread_mutex_unlock(socket->lock);
                         if (ret) {
                                goto error;
@@ -521,7 +522,8 @@ int _session_set_trace_chunk_no_lock_check(struct ltt_session *session,
                        pthread_mutex_lock(socket->lock);
                        ret = consumer_create_trace_chunk(socket,
                                        relayd_id,
-                                       session->id, new_trace_chunk);
+                                       session->id, new_trace_chunk,
+                                       DEFAULT_KERNEL_TRACE_DIR);
                        pthread_mutex_unlock(socket->lock);
                         if (ret) {
                                goto error;
@@ -575,7 +577,7 @@ struct lttng_trace_chunk *session_create_new_trace_chunk(
        const time_t chunk_creation_ts = time(NULL);
        bool is_local_trace;
        const char *base_path;
-       struct lttng_directory_handle session_output_directory;
+       struct lttng_directory_handle *session_output_directory = NULL;
        const struct lttng_credentials session_credentials = {
                .uid = session->uid,
                .gid = session->gid,
@@ -640,20 +642,21 @@ struct lttng_trace_chunk *session_create_new_trace_chunk(
        if (ret) {
                goto error;
        }
-       ret = lttng_directory_handle_init(&session_output_directory,
-                       base_path);
-       if (ret) {
+       session_output_directory = lttng_directory_handle_create(base_path);
+       if (!session_output_directory) {
                goto error;
        }
        chunk_status = lttng_trace_chunk_set_as_owner(trace_chunk,
-                       &session_output_directory);
-       lttng_directory_handle_fini(&session_output_directory);
+                       session_output_directory);
+       lttng_directory_handle_put(session_output_directory);
+       session_output_directory = NULL;
        if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
                goto error;
        }
 end:
        return trace_chunk;
 error:
+       lttng_directory_handle_put(session_output_directory);
        lttng_trace_chunk_put(trace_chunk);
        trace_chunk = NULL;
        goto end;
@@ -811,7 +814,6 @@ void session_release(struct urcu_ref *ref)
 
        DBG("Destroying session %s (id %" PRIu64 ")", session->name, session->id);
 
-       consumer_output_put(session->consumer);
        snapshot_destroy(&session->snapshot);
 
        pthread_mutex_destroy(&session->lock);
@@ -823,6 +825,7 @@ void session_release(struct urcu_ref *ref)
        }
        session_notify_destruction(session);
 
+       consumer_output_put(session->consumer);
        kernel_free_session(ksess);
        session->kernel_session = NULL;
        if (usess) {
@@ -962,7 +965,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,
-               const char *base_path, struct ltt_session **out_session)
+               struct ltt_session **out_session)
 {
        int ret;
        enum lttng_error_code ret_code;
@@ -1086,16 +1089,6 @@ 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;
 
@@ -1163,7 +1156,7 @@ int session_access_ok(struct ltt_session *session, uid_t uid, gid_t gid)
  *
  * Be careful of the result passed to this function. For instance,
  * on failure to launch a rotation, a client will expect the rotation
- * state to be set to "NO_ROTATION". If an error occured while the
+ * state to be set to "NO_ROTATION". If an error occurred while the
  * rotation was "ONGOING", result should be set to "ERROR", which will
  * allow a client to report it.
  *
This page took 0.027431 seconds and 5 git commands to generate.