Fix: Set a single return point and mutex unlock
[lttng-tools.git] / src / common / ust-consumer / ust-consumer.c
index 1bafeee07daccb79ef8f5377256ec6ed78257018..e8e3f9396c9b784ec40d3d98357b9d20aaf04dad 100644 (file)
@@ -537,13 +537,17 @@ int lttng_ustconsumer_data_available(struct lttng_consumer_stream *stream)
 
        assert(stream);
 
+       DBG("UST consumer checking data availability");
+
        /*
         * Try to lock the stream mutex. On failure, we know that the stream is
         * being used else where hence there is data still being extracted.
         */
        ret = pthread_mutex_trylock(&stream->lock);
        if (ret == EBUSY) {
-               goto data_not_available;
+               /* Data not available */
+               ret = 0;
+               goto end;
        }
        /* The stream is now locked so we can do our ustctl calls */
 
@@ -552,14 +556,14 @@ int lttng_ustconsumer_data_available(struct lttng_consumer_stream *stream)
                /* There is still data so let's put back this subbuffer. */
                ret = ustctl_put_subbuf(stream->chan->handle, stream->buf);
                assert(ret == 0);
-               pthread_mutex_unlock(&stream->lock);
-               goto data_not_available;
+               goto end_unlock;
        }
 
        /* Data is available to be read for this stream. */
-       pthread_mutex_unlock(&stream->lock);
-       return 1;
+       ret = 1;
 
-data_not_available:
-       return 0;
+end_unlock:
+       pthread_mutex_unlock(&stream->lock);
+end:
+       return ret;
 }
This page took 0.028016 seconds and 5 git commands to generate.