X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fagent-thread.cpp;h=e54a7cecf6f450ec1e1594b42e9edb2e01a45b8b;hb=52e345b9ac912d033c2a2c25a170a01cf209839d;hp=5e158b49bea408d2c161121f90eed7fbe4294359;hpb=7966af5763c4aaca39df9bbfa9277ff15715c720;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/agent-thread.cpp b/src/bin/lttng-sessiond/agent-thread.cpp index 5e158b49b..e54a7cecf 100644 --- a/src/bin/lttng-sessiond/agent-thread.cpp +++ b/src/bin/lttng-sessiond/agent-thread.cpp @@ -7,21 +7,22 @@ #define _LGPL_SOURCE -#include -#include -#include -#include - -#include - -#include "fd-limit.h" -#include "agent-thread.h" -#include "agent.h" -#include "lttng-sessiond.h" -#include "session.h" -#include "utils.h" -#include "thread.h" - +#include +#include +#include +#include + +#include + +#include "fd-limit.hpp" +#include "agent-thread.hpp" +#include "agent.hpp" +#include "lttng-sessiond.hpp" +#include "session.hpp" +#include "utils.hpp" +#include "thread.hpp" + +namespace { struct thread_notifiers { struct lttng_pipe *quit_pipe; sem_t ready; @@ -36,15 +37,15 @@ struct agent_protocol_version { unsigned int major, minor; }; -static int agent_tracing_enabled = -1; +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 * default listening address. */ -static const char *default_reg_uri = - "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS; +const char *default_reg_uri = "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS; +} /* namespace */ /* * Update agent application using the given socket. This is done just after @@ -354,12 +355,12 @@ void wait_until_thread_is_ready(struct thread_notifiers *notifiers) */ static void *thread_agent_management(void *data) { - int i, ret, pollfd; - uint32_t revents, nb_fd; + int i, ret; + uint32_t nb_fd; struct lttng_poll_event events; struct lttcomm_sock *reg_sock; struct thread_notifiers *notifiers = (thread_notifiers *) data; - const int quit_pipe_read_fd = lttng_pipe_get_readfd( + const auto thread_quit_pipe_fd = lttng_pipe_get_readfd( notifiers->quit_pipe); DBG("Manage agent application registration."); @@ -376,8 +377,7 @@ static void *thread_agent_management(void *data) goto error_poll_create; } - ret = lttng_poll_add(&events, quit_pipe_read_fd, - LPOLLIN | LPOLLERR); + ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN); if (ret < 0) { goto error_tcp_socket; } @@ -410,8 +410,7 @@ static void *thread_agent_management(void *data) mark_thread_as_ready(notifiers); /* Add TCP socket to the poll set. */ - ret = lttng_poll_add(&events, reg_sock->fd, - LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP); + ret = lttng_poll_add(&events, reg_sock->fd, LPOLLIN | LPOLLRDHUP); if (ret < 0) { goto error; } @@ -438,11 +437,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. */ - if (pollfd == quit_pipe_read_fd) { + /* Activity on thread quit pipe, exiting. */ + if (pollfd == thread_quit_pipe_fd) { + DBG("Activity on thread quit pipe"); goto exit; } @@ -482,8 +482,7 @@ restart: * read), only add poll error event to only * detect shutdown. */ - ret = lttng_poll_add(&events, new_app_socket_fd, - LPOLLERR | LPOLLHUP | LPOLLRDHUP); + ret = lttng_poll_add(&events, new_app_socket_fd, LPOLLRDHUP); if (ret < 0) { agent_destroy_app(new_app); continue; @@ -570,7 +569,7 @@ bool launch_agent_management_thread(void) struct thread_notifiers *notifiers; struct lttng_thread *thread; - notifiers = (thread_notifiers *) zmalloc(sizeof(*notifiers)); + notifiers = zmalloc(); if (!notifiers) { goto error_alloc; }