Fix: Set a single return point and mutex unlock
authorDavid Goulet <dgoulet@efficios.com>
Mon, 22 Oct 2012 20:37:10 +0000 (16:37 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 22 Oct 2012 20:37:10 +0000 (16:37 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index 4e000fbd167e294c6b9139b6b7bdd2cf0098d6f1..249df8a47bc4789ae9aedee05300e248c52e926e 100644 (file)
@@ -502,7 +502,9 @@ int lttng_kconsumer_data_available(struct lttng_consumer_stream *stream)
         */
        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 */
 
@@ -511,14 +513,14 @@ int lttng_kconsumer_data_available(struct lttng_consumer_stream *stream)
                /* There is still data so let's put back this subbuffer. */
                ret = kernctl_put_subbuf(stream->wait_fd);
                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;
 }
index c2ad0fdd8cef613f170f4c43673d5d356fde8f93..e8e3f9396c9b784ec40d3d98357b9d20aaf04dad 100644 (file)
@@ -545,7 +545,9 @@ int lttng_ustconsumer_data_available(struct lttng_consumer_stream *stream)
         */
        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 */
 
@@ -554,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.028248 seconds and 4 git commands to generate.