Cleanup: ust_session_id unused by buffer_reg_uid_consumer_channel_key
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 8120b6df21188ea88331bba2a7c27c883d9b410d..97083e15a95f7c5b1c919143e9724ff51fd4cbcc 100644 (file)
@@ -2847,6 +2847,7 @@ error:
  * Create and send to the application the created buffers with per UID buffers.
  *
  * This MUST be called with a RCU read side lock acquired.
+ * The session list lock and the session's lock must be acquired.
  *
  * Return 0 on success else a negative value.
  */
@@ -2857,7 +2858,6 @@ static int create_channel_per_uid(struct ust_app *app,
        int ret;
        struct buffer_reg_uid *reg_uid;
        struct buffer_reg_channel *reg_chan;
-       bool created = false;
 
        assert(app);
        assert(usess);
@@ -2876,51 +2876,50 @@ static int create_channel_per_uid(struct ust_app *app,
 
        reg_chan = buffer_reg_channel_find(ua_chan->tracing_channel_id,
                        reg_uid);
-       if (!reg_chan) {
-               /* Create the buffer registry channel object. */
-               ret = create_buffer_reg_channel(reg_uid->registry, ua_chan, &reg_chan);
-               if (ret < 0) {
-                       ERR("Error creating the UST channel \"%s\" registry instance",
-                               ua_chan->name);
-                       goto error;
-               }
-               assert(reg_chan);
+       if (reg_chan) {
+               goto send_channel;
+       }
 
-               /*
-                * Create the buffers on the consumer side. This call populates the
-                * ust app channel object with all streams and data object.
-                */
-               ret = do_consumer_create_channel(usess, ua_sess, ua_chan,
-                               app->bits_per_long, reg_uid->registry->reg.ust);
-               if (ret < 0) {
-                       ERR("Error creating UST channel \"%s\" on the consumer daemon",
+       /* Create the buffer registry channel object. */
+       ret = create_buffer_reg_channel(reg_uid->registry, ua_chan, &reg_chan);
+       if (ret < 0) {
+               ERR("Error creating the UST channel \"%s\" registry instance",
                                ua_chan->name);
+               goto error;
+       }
 
-                       /*
-                        * Let's remove the previously created buffer registry channel so
-                        * it's not visible anymore in the session registry.
-                        */
-                       ust_registry_channel_del_free(reg_uid->registry->reg.ust,
-                                       ua_chan->tracing_channel_id, false);
-                       buffer_reg_channel_remove(reg_uid->registry, reg_chan);
-                       buffer_reg_channel_destroy(reg_chan, LTTNG_DOMAIN_UST);
-                       goto error;
-               }
+       /*
+        * Create the buffers on the consumer side. This call populates the
+        * ust app channel object with all streams and data object.
+        */
+       ret = do_consumer_create_channel(usess, ua_sess, ua_chan,
+                       app->bits_per_long, reg_uid->registry->reg.ust);
+       if (ret < 0) {
+               ERR("Error creating UST channel \"%s\" on the consumer daemon",
+                               ua_chan->name);
 
                /*
-                * Setup the streams and add it to the session registry.
+                * Let's remove the previously created buffer registry channel so
+                * it's not visible anymore in the session registry.
                 */
-               ret = setup_buffer_reg_channel(reg_uid->registry,
-                               ua_chan, reg_chan, app);
-               if (ret < 0) {
-                       ERR("Error setting up UST channel \"%s\"",
-                               ua_chan->name);
-                       goto error;
-               }
-               created = true;
+               ust_registry_channel_del_free(reg_uid->registry->reg.ust,
+                               ua_chan->tracing_channel_id, false);
+               buffer_reg_channel_remove(reg_uid->registry, reg_chan);
+               buffer_reg_channel_destroy(reg_chan, LTTNG_DOMAIN_UST);
+               goto error;
        }
 
-       if (created) {
+       /*
+        * Setup the streams and add it to the session registry.
+        */
+       ret = setup_buffer_reg_channel(reg_uid->registry,
+                       ua_chan, reg_chan, app);
+       if (ret < 0) {
+               ERR("Error setting up UST channel \"%s\"", ua_chan->name);
+               goto error;
+       }
+
+       {
                enum lttng_error_code cmd_ret;
                struct ltt_session *session;
                uint64_t chan_reg_key;
@@ -2939,6 +2938,8 @@ static int create_channel_per_uid(struct ust_app *app,
                session = session_find_by_id(ua_sess->tracing_id);
                assert(session);
 
+               assert(pthread_mutex_trylock(&session->lock));
+               assert(session_trylock_list());
                cmd_ret = notification_thread_command_add_channel(
                                notification_thread_handle, session->name,
                                ua_sess->euid, ua_sess->egid,
@@ -2953,6 +2954,7 @@ static int create_channel_per_uid(struct ust_app *app,
                }
        }
 
+send_channel:
        /* Send buffers to the application. */
        ret = send_channel_uid_to_ust(reg_chan, app, ua_sess, ua_chan);
        if (ret < 0) {
@@ -2970,6 +2972,7 @@ error:
  * Create and send to the application the created buffers with per PID buffers.
  *
  * Called with UST app session lock held.
+ * The session list lock and the session's lock must be acquired.
  *
  * Return 0 on success else a negative value.
  */
@@ -3032,6 +3035,9 @@ static int create_channel_per_pid(struct ust_app *app,
        chan_reg->consumer_key = ua_chan->key;
        pthread_mutex_unlock(&registry->lock);
 
+       assert(pthread_mutex_trylock(&session->lock));
+       assert(session_trylock_list());
+
        cmd_ret = notification_thread_command_add_channel(
                        notification_thread_handle, session->name,
                        ua_sess->euid, ua_sess->egid,
@@ -6143,8 +6149,7 @@ int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
        *lost = 0;
 
        ret = buffer_reg_uid_consumer_channel_key(
-                       buffer_reg_uid_list, ust_session_id,
-                       uchan_id, &consumer_chan_key);
+                       buffer_reg_uid_list, uchan_id, &consumer_chan_key);
        if (ret < 0) {
                /* Not found */
                ret = 0;
This page took 0.025057 seconds and 4 git commands to generate.