X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-consumerd%2Fhealth-consumerd.c;h=2ea6303f77533fd28bf9684598733bdf4f8cf9c9;hb=4adbcc726eda1a14966e9f9ea7c0381a048ae8f6;hp=413df9acfb92eff3ad4e3566708c7709edd6fe24;hpb=dbc8403ddf4274527a5be169978d5f08991c9501;p=lttng-tools.git diff --git a/src/bin/lttng-consumerd/health-consumerd.c b/src/bin/lttng-consumerd/health-consumerd.c index 413df9acf..2ea6303f7 100644 --- a/src/bin/lttng-consumerd/health-consumerd.c +++ b/src/bin/lttng-consumerd/health-consumerd.c @@ -15,7 +15,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -36,15 +36,14 @@ #include #include #include -#include #include #include #include #include #include -#include -#include +#include +#include #include #include #include @@ -233,6 +232,10 @@ void *thread_manage_health(void *data) goto error; } + /* Perform prior memory accesses before decrementing ready */ + cmm_smp_mb__before_uatomic_dec(); + uatomic_dec(<tng_consumer_ready); + while (1) { DBG("Health check ready"); @@ -256,6 +259,11 @@ restart: revents = LTTNG_POLL_GETEV(&events, i); pollfd = LTTNG_POLL_GETFD(&events, i); + if (!revents) { + /* No activity for this FD (poll implementation). */ + continue; + } + /* Thread quit pipe has been closed. Killing thread. */ ret = check_health_quit_pipe(pollfd, revents); if (ret) { @@ -265,7 +273,8 @@ restart: /* Event on the registration socket */ if (pollfd == sock) { - if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { + if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP) + && !(revents & LPOLLIN)) { ERR("Health socket poll error"); goto error; } @@ -299,7 +308,7 @@ restart: assert(msg.cmd == HEALTH_CMD_CHECK); - reply.ret_code = 0; + memset(&reply, 0, sizeof(reply)); for (i = 0; i < NR_HEALTH_CONSUMERD_TYPES; i++) { /* * health_check_state return 0 if thread is in @@ -310,7 +319,7 @@ restart: } } - DBG2("Health check return value %" PRIx64, reply.ret_code); + DBG("Health check return value %" PRIx64, reply.ret_code); ret = send_unix_sock(new_sock, (void *) &reply, sizeof(reply)); if (ret < 0) {