X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fagent-thread.c;h=189e3ba6b671d38db58b19b6c998530ebcc3fae0;hb=2df44f1e14d94e6506192635d7aff0e87a3462f9;hp=4d53d6e09286a8d4968b38ac458ba80e64077705;hpb=b86685ef513314b56785e3d6c457e321dc8a9d1c;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/agent-thread.c b/src/bin/lttng-sessiond/agent-thread.c index 4d53d6e09..189e3ba6b 100644 --- a/src/bin/lttng-sessiond/agent-thread.c +++ b/src/bin/lttng-sessiond/agent-thread.c @@ -32,6 +32,8 @@ #include "session.h" #include "utils.h" +static int agent_tracing_enabled = -1; + /* * Note that there is not port here. It's set after this URI is parsed so we * can let the user define a custom one. However, localhost is ALWAYS the @@ -223,6 +225,15 @@ error: return ret; } +bool agent_tracing_is_enabled(void) +{ + int enabled; + + enabled = uatomic_read(&agent_tracing_enabled); + assert(enabled != -1); + return enabled == 1; +} + /* * This thread manage application notify communication. */ @@ -244,10 +255,17 @@ void *agent_thread_manage_registration(void *data) /* Create pollset with size 2, quit pipe and socket. */ ret = sessiond_set_thread_pollset(&events, 2); if (ret < 0) { + sessiond_notify_ready(); goto error_poll_create; } reg_sock = init_tcp_socket(); + uatomic_set(&agent_tracing_enabled, !!reg_sock); + + /* + * Signal that the agent thread is ready. The command thread + * may start to query whether or not agent tracing is enabled. + */ sessiond_notify_ready(); if (!reg_sock) { goto error_tcp_socket; @@ -348,6 +366,7 @@ restart: } exit: + uatomic_set(&agent_tracing_enabled, 0); /* Whatever happens, try to delete it and exit. */ (void) lttng_poll_del(&events, reg_sock->fd); error: