X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fconnection.c;h=e8c3d4bea5a50f2a28d69d88a94fb7b4744c168d;hp=f3d7e642ef2aa0139bce4a1f927d8a3ee56f1f77;hb=ce4d40839ac3beef1a58730d3636a522497bc60f;hpb=890d8fe47755c3bad936389cf48ffa141cff41c9 diff --git a/src/bin/lttng-relayd/connection.c b/src/bin/lttng-relayd/connection.c index f3d7e642e..e8c3d4bea 100644 --- a/src/bin/lttng-relayd/connection.c +++ b/src/bin/lttng-relayd/connection.c @@ -27,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, @@ -75,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; @@ -131,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(); }