Fix: use global thread quit pipe in live
authorDavid Goulet <dgoulet@efficios.com>
Fri, 27 Sep 2013 22:05:17 +0000 (18:05 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 27 Sep 2013 22:28:47 +0000 (18:28 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-relayd/live.c
src/bin/lttng-relayd/live.h
src/bin/lttng-relayd/main.c

index cbf32790c88f90d3f7641e05ef1467dd9c76749e..d09c2f13ea39af1f0971dcf5aed37273c6503e55 100644 (file)
@@ -96,8 +96,6 @@ void cleanup(void)
 {
        DBG("Cleaning up");
 
-       /* Close thread quit pipes */
-       utils_close_pipe(live_thread_quit_pipe);
        free(live_uri);
 }
 
@@ -139,21 +137,6 @@ void stop_threads(void)
        futex_nto1_wake(&viewer_cmd_queue.futex);
 }
 
-/*
- * Init thread quit pipe.
- *
- * Return -1 on error or 0 if all pipes are created.
- */
-static
-int init_thread_quit_pipe(void)
-{
-       int ret;
-
-       ret = utils_create_pipe_cloexec(live_thread_quit_pipe);
-
-       return ret;
-}
-
 /*
  * Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
  */
@@ -1719,7 +1702,7 @@ error:
  * main
  */
 int live_start_threads(struct lttng_uri *uri,
-               struct relay_local_data *relay_ctx)
+               struct relay_local_data *relay_ctx, int quit_pipe[2])
 {
        int ret = 0;
        void *status;
@@ -1728,10 +1711,8 @@ int live_start_threads(struct lttng_uri *uri,
        assert(uri);
        live_uri = uri;
 
-       /* Create thread quit pipe */
-       if ((ret = init_thread_quit_pipe()) < 0) {
-               goto error;
-       }
+       live_thread_quit_pipe[0] = quit_pipe[0];
+       live_thread_quit_pipe[1] = quit_pipe[1];
 
        /* Check if daemon is UID = 0 */
        is_root = !getuid();
index 52608a4f7aeddabb87e2303cd2e730c68b33b8d1..5d8b77dd4191a6f7b1a7c38758261d01d2e66fae 100644 (file)
@@ -24,7 +24,7 @@
 #include "lttng-relayd.h"
 
 int live_start_threads(struct lttng_uri *live_uri,
-               struct relay_local_data *relay_ctx);
+               struct relay_local_data *relay_ctx, int quit_pipe[2]);
 void live_stop_threads(void);
 
 struct relay_viewer_stream *live_find_viewer_stream_by_id(uint64_t stream_id);
index dffcaff9855a61b265bba6b3eb376a990188a76e..dc41caad031dade163e0353c008c5371edbec7b3 100644 (file)
@@ -2527,7 +2527,7 @@ int main(int argc, char **argv)
                goto exit_listener;
        }
 
-       ret = live_start_threads(live_uri, relay_ctx);
+       ret = live_start_threads(live_uri, relay_ctx, thread_quit_pipe);
        if (ret != 0) {
                ERR("Starting live viewer threads");
        }
@@ -2552,6 +2552,8 @@ exit_dispatcher:
                PERROR("pthread_join");
                goto error;     /* join error, exit without cleanup */
        }
+
+       live_stop_threads();
        lttng_ht_destroy(viewer_streams_ht);
 
 exit_relay_ctx_viewer_streams:
@@ -2564,7 +2566,6 @@ exit_relay_ctx_sessions:
        free(relay_ctx);
 
 exit:
-       live_stop_threads();
        cleanup();
        if (!ret) {
                exit(EXIT_SUCCESS);
This page took 0.029062 seconds and 4 git commands to generate.