Fix out of order channel insert in hash table
authorDavid Goulet <dgoulet@efficios.com>
Thu, 12 Jan 2012 18:04:51 +0000 (13:04 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 12 Jan 2012 18:07:59 +0000 (13:07 -0500)
The channel, ust-app side, was added to the hash table of the session
even if the creation failed on the tracer side. When enabling event for
that channel, a segfault was hit since the channel did not exist on the
tracer side and channel_data was NULL at this point.

Now the channel insertion in the hash table is done *after* enabling it
on the tracer side.

Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
lttng-sessiond/channel.c
lttng-sessiond/ust-app.c

index b4dc48d161e662f12678e5d8de900e5a7c2761b0..3dc04ccb83829ad2077dc2ced938d3ee6c40671b 100644 (file)
@@ -236,11 +236,16 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                ret = LTTCOMM_FATAL;
                goto error;
        }
+       uchan->enabled = 1;
 
        switch (domain) {
        case LTTNG_DOMAIN_UST:
                DBG2("Channel %s being created in UST global domain", uchan->name);
-               chan_ht = usess->domain_global.channels;
+
+               /* Adding the channel to the channel hash table. */
+               rcu_read_lock();
+               lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node);
+               rcu_read_unlock();
 
                /* Enable channel for global domain */
                ret = ust_app_create_channel_glb(usess, uchan);
@@ -258,8 +263,6 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                goto error_free_chan;
        }
 
-       uchan->enabled = 1;
-       lttng_ht_add_unique_str(chan_ht, &uchan->node);
        DBG2("Channel %s created successfully", uchan->name);
 
        free(defattr);
index 9c500481e0b52531962733a604b2cfdc51039e35..4f68a87eecd86270cc0011cd528d38c79ec3fc96 100644 (file)
@@ -584,7 +584,7 @@ static int create_ust_channel(struct ust_app *app,
        ret = ustctl_create_channel(app->key.sock, ua_sess->handle,
                        (struct lttng_ust_channel_attr *)&ua_chan->attr, &ua_chan->obj);
        if (ret < 0) {
-               DBG("Error creating channel %s for app (pid: %d, sock: %d) "
+               ERR("Creating channel %s for app (pid: %d, sock: %d) "
                                "and session handle %d with ret %d",
                                ua_chan->name, app->key.pid, app->key.sock,
                                ua_sess->handle, ret);
@@ -1062,8 +1062,6 @@ static struct ust_app_channel *create_ust_app_channel(
                        goto error;
                }
                shadow_copy_channel(ua_chan, uchan);
-
-               lttng_ht_add_unique_str(ua_sess->channels, &ua_chan->node);
        } else {
                ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
        }
@@ -1073,6 +1071,8 @@ static struct ust_app_channel *create_ust_app_channel(
                goto error;
        }
 
+       lttng_ht_add_unique_str(ua_sess->channels, &ua_chan->node);
+
        return ua_chan;
 
 error:
This page took 0.027944 seconds and 4 git commands to generate.