Fix: holding the stream lock does not equate to having data pending
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 11 Sep 2018 00:09:14 +0000 (20:09 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 18 Sep 2018 00:51:47 +0000 (20:51 -0400)
The live timer can hold the stream lock while sending empty beacon. An
empty beacon does not mean that data is still pending for the stream.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer/consumer.c

index 2c82836558287418a171f7e312c45d1fe362f459..1d6f8b4cc4ce7cba975c85eb6a2c01fcb6e19e5b 100644 (file)
@@ -3673,34 +3673,6 @@ error_nosignal:
        }
 }
 
-/*
- * Try to lock the stream mutex.
- *
- * On success, 1 is returned else 0 indicating that the mutex is NOT lock.
- */
-static int stream_try_lock(struct lttng_consumer_stream *stream)
-{
-       int ret;
-
-       assert(stream);
-
-       /*
-        * 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) {
-               /* For both EBUSY and EINVAL error, the mutex is NOT locked. */
-               ret = 0;
-               goto end;
-       }
-
-       ret = 1;
-
-end:
-       return ret;
-}
-
 /*
  * Search for a relayd associated to the session id and return the reference.
  *
@@ -3786,11 +3758,7 @@ int consumer_data_pending(uint64_t id)
                        ht->hash_fct(&id, lttng_ht_seed),
                        ht->match_fct, &id,
                        &iter.iter, stream, node_session_id.node) {
-               /* If this call fails, the stream is being used hence data pending. */
-               ret = stream_try_lock(stream);
-               if (!ret) {
-                       goto data_pending;
-               }
+               pthread_mutex_lock(&stream->lock);
 
                /*
                 * A removed node from the hash table indicates that the stream has
This page took 0.02852 seconds and 5 git commands to generate.