X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng-relayd%2Fctf-trace.c;h=4ca6dba1e40c489bdd92f6a0a90636d5841dd94e;hb=ce4d40839ac3beef1a58730d3636a522497bc60f;hp=d965cec8caa72aa9dcf771282f399a63868a27ab;hpb=7591bab11eceedc6a0d1e02fd6f85592267a63b5;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/ctf-trace.c b/src/bin/lttng-relayd/ctf-trace.c index d965cec8c..4ca6dba1e 100644 --- a/src/bin/lttng-relayd/ctf-trace.c +++ b/src/bin/lttng-relayd/ctf-trace.c @@ -17,7 +17,6 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include @@ -76,17 +75,7 @@ void ctf_trace_release(struct urcu_ref *ref) */ bool ctf_trace_get(struct ctf_trace *trace) { - bool has_ref = false; - - /* Confirm that the trace refcount has not reached 0. */ - pthread_mutex_lock(&trace->reflock); - if (trace->ref.refcount != 0) { - has_ref = true; - urcu_ref_get(&trace->ref); - } - pthread_mutex_unlock(&trace->reflock); - - return has_ref; + return urcu_ref_get_unless_zero(&trace->ref); } /* @@ -124,7 +113,6 @@ static struct ctf_trace *ctf_trace_create(struct relay_session *session, trace->session = session; urcu_ref_init(&trace->ref); pthread_mutex_init(&trace->lock, NULL); - pthread_mutex_init(&trace->reflock, NULL); pthread_mutex_init(&trace->stream_list_lock, NULL); lttng_ht_add_str(session->ctf_traces_ht, &trace->node); @@ -169,9 +157,7 @@ end: void ctf_trace_put(struct ctf_trace *trace) { rcu_read_lock(); - pthread_mutex_lock(&trace->reflock); urcu_ref_put(&trace->ref, ctf_trace_release); - pthread_mutex_unlock(&trace->reflock); rcu_read_unlock(); } @@ -183,9 +169,10 @@ int ctf_trace_close(struct ctf_trace *trace) cds_list_for_each_entry_rcu(stream, &trace->stream_list, stream_node) { /* - * Close the stream. + * Close stream since the connection owning the trace is being + * torn down. */ - stream_close(stream); + try_stream_close(stream); } rcu_read_unlock(); /*