Fix: add missing rcu read side lock
authorDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 16:40:13 +0000 (11:40 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 17:43:18 +0000 (12:43 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/main.c

index 491acde45f760a5613c338a91263231cffffbbc3..8c6204c4d99352caa9ba567df11fcc97b3d2cb32 100644 (file)
@@ -152,6 +152,7 @@ static void list_lttng_channels(int domain, struct ltt_session *session,
                struct lttng_ht_iter iter;
                struct ltt_ust_channel *uchan;
 
+               rcu_read_lock();
                cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
                                &iter.iter, uchan, node.node) {
                        strncpy(channels[i].name, uchan->name, LTTNG_SYMBOL_NAME_LEN);
@@ -171,6 +172,7 @@ static void list_lttng_channels(int domain, struct ltt_session *session,
                        }
                        i++;
                }
+               rcu_read_unlock();
                break;
        }
        default:
@@ -433,6 +435,8 @@ static int init_kernel_tracing(struct ltt_kernel_session *session)
 
        assert(session);
 
+       rcu_read_lock();
+
        if (session->consumer_fds_sent == 0 && session->consumer != NULL) {
                cds_lfht_for_each_entry(session->consumer->socks->ht, &iter.iter,
                                socket, node.node) {
@@ -450,6 +454,7 @@ static int init_kernel_tracing(struct ltt_kernel_session *session)
        }
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -643,6 +648,8 @@ static int setup_relayd(struct ltt_session *session)
 
        DBG2("Setting relayd for session %s", session->name);
 
+       rcu_read_lock();
+
        if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET
                        && usess->consumer->enabled) {
                /* For each consumer socket, send relayd sockets */
@@ -679,6 +686,7 @@ static int setup_relayd(struct ltt_session *session)
        }
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
index 74afd4e0cad5ff87d307de751672ad1ae86bad61..cee61f764ce192350583154df8e40d808ef7edac 100644 (file)
@@ -108,16 +108,20 @@ static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain,
                goto error;
        }
 
+       rcu_read_lock();
+
        /* Lookup context before adding it */
        lttng_ht_lookup(uchan->ctx, (void *)((unsigned long)uctx->ctx.ctx), &iter);
        uctx_node = lttng_ht_iter_get_node_ulong(&iter);
        if (uctx_node != NULL) {
                ret = -EEXIST;
+               rcu_read_unlock();
                goto error;
        }
 
        /* Add ltt UST context node to ltt UST channel */
        lttng_ht_add_unique_ulong(uchan->ctx, &uctx->node);
+       rcu_read_unlock();
 
        DBG("Context UST %d added to channel %s", uctx->ctx.ctx, uchan->name);
 
@@ -250,6 +254,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
                /* Add ctx to channel */
                ret = add_uctx_to_channel(usess, domain, uchan, ctx);
        } else {
+               rcu_read_lock();
                /* Add ctx all events, all channels */
                cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) {
                        ret = add_uctx_to_channel(usess, domain, uchan, ctx);
@@ -258,6 +263,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
                                continue;
                        }
                }
+               rcu_read_unlock();
        }
 
        switch (ret) {
index 237a2cf8d75a3f3ee8dc1a68c7c63dfccc1526b2..7482f402302bde8ab8df531f2de8fbc1ed8e9668 100644 (file)
@@ -626,7 +626,7 @@ static int update_kernel_stream(struct consumer_data *consumer_data, int fd)
                                        struct lttng_ht_iter iter;
                                        struct consumer_socket *socket;
 
-
+                                       rcu_read_lock();
                                        cds_lfht_for_each_entry(ksess->consumer->socks->ht,
                                                        &iter.iter, socket, node.node) {
                                                /* Code flow error */
@@ -637,9 +637,11 @@ static int update_kernel_stream(struct consumer_data *consumer_data, int fd)
                                                                channel, ksess);
                                                pthread_mutex_unlock(socket->lock);
                                                if (ret < 0) {
+                                                       rcu_read_unlock();
                                                        goto error;
                                                }
                                        }
+                                       rcu_read_unlock();
                                }
                                goto error;
                        }
This page took 0.03118 seconds and 4 git commands to generate.