Fix: relayd refcount updates for stream
[lttng-tools.git] / src / common / consumer-stream.c
index 03bac86870031eb2b63661f178f5cee0601748c6..723ec829f80095ff17bd3e5996540d01d754072a 100644 (file)
@@ -58,8 +58,10 @@ void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
        assert(stream);
        assert(relayd);
 
-       uatomic_dec(&relayd->refcount);
-       assert(uatomic_read(&relayd->refcount) >= 0);
+       if (stream->sent_to_relayd) {
+               uatomic_dec(&relayd->refcount);
+               assert(uatomic_read(&relayd->refcount) >= 0);
+       }
 
        /* Closing streams requires to lock the control socket. */
        pthread_mutex_lock(&relayd->ctrl_sock_mutex);
@@ -82,6 +84,7 @@ void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
                consumer_destroy_relayd(relayd);
        }
        stream->net_seq_idx = (uint64_t) -1ULL;
+       stream->sent_to_relayd = 0;
 }
 
 /*
This page took 0.023647 seconds and 4 git commands to generate.