X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.cpp;h=b1e0c098594f26004bdf329567a6b6eb08731dac;hb=49cddecdbb1e042877ca3855b177ade68151030f;hp=8f274abcb0524305adf35a4ce05fe0cdefbeb2a0;hpb=5c7248cd5bce45bf64d563fb4e130a63bf345f11;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index 8f274abcb..b1e0c0985 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -22,7 +22,6 @@ #include "lttng-syscall.hpp" #include "notification-thread-commands.hpp" #include "notification-thread.hpp" -#include "rotate.hpp" #include "rotation-thread.hpp" #include "session.hpp" #include "timer.hpp" @@ -41,6 +40,7 @@ #include #include #include +#include #include #include @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -324,7 +325,6 @@ static enum lttng_error_code list_lttng_agent_events(struct agent *agt, DBG3("Listing agent events"); - rcu_read_lock(); agent_event_count = lttng_ht_get_count(agt->events); if (agent_event_count == 0) { /* Early exit. */ @@ -338,39 +338,46 @@ static enum lttng_error_code list_lttng_agent_events(struct agent *agt, local_nb_events = (unsigned int) agent_event_count; - cds_lfht_for_each_entry (agt->events->ht, &iter.iter, event, node.node) { - struct lttng_event *tmp_event = lttng_event_create(); + { + lttng::urcu::read_lock_guard read_lock; - if (!tmp_event) { - ret_code = LTTNG_ERR_NOMEM; - goto error; - } + cds_lfht_for_each_entry (agt->events->ht, &iter.iter, event, node.node) { + struct lttng_event *tmp_event = lttng_event_create(); - if (lttng_strncpy(tmp_event->name, event->name, sizeof(tmp_event->name))) { - lttng_event_destroy(tmp_event); - ret_code = LTTNG_ERR_FATAL; - goto error; - } + if (!tmp_event) { + ret_code = LTTNG_ERR_NOMEM; + goto error; + } - tmp_event->name[sizeof(tmp_event->name) - 1] = '\0'; - tmp_event->enabled = !!event->enabled_count; - tmp_event->loglevel = event->loglevel_value; - tmp_event->loglevel_type = event->loglevel_type; + if (lttng_strncpy(tmp_event->name, event->name, sizeof(tmp_event->name))) { + lttng_event_destroy(tmp_event); + ret_code = LTTNG_ERR_FATAL; + goto error; + } - ret = lttng_event_serialize( - tmp_event, 0, nullptr, event->filter_expression, 0, nullptr, reply_payload); - lttng_event_destroy(tmp_event); - if (ret) { - ret_code = LTTNG_ERR_FATAL; - goto error; + tmp_event->name[sizeof(tmp_event->name) - 1] = '\0'; + tmp_event->enabled = !!event->enabled_count; + tmp_event->loglevel = event->loglevel_value; + tmp_event->loglevel_type = event->loglevel_type; + + ret = lttng_event_serialize(tmp_event, + 0, + nullptr, + event->filter_expression, + 0, + nullptr, + reply_payload); + lttng_event_destroy(tmp_event); + if (ret) { + ret_code = LTTNG_ERR_FATAL; + goto error; + } } } - end: ret_code = LTTNG_OK; *nb_events = local_nb_events; error: - rcu_read_unlock(); return ret_code; } @@ -396,7 +403,7 @@ static enum lttng_error_code list_lttng_ust_global_events(char *channel_name, DBG("Listing UST global events for channel %s", channel_name); - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(ust_global->channels, (void *) channel_name, &iter); node = lttng_ht_iter_get_node_str(&iter); @@ -478,14 +485,22 @@ static enum lttng_error_code list_lttng_ust_global_events(char *channel_name, tmp_event->exclusion = 1; } + std::vector exclusion_names; + if (uevent->exclusion) { + for (int i = 0; i < uevent->exclusion->count; i++) { + exclusion_names.emplace_back( + LTTNG_EVENT_EXCLUSION_NAME_AT(uevent->exclusion, i)); + } + } + /* * We do not care about the filter bytecode and the fd from the * userspace_probe_location. */ ret = lttng_event_serialize(tmp_event, - uevent->exclusion ? uevent->exclusion->count : 0, - uevent->exclusion ? (char **) uevent->exclusion->names : - nullptr, + exclusion_names.size(), + exclusion_names.size() ? exclusion_names.data() : + nullptr, uevent->filter_expression, 0, nullptr, @@ -502,7 +517,6 @@ end: ret_code = LTTNG_OK; *nb_events = local_nb_events; error: - rcu_read_unlock(); return ret_code; } @@ -738,9 +752,9 @@ static int init_kernel_tracing(struct ltt_kernel_session *session) LTTNG_ASSERT(session); - rcu_read_lock(); - if (session->consumer_fds_sent == 0 && session->consumer != nullptr) { + lttng::urcu::read_lock_guard read_lock; + cds_lfht_for_each_entry ( session->consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); @@ -754,7 +768,6 @@ static int init_kernel_tracing(struct ltt_kernel_session *session) } error: - rcu_read_unlock(); return ret; } @@ -921,7 +934,7 @@ close_sock: * since the relayd connection failed thus making any tracing or/and * streaming not usable. */ - consumer->enabled = 0; + consumer->enabled = false; } (void) relayd_close(rsock); free(rsock); @@ -1016,7 +1029,6 @@ int cmd_setup_relayd(struct ltt_session *session) DBG("Setting relayd for session %s", session->name); - rcu_read_lock(); if (session->current_trace_chunk) { enum lttng_trace_chunk_status status = lttng_trace_chunk_get_id( session->current_trace_chunk, ¤t_chunk_id.value); @@ -1033,6 +1045,8 @@ int cmd_setup_relayd(struct ltt_session *session) if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET && usess->consumer->enabled) { /* For each consumer socket, send relayd sockets */ + lttng::urcu::read_lock_guard read_lock; + cds_lfht_for_each_entry ( usess->consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); @@ -1054,6 +1068,7 @@ int cmd_setup_relayd(struct ltt_session *session) /* Session is now ready for network streaming. */ session->net_handle = 1; } + session->consumer->relay_major_version = usess->consumer->relay_major_version; session->consumer->relay_minor_version = usess->consumer->relay_minor_version; session->consumer->relay_allows_clear = usess->consumer->relay_allows_clear; @@ -1061,6 +1076,8 @@ int cmd_setup_relayd(struct ltt_session *session) if (ksess && ksess->consumer && ksess->consumer->type == CONSUMER_DST_NET && ksess->consumer->enabled) { + lttng::urcu::read_lock_guard read_lock; + cds_lfht_for_each_entry ( ksess->consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); @@ -1082,13 +1099,13 @@ int cmd_setup_relayd(struct ltt_session *session) /* Session is now ready for network streaming. */ session->net_handle = 1; } + session->consumer->relay_major_version = ksess->consumer->relay_major_version; session->consumer->relay_minor_version = ksess->consumer->relay_minor_version; session->consumer->relay_allows_clear = ksess->consumer->relay_allows_clear; } error: - rcu_read_unlock(); return ret; } @@ -1149,7 +1166,7 @@ int start_kernel_session(struct ltt_kernel_session *ksess) /* Quiescent wait after starting trace */ kernel_wait_quiescent(); - ksess->active = 1; + ksess->active = true; ret = LTTNG_OK; @@ -1194,7 +1211,7 @@ int stop_kernel_session(struct ltt_kernel_session *ksess) } } - ksess->active = 0; + ksess->active = false; if (error_occurred) { ret = LTTNG_ERR_UNK; } else { @@ -1216,7 +1233,7 @@ int cmd_disable_channel(struct ltt_session *session, usess = session->ust_session; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; switch (domain) { case LTTNG_DOMAIN_KERNEL: @@ -1256,7 +1273,6 @@ int cmd_disable_channel(struct ltt_session *session, ret = LTTNG_OK; error: - rcu_read_unlock(); return ret; } @@ -1325,6 +1341,8 @@ static enum lttng_error_code cmd_enable_channel_internal(struct ltt_session *ses LTTNG_ASSERT(_attr); LTTNG_ASSERT(domain); + lttng::urcu::read_lock_guard read_lock; + attr = lttng_channel_copy(_attr); if (!attr) { ret_code = LTTNG_ERR_NOMEM; @@ -1341,8 +1359,6 @@ static enum lttng_error_code cmd_enable_channel_internal(struct ltt_session *ses DBG("Enabling channel %s for session %s", attr->name, session->name); - rcu_read_lock(); - /* * If the session is a live session, remove the switch timer, the * live timer does the same thing but sends also synchronisation @@ -1488,7 +1504,6 @@ static enum lttng_error_code cmd_enable_channel_internal(struct ltt_session *ses session->has_non_mmap_channel = true; } error: - rcu_read_unlock(); end: lttng_channel_destroy(attr); return ret_code; @@ -1727,6 +1742,8 @@ int cmd_disable_event(struct command_ctx *cmd_ctx, event_name = event->name; + lttng::urcu::read_lock_guard read_lock; + /* Error out on unhandled search criteria */ if (event->loglevel_type || event->loglevel != -1 || event->enabled || event->pid || event->filter || event->exclusion) { @@ -1734,8 +1751,6 @@ int cmd_disable_event(struct command_ctx *cmd_ctx, goto error; } - rcu_read_lock(); - switch (domain) { case LTTNG_DOMAIN_KERNEL: { @@ -1880,7 +1895,6 @@ int cmd_disable_event(struct command_ctx *cmd_ctx, ret = LTTNG_OK; error_unlock: - rcu_read_unlock(); error: free(exclusion); free(bytecode); @@ -2082,9 +2096,7 @@ static int _cmd_enable_event(struct ltt_session *session, } } - DBG("Enable event command for event \'%s\'", event->name); - - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; switch (domain->type) { case LTTNG_DOMAIN_KERNEL: @@ -2325,6 +2337,7 @@ static int _cmd_enable_event(struct ltt_session *session, memset(&uevent, 0, sizeof(uevent)); uevent.type = LTTNG_EVENT_TRACEPOINT; uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL; + uevent.loglevel = -1; default_event_name = event_get_default_agent_ust_name(domain->type); if (!default_event_name) { ret = LTTNG_ERR_FATAL; @@ -2426,7 +2439,6 @@ error: free(filter); free(exclusion); channel_attr_destroy(attr); - rcu_read_unlock(); return ret; } @@ -2758,7 +2770,7 @@ int cmd_start_trace(struct ltt_session *session) goto error; } - session->active = 1; + session->active = true; session->rotated_after_last_stop = false; session->cleared_after_last_stop = false; if (session->output_traces && !session->current_trace_chunk) { @@ -2852,9 +2864,9 @@ int cmd_start_trace(struct ltt_session *session) error: if (ret == LTTNG_OK) { /* Flag this after a successful start. */ - session->has_been_started |= 1; + session->has_been_started = true; } else { - session->active = 0; + session->active = false; /* Restore initial state on error. */ session->rotated_after_last_stop = session_rotated_after_last_stop; session->cleared_after_last_stop = session_cleared_after_last_stop; @@ -2900,7 +2912,7 @@ int cmd_stop_trace(struct ltt_session *session) DBG("Completed stop session \"%s\" (id %" PRIu64 ")", session->name, session->id); /* Flag inactive after a successful stop. */ - session->active = 0; + session->active = false; ret = LTTNG_OK; error: @@ -3202,7 +3214,7 @@ cmd_create_session_from_descriptor(struct lttng_session_descriptor *descriptor, if (ret_code != LTTNG_OK) { goto end; } - new_session->consumer->enabled = 1; + new_session->consumer->enabled = true; ret_code = LTTNG_OK; end: /* Release reference provided by the session_create function. */ @@ -3386,9 +3398,7 @@ error: * * Called with session lock held. */ -int cmd_destroy_session(struct ltt_session *session, - struct notification_thread_handle *notification_thread_handle, - int *sock_fd) +int cmd_destroy_session(struct ltt_session *session, int *sock_fd) { int ret; enum lttng_error_code destruction_last_error = LTTNG_OK; @@ -3430,7 +3440,15 @@ int cmd_destroy_session(struct ltt_session *session, } if (session->rotate_size) { - unsubscribe_session_consumed_size_rotation(session, notification_thread_handle); + try { + the_rotation_thread_handle->unsubscribe_session_consumed_size_rotation( + *session); + } catch (const std::exception& e) { + /* Continue the destruction of the session anyway. */ + ERR("Failed to unsubscribe rotation thread notification channel from consumed size condition during session destruction: %s", + e.what()); + } + session->rotate_size = 0; } @@ -3609,9 +3627,8 @@ int cmd_register_consumer(struct ltt_session *session, pthread_mutex_init(socket->lock, nullptr); socket->registered = 1; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; consumer_add_socket(socket, ksess->consumer); - rcu_read_unlock(); pthread_mutex_lock(&cdata->pid_mutex); cdata->pid = -1; @@ -3653,14 +3670,14 @@ ssize_t cmd_list_domains(struct ltt_session *session, struct lttng_domain **doma DBG3("Listing domains found UST global domain"); nb_dom++; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; + cds_lfht_for_each_entry ( session->ust_session->agents->ht, &iter.iter, agt, node.node) { if (agt->being_used) { nb_dom++; } } - rcu_read_unlock(); } if (!nb_dom) { @@ -3687,16 +3704,19 @@ ssize_t cmd_list_domains(struct ltt_session *session, struct lttng_domain **doma (*domains)[index].buf_type = session->ust_session->buffer_type; index++; - rcu_read_lock(); - cds_lfht_for_each_entry ( - session->ust_session->agents->ht, &iter.iter, agt, node.node) { - if (agt->being_used) { - (*domains)[index].type = agt->domain; - (*domains)[index].buf_type = session->ust_session->buffer_type; - index++; + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry ( + session->ust_session->agents->ht, &iter.iter, agt, node.node) { + if (agt->being_used) { + (*domains)[index].type = agt->domain; + (*domains)[index].buf_type = + session->ust_session->buffer_type; + index++; + } } } - rcu_read_unlock(); } end: return nb_dom; @@ -3780,47 +3800,51 @@ enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain, struct lttng_ht_iter iter; struct ltt_ust_channel *uchan; - rcu_read_lock(); - cds_lfht_for_each_entry (session->ust_session->domain_global.channels->ht, - &iter.iter, - uchan, - node.node) { - uint64_t discarded_events = 0, lost_packets = 0; - struct lttng_channel *channel = nullptr; - struct lttng_channel_extended *extended; - - channel = trace_ust_channel_to_lttng_channel(uchan); - if (!channel) { - ret_code = LTTNG_ERR_NOMEM; - goto end; - } + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (session->ust_session->domain_global.channels->ht, + &iter.iter, + uchan, + node.node) { + uint64_t discarded_events = 0, lost_packets = 0; + struct lttng_channel *channel = nullptr; + struct lttng_channel_extended *extended; - extended = (struct lttng_channel_extended *) channel->attr.extended.ptr; + channel = trace_ust_channel_to_lttng_channel(uchan); + if (!channel) { + ret_code = LTTNG_ERR_NOMEM; + goto end; + } - ret = get_ust_runtime_stats( - session, uchan, &discarded_events, &lost_packets); - if (ret < 0) { - lttng_channel_destroy(channel); - ret_code = LTTNG_ERR_UNK; - goto end; - } + extended = (struct lttng_channel_extended *) + channel->attr.extended.ptr; - extended->discarded_events = discarded_events; - extended->lost_packets = lost_packets; + ret = get_ust_runtime_stats( + session, uchan, &discarded_events, &lost_packets); + if (ret < 0) { + lttng_channel_destroy(channel); + ret_code = LTTNG_ERR_UNK; + goto end; + } + + extended->discarded_events = discarded_events; + extended->lost_packets = lost_packets; + + ret = lttng_channel_serialize(channel, &payload->buffer); + if (ret) { + ERR("Failed to serialize lttng_channel: channel name = '%s'", + channel->name); + lttng_channel_destroy(channel); + ret_code = LTTNG_ERR_UNK; + goto end; + } - ret = lttng_channel_serialize(channel, &payload->buffer); - if (ret) { - ERR("Failed to serialize lttng_channel: channel name = '%s'", - channel->name); lttng_channel_destroy(channel); - ret_code = LTTNG_ERR_UNK; - goto end; + i++; } - - lttng_channel_destroy(channel); - i++; } - rcu_read_unlock(); + break; } default: @@ -3895,7 +3919,8 @@ enum lttng_error_code cmd_list_events(enum lttng_domain_type domain, struct lttng_ht_iter iter; struct agent *agt; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; + cds_lfht_for_each_entry ( session->ust_session->agents->ht, &iter.iter, agt, node.node) { if (agt->domain == domain) { @@ -3904,8 +3929,6 @@ enum lttng_error_code cmd_list_events(enum lttng_domain_type domain, break; } } - - rcu_read_unlock(); } break; default: @@ -3995,6 +4018,19 @@ void cmd_list_lttng_sessions(struct lttng_session *sessions, } } +/* + * Command LTTCOMM_SESSIOND_COMMAND_KERNEL_TRACER_STATUS + */ +enum lttng_error_code cmd_kernel_tracer_status(enum lttng_kernel_tracer_status *status) +{ + if (status == nullptr) { + return LTTNG_ERR_INVALID; + } + + *status = get_kernel_tracer_status(); + return LTTNG_OK; +} + /* * Command LTTNG_DATA_PENDING returning 0 if the data is NOT pending meaning * ready for trace analysis (or any kind of reader) or else 1 for pending data. @@ -4119,12 +4155,10 @@ int cmd_snapshot_add_output(struct ltt_session *session, goto free_error; } - rcu_read_lock(); snapshot_add_output(&session->snapshot, new_output); if (id) { *id = new_output->id; } - rcu_read_unlock(); return LTTNG_OK; @@ -4147,7 +4181,7 @@ int cmd_snapshot_del_output(struct ltt_session *session, const struct lttng_snap LTTNG_ASSERT(session); LTTNG_ASSERT(output); - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; /* * Permission denied to create an output if the session is not @@ -4177,7 +4211,6 @@ int cmd_snapshot_del_output(struct ltt_session *session, const struct lttng_snap ret = LTTNG_OK; error: - rcu_read_unlock(); return ret; } @@ -4222,49 +4255,54 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, } /* Copy list from session to the new list object. */ - rcu_read_lock(); - cds_lfht_for_each_entry (session->snapshot.output_ht->ht, &iter.iter, output, node.node) { - LTTNG_ASSERT(output->consumer); - list[idx].id = output->id; - list[idx].max_size = output->max_size; - if (lttng_strncpy(list[idx].name, output->name, sizeof(list[idx].name))) { - ret = -LTTNG_ERR_INVALID; - goto error; - } - if (output->consumer->type == CONSUMER_DST_LOCAL) { - if (lttng_strncpy(list[idx].ctrl_url, - output->consumer->dst.session_root_path, - sizeof(list[idx].ctrl_url))) { + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry ( + session->snapshot.output_ht->ht, &iter.iter, output, node.node) { + LTTNG_ASSERT(output->consumer); + list[idx].id = output->id; + list[idx].max_size = output->max_size; + if (lttng_strncpy(list[idx].name, output->name, sizeof(list[idx].name))) { ret = -LTTNG_ERR_INVALID; goto error; } - } else { - /* Control URI. */ - ret = uri_to_str_url(&output->consumer->dst.net.control, - list[idx].ctrl_url, - sizeof(list[idx].ctrl_url)); - if (ret < 0) { - ret = -LTTNG_ERR_NOMEM; - goto error; - } - /* Data URI. */ - ret = uri_to_str_url(&output->consumer->dst.net.data, - list[idx].data_url, - sizeof(list[idx].data_url)); - if (ret < 0) { - ret = -LTTNG_ERR_NOMEM; - goto error; + if (output->consumer->type == CONSUMER_DST_LOCAL) { + if (lttng_strncpy(list[idx].ctrl_url, + output->consumer->dst.session_root_path, + sizeof(list[idx].ctrl_url))) { + ret = -LTTNG_ERR_INVALID; + goto error; + } + } else { + /* Control URI. */ + ret = uri_to_str_url(&output->consumer->dst.net.control, + list[idx].ctrl_url, + sizeof(list[idx].ctrl_url)); + if (ret < 0) { + ret = -LTTNG_ERR_NOMEM; + goto error; + } + + /* Data URI. */ + ret = uri_to_str_url(&output->consumer->dst.net.data, + list[idx].data_url, + sizeof(list[idx].data_url)); + if (ret < 0) { + ret = -LTTNG_ERR_NOMEM; + goto error; + } } + + idx++; } - idx++; } *outputs = list; list = nullptr; ret = session->snapshot.nb_output; error: - rcu_read_unlock(); free(list); end: return ret; @@ -4451,6 +4489,8 @@ synchronize_tracer_notifier_register(struct notification_thread_handle *notifica (int) trigger_owner, ret_code); } + + goto end_unlock_session_list; } break; } @@ -4955,27 +4995,28 @@ static enum lttng_error_code set_relayd_for_snapshot(struct consumer_output *out * For each consumer socket, create and send the relayd object of the * snapshot output. */ - rcu_read_lock(); - cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) { - pthread_mutex_lock(socket->lock); - status = send_consumer_relayd_sockets( - session->id, - output, - socket, - session->name, - session->hostname, - base_path, - session->live_timer, - current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr, - session->creation_time, - session->name_contains_creation_time); - pthread_mutex_unlock(socket->lock); - if (status != LTTNG_OK) { - rcu_read_unlock(); - goto error; + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) { + pthread_mutex_lock(socket->lock); + status = send_consumer_relayd_sockets( + session->id, + output, + socket, + session->name, + session->hostname, + base_path, + session->live_timer, + current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr, + session->creation_time, + session->name_contains_creation_time); + pthread_mutex_unlock(socket->lock); + if (status != LTTNG_OK) { + goto error; + } } } - rcu_read_unlock(); error: return status; @@ -5349,7 +5390,8 @@ int cmd_snapshot_record(struct ltt_session *session, struct snapshot_output *sout; struct lttng_ht_iter iter; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; + cds_lfht_for_each_entry ( session->snapshot.output_ht->ht, &iter.iter, sout, node.node) { struct snapshot_output output_copy; @@ -5374,19 +5416,17 @@ int cmd_snapshot_record(struct ltt_session *session, output->name, sizeof(output_copy.name))) { cmd_ret = LTTNG_ERR_INVALID; - rcu_read_unlock(); goto error; } } cmd_ret = snapshot_record(session, &output_copy); if (cmd_ret != LTTNG_OK) { - rcu_read_unlock(); goto error; } + snapshot_success = 1; } - rcu_read_unlock(); } if (snapshot_success) { @@ -5399,6 +5439,7 @@ error: if (tmp_output) { snapshot_output_destroy(tmp_output); } + return cmd_ret; } @@ -5606,7 +5647,7 @@ end: ret = (cmd_ret == LTTNG_OK) ? cmd_ret : -((int) cmd_ret); return ret; error: - if (session_reset_rotation_state(session, LTTNG_ROTATION_STATE_ERROR)) { + if (session_reset_rotation_state(*session, LTTNG_ROTATION_STATE_ERROR)) { ERR("Failed to reset rotation state of session \"%s\"", session->name); } goto end; @@ -5773,8 +5814,7 @@ end: int cmd_rotation_set_schedule(struct ltt_session *session, bool activate, enum lttng_rotation_schedule_type schedule_type, - uint64_t new_value, - struct notification_thread_handle *notification_thread_handle) + uint64_t new_value) { int ret; uint64_t *parameter_value; @@ -5876,18 +5916,22 @@ int cmd_rotation_set_schedule(struct ltt_session *session, break; case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD: if (activate) { - ret = subscribe_session_consumed_size_rotation( - session, new_value, notification_thread_handle); - if (ret) { - ERR("Failed to enable consumed-size notification in ROTATION_SET_SCHEDULE command"); + try { + the_rotation_thread_handle->subscribe_session_consumed_size_rotation( + *session, new_value); + } catch (const std::exception& e) { + ERR("Failed to enable consumed-size notification in ROTATION_SET_SCHEDULE command: %s", + e.what()); ret = LTTNG_ERR_UNK; goto end; } } else { - ret = unsubscribe_session_consumed_size_rotation( - session, notification_thread_handle); - if (ret) { - ERR("Failed to disable consumed-size notification in ROTATION_SET_SCHEDULE command"); + try { + the_rotation_thread_handle + ->unsubscribe_session_consumed_size_rotation(*session); + } catch (const std::exception& e) { + ERR("Failed to disable consumed-size notification in ROTATION_SET_SCHEDULE command: %s", + e.what()); ret = LTTNG_ERR_UNK; goto end; }