#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"
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/string-utils/string-utils.hpp>
#include <common/trace-chunk.hpp>
+#include <common/urcu.hpp>
#include <common/utils.hpp>
#include <lttng/action/action-internal.hpp>
static int build_network_session_path(char *dst, size_t size, struct ltt_session *session)
{
int ret, kdata_port, udata_port;
- struct lttng_uri *kuri = NULL, *uuri = NULL, *uri = NULL;
+ struct lttng_uri *kuri = nullptr, *uuri = nullptr, *uri = nullptr;
char tmp_uurl[PATH_MAX], tmp_urls[PATH_MAX];
LTTNG_ASSERT(session);
udata_port = session->ust_session->consumer->dst.net.data.port;
}
- if (uuri == NULL && kuri == NULL) {
+ if (uuri == nullptr && kuri == nullptr) {
uri = &session->consumer->dst.net.control;
kdata_port = session->consumer->dst.net.data.port;
} else if (kuri && uuri) {
} else {
uri = kuri;
}
- } else if (kuri && uuri == NULL) {
+ } else if (kuri && uuri == nullptr) {
uri = kuri;
- } else if (uuri && kuri == NULL) {
+ } else if (uuri && kuri == nullptr) {
uri = uuri;
}
DBG3("Listing agent events");
- rcu_read_lock();
agent_event_count = lttng_ht_get_count(agt->events);
if (agent_event_count == 0) {
/* Early exit. */
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, NULL, event->filter_expression, 0, NULL, 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;
}
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);
- if (node == NULL) {
+ if (node == nullptr) {
ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
DBG3("Listing UST global %d events", *nb_events);
cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) {
- struct lttng_event *tmp_event = NULL;
+ struct lttng_event *tmp_event = nullptr;
if (uevent->internal) {
/* This event should remain hidden from clients */
tmp_event->exclusion = 1;
}
+ std::vector<const char *> 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 :
- NULL,
+ exclusion_names.size(),
+ exclusion_names.size() ? exclusion_names.data() :
+ nullptr,
uevent->filter_expression,
0,
- NULL,
+ nullptr,
reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_OK;
*nb_events = local_nb_events;
error:
- rcu_read_unlock();
return ret_code;
}
assert(reply_payload);
kchan = trace_kernel_get_channel_by_name(channel_name, kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
ret_code = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto end;
}
}
ret = lttng_event_serialize(
- tmp_event, 0, NULL, event->filter_expression, 0, NULL, reply_payload);
+ tmp_event, 0, nullptr, event->filter_expression, 0, nullptr, reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_ERR_FATAL;
LTTNG_ASSERT(uri);
- if (consumer == NULL) {
+ if (consumer == nullptr) {
DBG("No consumer detected. Don't add URI. Stopping.");
ret_code = LTTNG_ERR_NO_CONSUMER;
goto error;
LTTNG_ASSERT(session);
- rcu_read_lock();
+ if (session->consumer_fds_sent == 0 && session->consumer != nullptr) {
+ lttng::urcu::read_lock_guard read_lock;
- if (session->consumer_fds_sent == 0 && session->consumer != NULL) {
cds_lfht_for_each_entry (
session->consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
}
error:
- rcu_read_unlock();
return ret;
}
bool session_name_contains_creation_time)
{
int ret;
- struct lttcomm_relayd_sock *rsock = NULL;
+ struct lttcomm_relayd_sock *rsock = nullptr;
enum lttng_error_code status;
/* Connect to relayd and make version check if uri is the control. */
* 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);
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);
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);
session->hostname,
session->base_path,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr,
session->creation_time,
session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
/* 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;
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);
session->hostname,
session->base_path,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr,
session->creation_time,
session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
/* 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;
}
struct ltt_kernel_channel *kchan;
/* Open kernel metadata */
- if (ksess->metadata == NULL && ksess->output_traces) {
+ if (ksess->metadata == nullptr && ksess->output_traces) {
ret = kernel_open_metadata(ksess);
if (ret < 0) {
ret = LTTNG_ERR_KERN_META_FAIL;
/* Quiescent wait after starting trace */
kernel_wait_quiescent();
- ksess->active = 1;
+ ksess->active = true;
ret = LTTNG_OK;
}
}
- ksess->active = 0;
+ ksess->active = false;
if (error_occurred) {
ret = LTTNG_ERR_UNK;
} else {
usess = session->ust_session;
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
chan_ht = usess->domain_global.channels;
uchan = trace_ust_find_channel_by_name(chan_ht, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
ret = LTTNG_OK;
error:
- rcu_read_unlock();
return ret;
}
int ret;
size_t channel_len;
ssize_t sock_recv_len;
- struct lttng_channel *channel = NULL;
+ struct lttng_channel *channel = nullptr;
struct lttng_buffer_view view;
struct lttng_dynamic_buffer channel_buffer;
const struct lttng_domain command_domain = cmd_ctx->lsm.domain;
struct ltt_ust_session *usess = session->ust_session;
struct lttng_ht *chan_ht;
size_t len;
- struct lttng_channel *attr = NULL;
+ struct lttng_channel *attr = nullptr;
LTTNG_ASSERT(session);
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;
len = lttng_strnlen(attr->name, sizeof(attr->name));
/* Validate channel name */
- if (attr->name[0] == '.' || memchr(attr->name, '/', len) != NULL) {
+ if (attr->name[0] == '.' || memchr(attr->name, '/', len) != nullptr) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto end;
}
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
struct ltt_kernel_channel *kchan;
kchan = trace_kernel_get_channel_by_name(attr->name, session->kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
/*
* Don't try to create a channel if the session has been started at
* some point in time before. The tracer does not allow it.
* adhered to.
*/
if (domain->type == LTTNG_DOMAIN_JUL) {
- if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME, LTTNG_SYMBOL_NAME_LEN)) {
+ if (strncmp(attr->name,
+ DEFAULT_JUL_CHANNEL_NAME,
+ LTTNG_SYMBOL_NAME_LEN - 1) != 0) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto error;
}
} else if (domain->type == LTTNG_DOMAIN_LOG4J) {
- if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME, LTTNG_SYMBOL_NAME_LEN)) {
+ if (strncmp(attr->name,
+ DEFAULT_LOG4J_CHANNEL_NAME,
+ LTTNG_SYMBOL_NAME_LEN - 1) != 0) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto error;
}
} else if (domain->type == LTTNG_DOMAIN_PYTHON) {
if (strncmp(attr->name,
DEFAULT_PYTHON_CHANNEL_NAME,
- LTTNG_SYMBOL_NAME_LEN)) {
+ LTTNG_SYMBOL_NAME_LEN - 1) != 0) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto error;
}
chan_ht = usess->domain_global.channels;
uchan = trace_ust_find_channel_by_name(chan_ht, attr->name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
/*
* Don't try to create a channel if the session has been started at
* some point in time before. The tracer does not allow it.
session->has_non_mmap_channel = true;
}
error:
- rcu_read_unlock();
end:
lttng_channel_destroy(attr);
return ret_code;
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) {
goto error;
}
- rcu_read_lock();
-
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
{
}
kchan = trace_kernel_get_channel_by_name(channel_name, ksess);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto error_unlock;
}
case LTTNG_EVENT_FUNCTION:
case LTTNG_EVENT_FUNCTION_ENTRY: /* fall-through */
if (event_name[0] == '\0') {
- ret = event_kernel_disable_event(kchan, NULL, event->type);
+ ret = event_kernel_disable_event(kchan, nullptr, event->type);
} else {
ret = event_kernel_disable_event(kchan, event_name, event->type);
}
}
uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error_unlock;
}
ret = LTTNG_OK;
error_unlock:
- rcu_read_unlock();
error:
free(exclusion);
free(bytecode);
if (session->kernel_session->channel_count == 0) {
/* Create default channel */
- ret = channel_kernel_create(session->kernel_session, NULL, kwpipe);
+ ret = channel_kernel_create(session->kernel_session, nullptr, kwpipe);
if (ret != LTTNG_OK) {
goto error;
}
* name, return an error.
*/
if (domain == LTTNG_DOMAIN_JUL && *channel_name &&
- strcmp(channel_name, DEFAULT_JUL_CHANNEL_NAME)) {
+ strcmp(channel_name, DEFAULT_JUL_CHANNEL_NAME) != 0) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
} else if (domain == LTTNG_DOMAIN_LOG4J && *channel_name &&
- strcmp(channel_name, DEFAULT_LOG4J_CHANNEL_NAME)) {
+ strcmp(channel_name, DEFAULT_LOG4J_CHANNEL_NAME) != 0) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
struct lttng_channel *attr;
/* Create default channel */
attr = channel_new_default_attr(domain, usess->buffer_type);
- if (attr == NULL) {
+ if (attr == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
bool internal_event)
{
int ret = 0, channel_created = 0;
- struct lttng_channel *attr = NULL;
+ struct lttng_channel *attr = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(event);
}
}
- 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:
}
kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
- if (attr == NULL) {
+ if (attr == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
/* Get the newly created kernel channel pointer */
kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
/* This sould not happen... */
ret = LTTNG_ERR_FATAL;
goto error;
switch (event->type) {
case LTTNG_EVENT_ALL:
{
- char *filter_expression_a = NULL;
- struct lttng_bytecode *filter_a = NULL;
+ char *filter_expression_a = nullptr;
+ struct lttng_bytecode *filter_a = nullptr;
/*
* We need to duplicate filter_expression and filter,
event->type = LTTNG_EVENT_TRACEPOINT; /* Hack */
ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret != LTTNG_OK) {
if (channel_created) {
/* Let's not leak a useless channel. */
ret = event_kernel_enable_event(
kchan, event, filter_expression_a, filter_a);
/* We have passed ownership */
- filter_expression_a = NULL;
- filter_a = NULL;
+ filter_expression_a = nullptr;
+ filter_a = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
case LTTNG_EVENT_TRACEPOINT:
ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret != LTTNG_OK) {
if (channel_created) {
/* Let's not leak a useless channel. */
case LTTNG_EVENT_SYSCALL:
ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
/* Get channel from global UST domain */
uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
/* Create default channel */
attr = channel_new_default_attr(LTTNG_DOMAIN_UST, usess->buffer_type);
- if (attr == NULL) {
+ if (attr == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
ret = event_ust_enable_tracepoint(
usess, uchan, event, filter_expression, filter, exclusion, internal_event);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
- exclusion = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
+ exclusion = nullptr;
if (ret == LTTNG_ERR_UST_EVENT_ENABLED) {
goto already_enabled;
} else if (ret != LTTNG_OK) {
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;
}
{
- char *filter_expression_copy = NULL;
- struct lttng_bytecode *filter_copy = NULL;
+ char *filter_expression_copy = nullptr;
+ struct lttng_bytecode *filter_copy = nullptr;
if (filter) {
const size_t filter_size =
&uevent,
filter_expression_copy,
filter_copy,
- NULL,
+ nullptr,
wpipe);
}
} else {
ret = event_agent_enable(usess, agt, event, filter, filter_expression);
}
- filter = NULL;
- filter_expression = NULL;
+ filter = nullptr;
+ filter_expression = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
free(filter);
free(exclusion);
channel_attr_destroy(attr);
- rcu_read_unlock();
return ret;
}
exclusion,
wpipe,
false);
- filter_expression = NULL;
- bytecode = NULL;
- exclusion = NULL;
+ filter_expression = nullptr;
+ bytecode = nullptr;
+ exclusion = nullptr;
return ret;
}
enum lttng_error_code ret_code;
int ret;
ssize_t i, nb_events = 0;
- struct lttng_event *events = NULL;
+ struct lttng_event *events = nullptr;
struct lttcomm_list_command_header reply_command_header = {};
size_t reply_command_header_offset;
}
for (i = 0; i < nb_events; i++) {
- ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(
+ &events[i], 0, nullptr, nullptr, 0, nullptr, reply_payload);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
enum lttng_error_code ret_code;
int ret;
unsigned int i, nb_fields;
- struct lttng_event_field *fields = NULL;
+ struct lttng_event_field *fields = nullptr;
struct lttcomm_list_command_header reply_command_header = {};
size_t reply_command_header_offset;
enum lttng_error_code ret_code;
ssize_t nb_events, i;
int ret;
- struct lttng_event *events = NULL;
+ struct lttng_event *events = nullptr;
struct lttcomm_list_command_header reply_command_header = {};
size_t reply_command_header_offset;
}
for (i = 0; i < nb_events; i++) {
- ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(
+ &events[i], 0, nullptr, nullptr, 0, nullptr, reply_payload);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
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) {
struct lttng_trace_chunk *trace_chunk;
DBG("Creating initial trace chunk of session \"%s\"", session->name);
- trace_chunk = session_create_new_trace_chunk(session, NULL, NULL, NULL);
+ trace_chunk =
+ session_create_new_trace_chunk(session, nullptr, nullptr, nullptr);
if (!trace_chunk) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
LTTNG_ASSERT(!session->current_trace_chunk);
ret = (lttng_error_code) session_set_trace_chunk(
- session, trace_chunk, NULL);
+ session, trace_chunk, nullptr);
lttng_trace_chunk_put(trace_chunk);
if (ret) {
ret = LTTNG_ERR_CREATE_TRACE_CHUNK_FAIL_CONSUMER;
* rotation should happen on reception of the command.
*/
ret = (lttng_error_code) cmd_rotate_session(
- session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
+ session, nullptr, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
if (ret != LTTNG_OK) {
goto error;
}
}
/* Kernel tracing */
- if (ksession != NULL) {
+ if (ksession != nullptr) {
DBG("Start kernel tracing session %s", session->name);
ret = (lttng_error_code) start_kernel_session(ksession);
if (ret != LTTNG_OK) {
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;
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:
continue;
}
- if (session->base_path != NULL) {
+ if (session->base_path != nullptr) {
free(session->base_path);
- session->base_path = NULL;
+ session->base_path = nullptr;
}
/* Set session base_path */
switch (session_type) {
case LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT:
{
- struct snapshot_output *new_output = NULL;
+ struct snapshot_output *new_output = nullptr;
new_output = snapshot_output_alloc();
if (!new_output) {
ret = snapshot_output_init_with_uri(session,
DEFAULT_SNAPSHOT_MAX_SIZE,
- NULL,
+ nullptr,
uris,
uri_count,
session->consumer,
int ret;
enum lttng_error_code ret_code;
const char *session_name;
- struct ltt_session *new_session = NULL;
+ struct ltt_session *new_session = nullptr;
enum lttng_session_descriptor_status descriptor_status;
session_lock_list();
case LTTNG_SESSION_DESCRIPTOR_STATUS_OK:
break;
case LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET:
- session_name = NULL;
+ session_name = nullptr;
break;
default:
ret_code = LTTNG_ERR_INVALID;
(void) notification_thread_command_remove_session(
the_notification_thread_handle, session->id);
},
- NULL);
+ nullptr);
if (ret) {
PERROR("Failed to add notification thread command to session's destroy notifiers: session name = %s",
new_session->name);
* not auto-generated.
*/
ret_code = lttng_session_descriptor_set_default_output(
- descriptor, session_name ? &new_session->creation_time : NULL, home_path);
+ descriptor,
+ session_name ? &new_session->creation_time : nullptr,
+ home_path);
if (ret_code != LTTNG_OK) {
goto end;
}
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. */
struct lttng_dynamic_buffer payload;
struct lttng_buffer_view home_dir_view;
struct lttng_buffer_view session_descriptor_view;
- struct lttng_session_descriptor *session_descriptor = NULL;
+ struct lttng_session_descriptor *session_descriptor = nullptr;
enum lttng_error_code ret_code;
lttng_dynamic_buffer_init(&payload);
* Sets the descriptor's auto-generated properties (name, output) if
* needed.
*/
- ret_code =
- cmd_create_session_from_descriptor(session_descriptor,
- &cmd_ctx->creds,
- home_dir_view.size ? home_dir_view.data : NULL);
+ ret_code = cmd_create_session_from_descriptor(session_descriptor,
+ &cmd_ctx->creds,
+ home_dir_view.size ? home_dir_view.data :
+ nullptr);
if (ret_code != LTTNG_OK) {
goto error;
}
ret_code = LTTNG_OK;
*return_descriptor = session_descriptor;
- session_descriptor = NULL;
+ session_descriptor = nullptr;
error:
lttng_dynamic_buffer_reset(&payload);
lttng_session_descriptor_destroy(session_descriptor);
(cmd_destroy_session_reply_context *) _reply_context;
struct lttng_dynamic_buffer payload;
struct lttcomm_session_destroy_command_header cmd_header;
- struct lttng_trace_archive_location *location = NULL;
+ struct lttng_trace_archive_location *location = nullptr;
struct lttcomm_lttng_msg llm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_DESTROY_SESSION,
.ret_code = reply_context->destruction_status,
*
* 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;
- struct cmd_destroy_session_reply_context *reply_context = NULL;
+ struct cmd_destroy_session_reply_context *reply_context = nullptr;
if (sock_fd) {
reply_context = zmalloc<cmd_destroy_session_reply_context>();
}
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;
}
* occurred during the session's lifetime.
*/
ret = cmd_rotate_session(
- session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ session, nullptr, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret != LTTNG_OK) {
ERR("Failed to perform an implicit rotation as part of the destruction of session \"%s\": %s",
session->name,
* place.
*/
ret = cmd_rotate_session(
- session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
+ session, nullptr, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
/*
* Rotation operations may not be supported by the kernel
* tracer. Hence, do not consider this implicit rotation as
struct consumer_data *cdata)
{
int ret, sock;
- struct consumer_socket *socket = NULL;
+ struct consumer_socket *socket = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(cdata);
cdata->cmd_sock = sock;
socket = consumer_allocate_socket(&cdata->cmd_sock);
- if (socket == NULL) {
+ if (socket == nullptr) {
ret = close(sock);
if (ret < 0) {
PERROR("close register consumer");
}
socket->lock = zmalloc<pthread_mutex_t>();
- if (socket->lock == NULL) {
+ if (socket->lock == nullptr) {
PERROR("zmalloc pthread mutex");
ret = LTTNG_ERR_FATAL;
goto error;
}
- pthread_mutex_init(socket->lock, NULL);
+ 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;
struct agent *agt;
struct lttng_ht_iter iter;
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
DBG3("Listing domains found kernel domain");
nb_dom++;
}
- if (session->ust_session != NULL) {
+ if (session->ust_session != nullptr) {
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) {
}
*domains = calloc<lttng_domain>(nb_dom);
- if (*domains == NULL) {
+ if (*domains == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
(*domains)[index].type = LTTNG_DOMAIN_KERNEL;
/* Kernel session buffer type is always GLOBAL */
index++;
}
- if (session->ust_session != NULL) {
+ if (session->ust_session != nullptr) {
(*domains)[index].type = LTTNG_DOMAIN_UST;
(*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;
{
/* Kernel channels */
struct ltt_kernel_channel *kchan;
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
cds_list_for_each_entry (
kchan, &session->kernel_session->channel_list.head, list) {
uint64_t discarded_events, lost_packets;
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 = NULL;
- 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:
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
ret_code = list_lttng_kernel_events(
channel_name, session->kernel_session, reply_payload, &nb_events);
}
break;
case LTTNG_DOMAIN_UST:
{
- if (session->ust_session != NULL) {
+ if (session->ust_session != nullptr) {
ret_code =
list_lttng_ust_global_events(channel_name,
&session->ust_session->domain_global,
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) {
break;
}
}
-
- rcu_read_unlock();
}
break;
default:
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;
int cmd_snapshot_del_output(struct ltt_session *session, const struct lttng_snapshot_output *output)
{
int ret;
- struct snapshot_output *sout = NULL;
+ struct snapshot_output *sout = nullptr;
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
ret = LTTNG_OK;
error:
- rcu_read_unlock();
return ret;
}
struct lttng_snapshot_output **outputs)
{
int ret, idx = 0;
- struct lttng_snapshot_output *list = NULL;
+ struct lttng_snapshot_output *list = nullptr;
struct lttng_ht_iter iter;
struct snapshot_output *output;
}
/* 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 = NULL;
+ list = nullptr;
ret = session->snapshot.nb_output;
error:
- rcu_read_unlock();
free(list);
end:
return ret;
(int) trigger_owner,
ret_code);
}
+
+ goto end_unlock_session_list;
}
break;
}
lttng_trigger_get(trigger);
*return_trigger = trigger;
/* Ownership of trigger was transferred to caller. */
- trigger = NULL;
+ trigger = nullptr;
}
end:
return ret_code;
const char *trigger_name;
uid_t trigger_owner;
enum lttng_trigger_status trigger_status;
- struct lttng_trigger *sessiond_trigger = NULL;
+ struct lttng_trigger *sessiond_trigger = nullptr;
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
{
int ret;
enum lttng_error_code ret_code;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
/* Get the set of triggers from the notification thread. */
ret_code = notification_thread_command_list_triggers(
}
*return_triggers = triggers;
- triggers = NULL;
+ triggers = nullptr;
ret_code = LTTNG_OK;
end:
lttng_triggers_destroy(triggers);
{
enum lttng_error_code ret_code;
const struct lttng_trigger *query_target_trigger;
- const struct lttng_action *query_target_action = NULL;
- struct lttng_trigger *matching_trigger = NULL;
+ const struct lttng_action *query_target_action = nullptr;
+ struct lttng_trigger *matching_trigger = nullptr;
const char *trigger_name;
uid_t trigger_owner;
enum lttng_trigger_status trigger_status;
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
switch (lttng_error_query_get_target_type(query)) {
case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
}
/* No longer needed. */
- query_target_trigger = NULL;
+ query_target_trigger = nullptr;
if (lttng_error_query_get_target_type(query) == LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION) {
/* Get the sessiond-side version of the target action. */
}
*_results = results;
- results = NULL;
+ results = nullptr;
ret_code = LTTNG_OK;
end:
lttng_trigger_put(matching_trigger);
* 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 : NULL,
- 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;
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
struct lttng_trace_chunk *snapshot_trace_chunk;
- struct consumer_output *original_ust_consumer_output = NULL;
- struct consumer_output *original_kernel_consumer_output = NULL;
- struct consumer_output *snapshot_ust_consumer_output = NULL;
- struct consumer_output *snapshot_kernel_consumer_output = NULL;
+ struct consumer_output *original_ust_consumer_output = nullptr;
+ struct consumer_output *original_kernel_consumer_output = nullptr;
+ struct consumer_output *snapshot_ust_consumer_output = nullptr;
+ struct consumer_output *snapshot_kernel_consumer_output = nullptr;
ret = snprintf(snapshot_chunk_name,
sizeof(snapshot_chunk_name),
goto error;
}
LTTNG_ASSERT(!session->current_trace_chunk);
- ret = session_set_trace_chunk(session, snapshot_trace_chunk, NULL);
+ ret = session_set_trace_chunk(session, snapshot_trace_chunk, nullptr);
lttng_trace_chunk_put(snapshot_trace_chunk);
- snapshot_trace_chunk = NULL;
+ snapshot_trace_chunk = nullptr;
if (ret) {
ERR("Failed to set temporary trace chunk to record a snapshot of session \"%s\"",
session->name);
}
error_close_trace_chunk:
- if (session_set_trace_chunk(session, NULL, &snapshot_trace_chunk)) {
+ if (session_set_trace_chunk(session, nullptr, &snapshot_trace_chunk)) {
ERR("Failed to release the current trace chunk of session \"%s\"", session->name);
ret_code = LTTNG_ERR_UNK;
}
if (session_close_trace_chunk(session,
snapshot_trace_chunk,
LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION,
- NULL)) {
+ nullptr)) {
/*
* Don't goto end; make sure the chunk is closed for the session
* to allow future snapshots.
}
lttng_trace_chunk_put(snapshot_trace_chunk);
- snapshot_trace_chunk = NULL;
+ snapshot_trace_chunk = nullptr;
error:
if (original_ust_consumer_output) {
session->ust_session->consumer = original_ust_consumer_output;
int ret;
unsigned int snapshot_success = 0;
char datetime[16];
- struct snapshot_output *tmp_output = NULL;
+ struct snapshot_output *tmp_output = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(output);
output->data_url,
session->consumer,
tmp_output,
- NULL);
+ nullptr);
if (ret < 0) {
if (ret == -ENOMEM) {
cmd_ret = LTTNG_ERR_NOMEM;
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;
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) {
if (tmp_output) {
snapshot_output_destroy(tmp_output);
}
+
return cmd_ret;
}
int ret;
uint64_t ongoing_rotation_chunk_id;
enum lttng_error_code cmd_ret = LTTNG_OK;
- struct lttng_trace_chunk *chunk_being_archived = NULL;
- struct lttng_trace_chunk *new_trace_chunk = NULL;
+ struct lttng_trace_chunk *chunk_being_archived = nullptr;
+ struct lttng_trace_chunk *new_trace_chunk = nullptr;
enum lttng_trace_chunk_status chunk_status;
bool failed_to_rotate = false;
enum lttng_error_code rotation_fail_code = LTTNG_OK;
}
if (session->active) {
- new_trace_chunk = session_create_new_trace_chunk(session, NULL, NULL, NULL);
+ new_trace_chunk =
+ session_create_new_trace_chunk(session, nullptr, nullptr, nullptr);
if (!new_trace_chunk) {
cmd_ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
session->chunk_being_archived = chunk_being_archived;
- chunk_being_archived = NULL;
+ chunk_being_archived = nullptr;
if (!quiet_rotation) {
ret = notification_thread_command_session_rotation_ongoing(
the_notification_thread_handle, session->id, ongoing_rotation_chunk_id);
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;
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;
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;
}
* Returns a pointer to a handler to run on completion of a command.
* Returns NULL if no handler has to be run for the last command executed.
*/
-const struct cmd_completion_handler *cmd_pop_completion_handler(void)
+const struct cmd_completion_handler *cmd_pop_completion_handler()
{
struct cmd_completion_handler *handler = current_completion_handler;
- current_completion_handler = NULL;
+ current_completion_handler = nullptr;
return handler;
}
/*
* Init command subsystem.
*/
-void cmd_init(void)
+void cmd_init()
{
/*
* Set network sequence index to 1 for streams to match a relayd