X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-consumerd%2Fhealth-consumerd.c;h=dc8b32aa880d74b8685c16422917e430c1af2f70;hb=46440d0ccf65b098757389ffebb0f7452626c4a3;hp=60808f37094d304480468875c5cde6b944599c9c;hpb=6c71277b0dc97ce8a4ac6b8d359b4b349c04b658;p=lttng-tools.git diff --git a/src/bin/lttng-consumerd/health-consumerd.c b/src/bin/lttng-consumerd/health-consumerd.c index 60808f370..dc8b32aa8 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 @@ -119,8 +118,6 @@ int setup_health_path(void) goto end; } } else { - static char *rundir; - home_path = utils_get_home_dir(); if (home_path == NULL) { /* TODO: Add --socket PATH option */ @@ -129,16 +126,6 @@ int setup_health_path(void) goto end; } - /* - * Create rundir from home path. This will create something like - * $HOME/.lttng - */ - ret = asprintf(&rundir, DEFAULT_LTTNG_HOME_RUNDIR, home_path); - if (ret < 0) { - ret = -ENOMEM; - goto end; - } - /* Set health check Unix path */ if (strlen(health_unix_sock_path) != 0) { goto end; @@ -146,22 +133,21 @@ int setup_health_path(void) switch (type) { case LTTNG_CONSUMER_KERNEL: snprintf(health_unix_sock_path, sizeof(health_unix_sock_path), - DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK, rundir); + DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK, home_path); break; case LTTNG_CONSUMER64_UST: snprintf(health_unix_sock_path, sizeof(health_unix_sock_path), - DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK, rundir); + DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK, home_path); break; case LTTNG_CONSUMER32_UST: snprintf(health_unix_sock_path, sizeof(health_unix_sock_path), - DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK, rundir); + DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK, home_path); break; default: ret = -EINVAL; goto end; } } - end: return ret; } @@ -191,19 +177,26 @@ void *thread_manage_health(void *data) sock = lttcomm_create_unix_sock(health_unix_sock_path); if (sock < 0) { ERR("Unable to create health check Unix socket"); - ret = -1; + err = -1; goto error; } is_root = !getuid(); if (is_root) { /* lttng health client socket path permissions */ - ret = chown(health_unix_sock_path, 0, - utils_get_group_id(tracing_group_name)); + gid_t gid; + + ret = utils_get_group_id(tracing_group_name, true, &gid); + if (ret) { + /* Default to root group. */ + gid = 0; + } + + ret = chown(health_unix_sock_path, 0, gid); if (ret < 0) { ERR("Unable to set group on %s", health_unix_sock_path); PERROR("chown"); - ret = -1; + err = -1; goto error; } @@ -212,7 +205,7 @@ void *thread_manage_health(void *data) if (ret < 0) { ERR("Unable to set permissions on %s", health_unix_sock_path); PERROR("chmod"); - ret = -1; + err = -1; goto error; } } @@ -246,6 +239,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"); @@ -278,7 +275,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; } @@ -312,7 +310,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 @@ -323,7 +321,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) {