X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fconnection.c;h=e8c3d4bea5a50f2a28d69d88a94fb7b4744c168d;hp=fce6c84d58c922f5d26491c62160ba49ab2577ef;hb=ce4d40839ac3beef1a58730d3636a522497bc60f;hpb=7591bab11eceedc6a0d1e02fd6f85592267a63b5 diff --git a/src/bin/lttng-relayd/connection.c b/src/bin/lttng-relayd/connection.c index fce6c84d5..e8c3d4bea 100644 --- a/src/bin/lttng-relayd/connection.c +++ b/src/bin/lttng-relayd/connection.c @@ -17,7 +17,6 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -28,16 +27,7 @@ bool connection_get(struct relay_connection *conn) { - bool has_ref = false; - - pthread_mutex_lock(&conn->reflock); - if (conn->ref.refcount != 0) { - has_ref = true; - urcu_ref_get(&conn->ref); - } - pthread_mutex_unlock(&conn->reflock); - - return has_ref; + return urcu_ref_get_unless_zero(&conn->ref); } struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht, @@ -76,7 +66,6 @@ struct relay_connection *connection_create(struct lttcomm_sock *sock, PERROR("zmalloc relay connection"); goto end; } - pthread_mutex_init(&conn->reflock, NULL); urcu_ref_init(&conn->ref); conn->type = type; conn->sock = sock; @@ -132,9 +121,7 @@ static void connection_release(struct urcu_ref *ref) void connection_put(struct relay_connection *conn) { rcu_read_lock(); - pthread_mutex_lock(&conn->reflock); urcu_ref_put(&conn->ref, connection_release); - pthread_mutex_unlock(&conn->reflock); rcu_read_unlock(); }