relayd: use same pipe for live and main
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Jan 2014 04:34:17 +0000 (23:34 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 28 Jan 2014 21:19:42 +0000 (16:19 -0500)
Don't use a duplicate of file descriptors. Ownership is easier to track
without a copy.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-relayd/live.c
src/bin/lttng-relayd/live.h
src/bin/lttng-relayd/lttng-relayd.h
src/bin/lttng-relayd/main.c

index 84057bfb4048bf4ab8f6b4c0c23ec27e55d30da1..bfa7b85259ad7d3d2a75fdba5dfb416feccfe13c 100644 (file)
 
 static struct lttng_uri *live_uri;
 
-/*
- * Quit pipe for all threads. This permits a single cancellation point
- * for all threads when receiving an event on the pipe.
- */
-static int live_thread_quit_pipe[2] = { -1, -1 };
-
 /*
  * This pipe is used to inform the worker thread that a command is queued and
  * ready to be processed.
@@ -126,7 +120,7 @@ void stop_threads(void)
 
        /* Stopping all threads */
        DBG("Terminating all live threads");
-       ret = notify_thread_pipe(live_thread_quit_pipe[1]);
+       ret = notify_thread_pipe(thread_quit_pipe[1]);
        if (ret < 0) {
                ERR("write error on thread quit pipe");
        }
@@ -155,7 +149,7 @@ int create_thread_poll_set(struct lttng_poll_event *events, int size)
        }
 
        /* Add quit pipe */
-       ret = lttng_poll_add(events, live_thread_quit_pipe[0], LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(events, thread_quit_pipe[0], LPOLLIN | LPOLLERR);
        if (ret < 0) {
                goto error;
        }
@@ -174,7 +168,7 @@ error:
 static
 int check_thread_quit_pipe(int fd, uint32_t events)
 {
-       if (fd == live_thread_quit_pipe[0] && (events & LPOLLIN)) {
+       if (fd == thread_quit_pipe[0] && (events & LPOLLIN)) {
                return 1;
        }
 
@@ -2044,7 +2038,7 @@ error:
  * main
  */
 int live_start_threads(struct lttng_uri *uri,
-               struct relay_local_data *relay_ctx, int quit_pipe[2])
+               struct relay_local_data *relay_ctx)
 {
        int ret = 0;
        void *status;
@@ -2053,9 +2047,6 @@ int live_start_threads(struct lttng_uri *uri,
        assert(uri);
        live_uri = uri;
 
-       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 5d8b77dd4191a6f7b1a7c38758261d01d2e66fae..52608a4f7aeddabb87e2303cd2e730c68b33b8d1 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, int quit_pipe[2]);
+               struct relay_local_data *relay_ctx);
 void live_stop_threads(void);
 
 struct relay_viewer_stream *live_find_viewer_stream_by_id(uint64_t stream_id);
index 4d23615676bcb9def4560e570305400597c8e7b4..c08c17a4faf83d552d7d43ebe79610adf7d307d3 100644 (file)
@@ -239,6 +239,8 @@ extern const char *tracing_group_name;
 
 extern const char * const config_section_name;
 
+extern int thread_quit_pipe[2];
+
 struct relay_stream *relay_stream_find_by_id(uint64_t stream_id);
 void lttng_relay_notify_ready(void);
 
index 62e149ed2cbdaf574968cbbe93659c48c8907db3..789e3300abc1e33a604a5d5aa78ffc816ae3ce4d 100644 (file)
@@ -90,7 +90,7 @@ const char * const config_section_name = "relayd";
  * Quit pipe for all threads. This permits a single cancellation point
  * for all threads when receiving an event on the pipe.
  */
-static int thread_quit_pipe[2] = { -1, -1 };
+int thread_quit_pipe[2] = { -1, -1 };
 
 /*
  * This pipe is used to inform the worker thread that a command is queued and
@@ -2998,7 +2998,7 @@ int main(int argc, char **argv)
                goto exit_listener;
        }
 
-       ret = live_start_threads(live_uri, relay_ctx, thread_quit_pipe);
+       ret = live_start_threads(live_uri, relay_ctx);
        if (ret != 0) {
                ERR("Starting live viewer threads");
                goto exit_live;
This page took 0.030867 seconds and 5 git commands to generate.