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:06:22 +0000 (12:06 -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 ff418e17ee0df63f8a82518db844d500fd879bcb..3a70d48692917108d8ed1447b6a7a2a409542d3d 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 e5a22460fc3c6fe2342bf82d015d6da84a85ffd2..339b20d3ee433be2d17f33d3462b104ab6266448 100644 (file)
@@ -638,7 +638,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 */
@@ -649,9 +649,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.03161 seconds and 4 git commands to generate.