From 412d7227e69ec845e44c49082a417f9454d9b55d Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 31 Mar 2021 10:36:33 -0400 Subject: [PATCH] Clean-up: sessiond: prepend `the_` to global variable names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This avoids name clashes between global variables and local variables or function parameters (notification_thread_handle, for example). This is a step towards enabling -Wshadow. This also helps readability, in my opinion, as it helps quickly spot that some code is using a global variable. Change-Id: Ib0e35ad7efcc54fa88e1900cab3388b98a06b8d9 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/action-executor.c | 5 +- src/bin/lttng-sessiond/agent-thread.c | 31 +- src/bin/lttng-sessiond/agent.c | 46 +-- src/bin/lttng-sessiond/agent.h | 4 +- src/bin/lttng-sessiond/channel.c | 2 +- src/bin/lttng-sessiond/client.c | 199 +++++----- src/bin/lttng-sessiond/cmd.c | 6 +- src/bin/lttng-sessiond/consumer.c | 12 +- src/bin/lttng-sessiond/dispatch.c | 7 +- src/bin/lttng-sessiond/globals.c | 40 +- src/bin/lttng-sessiond/health-sessiond.h | 2 +- src/bin/lttng-sessiond/health.c | 16 +- src/bin/lttng-sessiond/ht-cleanup.c | 18 +- src/bin/lttng-sessiond/kernel-consumer.c | 10 +- src/bin/lttng-sessiond/kernel.c | 6 +- src/bin/lttng-sessiond/lttng-sessiond.h | 34 +- src/bin/lttng-sessiond/main.c | 395 ++++++++++--------- src/bin/lttng-sessiond/manage-apps.c | 4 +- src/bin/lttng-sessiond/manage-consumer.c | 10 +- src/bin/lttng-sessiond/manage-kernel.c | 4 +- src/bin/lttng-sessiond/modprobe.c | 4 +- src/bin/lttng-sessiond/notification-thread.c | 8 +- src/bin/lttng-sessiond/notify-apps.c | 6 +- src/bin/lttng-sessiond/process-utils.c | 8 +- src/bin/lttng-sessiond/register.c | 28 +- src/bin/lttng-sessiond/rotation-thread.c | 4 +- src/bin/lttng-sessiond/session.c | 2 +- src/bin/lttng-sessiond/timer.c | 4 +- src/bin/lttng-sessiond/trace-kernel.c | 8 +- src/bin/lttng-sessiond/ust-app.c | 39 +- src/bin/lttng-sessiond/ust-app.h | 2 +- src/bin/lttng-sessiond/ust-registry.c | 4 +- src/bin/lttng-sessiond/utils.c | 4 +- tests/unit/test_session.c | 2 +- 34 files changed, 509 insertions(+), 465 deletions(-) diff --git a/src/bin/lttng-sessiond/action-executor.c b/src/bin/lttng-sessiond/action-executor.c index 86bada257..e5e72b09f 100644 --- a/src/bin/lttng-sessiond/action-executor.c +++ b/src/bin/lttng-sessiond/action-executor.c @@ -539,7 +539,8 @@ static void *action_executor_thread(void *_data) assert(executor); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR); + health_register(the_health_sessiond, + HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR); rcu_register_thread(); rcu_thread_online(); @@ -592,7 +593,7 @@ static void *action_executor_thread(void *_data) rcu_thread_offline(); rcu_unregister_thread(); - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); return NULL; } diff --git a/src/bin/lttng-sessiond/agent-thread.c b/src/bin/lttng-sessiond/agent-thread.c index 2015498ff..720639efd 100644 --- a/src/bin/lttng-sessiond/agent-thread.c +++ b/src/bin/lttng-sessiond/agent-thread.c @@ -90,8 +90,8 @@ static void update_agent_app(const struct agent_app *app) * We are protected against the addition of new events by the session * list lock being held. */ - cds_lfht_for_each_entry (trigger_agents_ht_by_domain->ht, &iter.iter, - trigger_agent, node.node) { + cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht, + &iter.iter, trigger_agent, node.node) { agent_update(trigger_agent, app); } rcu_read_unlock(); @@ -114,8 +114,8 @@ static struct lttcomm_sock *init_tcp_socket(void) */ ret = uri_parse(default_reg_uri, &uri); assert(ret); - assert(config.agent_tcp_port.begin > 0); - uri->port = config.agent_tcp_port.begin; + assert(the_config.agent_tcp_port.begin > 0); + uri->port = the_config.agent_tcp_port.begin; sock = lttcomm_alloc_sock_from_uri(uri); uri_free(uri); @@ -129,8 +129,8 @@ static struct lttcomm_sock *init_tcp_socket(void) goto error; } - for (port = config.agent_tcp_port.begin; - port <= config.agent_tcp_port.end; port++) { + for (port = the_config.agent_tcp_port.begin; + port <= the_config.agent_tcp_port.end; port++) { ret = lttcomm_sock_set_port(sock, (uint16_t) port); if (ret) { ERR("[agent-thread] Failed to set port %u on socket", @@ -154,16 +154,17 @@ static struct lttcomm_sock *init_tcp_socket(void) } if (!bind_succeeded) { - if (config.agent_tcp_port.begin == config.agent_tcp_port.end) { + if (the_config.agent_tcp_port.begin == + the_config.agent_tcp_port.end) { WARN("Another process is already using the agent port %i. " - "Agent support will be deactivated.", - config.agent_tcp_port.begin); + "Agent support will be deactivated.", + the_config.agent_tcp_port.begin); goto error; } else { WARN("All ports in the range [%i, %i] are already in use. " - "Agent support will be deactivated.", - config.agent_tcp_port.begin, - config.agent_tcp_port.end); + "Agent support will be deactivated.", + the_config.agent_tcp_port.begin, + the_config.agent_tcp_port.end); goto error; } } @@ -330,8 +331,8 @@ bool agent_tracing_is_enabled(void) */ static int write_agent_port(uint16_t port) { - return utils_create_pid_file((pid_t) port, - config.agent_port_file_path.value); + return utils_create_pid_file( + (pid_t) port, the_config.agent_port_file_path.value); } static @@ -368,7 +369,7 @@ static void *thread_agent_management(void *data) rcu_thread_online(); /* Agent initialization call MUST be called before starting the thread. */ - assert(agent_apps_ht_by_sock); + assert(the_agent_apps_ht_by_sock); /* Create pollset with size 2, quit pipe and registration socket. */ ret = lttng_poll_create(&events, 2, LTTNG_CLOEXEC); diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index b726e0184..10c2d7c85 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -677,7 +677,7 @@ int agent_enable_event(struct agent_event *event, rcu_read_lock(); - cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app, + cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { if (app->domain != domain) { continue; @@ -752,7 +752,7 @@ int agent_enable_context(const struct lttng_event_context *ctx, rcu_read_lock(); - cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app, + cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { struct agent_app_ctx *agent_ctx; @@ -812,7 +812,7 @@ int agent_disable_event(struct agent_event *event, rcu_read_lock(); - cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app, + cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { if (app->domain != domain) { continue; @@ -852,7 +852,7 @@ static int disable_context(struct agent_app_ctx *ctx, rcu_read_lock(); DBG2("Disabling agent application context %s:%s", ctx->provider_name, ctx->ctx_name); - cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app, + cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { if (app->domain != domain) { continue; @@ -896,7 +896,7 @@ int agent_list_events(struct lttng_event **events, } rcu_read_lock(); - cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app, + cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { ssize_t nb_ev; struct lttng_event *agent_events; @@ -994,7 +994,8 @@ struct agent_app *agent_find_app_by_sock(int sock) assert(sock >= 0); - lttng_ht_lookup(agent_apps_ht_by_sock, (void *)((unsigned long) sock), &iter); + lttng_ht_lookup(the_agent_apps_ht_by_sock, + (void *) ((unsigned long) sock), &iter); node = lttng_ht_iter_get_node_ulong(&iter); if (node == NULL) { goto error; @@ -1017,7 +1018,7 @@ void agent_add_app(struct agent_app *app) assert(app); DBG3("Agent adding app sock: %d and pid: %d to ht", app->sock->fd, app->pid); - lttng_ht_add_unique_ulong(agent_apps_ht_by_sock, &app->node); + lttng_ht_add_unique_ulong(the_agent_apps_ht_by_sock, &app->node); } /* @@ -1035,7 +1036,7 @@ void agent_delete_app(struct agent_app *app) DBG3("Agent deleting app pid: %d and sock: %d", app->pid, app->sock->fd); iter.iter.node = &app->node.node; - ret = lttng_ht_del(agent_apps_ht_by_sock, &iter); + ret = lttng_ht_del(the_agent_apps_ht_by_sock, &iter); assert(!ret); } @@ -1423,8 +1424,8 @@ void agent_destroy(struct agent *agt) */ int agent_app_ht_alloc(void) { - agent_apps_ht_by_sock = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); - return agent_apps_ht_by_sock ? 0 : -1; + the_agent_apps_ht_by_sock = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); + return the_agent_apps_ht_by_sock ? 0 : -1; } /* @@ -1461,11 +1462,12 @@ void agent_app_ht_clean(void) struct lttng_ht_node_ulong *node; struct lttng_ht_iter iter; - if (!agent_apps_ht_by_sock) { + if (!the_agent_apps_ht_by_sock) { return; } rcu_read_lock(); - cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, node, node) { + cds_lfht_for_each_entry( + the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) { struct agent_app *app; app = caa_container_of(node, struct agent_app, node); @@ -1473,7 +1475,7 @@ void agent_app_ht_clean(void) } rcu_read_unlock(); - lttng_ht_destroy(agent_apps_ht_by_sock); + lttng_ht_destroy(the_agent_apps_ht_by_sock); } /* @@ -1534,8 +1536,8 @@ void agent_update(const struct agent *agt, const struct agent_app *app) */ int agent_by_event_notifier_domain_ht_create(void) { - trigger_agents_ht_by_domain = lttng_ht_new(0, LTTNG_HT_TYPE_U64); - return trigger_agents_ht_by_domain ? 0 : -1; + the_trigger_agents_ht_by_domain = lttng_ht_new(0, LTTNG_HT_TYPE_U64); + return the_trigger_agents_ht_by_domain ? 0 : -1; } /* @@ -1546,24 +1548,24 @@ void agent_by_event_notifier_domain_ht_destroy(void) struct lttng_ht_node_u64 *node; struct lttng_ht_iter iter; - if (!trigger_agents_ht_by_domain) { + if (!the_trigger_agents_ht_by_domain) { return; } rcu_read_lock(); - cds_lfht_for_each_entry (trigger_agents_ht_by_domain->ht, &iter.iter, - node, node) { + cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht, + &iter.iter, node, node) { struct agent *agent = caa_container_of(node, struct agent, node); const int ret = lttng_ht_del( - trigger_agents_ht_by_domain, &iter); + the_trigger_agents_ht_by_domain, &iter); assert(ret == 0); agent_destroy(agent); } rcu_read_unlock(); - lttng_ht_destroy(trigger_agents_ht_by_domain); + lttng_ht_destroy(the_trigger_agents_ht_by_domain); } struct agent *agent_find_by_event_notifier_domain( @@ -1574,12 +1576,12 @@ struct agent *agent_find_by_event_notifier_domain( struct lttng_ht_iter iter; const uint64_t key = (uint64_t) domain_type; - assert(trigger_agents_ht_by_domain); + assert(the_trigger_agents_ht_by_domain); DBG3("Per-event notifier domain agent lookup for domain '%s'", lttng_domain_type_str(domain_type)); - lttng_ht_lookup(trigger_agents_ht_by_domain, &key, &iter); + lttng_ht_lookup(the_trigger_agents_ht_by_domain, &key, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (!node) { goto end; diff --git a/src/bin/lttng-sessiond/agent.h b/src/bin/lttng-sessiond/agent.h index c88af21c5..b0a4fa863 100644 --- a/src/bin/lttng-sessiond/agent.h +++ b/src/bin/lttng-sessiond/agent.h @@ -22,11 +22,11 @@ * Hash table that contains the agent app created upon registration indexed by * socket. Global to the session daemon. */ -extern struct lttng_ht *agent_apps_ht_by_sock; +extern struct lttng_ht *the_agent_apps_ht_by_sock; /* * Hash table that contains the trigger agents by domain */ -extern struct lttng_ht *trigger_agents_ht_by_domain; +extern struct lttng_ht *the_trigger_agents_ht_by_domain; struct agent_ht_key { const char *name; diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 049c784b3..2beb4f711 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -397,7 +397,7 @@ int channel_ust_create(struct ltt_ust_session *usess, /* * Invalid subbuffer size if it's lower then the page size. */ - if (attr->attr.subbuf_size < page_size) { + if (attr->attr.subbuf_size < the_page_size) { ret = LTTNG_ERR_INVALID; goto error; } diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index 770a2ee44..c9ff2ec70 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -208,7 +208,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) /* * Exec consumerd. */ - if (config.verbose_consumer) { + if (the_config.verbose_consumer) { verbosity = "--verbose"; } else if (lttng_opt_quiet) { verbosity = "--quiet"; @@ -224,35 +224,37 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) * fallback on the 32-bit one, */ DBG3("Looking for a kernel consumer at these locations:"); - DBG3(" 1) %s", config.consumerd64_bin_path.value ? : "NULL"); + DBG3(" 1) %s", the_config.consumerd64_bin_path.value ? : "NULL"); DBG3(" 2) %s/%s", INSTALL_BIN_PATH, DEFAULT_CONSUMERD_FILE); - DBG3(" 3) %s", config.consumerd32_bin_path.value ? : "NULL"); - if (stat(config.consumerd64_bin_path.value, &st) == 0) { + DBG3(" 3) %s", the_config.consumerd32_bin_path.value ? : "NULL"); + if (stat(the_config.consumerd64_bin_path.value, &st) == 0) { DBG3("Found location #1"); - consumer_to_use = config.consumerd64_bin_path.value; + consumer_to_use = the_config.consumerd64_bin_path.value; } else if (stat(INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE, &st) == 0) { DBG3("Found location #2"); consumer_to_use = INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE; - } else if (config.consumerd32_bin_path.value && - stat(config.consumerd32_bin_path.value, &st) == 0) { + } else if (the_config.consumerd32_bin_path.value && + stat(the_config.consumerd32_bin_path.value, &st) == 0) { DBG3("Found location #3"); - consumer_to_use = config.consumerd32_bin_path.value; + consumer_to_use = the_config.consumerd32_bin_path.value; } else { DBG("Could not find any valid consumerd executable"); ret = -EINVAL; goto error; } DBG("Using kernel consumer at: %s", consumer_to_use); - (void) execl(consumer_to_use, - "lttng-consumerd", verbosity, "-k", - "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, - "--consumerd-err-sock", consumer_data->err_unix_sock_path, - "--group", config.tracing_group_name.value, - NULL); + (void) execl(consumer_to_use, "lttng-consumerd", + verbosity, "-k", "--consumerd-cmd-sock", + consumer_data->cmd_unix_sock_path, + "--consumerd-err-sock", + consumer_data->err_unix_sock_path, + "--group", + the_config.tracing_group_name.value, + NULL); break; case LTTNG_CONSUMER64_UST: { - if (config.consumerd64_lib_dir.value) { + if (the_config.consumerd64_lib_dir.value) { const char *tmp; size_t tmplen; char *tmpnew; @@ -261,13 +263,13 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) if (!tmp) { tmp = ""; } - tmplen = strlen(config.consumerd64_lib_dir.value) + 1 /* : */ + strlen(tmp); + tmplen = strlen(the_config.consumerd64_lib_dir.value) + 1 /* : */ + strlen(tmp); tmpnew = zmalloc(tmplen + 1 /* \0 */); if (!tmpnew) { ret = -ENOMEM; goto error; } - strcat(tmpnew, config.consumerd64_lib_dir.value); + strcat(tmpnew, the_config.consumerd64_lib_dir.value); if (tmp[0] != '\0') { strcat(tmpnew, ":"); strcat(tmpnew, tmp); @@ -279,17 +281,22 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) goto error; } } - DBG("Using 64-bit UST consumer at: %s", config.consumerd64_bin_path.value); - (void) execl(config.consumerd64_bin_path.value, "lttng-consumerd", verbosity, "-u", - "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, - "--consumerd-err-sock", consumer_data->err_unix_sock_path, - "--group", config.tracing_group_name.value, + DBG("Using 64-bit UST consumer at: %s", + the_config.consumerd64_bin_path.value); + (void) execl(the_config.consumerd64_bin_path.value, + "lttng-consumerd", verbosity, "-u", + "--consumerd-cmd-sock", + consumer_data->cmd_unix_sock_path, + "--consumerd-err-sock", + consumer_data->err_unix_sock_path, + "--group", + the_config.tracing_group_name.value, NULL); break; } case LTTNG_CONSUMER32_UST: { - if (config.consumerd32_lib_dir.value) { + if (the_config.consumerd32_lib_dir.value) { const char *tmp; size_t tmplen; char *tmpnew; @@ -298,13 +305,13 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) if (!tmp) { tmp = ""; } - tmplen = strlen(config.consumerd32_lib_dir.value) + 1 /* : */ + strlen(tmp); + tmplen = strlen(the_config.consumerd32_lib_dir.value) + 1 /* : */ + strlen(tmp); tmpnew = zmalloc(tmplen + 1 /* \0 */); if (!tmpnew) { ret = -ENOMEM; goto error; } - strcat(tmpnew, config.consumerd32_lib_dir.value); + strcat(tmpnew, the_config.consumerd32_lib_dir.value); if (tmp[0] != '\0') { strcat(tmpnew, ":"); strcat(tmpnew, tmp); @@ -316,11 +323,16 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) goto error; } } - DBG("Using 32-bit UST consumer at: %s", config.consumerd32_bin_path.value); - (void) execl(config.consumerd32_bin_path.value, "lttng-consumerd", verbosity, "-u", - "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, - "--consumerd-err-sock", consumer_data->err_unix_sock_path, - "--group", config.tracing_group_name.value, + DBG("Using 32-bit UST consumer at: %s", + the_config.consumerd32_bin_path.value); + (void) execl(the_config.consumerd32_bin_path.value, + "lttng-consumerd", verbosity, "-u", + "--consumerd-cmd-sock", + consumer_data->cmd_unix_sock_path, + "--consumerd-err-sock", + consumer_data->err_unix_sock_path, + "--group", + the_config.tracing_group_name.value, NULL); break; } @@ -784,7 +796,8 @@ static int check_rotate_compatible(void) { int ret = 1; - if (kernel_tracer_version.major != 2 || kernel_tracer_version.minor < 11) { + if (the_kernel_tracer_version.major != 2 || + the_kernel_tracer_version.minor < 11) { DBG("Kernel tracer version is not compatible with the rotation feature"); ret = 0; } @@ -893,8 +906,8 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, break; } - if (config.no_kernel && need_domain - && cmd_ctx->lsm.domain.type == LTTNG_DOMAIN_KERNEL) { + if (the_config.no_kernel && need_domain && + cmd_ctx->lsm.domain.type == LTTNG_DOMAIN_KERNEL) { if (!is_root) { ret = LTTNG_ERR_NEED_ROOT_SESSIOND; } else { @@ -905,13 +918,13 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, /* Deny register consumer if we already have a spawned consumer. */ if (cmd_ctx->lsm.cmd_type == LTTNG_REGISTER_CONSUMER) { - pthread_mutex_lock(&kconsumer_data.pid_mutex); - if (kconsumer_data.pid > 0) { + pthread_mutex_lock(&the_kconsumer_data.pid_mutex); + if (the_kconsumer_data.pid > 0) { ret = LTTNG_ERR_KERN_CONSUMER_FAIL; - pthread_mutex_unlock(&kconsumer_data.pid_mutex); + pthread_mutex_unlock(&the_kconsumer_data.pid_mutex); goto error; } - pthread_mutex_unlock(&kconsumer_data.pid_mutex); + pthread_mutex_unlock(&the_kconsumer_data.pid_mutex); } /* @@ -1034,8 +1047,8 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, } /* Consumer is in an ERROR state. Report back to client */ - if (need_consumerd && uatomic_read(&kernel_consumerd_state) == - CONSUMER_ERROR) { + if (need_consumerd && uatomic_read(&the_kernel_consumerd_state) == + CONSUMER_ERROR) { ret = LTTNG_ERR_NO_KERNCONSUMERD; goto error; } @@ -1051,25 +1064,25 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, } /* Start the kernel consumer daemon */ - pthread_mutex_lock(&kconsumer_data.pid_mutex); - if (kconsumer_data.pid == 0 && + pthread_mutex_lock(&the_kconsumer_data.pid_mutex); + if (the_kconsumer_data.pid == 0 && cmd_ctx->lsm.cmd_type != LTTNG_REGISTER_CONSUMER) { - pthread_mutex_unlock(&kconsumer_data.pid_mutex); - ret = start_consumerd(&kconsumer_data); + pthread_mutex_unlock(&the_kconsumer_data.pid_mutex); + ret = start_consumerd(&the_kconsumer_data); if (ret < 0) { ret = LTTNG_ERR_KERN_CONSUMER_FAIL; goto error; } - uatomic_set(&kernel_consumerd_state, CONSUMER_STARTED); + uatomic_set(&the_kernel_consumerd_state, CONSUMER_STARTED); } else { - pthread_mutex_unlock(&kconsumer_data.pid_mutex); + pthread_mutex_unlock(&the_kconsumer_data.pid_mutex); } /* * The consumer was just spawned so we need to add the socket to * the consumer output of the session if exist. */ - ret = consumer_create_socket(&kconsumer_data, + ret = consumer_create_socket(&the_kconsumer_data, cmd_ctx->session->kernel_session->consumer); if (ret < 0) { goto error; @@ -1093,8 +1106,9 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, } /* Consumer is in an ERROR state. Report back to client */ - if (need_consumerd && uatomic_read(&ust_consumerd_state) == - CONSUMER_ERROR) { + if (need_consumerd && + uatomic_read(&the_ust_consumerd_state) == + CONSUMER_ERROR) { ret = LTTNG_ERR_NO_USTCONSUMERD; goto error; } @@ -1111,58 +1125,58 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, /* Start the UST consumer daemons */ /* 64-bit */ - pthread_mutex_lock(&ustconsumer64_data.pid_mutex); - if (config.consumerd64_bin_path.value && - ustconsumer64_data.pid == 0 && + pthread_mutex_lock(&the_ustconsumer64_data.pid_mutex); + if (the_config.consumerd64_bin_path.value && + the_ustconsumer64_data.pid == 0 && cmd_ctx->lsm.cmd_type != LTTNG_REGISTER_CONSUMER) { - pthread_mutex_unlock(&ustconsumer64_data.pid_mutex); - ret = start_consumerd(&ustconsumer64_data); + pthread_mutex_unlock(&the_ustconsumer64_data.pid_mutex); + ret = start_consumerd(&the_ustconsumer64_data); if (ret < 0) { ret = LTTNG_ERR_UST_CONSUMER64_FAIL; - uatomic_set(&ust_consumerd64_fd, -EINVAL); + uatomic_set(&the_ust_consumerd64_fd, -EINVAL); goto error; } - uatomic_set(&ust_consumerd64_fd, ustconsumer64_data.cmd_sock); - uatomic_set(&ust_consumerd_state, CONSUMER_STARTED); + uatomic_set(&the_ust_consumerd64_fd, the_ustconsumer64_data.cmd_sock); + uatomic_set(&the_ust_consumerd_state, CONSUMER_STARTED); } else { - pthread_mutex_unlock(&ustconsumer64_data.pid_mutex); + pthread_mutex_unlock(&the_ustconsumer64_data.pid_mutex); } /* * Setup socket for consumer 64 bit. No need for atomic access * since it was set above and can ONLY be set in this thread. */ - ret = consumer_create_socket(&ustconsumer64_data, + ret = consumer_create_socket(&the_ustconsumer64_data, cmd_ctx->session->ust_session->consumer); if (ret < 0) { goto error; } /* 32-bit */ - pthread_mutex_lock(&ustconsumer32_data.pid_mutex); - if (config.consumerd32_bin_path.value && - ustconsumer32_data.pid == 0 && + pthread_mutex_lock(&the_ustconsumer32_data.pid_mutex); + if (the_config.consumerd32_bin_path.value && + the_ustconsumer32_data.pid == 0 && cmd_ctx->lsm.cmd_type != LTTNG_REGISTER_CONSUMER) { - pthread_mutex_unlock(&ustconsumer32_data.pid_mutex); - ret = start_consumerd(&ustconsumer32_data); + pthread_mutex_unlock(&the_ustconsumer32_data.pid_mutex); + ret = start_consumerd(&the_ustconsumer32_data); if (ret < 0) { ret = LTTNG_ERR_UST_CONSUMER32_FAIL; - uatomic_set(&ust_consumerd32_fd, -EINVAL); + uatomic_set(&the_ust_consumerd32_fd, -EINVAL); goto error; } - uatomic_set(&ust_consumerd32_fd, ustconsumer32_data.cmd_sock); - uatomic_set(&ust_consumerd_state, CONSUMER_STARTED); + uatomic_set(&the_ust_consumerd32_fd, the_ustconsumer32_data.cmd_sock); + uatomic_set(&the_ust_consumerd_state, CONSUMER_STARTED); } else { - pthread_mutex_unlock(&ustconsumer32_data.pid_mutex); + pthread_mutex_unlock(&the_ustconsumer32_data.pid_mutex); } /* * Setup socket for consumer 32 bit. No need for atomic access * since it was set above and can ONLY be set in this thread. */ - ret = consumer_create_socket(&ustconsumer32_data, + ret = consumer_create_socket(&the_ustconsumer32_data, cmd_ctx->session->ust_session->consumer); if (ret < 0) { goto error; @@ -1185,13 +1199,13 @@ skip_domain: case LTTNG_DOMAIN_LOG4J: case LTTNG_DOMAIN_PYTHON: case LTTNG_DOMAIN_UST: - if (uatomic_read(&ust_consumerd_state) != CONSUMER_STARTED) { + if (uatomic_read(&the_ust_consumerd_state) != CONSUMER_STARTED) { ret = LTTNG_ERR_NO_USTCONSUMERD; goto error; } break; case LTTNG_DOMAIN_KERNEL: - if (uatomic_read(&kernel_consumerd_state) != CONSUMER_STARTED) { + if (uatomic_read(&the_kernel_consumerd_state) != CONSUMER_STARTED) { ret = LTTNG_ERR_NO_KERNCONSUMERD; goto error; } @@ -1292,7 +1306,7 @@ skip_domain: cmd_ctx->lsm.domain.type, cmd_ctx->lsm.u.context.channel_name, ALIGNED_CONST_PTR(cmd_ctx->lsm.u.context.ctx), - kernel_poll_pipe[1]); + the_kernel_poll_pipe[1]); cmd_ctx->lsm.u.context.ctx.u.app_ctx.provider_name = NULL; cmd_ctx->lsm.u.context.ctx.u.app_ctx.ctx_name = NULL; @@ -1351,7 +1365,7 @@ error_add_context: ret = cmd_enable_channel(cmd_ctx->session, ALIGNED_CONST_PTR(cmd_ctx->lsm.domain), ALIGNED_CONST_PTR(cmd_ctx->lsm.u.channel.chan), - kernel_poll_pipe[1]); + the_kernel_poll_pipe[1]); break; } case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE: @@ -1685,7 +1699,7 @@ error_add_context: cmd_ctx->lsm.u.enable.channel_name, ev, filter_expression, bytecode, exclusion, - kernel_poll_pipe[1]); + the_kernel_poll_pipe[1]); lttng_event_destroy(ev); break; } @@ -1841,8 +1855,7 @@ error_add_context: case LTTNG_DESTROY_SESSION: { ret = cmd_destroy_session(cmd_ctx->session, - notification_thread_handle, - sock); + the_notification_thread_handle, sock); break; } case LTTNG_LIST_DOMAINS: @@ -1968,7 +1981,7 @@ error_add_context: switch (cmd_ctx->lsm.domain.type) { case LTTNG_DOMAIN_KERNEL: - cdata = &kconsumer_data; + cdata = &the_kconsumer_data; break; default: ret = LTTNG_ERR_UND; @@ -2159,7 +2172,8 @@ error_add_context: original_reply_payload_size = cmd_ctx->reply_payload.buffer.size; ret = cmd_register_trigger(&cmd_creds, payload_trigger, - notification_thread_handle, &return_trigger); + the_notification_thread_handle, + &return_trigger); if (ret != LTTNG_OK) { lttng_trigger_put(payload_trigger); goto error; @@ -2197,7 +2211,7 @@ error_add_context: } ret = cmd_unregister_trigger(&cmd_creds, payload_trigger, - notification_thread_handle); + the_notification_thread_handle); lttng_trigger_put(payload_trigger); break; } @@ -2270,11 +2284,9 @@ error_add_context: schedule_type = (enum lttng_rotation_schedule_type) cmd_ctx->lsm.u.rotation_set_schedule.type; value = cmd_ctx->lsm.u.rotation_set_schedule.value; - ret = cmd_rotation_set_schedule(cmd_ctx->session, - set_schedule, - schedule_type, - value, - notification_thread_handle); + ret = cmd_rotation_set_schedule(cmd_ctx->session, set_schedule, + schedule_type, value, + the_notification_thread_handle); if (ret != LTTNG_OK) { goto error; } @@ -2319,8 +2331,8 @@ error_add_context: original_payload_size = cmd_ctx->reply_payload.buffer.size; - ret = cmd_list_triggers(cmd_ctx, - notification_thread_handle, &return_triggers); + ret = cmd_list_triggers(cmd_ctx, the_notification_thread_handle, + &return_triggers); if (ret != LTTNG_OK) { goto error; } @@ -2377,9 +2389,11 @@ static int create_client_sock(void) const mode_t old_umask = umask(0); /* Create client tool unix socket */ - client_sock = lttcomm_create_unix_sock(config.client_unix_sock_path.value); + client_sock = lttcomm_create_unix_sock( + the_config.client_unix_sock_path.value); if (client_sock < 0) { - ERR("Create unix sock failed: %s", config.client_unix_sock_path.value); + ERR("Create unix sock failed: %s", + the_config.client_unix_sock_path.value); ret = -1; goto end; } @@ -2393,10 +2407,11 @@ static int create_client_sock(void) } /* File permission MUST be 660 */ - ret = chmod(config.client_unix_sock_path.value, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + ret = chmod(the_config.client_unix_sock_path.value, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); if (ret < 0) { ERR("Set file permissions failed: %s", - config.client_unix_sock_path.value); + the_config.client_unix_sock_path.value); PERROR("chmod"); (void) lttcomm_close_unix_sock(client_sock); ret = -1; @@ -2446,7 +2461,7 @@ static void *thread_manage_clients(void *data) rcu_register_thread(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_CMD); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_CMD); health_code_update(); @@ -2684,7 +2699,7 @@ error: error_listen: error_create_poll: - unlink(config.client_unix_sock_path.value); + unlink(the_config.client_unix_sock_path.value); ret = close(client_sock); if (ret) { PERROR("close"); @@ -2695,7 +2710,7 @@ error_create_poll: ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); DBG("Client thread dying"); lttng_payload_reset(&cmd_ctx.reply_payload); diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 28e0df019..73773bd13 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -4360,7 +4360,7 @@ enum lttng_error_code synchronize_tracer_notifier_register( goto end_unlock_session_list; } - agent_add(agt, trigger_agents_ht_by_domain); + agent_add(agt, the_trigger_agents_ht_by_domain); } ret_code = trigger_agent_enable(trigger, agt); @@ -5320,8 +5320,8 @@ int cmd_rotate_session(struct ltt_session *session, chunk_being_archived = NULL; if (!quiet_rotation) { ret = notification_thread_command_session_rotation_ongoing( - notification_thread_handle, - session->name, session->uid, session->gid, + the_notification_thread_handle, session->name, + session->uid, session->gid, ongoing_rotation_chunk_id); if (ret != LTTNG_OK) { ERR("Failed to notify notification thread that a session rotation is ongoing for session %s", diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 115a46e2e..4ba40a075 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -370,10 +370,10 @@ struct consumer_socket *consumer_find_socket_by_bitness(int bits, switch (bits) { case 64: - consumer_fd = uatomic_read(&ust_consumerd64_fd); + consumer_fd = uatomic_read(&the_ust_consumerd64_fd); break; case 32: - consumer_fd = uatomic_read(&ust_consumerd32_fd); + consumer_fd = uatomic_read(&the_ust_consumerd32_fd); break; default: assert(0); @@ -1153,12 +1153,10 @@ int consumer_send_relayd_socket(struct consumer_socket *consumer_sock, char output_path[LTTNG_PATH_MAX] = {}; uint64_t relayd_session_id; - ret = relayd_create_session(rsock, - &relayd_session_id, + ret = relayd_create_session(rsock, &relayd_session_id, session_name, hostname, base_path, - session_live_timer, - consumer->snapshot, session_id, - sessiond_uuid, current_chunk_id, + session_live_timer, consumer->snapshot, + session_id, the_sessiond_uuid, current_chunk_id, session_creation_time, session_name_contains_creation_time, output_path); diff --git a/src/bin/lttng-sessiond/dispatch.c b/src/bin/lttng-sessiond/dispatch.c index d33a3cba8..22380fcdd 100644 --- a/src/bin/lttng-sessiond/dispatch.c +++ b/src/bin/lttng-sessiond/dispatch.c @@ -39,7 +39,7 @@ static void update_ust_app(int app_sock) struct ust_app *app; /* Consumer is in an ERROR state. Stop any application update. */ - if (uatomic_read(&ust_consumerd_state) == CONSUMER_ERROR) { + if (uatomic_read(&the_ust_consumerd_state) == CONSUMER_ERROR) { /* Stop the update process since the consumer is dead. */ return; } @@ -235,7 +235,8 @@ static void *thread_dispatch_ust_registration(void *data) rcu_register_thread(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH); + health_register(the_health_sessiond, + HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH); if (testpoint(sessiond_thread_app_reg_dispatch)) { goto error_testpoint; @@ -486,7 +487,7 @@ error_testpoint: health_error(); ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); rcu_unregister_thread(); return NULL; } diff --git a/src/bin/lttng-sessiond/globals.c b/src/bin/lttng-sessiond/globals.c index 85c1eec90..53be62d7e 100644 --- a/src/bin/lttng-sessiond/globals.c +++ b/src/bin/lttng-sessiond/globals.c @@ -10,31 +10,31 @@ #include "lttng-sessiond.h" #include -lttng_uuid sessiond_uuid; +lttng_uuid the_sessiond_uuid; -int ust_consumerd64_fd = -1; -int ust_consumerd32_fd = -1; +int the_ust_consumerd64_fd = -1; +int the_ust_consumerd32_fd = -1; -long page_size; +long the_page_size; -struct health_app *health_sessiond; +struct health_app *the_health_sessiond; -struct notification_thread_handle *notification_thread_handle; +struct notification_thread_handle *the_notification_thread_handle; -struct lttng_ht *agent_apps_ht_by_sock = NULL; -struct lttng_ht *trigger_agents_ht_by_domain = NULL; +struct lttng_ht *the_agent_apps_ht_by_sock = NULL; +struct lttng_ht *the_trigger_agents_ht_by_domain = NULL; -struct lttng_kernel_tracer_version kernel_tracer_version; -struct lttng_kernel_tracer_abi_version kernel_tracer_abi_version; +struct lttng_kernel_tracer_version the_kernel_tracer_version; +struct lttng_kernel_tracer_abi_version the_kernel_tracer_abi_version; -int kernel_poll_pipe[2] = { -1, -1 }; +int the_kernel_poll_pipe[2] = {-1, -1}; -pid_t ppid; -pid_t child_ppid; +pid_t the_ppid; +pid_t the_child_ppid; -struct sessiond_config config; +struct sessiond_config the_config; -struct consumer_data kconsumer_data = { +struct consumer_data the_kconsumer_data = { .type = LTTNG_CONSUMER_KERNEL, .err_sock = -1, .cmd_sock = -1, @@ -43,7 +43,7 @@ struct consumer_data kconsumer_data = { .lock = PTHREAD_MUTEX_INITIALIZER, }; -struct consumer_data ustconsumer64_data = { +struct consumer_data the_ustconsumer64_data = { .type = LTTNG_CONSUMER64_UST, .err_sock = -1, .cmd_sock = -1, @@ -52,7 +52,7 @@ struct consumer_data ustconsumer64_data = { .lock = PTHREAD_MUTEX_INITIALIZER, }; -struct consumer_data ustconsumer32_data = { +struct consumer_data the_ustconsumer32_data = { .type = LTTNG_CONSUMER32_UST, .err_sock = -1, .cmd_sock = -1, @@ -61,12 +61,12 @@ struct consumer_data ustconsumer32_data = { .lock = PTHREAD_MUTEX_INITIALIZER, }; -enum consumerd_state ust_consumerd_state; -enum consumerd_state kernel_consumerd_state; +enum consumerd_state the_ust_consumerd_state; +enum consumerd_state the_kernel_consumerd_state; static void __attribute__((constructor)) init_sessiond_uuid(void) { - if (lttng_uuid_generate(sessiond_uuid)) { + if (lttng_uuid_generate(the_sessiond_uuid)) { ERR("Failed to generate a session daemon UUID"); abort(); } diff --git a/src/bin/lttng-sessiond/health-sessiond.h b/src/bin/lttng-sessiond/health-sessiond.h index b541822f8..af950b134 100644 --- a/src/bin/lttng-sessiond/health-sessiond.h +++ b/src/bin/lttng-sessiond/health-sessiond.h @@ -29,7 +29,7 @@ enum health_type_sessiond { }; /* Application health monitoring */ -extern struct health_app *health_sessiond; +extern struct health_app *the_health_sessiond; bool launch_health_management_thread(void); diff --git a/src/bin/lttng-sessiond/health.c b/src/bin/lttng-sessiond/health.c index 483616ac2..7fc557da5 100644 --- a/src/bin/lttng-sessiond/health.c +++ b/src/bin/lttng-sessiond/health.c @@ -77,7 +77,7 @@ static void *thread_manage_health(void *data) } /* Create unix socket */ - sock = lttcomm_create_unix_sock(config.health_unix_sock_path.value); + sock = lttcomm_create_unix_sock(the_config.health_unix_sock_path.value); if (sock < 0) { ERR("Unable to create health check Unix socket"); goto error; @@ -87,23 +87,23 @@ static void *thread_manage_health(void *data) /* lttng health client socket path permissions */ gid_t gid; - ret = utils_get_group_id(config.tracing_group_name.value, true, &gid); + ret = utils_get_group_id(the_config.tracing_group_name.value, true, &gid); if (ret) { /* Default to root group. */ gid = 0; } - ret = chown(config.health_unix_sock_path.value, 0, gid); + ret = chown(the_config.health_unix_sock_path.value, 0, gid); if (ret < 0) { - ERR("Unable to set group on %s", config.health_unix_sock_path.value); + ERR("Unable to set group on %s", the_config.health_unix_sock_path.value); PERROR("chown"); goto error; } - ret = chmod(config.health_unix_sock_path.value, + ret = chmod(the_config.health_unix_sock_path.value, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); if (ret < 0) { - ERR("Unable to set permissions on %s", config.health_unix_sock_path.value); + ERR("Unable to set permissions on %s", the_config.health_unix_sock_path.value); PERROR("chmod"); goto error; } @@ -203,7 +203,7 @@ restart: * health_check_state returns 0 if health is * bad. */ - if (!health_check_state(health_sessiond, i)) { + if (!health_check_state(the_health_sessiond, i)) { reply.ret_code |= 1ULL << i; } } @@ -229,7 +229,7 @@ error: ERR("Health error occurred in %s", __func__); } DBG("Health check thread dying"); - unlink(config.health_unix_sock_path.value); + unlink(the_config.health_unix_sock_path.value); if (sock >= 0) { ret = close(sock); if (ret) { diff --git a/src/bin/lttng-sessiond/ht-cleanup.c b/src/bin/lttng-sessiond/ht-cleanup.c index 8de175d11..c670baf49 100644 --- a/src/bin/lttng-sessiond/ht-cleanup.c +++ b/src/bin/lttng-sessiond/ht-cleanup.c @@ -70,7 +70,7 @@ static int set_pollset(struct lttng_poll_event *events, size_t size) goto error; } - ret = lttng_poll_add(events, ht_cleanup_pipe[0], LPOLLIN | LPOLLERR); + ret = lttng_poll_add(events, the_ht_cleanup_pipe[0], LPOLLIN | LPOLLERR); if (ret < 0) { DBG("[ht-thread] lttng_poll_add error %d.", ret); goto error; @@ -85,7 +85,7 @@ error: static void cleanup_ht_cleanup_thread(void *data) { utils_close_pipe(ht_cleanup_quit_pipe); - utils_close_pipe(ht_cleanup_pipe); + utils_close_pipe(the_ht_cleanup_pipe); } static void *thread_ht_cleanup(void *data) @@ -100,7 +100,7 @@ static void *thread_ht_cleanup(void *data) rcu_register_thread(); rcu_thread_online(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_HT_CLEANUP); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_HT_CLEANUP); if (testpoint(sessiond_thread_ht_cleanup)) { DBG("[ht-thread] testpoint."); @@ -145,14 +145,14 @@ static void *thread_ht_cleanup(void *data) revents = LTTNG_POLL_GETEV(&events, i); pollfd = LTTNG_POLL_GETFD(&events, i); - if (pollfd != ht_cleanup_pipe[0]) { + if (pollfd != the_ht_cleanup_pipe[0]) { continue; } if (revents & LPOLLIN) { /* Get socket from dispatch thread. */ - size_ret = lttng_read(ht_cleanup_pipe[0], &ht, - sizeof(ht)); + size_ret = lttng_read(the_ht_cleanup_pipe[0], + &ht, sizeof(ht)); if (size_ret < sizeof(ht)) { PERROR("ht cleanup notify pipe"); goto error; @@ -195,7 +195,7 @@ static void *thread_ht_cleanup(void *data) continue; } - if (pollfd == ht_cleanup_pipe[0]) { + if (pollfd == the_ht_cleanup_pipe[0]) { continue; } @@ -219,7 +219,7 @@ error_testpoint: health_error(); ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); rcu_thread_offline(); rcu_unregister_thread(); return NULL; @@ -243,7 +243,7 @@ struct lttng_thread *launch_ht_cleanup_thread(void) int ret; struct lttng_thread *thread; - ret = init_pipe(ht_cleanup_pipe); + ret = init_pipe(the_ht_cleanup_pipe); if (ret) { goto error; } diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 6244963cc..11a34af2a 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -175,11 +175,11 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, assert(session_trylock_list()); status = notification_thread_command_add_channel( - notification_thread_handle, session->name, - ksession->uid, ksession->gid, - channel->channel->name, channel->key, - LTTNG_DOMAIN_KERNEL, - channel->channel->attr.subbuf_size * channel->channel->attr.num_subbuf); + the_notification_thread_handle, session->name, + ksession->uid, ksession->gid, channel->channel->name, + channel->key, LTTNG_DOMAIN_KERNEL, + channel->channel->attr.subbuf_size * + channel->channel->attr.num_subbuf); rcu_read_unlock(); if (status != LTTNG_OK) { ret = -1; diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index c377509ab..1da49a172 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -1946,8 +1946,8 @@ int init_kernel_tracer(void) } /* Validate kernel version */ - ret = kernel_validate_version(&kernel_tracer_version, - &kernel_tracer_abi_version); + ret = kernel_validate_version(&the_kernel_tracer_version, + &the_kernel_tracer_abi_version); if (ret < 0) { goto error_version; } @@ -2073,7 +2073,7 @@ void cleanup_kernel_tracer(void) DBG2("Closing kernel event notifier group notification file descriptor"); if (kernel_tracer_event_notifier_group_notification_fd >= 0) { int ret = notification_thread_command_remove_tracer_event_source( - notification_thread_handle, + the_notification_thread_handle, kernel_tracer_event_notifier_group_notification_fd); if (ret != LTTNG_OK) { ERR("Failed to remove kernel event notifier notification from notification thread"); diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index edc1bc115..3c4261ea7 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -34,7 +34,7 @@ enum consumerd_state { }; /* Unique identifier of a session daemon instance. */ -extern lttng_uuid sessiond_uuid; +extern lttng_uuid the_sessiond_uuid; /* * This consumer daemon state is used to validate if a client command will be @@ -57,8 +57,8 @@ extern lttng_uuid sessiond_uuid; * command is safe. After that, we can not guarantee the correctness of the * client request vis-a-vis the consumer. */ -extern enum consumerd_state ust_consumerd_state; -extern enum consumerd_state kernel_consumerd_state; +extern enum consumerd_state the_ust_consumerd_state; +extern enum consumerd_state the_kernel_consumerd_state; extern const char default_home_dir[], default_tracing_group[], @@ -66,11 +66,11 @@ extern const char default_home_dir[], default_global_apps_pipe[]; /* Set in main.c at boot time of the daemon */ -extern struct lttng_kernel_tracer_version kernel_tracer_version; -extern struct lttng_kernel_tracer_abi_version kernel_tracer_abi_version; +extern struct lttng_kernel_tracer_version the_kernel_tracer_version; +extern struct lttng_kernel_tracer_abi_version the_kernel_tracer_abi_version; /* Notification thread handle. */ -extern struct notification_thread_handle *notification_thread_handle; +extern struct notification_thread_handle *the_notification_thread_handle; /* * This contains extra data needed for processing a command received by the @@ -127,32 +127,32 @@ struct ust_reg_wait_node { * be called by call_rcu thread, because it may hang (waiting for * call_rcu completion). */ -extern int ht_cleanup_pipe[2]; +extern int the_ht_cleanup_pipe[2]; -extern int kernel_poll_pipe[2]; +extern int the_kernel_poll_pipe[2]; /* * Populated when the daemon starts with the current page size of the system. * Set in main() with the current page size. */ -extern long page_size; +extern long the_page_size; /* Application health monitoring */ -extern struct health_app *health_sessiond; +extern struct health_app *the_health_sessiond; -extern struct sessiond_config config; +extern struct sessiond_config the_config; -extern int ust_consumerd64_fd, ust_consumerd32_fd; +extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd; /* Parent PID for --sig-parent option */ -extern pid_t ppid; +extern pid_t the_ppid; /* Internal parent PID use with daemonize. */ -extern pid_t child_ppid; +extern pid_t the_child_ppid; /* Consumer daemon specific control data. */ -extern struct consumer_data ustconsumer32_data; -extern struct consumer_data ustconsumer64_data; -extern struct consumer_data kconsumer_data; +extern struct consumer_data the_ustconsumer32_data; +extern struct consumer_data the_ustconsumer64_data; +extern struct consumer_data the_kconsumer_data; int sessiond_init_thread_quit_pipe(void); int sessiond_check_thread_quit_pipe(int fd, uint32_t events); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index e0b5595f3..d733f7061 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -178,56 +178,56 @@ static void close_consumer_sockets(void) { int ret; - if (kconsumer_data.err_sock >= 0) { - ret = close(kconsumer_data.err_sock); + if (the_kconsumer_data.err_sock >= 0) { + ret = close(the_kconsumer_data.err_sock); if (ret < 0) { PERROR("kernel consumer err_sock close"); } } - if (ustconsumer32_data.err_sock >= 0) { - ret = close(ustconsumer32_data.err_sock); + if (the_ustconsumer32_data.err_sock >= 0) { + ret = close(the_ustconsumer32_data.err_sock); if (ret < 0) { PERROR("UST consumerd32 err_sock close"); } } - if (ustconsumer64_data.err_sock >= 0) { - ret = close(ustconsumer64_data.err_sock); + if (the_ustconsumer64_data.err_sock >= 0) { + ret = close(the_ustconsumer64_data.err_sock); if (ret < 0) { PERROR("UST consumerd64 err_sock close"); } } - if (kconsumer_data.cmd_sock >= 0) { - ret = close(kconsumer_data.cmd_sock); + if (the_kconsumer_data.cmd_sock >= 0) { + ret = close(the_kconsumer_data.cmd_sock); if (ret < 0) { PERROR("kernel consumer cmd_sock close"); } } - if (ustconsumer32_data.cmd_sock >= 0) { - ret = close(ustconsumer32_data.cmd_sock); + if (the_ustconsumer32_data.cmd_sock >= 0) { + ret = close(the_ustconsumer32_data.cmd_sock); if (ret < 0) { PERROR("UST consumerd32 cmd_sock close"); } } - if (ustconsumer64_data.cmd_sock >= 0) { - ret = close(ustconsumer64_data.cmd_sock); + if (the_ustconsumer64_data.cmd_sock >= 0) { + ret = close(the_ustconsumer64_data.cmd_sock); if (ret < 0) { PERROR("UST consumerd64 cmd_sock close"); } } - if (kconsumer_data.channel_monitor_pipe >= 0) { - ret = close(kconsumer_data.channel_monitor_pipe); + if (the_kconsumer_data.channel_monitor_pipe >= 0) { + ret = close(the_kconsumer_data.channel_monitor_pipe); if (ret < 0) { PERROR("kernel consumer channel monitor pipe close"); } } - if (ustconsumer32_data.channel_monitor_pipe >= 0) { - ret = close(ustconsumer32_data.channel_monitor_pipe); + if (the_ustconsumer32_data.channel_monitor_pipe >= 0) { + ret = close(the_ustconsumer32_data.channel_monitor_pipe); if (ret < 0) { PERROR("UST consumerd32 channel monitor pipe close"); } } - if (ustconsumer64_data.channel_monitor_pipe >= 0) { - ret = close(ustconsumer64_data.channel_monitor_pipe); + if (the_ustconsumer64_data.channel_monitor_pipe >= 0) { + ret = close(the_ustconsumer64_data.channel_monitor_pipe); if (ret < 0) { PERROR("UST consumerd64 channel monitor pipe close"); } @@ -278,43 +278,43 @@ static void sessiond_cleanup(void) sessiond_close_quit_pipe(); utils_close_pipe(apps_cmd_pipe); utils_close_pipe(apps_cmd_notify_pipe); - utils_close_pipe(kernel_poll_pipe); + utils_close_pipe(the_kernel_poll_pipe); - ret = remove(config.pid_file_path.value); + ret = remove(the_config.pid_file_path.value); if (ret < 0) { - PERROR("remove pidfile %s", config.pid_file_path.value); + PERROR("remove pidfile %s", the_config.pid_file_path.value); } DBG("Removing sessiond and consumerd content of directory %s", - config.rundir.value); + the_config.rundir.value); /* sessiond */ - DBG("Removing %s", config.pid_file_path.value); - (void) unlink(config.pid_file_path.value); + DBG("Removing %s", the_config.pid_file_path.value); + (void) unlink(the_config.pid_file_path.value); - DBG("Removing %s", config.agent_port_file_path.value); - (void) unlink(config.agent_port_file_path.value); + DBG("Removing %s", the_config.agent_port_file_path.value); + (void) unlink(the_config.agent_port_file_path.value); /* kconsumerd */ - DBG("Removing %s", kconsumer_data.err_unix_sock_path); - (void) unlink(kconsumer_data.err_unix_sock_path); + DBG("Removing %s", the_kconsumer_data.err_unix_sock_path); + (void) unlink(the_kconsumer_data.err_unix_sock_path); - DBG("Removing directory %s", config.kconsumerd_path.value); - (void) rmdir(config.kconsumerd_path.value); + DBG("Removing directory %s", the_config.kconsumerd_path.value); + (void) rmdir(the_config.kconsumerd_path.value); /* ust consumerd 32 */ - DBG("Removing %s", config.consumerd32_err_unix_sock_path.value); - (void) unlink(config.consumerd32_err_unix_sock_path.value); + DBG("Removing %s", the_config.consumerd32_err_unix_sock_path.value); + (void) unlink(the_config.consumerd32_err_unix_sock_path.value); - DBG("Removing directory %s", config.consumerd32_path.value); - (void) rmdir(config.consumerd32_path.value); + DBG("Removing directory %s", the_config.consumerd32_path.value); + (void) rmdir(the_config.consumerd32_path.value); /* ust consumerd 64 */ - DBG("Removing %s", config.consumerd64_err_unix_sock_path.value); - (void) unlink(config.consumerd64_err_unix_sock_path.value); + DBG("Removing %s", the_config.consumerd64_err_unix_sock_path.value); + (void) unlink(the_config.consumerd64_err_unix_sock_path.value); - DBG("Removing directory %s", config.consumerd64_path.value); - (void) rmdir(config.consumerd64_path.value); + DBG("Removing directory %s", the_config.consumerd64_path.value); + (void) rmdir(the_config.consumerd64_path.value); pthread_mutex_destroy(&session_list->lock); @@ -329,11 +329,11 @@ static void sessiond_cleanup(void) close_consumer_sockets(); - wait_consumer(&kconsumer_data); - wait_consumer(&ustconsumer64_data); - wait_consumer(&ustconsumer32_data); + wait_consumer(&the_kconsumer_data); + wait_consumer(&the_ustconsumer64_data); + wait_consumer(&the_ustconsumer32_data); - if (is_root && !config.no_kernel) { + if (is_root && !the_config.no_kernel) { cleanup_kernel_tracer(); } @@ -351,7 +351,7 @@ static void sessiond_cleanup_options(void) { DBG("Cleaning up options"); - sessiond_config_fini(&config); + sessiond_config_fini(&the_config); run_as_destroy_worker(); } @@ -380,9 +380,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "-c, --client-sock"); } else { - config_string_set(&config.client_unix_sock_path, + config_string_set(&the_config.client_unix_sock_path, strdup(arg)); - if (!config.client_unix_sock_path.value) { + if (!the_config.client_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -396,17 +396,17 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "-a, --apps-sock"); } else { - config_string_set(&config.apps_unix_sock_path, + config_string_set(&the_config.apps_unix_sock_path, strdup(arg)); - if (!config.apps_unix_sock_path.value) { + if (!the_config.apps_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } } } else if (string_match(optname, "daemonize") || opt == 'd') { - config.daemonize = true; + the_config.daemonize = true; } else if (string_match(optname, "background") || opt == 'b') { - config.background = true; + the_config.background = true; } else if (string_match(optname, "group") || opt == 'g') { if (!arg || *arg == '\0') { ret = -EINVAL; @@ -416,9 +416,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "-g, --group"); } else { - config_string_set(&config.tracing_group_name, + config_string_set(&the_config.tracing_group_name, strdup(arg)); - if (!config.tracing_group_name.value) { + if (!the_config.tracing_group_name.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -433,7 +433,7 @@ static int set_option(int opt, const char *arg, const char *optname) } else if (string_match(optname, "version") || opt == 'V') { opt_print_version = 1; } else if (string_match(optname, "sig-parent") || opt == 'S') { - config.sig_parent = true; + the_config.sig_parent = true; } else if (string_match(optname, "kconsumerd-err-sock")) { if (!arg || *arg == '\0') { ret = -EINVAL; @@ -443,9 +443,10 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--kconsumerd-err-sock"); } else { - config_string_set(&config.kconsumerd_err_unix_sock_path, + config_string_set( + &the_config.kconsumerd_err_unix_sock_path, strdup(arg)); - if (!config.kconsumerd_err_unix_sock_path.value) { + if (!the_config.kconsumerd_err_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -459,9 +460,10 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--kconsumerd-cmd-sock"); } else { - config_string_set(&config.kconsumerd_cmd_unix_sock_path, + config_string_set( + &the_config.kconsumerd_cmd_unix_sock_path, strdup(arg)); - if (!config.kconsumerd_cmd_unix_sock_path.value) { + if (!the_config.kconsumerd_cmd_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -475,9 +477,10 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--ustconsumerd64-err-sock"); } else { - config_string_set(&config.consumerd64_err_unix_sock_path, + config_string_set( + &the_config.consumerd64_err_unix_sock_path, strdup(arg)); - if (!config.consumerd64_err_unix_sock_path.value) { + if (!the_config.consumerd64_err_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -491,9 +494,10 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--ustconsumerd64-cmd-sock"); } else { - config_string_set(&config.consumerd64_cmd_unix_sock_path, + config_string_set( + &the_config.consumerd64_cmd_unix_sock_path, strdup(arg)); - if (!config.consumerd64_cmd_unix_sock_path.value) { + if (!the_config.consumerd64_cmd_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -507,9 +511,10 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--ustconsumerd32-err-sock"); } else { - config_string_set(&config.consumerd32_err_unix_sock_path, + config_string_set( + &the_config.consumerd32_err_unix_sock_path, strdup(arg)); - if (!config.consumerd32_err_unix_sock_path.value) { + if (!the_config.consumerd32_err_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } @@ -523,34 +528,37 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--ustconsumerd32-cmd-sock"); } else { - config_string_set(&config.consumerd32_cmd_unix_sock_path, + config_string_set( + &the_config.consumerd32_cmd_unix_sock_path, strdup(arg)); - if (!config.consumerd32_cmd_unix_sock_path.value) { + if (!the_config.consumerd32_cmd_unix_sock_path.value) { ret = -ENOMEM; PERROR("strdup"); } } } else if (string_match(optname, "no-kernel")) { - config.no_kernel = true; + the_config.no_kernel = true; } else if (string_match(optname, "quiet") || opt == 'q') { - config.quiet = true; + the_config.quiet = true; } else if (string_match(optname, "verbose") || opt == 'v') { /* Verbose level can increase using multiple -v */ if (arg) { /* Value obtained from config file */ - config.verbose = config_parse_value(arg); + the_config.verbose = config_parse_value(arg); } else { /* -v used on command line */ - config.verbose++; + the_config.verbose++; } /* Clamp value to [0, 3] */ - config.verbose = config.verbose < 0 ? 0 : - (config.verbose <= 3 ? config.verbose : 3); + the_config.verbose = the_config.verbose < 0 ? + 0 : + (the_config.verbose <= 3 ? the_config.verbose : + 3); } else if (string_match(optname, "verbose-consumer")) { if (arg) { - config.verbose_consumer = config_parse_value(arg); + the_config.verbose_consumer = config_parse_value(arg); } else { - config.verbose_consumer++; + the_config.verbose_consumer++; } } else if (string_match(optname, "consumerd32-path")) { if (!arg || *arg == '\0') { @@ -561,9 +569,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--consumerd32-path"); } else { - config_string_set(&config.consumerd32_bin_path, + config_string_set(&the_config.consumerd32_bin_path, strdup(arg)); - if (!config.consumerd32_bin_path.value) { + if (!the_config.consumerd32_bin_path.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -577,9 +585,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--consumerd32-libdir"); } else { - config_string_set(&config.consumerd32_lib_dir, + config_string_set(&the_config.consumerd32_lib_dir, strdup(arg)); - if (!config.consumerd32_lib_dir.value) { + if (!the_config.consumerd32_lib_dir.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -593,9 +601,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--consumerd64-path"); } else { - config_string_set(&config.consumerd64_bin_path, + config_string_set(&the_config.consumerd64_bin_path, strdup(arg)); - if (!config.consumerd64_bin_path.value) { + if (!the_config.consumerd64_bin_path.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -609,9 +617,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--consumerd64-libdir"); } else { - config_string_set(&config.consumerd64_lib_dir, + config_string_set(&the_config.consumerd64_lib_dir, strdup(arg)); - if (!config.consumerd64_lib_dir.value) { + if (!the_config.consumerd64_lib_dir.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -625,8 +633,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "-p, --pidfile"); } else { - config_string_set(&config.pid_file_path, strdup(arg)); - if (!config.pid_file_path.value) { + config_string_set( + &the_config.pid_file_path, strdup(arg)); + if (!the_config.pid_file_path.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -652,7 +661,8 @@ static int set_option(int opt, const char *arg, const char *optname) ERR("Port overflow in --agent-tcp-port parameter: %s", arg); return -1; } - config.agent_tcp_port.begin = config.agent_tcp_port.end = (int) v; + the_config.agent_tcp_port.begin = + the_config.agent_tcp_port.end = (int) v; DBG3("Agent TCP port set to non default: %i", (int) v); } } else if (string_match(optname, "load") || opt == 'l') { @@ -664,8 +674,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "-l, --load"); } else { - config_string_set(&config.load_session_path, strdup(arg)); - if (!config.load_session_path.value) { + config_string_set(&the_config.load_session_path, + strdup(arg)); + if (!the_config.load_session_path.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -679,8 +690,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--kmod-probes"); } else { - config_string_set(&config.kmod_probes_list, strdup(arg)); - if (!config.kmod_probes_list.value) { + config_string_set(&the_config.kmod_probes_list, + strdup(arg)); + if (!the_config.kmod_probes_list.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -694,9 +706,9 @@ static int set_option(int opt, const char *arg, const char *optname) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "--extra-kmod-probes"); } else { - config_string_set(&config.kmod_extra_probes_list, + config_string_set(&the_config.kmod_extra_probes_list, strdup(arg)); - if (!config.kmod_extra_probes_list.value) { + if (!the_config.kmod_extra_probes_list.value) { PERROR("strdup"); ret = -ENOMEM; } @@ -714,9 +726,9 @@ static int set_option(int opt, const char *arg, const char *optname) ERR("Value out of range for --event-notifier-error-number-of-bucket parameter: %s", arg); return -1; } - config.event_notifier_error_counter_bucket = (int) v; + the_config.event_notifier_error_counter_bucket = (int) v; DBG3("Number of event notifier error counter set to non default: %i", - config.event_notifier_error_counter_bucket); + the_config.event_notifier_error_counter_bucket); goto end; } else if (string_match(optname, "config") || opt == 'f') { /* This is handled in set_options() thus silent skip. */ @@ -893,7 +905,7 @@ end: */ static int create_lockfile(void) { - return utils_create_lock_file(config.lock_file_path.value); + return utils_create_lock_file(the_config.lock_file_path.value); } /* @@ -930,7 +942,7 @@ static void sessiond_cleanup_lock_file(void) * release the file system lock. */ if (lockfile_fd >= 0) { - ret = remove(config.lock_file_path.value); + ret = remove(the_config.lock_file_path.value); if (ret < 0) { PERROR("remove lock file"); } @@ -952,7 +964,8 @@ static int set_permissions(char *rundir) int ret; gid_t gid; - ret = utils_get_group_id(config.tracing_group_name.value, true, &gid); + ret = utils_get_group_id( + the_config.tracing_group_name.value, true, &gid); if (ret) { /* Default to root group. */ gid = 0; @@ -977,30 +990,34 @@ static int set_permissions(char *rundir) } /* lttng client socket path */ - ret = chown(config.client_unix_sock_path.value, 0, gid); + ret = chown(the_config.client_unix_sock_path.value, 0, gid); if (ret < 0) { - ERR("Unable to set group on %s", config.client_unix_sock_path.value); + ERR("Unable to set group on %s", + the_config.client_unix_sock_path.value); PERROR("chown"); } /* kconsumer error socket path */ - ret = chown(kconsumer_data.err_unix_sock_path, 0, 0); + ret = chown(the_kconsumer_data.err_unix_sock_path, 0, 0); if (ret < 0) { - ERR("Unable to set group on %s", kconsumer_data.err_unix_sock_path); + ERR("Unable to set group on %s", + the_kconsumer_data.err_unix_sock_path); PERROR("chown"); } /* 64-bit ustconsumer error socket path */ - ret = chown(ustconsumer64_data.err_unix_sock_path, 0, 0); + ret = chown(the_ustconsumer64_data.err_unix_sock_path, 0, 0); if (ret < 0) { - ERR("Unable to set group on %s", ustconsumer64_data.err_unix_sock_path); + ERR("Unable to set group on %s", + the_ustconsumer64_data.err_unix_sock_path); PERROR("chown"); } /* 32-bit ustconsumer compat32 error socket path */ - ret = chown(ustconsumer32_data.err_unix_sock_path, 0, 0); + ret = chown(the_ustconsumer32_data.err_unix_sock_path, 0, 0); if (ret < 0) { - ERR("Unable to set group on %s", ustconsumer32_data.err_unix_sock_path); + ERR("Unable to set group on %s", + the_ustconsumer32_data.err_unix_sock_path); PERROR("chown"); } @@ -1016,12 +1033,12 @@ static int create_lttng_rundir(void) { int ret; - DBG3("Creating LTTng run directory: %s", config.rundir.value); + DBG3("Creating LTTng run directory: %s", the_config.rundir.value); - ret = mkdir(config.rundir.value, S_IRWXU); + ret = mkdir(the_config.rundir.value, S_IRWXU); if (ret < 0) { if (errno != EEXIST) { - ERR("Unable to create %s", config.rundir.value); + ERR("Unable to create %s", the_config.rundir.value); goto error; } else { ret = 0; @@ -1043,13 +1060,13 @@ static int set_consumer_sockets(struct consumer_data *consumer_data) switch (consumer_data->type) { case LTTNG_CONSUMER_KERNEL: - path = config.kconsumerd_path.value; + path = the_config.kconsumerd_path.value; break; case LTTNG_CONSUMER64_UST: - path = config.consumerd64_path.value; + path = the_config.consumerd64_path.value; break; case LTTNG_CONSUMER32_UST: - path = config.consumerd32_path.value; + path = the_config.consumerd32_path.value; break; default: ERR("Consumer type unknown"); @@ -1069,8 +1086,8 @@ static int set_consumer_sockets(struct consumer_data *consumer_data) if (is_root) { gid_t gid; - ret = utils_get_group_id(config.tracing_group_name.value, true, - &gid); + ret = utils_get_group_id(the_config.tracing_group_name.value, + true, &gid); if (ret) { /* Default to root group. */ gid = 0; @@ -1207,7 +1224,7 @@ static void set_ulimit(void) static int write_pidfile(void) { - return utils_create_pid_file(getpid(), config.pid_file_path.value); + return utils_create_pid_file(getpid(), the_config.pid_file_path.value); } static int set_clock_plugin_env(void) @@ -1215,12 +1232,12 @@ static int set_clock_plugin_env(void) int ret = 0; char *env_value = NULL; - if (!config.lttng_ust_clock_plugin.value) { + if (!the_config.lttng_ust_clock_plugin.value) { goto end; } ret = asprintf(&env_value, "LTTNG_UST_CLOCK_PLUGIN=%s", - config.lttng_ust_clock_plugin.value); + the_config.lttng_ust_clock_plugin.value); if (ret < 0) { PERROR("asprintf"); goto end; @@ -1234,7 +1251,7 @@ static int set_clock_plugin_env(void) } DBG("Updated LTTNG_UST_CLOCK_PLUGIN environment variable to \"%s\"", - config.lttng_ust_clock_plugin.value); + the_config.lttng_ust_clock_plugin.value); end: return ret; } @@ -1264,8 +1281,8 @@ static void destroy_all_sessions_and_wait(void) goto unlock_session; } (void) cmd_stop_trace(session); - (void) cmd_destroy_session(session, notification_thread_handle, - NULL); + (void) cmd_destroy_session( + session, the_notification_thread_handle, NULL); unlock_session: session_unlock(session); session_put(session); @@ -1294,7 +1311,8 @@ static void unregister_all_triggers(void) * List all triggers as "root" since we wish to unregister all triggers. */ ret_code = notification_thread_command_list_triggers( - notification_thread_handle, creds.uid.value, &triggers); + the_notification_thread_handle, creds.uid.value, + &triggers); if (ret_code != LTTNG_OK) { ERR("Failed to list triggers while unregistering all triggers"); goto end; @@ -1322,8 +1340,8 @@ static void unregister_all_triggers(void) DBG("Unregistering trigger: trigger owner uid = %d, trigger name = '%s'", (int) trigger_owner, trigger_name); - ret_code = cmd_unregister_trigger( - &creds, trigger, notification_thread_handle); + ret_code = cmd_unregister_trigger(&creds, trigger, + the_notification_thread_handle); if (ret_code != LTTNG_OK) { ERR("Failed to unregister trigger: trigger owner uid = %d, trigger name = '%s', error: '%s'", (int) trigger_owner, trigger_name, @@ -1351,15 +1369,15 @@ static int launch_run_as_worker(const char *procname) * be leaked as the process forks a run-as worker (and performs * no exec*()). The same would apply to any opened fd. */ - return run_as_create_worker(procname, run_as_worker_post_fork_cleanup, - &config); + return run_as_create_worker( + procname, run_as_worker_post_fork_cleanup, &the_config); } static void sessiond_uuid_log(void) { char uuid_str[LTTNG_UUID_STR_LEN]; - lttng_uuid_to_str(sessiond_uuid, uuid_str); + lttng_uuid_to_str(the_sessiond_uuid, uuid_str); DBG("Starting lttng-sessiond {%s}", uuid_str); } @@ -1398,14 +1416,14 @@ int main(int argc, char **argv) goto exit_set_signal_handler; } - page_size = sysconf(_SC_PAGESIZE); - if (page_size < 0) { + the_page_size = sysconf(_SC_PAGESIZE); + if (the_page_size < 0) { PERROR("sysconf _SC_PAGESIZE"); - page_size = LONG_MAX; - WARN("Fallback page size to %ld", page_size); + the_page_size = LONG_MAX; + WARN("Fallback page size to %ld", the_page_size); } - ret = sessiond_config_init(&config); + ret = sessiond_config_init(&the_config); if (ret) { retval = -1; goto exit_set_signal_handler; @@ -1415,7 +1433,7 @@ int main(int argc, char **argv) * Init config from environment variables. * Command line option override env configuration per-doc. Do env first. */ - sessiond_config_apply_env_config(&config); + sessiond_config_apply_env_config(&the_config); /* * Parse arguments and load the daemon configuration file. @@ -1437,29 +1455,29 @@ int main(int argc, char **argv) * since daemonizing causes the sessiond's current working directory * to '/'. */ - ret = sessiond_config_resolve_paths(&config); + ret = sessiond_config_resolve_paths(&the_config); if (ret) { goto exit_options; } /* Apply config. */ - lttng_opt_verbose = config.verbose; - lttng_opt_quiet = config.quiet; - kconsumer_data.err_unix_sock_path = - config.kconsumerd_err_unix_sock_path.value; - kconsumer_data.cmd_unix_sock_path = - config.kconsumerd_cmd_unix_sock_path.value; - ustconsumer32_data.err_unix_sock_path = - config.consumerd32_err_unix_sock_path.value; - ustconsumer32_data.cmd_unix_sock_path = - config.consumerd32_cmd_unix_sock_path.value; - ustconsumer64_data.err_unix_sock_path = - config.consumerd64_err_unix_sock_path.value; - ustconsumer64_data.cmd_unix_sock_path = - config.consumerd64_cmd_unix_sock_path.value; + lttng_opt_verbose = the_config.verbose; + lttng_opt_quiet = the_config.quiet; + the_kconsumer_data.err_unix_sock_path = + the_config.kconsumerd_err_unix_sock_path.value; + the_kconsumer_data.cmd_unix_sock_path = + the_config.kconsumerd_cmd_unix_sock_path.value; + the_ustconsumer32_data.err_unix_sock_path = + the_config.consumerd32_err_unix_sock_path.value; + the_ustconsumer32_data.cmd_unix_sock_path = + the_config.consumerd32_cmd_unix_sock_path.value; + the_ustconsumer64_data.err_unix_sock_path = + the_config.consumerd64_err_unix_sock_path.value; + the_ustconsumer64_data.cmd_unix_sock_path = + the_config.consumerd64_cmd_unix_sock_path.value; set_clock_plugin_env(); - sessiond_config_log(&config); + sessiond_config_log(&the_config); sessiond_uuid_log(); if (opt_print_version) { @@ -1481,11 +1499,11 @@ int main(int argc, char **argv) } /* Daemonize */ - if (config.daemonize || config.background) { + if (the_config.daemonize || the_config.background) { int i; - ret = lttng_daemonize(&child_ppid, &recv_child_signal, - !config.background); + ret = lttng_daemonize(&the_child_ppid, &recv_child_signal, + !the_config.background); if (ret < 0) { retval = -1; goto exit_options; @@ -1517,8 +1535,8 @@ int main(int argc, char **argv) * Initialize the health check subsystem. This call should set the * appropriate time values. */ - health_sessiond = health_app_create(NR_HEALTH_SESSIOND_TYPES); - if (!health_sessiond) { + the_health_sessiond = health_app_create(NR_HEALTH_SESSIOND_TYPES); + if (!the_health_sessiond) { PERROR("health_app_create error"); retval = -1; goto stop_threads; @@ -1548,18 +1566,18 @@ int main(int argc, char **argv) retval = -1; goto stop_threads; } - kconsumer_data.channel_monitor_pipe = + the_kconsumer_data.channel_monitor_pipe = lttng_pipe_release_writefd( - kernel_channel_monitor_pipe); - if (kconsumer_data.channel_monitor_pipe < 0) { + kernel_channel_monitor_pipe); + if (the_kconsumer_data.channel_monitor_pipe < 0) { retval = -1; goto stop_threads; } } /* Set consumer initial state */ - kernel_consumerd_state = CONSUMER_STOPPED; - ust_consumerd_state = CONSUMER_STOPPED; + the_kernel_consumerd_state = CONSUMER_STOPPED; + the_ust_consumerd_state = CONSUMER_STOPPED; ust32_channel_monitor_pipe = lttng_pipe_open(0); if (!ust32_channel_monitor_pipe) { @@ -1567,9 +1585,9 @@ int main(int argc, char **argv) retval = -1; goto stop_threads; } - ustconsumer32_data.channel_monitor_pipe = lttng_pipe_release_writefd( - ust32_channel_monitor_pipe); - if (ustconsumer32_data.channel_monitor_pipe < 0) { + the_ustconsumer32_data.channel_monitor_pipe = + lttng_pipe_release_writefd(ust32_channel_monitor_pipe); + if (the_ustconsumer32_data.channel_monitor_pipe < 0) { retval = -1; goto stop_threads; } @@ -1593,9 +1611,9 @@ int main(int argc, char **argv) retval = -1; goto stop_threads; } - ustconsumer64_data.channel_monitor_pipe = lttng_pipe_release_writefd( - ust64_channel_monitor_pipe); - if (ustconsumer64_data.channel_monitor_pipe < 0) { + the_ustconsumer64_data.channel_monitor_pipe = + lttng_pipe_release_writefd(ust64_channel_monitor_pipe); + if (the_ustconsumer64_data.channel_monitor_pipe < 0) { retval = -1; goto stop_threads; } @@ -1610,7 +1628,7 @@ int main(int argc, char **argv) goto stop_threads; } - event_notifier_error_accounting_init(config.event_notifier_error_counter_bucket); + event_notifier_error_accounting_init(the_config.event_notifier_error_counter_bucket); /* * Initialize agent app hash table. We allocate the hash table here @@ -1634,13 +1652,13 @@ int main(int argc, char **argv) * kernel tracer. */ if (is_root) { - if (set_consumer_sockets(&kconsumer_data)) { + if (set_consumer_sockets(&the_kconsumer_data)) { retval = -1; goto stop_threads; } /* Setup kernel tracer */ - if (!config.no_kernel) { + if (!the_config.no_kernel) { init_kernel_tracer(); } @@ -1650,24 +1668,24 @@ int main(int argc, char **argv) /* init lttng_fd tracking must be done after set_ulimit. */ lttng_fd_init(); - if (set_consumer_sockets(&ustconsumer64_data)) { + if (set_consumer_sockets(&the_ustconsumer64_data)) { retval = -1; goto stop_threads; } - if (set_consumer_sockets(&ustconsumer32_data)) { + if (set_consumer_sockets(&the_ustconsumer32_data)) { retval = -1; goto stop_threads; } /* Get parent pid if -S, --sig-parent is specified. */ - if (config.sig_parent) { - ppid = getppid(); + if (the_config.sig_parent) { + the_ppid = getppid(); } /* Setup the kernel pipe for waking up the kernel thread */ - if (is_root && !config.no_kernel) { - if (utils_create_pipe_cloexec(kernel_poll_pipe)) { + if (is_root && !the_config.no_kernel) { + if (utils_create_pipe_cloexec(the_kernel_poll_pipe)) { retval = -1; goto stop_threads; } @@ -1697,9 +1715,9 @@ int main(int argc, char **argv) /* Check for the application socket timeout env variable. */ env_app_timeout = getenv(DEFAULT_APP_SOCKET_TIMEOUT_ENV); if (env_app_timeout) { - config.app_socket_timeout = atoi(env_app_timeout); + the_config.app_socket_timeout = atoi(env_app_timeout); } else { - config.app_socket_timeout = DEFAULT_APP_SOCKET_RW_TIMEOUT; + the_config.app_socket_timeout = DEFAULT_APP_SOCKET_RW_TIMEOUT; } ret = write_pidfile(); @@ -1721,11 +1739,10 @@ int main(int argc, char **argv) } /* notification_thread_data acquires the pipes' read side. */ - notification_thread_handle = notification_thread_handle_create( - ust32_channel_monitor_pipe, - ust64_channel_monitor_pipe, + the_notification_thread_handle = notification_thread_handle_create( + ust32_channel_monitor_pipe, ust64_channel_monitor_pipe, kernel_channel_monitor_pipe); - if (!notification_thread_handle) { + if (!the_notification_thread_handle) { retval = -1; ERR("Failed to create notification thread shared data"); goto stop_threads; @@ -1733,7 +1750,7 @@ int main(int argc, char **argv) /* Create notification thread. */ notification_thread = launch_notification_thread( - notification_thread_handle); + the_notification_thread_handle); if (!notification_thread) { retval = -1; goto stop_threads; @@ -1747,8 +1764,7 @@ int main(int argc, char **argv) /* rotation_thread_data acquires the pipes' read side. */ rotation_thread_handle = rotation_thread_handle_create( - rotation_timer_queue, - notification_thread_handle); + rotation_timer_queue, the_notification_thread_handle); if (!rotation_thread_handle) { retval = -1; ERR("Failed to create rotation thread shared data"); @@ -1770,7 +1786,7 @@ int main(int argc, char **argv) } /* Set credentials of the client socket and rundir */ - if (is_root && set_permissions(config.rundir.value)) { + if (is_root && set_permissions(the_config.rundir.value)) { retval = -1; goto stop_threads; } @@ -1808,16 +1824,16 @@ int main(int argc, char **argv) } /* Don't start this thread if kernel tracing is not requested nor root */ - if (is_root && !config.no_kernel) { + if (is_root && !the_config.no_kernel) { /* Create kernel thread to manage kernel event */ - if (!launch_kernel_management_thread(kernel_poll_pipe[0])) { + if (!launch_kernel_management_thread(the_kernel_poll_pipe[0])) { retval = -1; goto stop_threads; } if (kernel_get_notification_fd() >= 0) { ret = notification_thread_command_add_tracer_event_source( - notification_thread_handle, + the_notification_thread_handle, kernel_get_notification_fd(), LTTNG_DOMAIN_KERNEL); if (ret != LTTNG_OK) { @@ -1829,8 +1845,8 @@ int main(int argc, char **argv) } /* Load sessions. */ - ret = config_load_session(config.load_session_path.value, - NULL, 1, 1, NULL); + ret = config_load_session( + the_config.load_session_path.value, NULL, 1, 1, NULL); if (ret) { ERR("Session load failed: %s", error_get_str(ret)); retval = -1; @@ -1915,7 +1931,7 @@ stop_threads: * In short, at this point, we need to have called close() on all fds * received from the kernel tracer. */ - if (is_root && !config.no_kernel) { + if (is_root && !the_config.no_kernel) { DBG("Unloading kernel modules"); modprobe_remove_lttng_all(); } @@ -1949,15 +1965,16 @@ stop_threads: * session daemon's teardown in order to allow it to be notified * of the active session and channels at the moment of the teardown. */ - if (notification_thread_handle) { - notification_thread_handle_destroy(notification_thread_handle); + if (the_notification_thread_handle) { + notification_thread_handle_destroy( + the_notification_thread_handle); } lttng_pipe_destroy(ust32_channel_monitor_pipe); lttng_pipe_destroy(ust64_channel_monitor_pipe); lttng_pipe_destroy(kernel_channel_monitor_pipe); - if (health_sessiond) { - health_app_destroy(health_sessiond); + if (the_health_sessiond) { + health_app_destroy(the_health_sessiond); } exit_create_run_as_worker_cleanup: exit_options: diff --git a/src/bin/lttng-sessiond/manage-apps.c b/src/bin/lttng-sessiond/manage-apps.c index b5b77d896..e2f3ed26a 100644 --- a/src/bin/lttng-sessiond/manage-apps.c +++ b/src/bin/lttng-sessiond/manage-apps.c @@ -54,7 +54,7 @@ static void *thread_application_management(void *data) rcu_register_thread(); rcu_thread_online(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_APP_MANAGE); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_APP_MANAGE); if (testpoint(sessiond_thread_manage_apps)) { goto error_testpoint; @@ -190,7 +190,7 @@ error_testpoint: health_error(); ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); DBG("Application communication apps thread cleanup complete"); rcu_thread_offline(); rcu_unregister_thread(); diff --git a/src/bin/lttng-sessiond/manage-consumer.c b/src/bin/lttng-sessiond/manage-consumer.c index 380cd057c..de17c325a 100644 --- a/src/bin/lttng-sessiond/manage-consumer.c +++ b/src/bin/lttng-sessiond/manage-consumer.c @@ -67,7 +67,7 @@ static void *thread_consumer_management(void *data) rcu_register_thread(); rcu_thread_online(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_CONSUMER); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_CONSUMER); health_code_update(); @@ -243,7 +243,7 @@ static void *thread_consumer_management(void *data) cmd_socket_wrapper->lock = &consumer_data->lock; pthread_mutex_lock(cmd_socket_wrapper->lock); - ret = consumer_init(cmd_socket_wrapper, sessiond_uuid); + ret = consumer_init(cmd_socket_wrapper, the_sessiond_uuid); if (ret) { ERR("Failed to send sessiond uuid to consumer daemon"); mark_thread_intialization_as_failed(notifiers); @@ -350,10 +350,10 @@ error: /* Immediately set the consumerd state to stopped */ if (consumer_data->type == LTTNG_CONSUMER_KERNEL) { - uatomic_set(&kernel_consumerd_state, CONSUMER_ERROR); + uatomic_set(&the_kernel_consumerd_state, CONSUMER_ERROR); } else if (consumer_data->type == LTTNG_CONSUMER64_UST || consumer_data->type == LTTNG_CONSUMER32_UST) { - uatomic_set(&ust_consumerd_state, CONSUMER_ERROR); + uatomic_set(&the_ust_consumerd_state, CONSUMER_ERROR); } else { /* Code flow error... */ assert(0); @@ -406,7 +406,7 @@ error_poll: health_error(); ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); DBG("consumer thread cleanup completed"); rcu_thread_offline(); diff --git a/src/bin/lttng-sessiond/manage-kernel.c b/src/bin/lttng-sessiond/manage-kernel.c index 09e47f7db..55ecbf8b3 100644 --- a/src/bin/lttng-sessiond/manage-kernel.c +++ b/src/bin/lttng-sessiond/manage-kernel.c @@ -172,7 +172,7 @@ static void *thread_kernel_management(void *data) DBG("[thread] Thread manage kernel started"); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_KERNEL); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_KERNEL); /* * This first step of the while is to clean this structure which could free @@ -305,7 +305,7 @@ error_testpoint: WARN("Kernel thread died unexpectedly. " "Kernel tracing can continue but CPU hotplug is disabled."); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); DBG("Kernel thread dying"); return NULL; } diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index 8d162857f..f701ca5f8 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -718,7 +718,7 @@ int modprobe_lttng_data(void) * Base probes: either from command line option, environment * variable or default list. */ - list = config.kmod_probes_list.value; + list = the_config.kmod_probes_list.value; if (list) { /* User-specified probes. */ ret = append_list_to_probes(list); @@ -754,7 +754,7 @@ int modprobe_lttng_data(void) /* * Extra modules? Append them to current probes list. */ - list = config.kmod_extra_probes_list.value; + list = the_config.kmod_extra_probes_list.value; if (list) { ret = append_list_to_probes(list); if (ret) { diff --git a/src/bin/lttng-sessiond/notification-thread.c b/src/bin/lttng-sessiond/notification-thread.c index 580168296..56f1124fb 100644 --- a/src/bin/lttng-sessiond/notification-thread.c +++ b/src/bin/lttng-sessiond/notification-thread.c @@ -238,8 +238,8 @@ int notification_channel_socket_create(void) if (getuid() == 0) { gid_t gid; - ret = utils_get_group_id(config.tracing_group_name.value, true, - &gid); + ret = utils_get_group_id(the_config.tracing_group_name.value, + true, &gid); if (ret) { /* Default to root group. */ gid = 0; @@ -639,7 +639,7 @@ void *thread_notification(void *data) DBG("[notification-thread] Started notification thread"); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_NOTIFICATION); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_NOTIFICATION); rcu_register_thread(); rcu_thread_online(); @@ -778,7 +778,7 @@ error: end: rcu_thread_offline(); rcu_unregister_thread(); - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); return NULL; } diff --git a/src/bin/lttng-sessiond/notify-apps.c b/src/bin/lttng-sessiond/notify-apps.c index 9a63141dd..55a4b74fd 100644 --- a/src/bin/lttng-sessiond/notify-apps.c +++ b/src/bin/lttng-sessiond/notify-apps.c @@ -41,8 +41,8 @@ static void *thread_application_notification(void *data) rcu_register_thread(); rcu_thread_online(); - health_register(health_sessiond, - HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY); + health_register(the_health_sessiond, + HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY); if (testpoint(sessiond_thread_app_manage_notify)) { goto error_testpoint; @@ -185,7 +185,7 @@ error_testpoint: health_error(); ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); rcu_thread_offline(); rcu_unregister_thread(); return NULL; diff --git a/src/bin/lttng-sessiond/process-utils.c b/src/bin/lttng-sessiond/process-utils.c index a9cef051f..2d629b547 100644 --- a/src/bin/lttng-sessiond/process-utils.c +++ b/src/bin/lttng-sessiond/process-utils.c @@ -18,15 +18,15 @@ void sessiond_signal_parents(void) * for client side. This ppid is the one from the * external process that spawned us. */ - if (config.sig_parent) { - kill(ppid, SIGUSR1); + if (the_config.sig_parent) { + kill(the_ppid, SIGUSR1); } /* * Notify the parent of the fork() process that we are * ready. */ - if (config.daemonize || config.background) { - kill(child_ppid, SIGUSR1); + if (the_config.daemonize || the_config.background) { + kill(the_child_ppid, SIGUSR1); } } diff --git a/src/bin/lttng-sessiond/register.c b/src/bin/lttng-sessiond/register.c index ac1583dc2..bd6cd52dd 100644 --- a/src/bin/lttng-sessiond/register.c +++ b/src/bin/lttng-sessiond/register.c @@ -42,9 +42,11 @@ static int create_application_socket(void) const mode_t old_umask = umask(0); /* Create the application unix socket */ - apps_sock = lttcomm_create_unix_sock(config.apps_unix_sock_path.value); + apps_sock = lttcomm_create_unix_sock( + the_config.apps_unix_sock_path.value); if (apps_sock < 0) { - ERR("Create unix sock failed: %s", config.apps_unix_sock_path.value); + ERR("Create unix sock failed: %s", + the_config.apps_unix_sock_path.value); ret = -1; goto end; } @@ -58,11 +60,12 @@ static int create_application_socket(void) } /* File permission MUST be 666 */ - ret = chmod(config.apps_unix_sock_path.value, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + ret = chmod(the_config.apps_unix_sock_path.value, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | + S_IWOTH); if (ret < 0) { PERROR("Set file permissions failed on %s", - config.apps_unix_sock_path.value); + the_config.apps_unix_sock_path.value); goto error_close_socket; } @@ -90,7 +93,8 @@ static int notify_ust_apps(int active, bool is_root) DBG("Notifying applications of session daemon state: %d", active); /* See shm.c for this call implying mmap, shm and futex calls */ - wait_shm_mmap = shm_ust_get_mmap(config.wait_shm_path.value, is_root); + wait_shm_mmap = shm_ust_get_mmap( + the_config.wait_shm_path.value, is_root); if (wait_shm_mmap == NULL) { goto error; } @@ -166,7 +170,7 @@ static void *thread_application_registration(void *data) DBG("[thread] Manage application registration started"); pthread_cleanup_push(thread_init_cleanup, thread_state); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG); ret = lttcomm_listen_unix_sock(application_socket); if (ret < 0) { @@ -247,11 +251,11 @@ static void *thread_application_registration(void *data) * lttcomm_setsockopt_snd_timeout expect msec as * parameter. */ - if (config.app_socket_timeout >= 0) { + if (the_config.app_socket_timeout >= 0) { (void) lttcomm_setsockopt_rcv_timeout(sock, - config.app_socket_timeout * 1000); + the_config.app_socket_timeout * 1000); (void) lttcomm_setsockopt_snd_timeout(sock, - config.app_socket_timeout * 1000); + the_config.app_socket_timeout * 1000); } /* @@ -353,7 +357,7 @@ error: } lttng_fd_put(LTTNG_FD_APPS, 1); } - unlink(config.apps_unix_sock_path.value); + unlink(the_config.apps_unix_sock_path.value); error_poll_add: lttng_poll_clean(&events); @@ -364,7 +368,7 @@ error_create_poll: health_error(); ERR("Health error occurred in %s", __func__); } - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); return NULL; } diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index c8cf93e59..81cdb75d8 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -771,7 +771,7 @@ void *thread_rotation(void *data) DBG("[rotation-thread] Started rotation thread"); rcu_register_thread(); rcu_thread_online(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_ROTATION); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_ROTATION); health_code_update(); if (!handle) { @@ -863,7 +863,7 @@ error: DBG("[rotation-thread] Exit"); fini_thread_state(&thread); end: - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); rcu_thread_offline(); rcu_unregister_thread(); return NULL; diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index 6eda624ef..bb3b63b3a 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -954,7 +954,7 @@ void session_release(struct urcu_ref *ref) * Must notify the kernel thread here to update it's poll set in order to * remove the channel(s)' fd just destroyed. */ - ret = notify_thread_pipe(kernel_poll_pipe[1]); + ret = notify_thread_pipe(the_kernel_poll_pipe[1]); if (ret < 0) { PERROR("write kernel poll pipe"); } diff --git a/src/bin/lttng-sessiond/timer.c b/src/bin/lttng-sessiond/timer.c index f67aac4d0..bf56d9306 100644 --- a/src/bin/lttng-sessiond/timer.c +++ b/src/bin/lttng-sessiond/timer.c @@ -346,7 +346,7 @@ void *thread_timer(void *data) rcu_register_thread(); rcu_thread_online(); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_TIMER); + health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_TIMER); health_code_update(); /* Only self thread will receive signal mask. */ @@ -400,7 +400,7 @@ void *thread_timer(void *data) end: DBG("[timer-thread] Exit"); - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); rcu_thread_offline(); rcu_unregister_thread(); return NULL; diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index f779952a0..dc15829ba 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -946,11 +946,11 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel) /* Remove from channel list */ cds_list_del(&channel->list); - if (notification_thread_handle - && channel->published_to_notification_thread) { + if (the_notification_thread_handle && + channel->published_to_notification_thread) { status = notification_thread_command_remove_channel( - notification_thread_handle, - channel->key, LTTNG_DOMAIN_KERNEL); + the_notification_thread_handle, channel->key, + LTTNG_DOMAIN_KERNEL); assert(status == LTTNG_OK); } free(channel->channel->attr.extended.ptr); diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index b5ee6126e..3efda83c1 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1011,7 +1011,7 @@ void delete_ust_app(struct ust_app *app) app->event_notifier_group.event_pipe); ret_code = notification_thread_command_remove_tracer_event_source( - notification_thread_handle, + the_notification_thread_handle, event_notifier_read_fd); if (ret_code != LTTNG_OK) { ERR("Failed to remove application tracer event source from notification thread"); @@ -3352,11 +3352,12 @@ static int create_channel_per_uid(struct ust_app *app, pthread_mutex_unlock(®_uid->registry->reg.ust->lock); notification_ret = notification_thread_command_add_channel( - notification_thread_handle, session->name, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), - ua_chan->name, - ua_chan->key, LTTNG_DOMAIN_UST, + the_notification_thread_handle, session->name, + lttng_credentials_get_uid( + &ua_sess->effective_credentials), + lttng_credentials_get_gid( + &ua_sess->effective_credentials), + ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST, ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf); if (notification_ret != LTTNG_OK) { ret = - (int) notification_ret; @@ -3453,11 +3454,12 @@ static int create_channel_per_pid(struct ust_app *app, pthread_mutex_unlock(®istry->lock); cmd_ret = notification_thread_command_add_channel( - notification_thread_handle, session->name, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), - ua_chan->name, - ua_chan->key, LTTNG_DOMAIN_UST, + the_notification_thread_handle, session->name, + lttng_credentials_get_uid( + &ua_sess->effective_credentials), + lttng_credentials_get_gid( + &ua_sess->effective_credentials), + ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST, ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf); if (cmd_ret != LTTNG_OK) { ret = - (int) cmd_ret; @@ -3850,9 +3852,11 @@ struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock) DBG3("UST app creating application for socket %d", sock); if ((msg->bits_per_long == 64 && - (uatomic_read(&ust_consumerd64_fd) == -EINVAL)) - || (msg->bits_per_long == 32 && - (uatomic_read(&ust_consumerd32_fd) == -EINVAL))) { + (uatomic_read(&the_ust_consumerd64_fd) == + -EINVAL)) || + (msg->bits_per_long == 32 && + (uatomic_read(&the_ust_consumerd32_fd) == + -EINVAL))) { ERR("Registration failed: application \"%s\" (pid: %d) has " "%d-bit long, but no consumerd for this size is available.\n", msg->name, msg->pid, msg->bits_per_long); @@ -4046,8 +4050,9 @@ int ust_app_setup_event_notifier_group(struct ust_app *app) lttng_fd_put(LTTNG_FD_APPS, 1); lttng_ret = notification_thread_command_add_tracer_event_source( - notification_thread_handle, - lttng_pipe_get_readfd(app->event_notifier_group.event_pipe), + the_notification_thread_handle, + lttng_pipe_get_readfd( + app->event_notifier_group.event_pipe), LTTNG_DOMAIN_UST); if (lttng_ret != LTTNG_OK) { ERR("Failed to add tracer event source to notification thread"); @@ -5646,7 +5651,7 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) /* Get all triggers using uid 0 (root) */ ret_code = notification_thread_command_list_triggers( - notification_thread_handle, 0, &triggers); + the_notification_thread_handle, 0, &triggers); if (ret_code != LTTNG_OK) { ret = -1; goto end; diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 7a4cf1537..3dfb56215 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -26,7 +26,7 @@ struct lttng_bytecode; struct lttng_ust_filter_bytecode; -extern int ust_consumerd64_fd, ust_consumerd32_fd; +extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd; /* * Object used to close the notify socket in a call_rcu(). Since the diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 8eee74979..e1984af5f 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -732,8 +732,8 @@ static void destroy_channel(struct ust_registry_channel *chan, bool notif) if (notif) { cmd_ret = notification_thread_command_remove_channel( - notification_thread_handle, chan->consumer_key, - LTTNG_DOMAIN_UST); + the_notification_thread_handle, + chan->consumer_key, LTTNG_DOMAIN_UST); if (cmd_ret != LTTNG_OK) { ERR("Failed to remove channel from notification thread"); } diff --git a/src/bin/lttng-sessiond/utils.c b/src/bin/lttng-sessiond/utils.c index f84859fc6..e806082e3 100644 --- a/src/bin/lttng-sessiond/utils.c +++ b/src/bin/lttng-sessiond/utils.c @@ -16,7 +16,7 @@ #include "snapshot.h" #include "lttng-sessiond.h" -int ht_cleanup_pipe[2] = { -1, -1 }; +int the_ht_cleanup_pipe[2] = {-1, -1}; /* * Write to writable pipe used to notify a thread. @@ -41,7 +41,7 @@ int notify_thread_pipe(int wpipe) void ht_cleanup_push(struct lttng_ht *ht) { ssize_t ret; - int fd = ht_cleanup_pipe[1]; + int fd = the_ht_cleanup_pipe[1]; if (!ht) { return; diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c index 676ea316e..e6d9ec8bc 100644 --- a/tests/unit/test_session.c +++ b/tests/unit/test_session.c @@ -335,7 +335,7 @@ int main(int argc, char **argv) plan_tests(NUM_TESTS); - health_sessiond = health_app_create(NR_HEALTH_SESSIOND_TYPES); + the_health_sessiond = health_app_create(NR_HEALTH_SESSIOND_TYPES); ht_cleanup_thread = launch_ht_cleanup_thread(); assert(ht_cleanup_thread); lttng_thread_put(ht_cleanup_thread); -- 2.34.1