From: David Goulet Date: Mon, 7 Jan 2013 18:45:29 +0000 (-0500) Subject: Fix: add missing rcu read side lock/unlock X-Git-Tag: v2.2.0-rc1~131 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b82c5c4d0522a3948028146d2968cecc3d045119;p=lttng-tools.git Fix: add missing rcu read side lock/unlock Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 90c700129..344c6627d 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -376,10 +376,12 @@ struct consumer_output *consumer_copy_output(struct consumer_output *obj) /* Putting back the HT pointer and start copying socket(s). */ output->socks = tmp_ht_ptr; + rcu_read_lock(); cds_lfht_for_each_entry(obj->socks->ht, &iter.iter, socket, node.node) { /* Create new socket object. */ copy_sock = consumer_allocate_socket(socket->fd); if (copy_sock == NULL) { + rcu_read_unlock(); goto malloc_error; } @@ -387,6 +389,7 @@ struct consumer_output *consumer_copy_output(struct consumer_output *obj) copy_sock->lock = socket->lock; consumer_add_socket(copy_sock, output); } + rcu_read_unlock(); error: return output; @@ -793,6 +796,7 @@ int consumer_is_data_pending(unsigned int id, DBG3("Consumer data pending for id %u", id); /* Send command for each consumer */ + rcu_read_lock(); cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket, node.node) { /* Code flow error */ @@ -805,7 +809,7 @@ int consumer_is_data_pending(unsigned int id, /* The above call will print a PERROR on error. */ DBG("Error on consumer is data pending on sock %d", socket->fd); pthread_mutex_unlock(socket->lock); - goto error; + goto error_unlock; } /* @@ -822,7 +826,7 @@ int consumer_is_data_pending(unsigned int id, /* The above call will print a PERROR on error. */ DBG("Error on recv consumer is data pending on sock %d", socket->fd); pthread_mutex_unlock(socket->lock); - goto error; + goto error_unlock; } pthread_mutex_unlock(socket->lock); @@ -831,11 +835,13 @@ int consumer_is_data_pending(unsigned int id, break; } } + rcu_read_unlock(); DBG("Consumer data is %s pending for session id %u", ret_code == 1 ? "" : "NOT", id); return ret_code; -error: +error_unlock: + rcu_read_unlock(); return -1; }