X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.cpp;h=659713c23106d12afc0460945ab97b8131bc4bae;hb=84083c3c07b8c1f6320963c395d9c4a9012cdb44;hp=49fa0c6864401f9aa6a95872c7ab9b4bf5e9a307;hpb=0d19be9d7e89fa4ff548592edd6d00a723070ced;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index 49fa0c686..659713c23 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -74,6 +74,9 @@ /* Sleep for 100ms between each check for the shm path's deletion. */ #define SESSION_DESTROY_SHM_PATH_CHECK_DELAY_US 100000 +static enum lttng_error_code wait_on_path(void *path); + +namespace { struct cmd_destroy_session_reply_context { int reply_sock_fd; bool implicit_rotation_on_destroy; @@ -84,15 +87,13 @@ struct cmd_destroy_session_reply_context { enum lttng_error_code destruction_status; }; -static enum lttng_error_code wait_on_path(void *path); - /* * Command completion handler that is used by the destroy command * when a session that has a non-default shm_path is being destroyed. * * See comment in cmd_destroy_session() for the rationale. */ -static struct destroy_completion_handler { +struct destroy_completion_handler { struct cmd_completion_handler handler; char shm_path[member_sizeof(struct ltt_session, shm_path)]; } destroy_completion_handler = { @@ -103,17 +104,17 @@ static struct destroy_completion_handler { .shm_path = { 0 }, }; -static struct cmd_completion_handler *current_completion_handler; - /* * Used to keep a unique index for each relayd socket created where this value * is associated with streams on the consumer so it can match the right relayd * to send to. It must be accessed with the relayd_net_seq_idx_lock * held. */ -static pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER; -static uint64_t relayd_net_seq_idx; +pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER; +uint64_t relayd_net_seq_idx; +} /* namespace */ +static struct cmd_completion_handler *current_completion_handler; static int validate_ust_event_name(const char *); static int cmd_enable_event_internal(struct ltt_session *session, const struct lttng_domain *domain, @@ -2140,7 +2141,7 @@ static int _cmd_enable_event(struct ltt_session *session, } } if (filter) { - filter_a = (lttng_bytecode *) zmalloc(sizeof(*filter_a) + filter->len); + filter_a = zmalloc(sizeof(*filter_a) + filter->len); if (!filter_a) { free(filter_expression_a); ret = LTTNG_ERR_FATAL; @@ -2368,7 +2369,7 @@ static int _cmd_enable_event(struct ltt_session *session, struct lttng_bytecode) + filter->len; - filter_copy = (lttng_bytecode *) zmalloc(filter_size); + filter_copy = zmalloc(filter_size); if (!filter_copy) { ret = LTTNG_ERR_NOMEM; goto error; @@ -3380,11 +3381,12 @@ int cmd_destroy_session(struct ltt_session *session, struct cmd_destroy_session_reply_context *reply_context = NULL; if (sock_fd) { - reply_context = (cmd_destroy_session_reply_context *) zmalloc(sizeof(*reply_context)); + reply_context = zmalloc(); if (!reply_context) { ret = LTTNG_ERR_NOMEM; goto end; } + reply_context->reply_sock_fd = *sock_fd; } @@ -3583,12 +3585,13 @@ int cmd_register_consumer(struct ltt_session *session, goto error; } - socket->lock = (pthread_mutex_t *) zmalloc(sizeof(pthread_mutex_t)); + socket->lock = zmalloc(); if (socket->lock == NULL) { PERROR("zmalloc pthread mutex"); ret = LTTNG_ERR_FATAL; goto error; } + pthread_mutex_init(socket->lock, NULL); socket->registered = 1; @@ -3651,7 +3654,7 @@ ssize_t cmd_list_domains(struct ltt_session *session, goto end; } - *domains = (lttng_domain *) zmalloc(nb_dom * sizeof(struct lttng_domain)); + *domains = calloc(nb_dom); if (*domains == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -4193,7 +4196,7 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, goto end; } - list = (lttng_snapshot_output *) zmalloc(session->snapshot.nb_output * sizeof(*list)); + list = calloc(session->snapshot.nb_output); if (!list) { ret = -LTTNG_ERR_NOMEM; goto end; @@ -4325,60 +4328,62 @@ int ust_regenerate_metadata(struct ltt_ust_session *usess) rcu_read_lock(); cds_list_for_each_entry(uid_reg, &usess->buffer_reg_uid_list, lnode) { - struct ust_registry_session *registry; + ust_registry_session *registry; struct ust_registry_channel *chan; struct lttng_ht_iter iter_chan; session_reg = uid_reg->registry; registry = session_reg->reg.ust; - pthread_mutex_lock(®istry->lock); - registry->metadata_len_sent = 0; - memset(registry->metadata, 0, registry->metadata_alloc_len); - registry->metadata_len = 0; - registry->metadata_version++; - if (registry->metadata_fd > 0) { + pthread_mutex_lock(®istry->_lock); + registry->_metadata_len_sent = 0; + memset(registry->_metadata, 0, registry->_metadata_alloc_len); + registry->_metadata_len = 0; + registry->_metadata_version++; + if (registry->_metadata_fd > 0) { /* Clear the metadata file's content. */ - ret = clear_metadata_file(registry->metadata_fd); + ret = clear_metadata_file(registry->_metadata_fd); if (ret) { - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); goto end; } } - ret = ust_metadata_session_statedump(registry, NULL, - registry->major, registry->minor); + ret = ust_metadata_session_statedump(registry); if (ret) { - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); ERR("Failed to generate session metadata (err = %d)", ret); goto end; } - cds_lfht_for_each_entry(registry->channels->ht, &iter_chan.iter, + cds_lfht_for_each_entry(registry->_channels->ht, &iter_chan.iter, chan, node.node) { struct ust_registry_event *event; struct lttng_ht_iter iter_event; + chan->metadata_dumped = 0; + ret = ust_metadata_channel_statedump(registry, chan); if (ret) { - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); ERR("Failed to generate channel metadata " "(err = %d)", ret); goto end; } cds_lfht_for_each_entry(chan->events->ht, &iter_event.iter, - event, node.node) { + event, node.node) { + event->metadata_dumped = 0; ret = ust_metadata_event_statedump(registry, chan, event); if (ret) { - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); ERR("Failed to generate event metadata " "(err = %d)", ret); goto end; } } } - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); } end: