relayd: track the health quit pipe with the fd-tracker
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Nov 2019 22:10:02 +0000 (17:10 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 30 Jan 2020 06:55:34 +0000 (01:55 -0500)
Create the relayd health thread quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib82eabc0f152a706ac76a5042af2e3984d7e7f72

src/bin/lttng-relayd/main.c

index 43e60a48d78ebca51ff6378f20ffc818da494828..80d2fb1892658d9e4c46c1bce9631aa357dedbc3 100644 (file)
@@ -664,7 +664,10 @@ static void relayd_cleanup(void)
                health_app_destroy(health_relayd);
        }
        /* Close thread quit pipes */
-       utils_close_pipe(health_quit_pipe);
+       if (health_quit_pipe[0] != -1) {
+               (void) fd_tracker_util_pipe_close(
+                               the_fd_tracker, health_quit_pipe);
+       }
        if (thread_quit_pipe[0] != -1) {
                (void) fd_tracker_util_pipe_close(
                                the_fd_tracker, thread_quit_pipe);
@@ -842,6 +845,17 @@ static int init_thread_quit_pipe(void)
                        the_fd_tracker, "Quit pipe", thread_quit_pipe);
 }
 
+/*
+ * Init health quit pipe.
+ *
+ * Return -1 on error or 0 if all pipes are created.
+ */
+static int init_health_quit_pipe(void)
+{
+       return fd_tracker_util_pipe_open_cloexec(the_fd_tracker,
+                       "Health quit pipe", health_quit_pipe);
+}
+
 /*
  * Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
  */
@@ -4126,7 +4140,7 @@ int main(int argc, char **argv)
                goto exit_options;
        }
 
-       ret = utils_create_pipe(health_quit_pipe);
+       ret = init_health_quit_pipe();
        if (ret) {
                retval = -1;
                goto exit_options;
This page took 0.027498 seconds and 4 git commands to generate.