X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-consumerd%2Fhealth-consumerd.cpp;h=f8be972c595986fae6c4aca3b3363a59dc39dcf3;hb=8a00688e1d58cc5a2e77eba206ff23bd6105130c;hp=90b4b1e12439eb9dcc34a265c20c37a3608668ce;hpb=657d1bf105996bf8f6e13af697fb1112afa61b28;p=lttng-tools.git diff --git a/src/bin/lttng-consumerd/health-consumerd.cpp b/src/bin/lttng-consumerd/health-consumerd.cpp index 90b4b1e12..f8be972c5 100644 --- a/src/bin/lttng-consumerd/health-consumerd.cpp +++ b/src/bin/lttng-consumerd/health-consumerd.cpp @@ -29,36 +29,21 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include "lttng-consumerd.h" -#include "health-consumerd.h" +#include "lttng-consumerd.hpp" +#include "health-consumerd.hpp" /* Global health check unix path */ static char health_unix_sock_path[PATH_MAX]; -int health_quit_pipe[2]; - -/* - * Check if the thread quit pipe was triggered. - * - * Return 1 if it was triggered else 0; - */ -static -int check_health_quit_pipe(int fd, uint32_t events) -{ - if (fd == health_quit_pipe[0] && (events & LPOLLIN)) { - return 1; - } - - return 0; -} +int health_quit_pipe[2] = {-1, -1}; /* * Send data on a unix socket using the liblttsessiondcomm API. @@ -144,10 +129,10 @@ end: /* * Thread managing health check socket. */ -void *thread_manage_health(void *data) +void *thread_manage_health_consumerd(void *data __attribute__((unused))) { - int sock = -1, new_sock = -1, ret, i, pollfd, err = -1; - uint32_t revents, nb_fd; + int sock = -1, new_sock = -1, ret, i, err = -1; + uint32_t nb_fd; struct lttng_poll_event events; struct health_comm_msg msg; struct health_comm_reply reply; @@ -210,7 +195,7 @@ void *thread_manage_health(void *data) goto error; } - /* Size is set to 1 for the consumer_channel pipe */ + /* Size is set to 2 for the quit pipe and registration socket. */ ret = lttng_poll_create(&events, 2, LTTNG_CLOEXEC); if (ret < 0) { ERR("Poll set creation failed"); @@ -252,12 +237,12 @@ restart: for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ - revents = LTTNG_POLL_GETEV(&events, i); - pollfd = LTTNG_POLL_GETFD(&events, i); + const auto revents = LTTNG_POLL_GETEV(&events, i); + const auto pollfd = LTTNG_POLL_GETFD(&events, i); - /* Thread quit pipe has been closed. Killing thread. */ - ret = check_health_quit_pipe(pollfd, revents); - if (ret) { + /* Activity on health quit pipe, exiting. */ + if (pollfd == health_quit_pipe[0]) { + DBG("Activity on health quit pipe"); err = 0; goto exit; }