#include <common/common.hpp>
#include <common/compat/string.hpp>
#include <common/defaults.hpp>
+#include <common/urcu.hpp>
#include <inttypes.h>
#include <stdio.h>
struct lttcomm_consumer_msg lkm;
struct consumer_output *consumer;
enum lttng_error_code status;
- struct ltt_session *session = nullptr;
struct lttng_channel_extended *channel_attr_extended;
bool is_local_trace;
size_t consumer_path_offset = 0;
+ const lttng::urcu::read_lock_guard read_lock;
/* Safety net */
LTTNG_ASSERT(channel);
}
health_code_update();
- rcu_read_lock();
- session = session_find_by_id(ksession->id);
- LTTNG_ASSERT(session);
- ASSERT_LOCKED(session->lock);
- ASSERT_SESSION_LIST_LOCKED();
-
- status = notification_thread_command_add_channel(the_notification_thread_handle,
- session->id,
- channel->channel->name,
- channel->key,
- LTTNG_DOMAIN_KERNEL,
- channel->channel->attr.subbuf_size *
- channel->channel->attr.num_subbuf);
- rcu_read_unlock();
+
+ try {
+ const auto session = ltt_session::find_session(ksession->id);
+
+ ASSERT_SESSION_LIST_LOCKED();
+
+ status = notification_thread_command_add_channel(
+ the_notification_thread_handle,
+ session->id,
+ channel->channel->name,
+ channel->key,
+ LTTNG_DOMAIN_KERNEL,
+ channel->channel->attr.subbuf_size * channel->channel->attr.num_subbuf);
+ } catch (const lttng::sessiond::exceptions::session_not_found_error& ex) {
+ ERR_FMT("Fatal error during the creation of a kernel channel: {}, location='{}'",
+ ex.what(),
+ ex.source_location);
+ abort();
+ }
+
if (status != LTTNG_OK) {
ret = -1;
goto error;
channel->published_to_notification_thread = true;
error:
- if (session) {
- session_put(session);
- }
free(pathname);
return ret;
}
struct lttcomm_consumer_msg lkm;
struct consumer_output *consumer;
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
/* Safety net */
LTTNG_ASSERT(ksession);
health_code_update();
error:
- rcu_read_unlock();
return ret;
}
LTTNG_ASSERT(ksession->consumer);
LTTNG_ASSERT(sock);
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
/* Bail out if consumer is disabled */
if (!ksession->consumer->enabled) {
}
error:
- rcu_read_unlock();
return ret;
}