Fix: exit threads not only on goto restart
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 5 Jan 2015 21:43:08 +0000 (16:43 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 8 Jan 2015 22:10:57 +0000 (17:10 -0500)
Exit threads as soon as number of FD is 0, on every loop (no need for
goto restart special case). Number of FD being 0 is a sufficient
condition for exiting the thread: it means the quit pipe has been
removed from the poll set.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer.c

index 6754cee672b317453821407efeae7f174b39b68e..700149fe429d25104429f31b4c400c54246c30e8 100644 (file)
@@ -2179,14 +2179,6 @@ void *consumer_thread_metadata_poll(void *data)
        DBG("Metadata main loop started");
 
        while (1) {
-               health_code_update();
-
-               /* Only the metadata pipe is set */
-               if (LTTNG_POLL_GETNB(&events) == 0 && consumer_quit == 1) {
-                       err = 0;        /* All is OK */
-                       goto end;
-               }
-
 restart:
                health_code_update();
                health_poll_entry();
@@ -2201,7 +2193,10 @@ restart:
                                ERR("Poll EINTR catched");
                                goto restart;
                        }
-                       goto error;
+                       if (LTTNG_POLL_GETNB(&events) == 0) {
+                               err = 0;        /* All is OK */
+                       }
+                       goto end;
                }
 
                nb_fd = ret;
@@ -2757,14 +2752,6 @@ void *consumer_thread_channel_poll(void *data)
        DBG("Channel main loop started");
 
        while (1) {
-               health_code_update();
-
-               /* Only the channel pipe is set */
-               if (LTTNG_POLL_GETNB(&events) == 0 && consumer_quit == 1) {
-                       err = 0;        /* All is OK */
-                       goto end;
-               }
-
 restart:
                health_code_update();
                DBG("Channel poll wait");
@@ -2779,6 +2766,9 @@ restart:
                                ERR("Poll EINTR catched");
                                goto restart;
                        }
+                       if (LTTNG_POLL_GETNB(&events) == 0) {
+                               err = 0;        /* All is OK */
+                       }
                        goto end;
                }
 
This page took 0.027755 seconds and 4 git commands to generate.