lttng::urcu::read_lock_guard read_lock;
- ltt_session::ref session;
try {
- session = ltt_session::find_session(ua_chan->session->tracing_id);
+ const auto session = ltt_session::find_session(ua_chan->session->tracing_id);
+
+ if (!session->ust_session) {
+ /*
+ * Not finding the session is not an error because there are
+ * multiple ways the channels can be torn down.
+ *
+ * 1) The session daemon can initiate the destruction of the
+ * ust app session after receiving a destroy command or
+ * during its shutdown/teardown.
+ * 2) The application, since we are in per-pid tracing, is
+ * unregistering and tearing down its ust app session.
+ *
+ * Both paths are protected by the session list lock which
+ * ensures that the accounting of lost packets and discarded
+ * events is done exactly once. The session is then unpublished
+ * from the session list, resulting in this condition.
+ */
+ return;
+ }
+
+ if (ua_chan->attr.overwrite) {
+ consumer_get_lost_packets(ua_chan->session->tracing_id,
+ ua_chan->key,
+ session->ust_session->consumer,
+ &lost);
+ } else {
+ consumer_get_discarded_events(ua_chan->session->tracing_id,
+ ua_chan->key,
+ session->ust_session->consumer,
+ &discarded);
+ }
+ uchan = trace_ust_find_channel_by_name(session->ust_session->domain_global.channels,
+ ua_chan->name);
+ if (!uchan) {
+ ERR("Missing UST channel to store discarded counters");
+ return;
+ }
} catch (const lttng::sessiond::exceptions::session_not_found_error& ex) {
DBG_FMT("Failed to save per-pid lost/discarded counters: {}, location='{}'",
ex.what(),
ex.source_location);
- }
-
- if (!session || !session->ust_session) {
- /*
- * Not finding the session is not an error because there are
- * multiple ways the channels can be torn down.
- *
- * 1) The session daemon can initiate the destruction of the
- * ust app session after receiving a destroy command or
- * during its shutdown/teardown.
- * 2) The application, since we are in per-pid tracing, is
- * unregistering and tearing down its ust app session.
- *
- * Both paths are protected by the session list lock which
- * ensures that the accounting of lost packets and discarded
- * events is done exactly once. The session is then unpublished
- * from the session list, resulting in this condition.
- */
- return;
- }
-
- if (ua_chan->attr.overwrite) {
- consumer_get_lost_packets(ua_chan->session->tracing_id,
- ua_chan->key,
- session->ust_session->consumer,
- &lost);
- } else {
- consumer_get_discarded_events(ua_chan->session->tracing_id,
- ua_chan->key,
- session->ust_session->consumer,
- &discarded);
- }
- uchan = trace_ust_find_channel_by_name(session->ust_session->domain_global.channels,
- ua_chan->name);
- if (!uchan) {
- ERR("Missing UST channel to store discarded counters");
return;
}
int ret;
struct buffer_reg_uid *reg_uid;
struct buffer_reg_channel *buf_reg_chan;
- ltt_session::ref session;
enum lttng_error_code notification_ret;
LTTNG_ASSERT(app);
DBG("UST app creating channel %s with per UID buffers", ua_chan->name);
+ /* Guaranteed to exist; will not throw. */
+ const auto session = ltt_session::find_session(ua_sess->tracing_id);
+ ASSERT_SESSION_LIST_LOCKED();
+
reg_uid = buffer_reg_uid_find(usess->id, app->abi.bits_per_long, app->uid);
/*
* The session creation handles the creation of this global registry
goto error;
}
- /* Guaranteed to exist; will not throw. */
- session = ltt_session::find_session(ua_sess->tracing_id);
- ASSERT_LOCKED(session->_lock);
- ASSERT_SESSION_LIST_LOCKED();
-
/*
* Create the buffers on the consumer side. This call populates the
* ust app channel object with all streams and data object.
int ret;
lsu::registry_session *registry;
enum lttng_error_code cmd_ret;
- ltt_session::ref session;
uint64_t chan_reg_key;
LTTNG_ASSERT(app);
/* The UST app session lock is held, registry shall not be null. */
LTTNG_ASSERT(registry);
+ /* Guaranteed to exist; will not throw. */
+ const auto session = ltt_session::find_session(ua_sess->tracing_id);
+ ASSERT_LOCKED(session->_lock);
+ ASSERT_SESSION_LIST_LOCKED();
+
/* Create and add a new channel registry to session. */
try {
registry->add_channel(ua_chan->key);
goto error;
}
- /* Guaranteed to exist; will not throw. */
- session = ltt_session::find_session(ua_sess->tracing_id);
- ASSERT_LOCKED(session->_lock);
- ASSERT_SESSION_LIST_LOCKED();
-
/* Create and get channel on the consumer side. */
ret = do_consumer_create_channel(usess, ua_sess, ua_chan, app->abi.bits_per_long, registry);
if (ret < 0) {
int ret = 0;
struct ust_app_channel *metadata;
struct consumer_socket *socket;
- ltt_session::ref session;
LTTNG_ASSERT(ua_sess);
LTTNG_ASSERT(app);
/* The UST app session is held registry shall not be null. */
LTTNG_ASSERT(locked_registry);
+ /* Guaranteed to exist; will not throw. */
+ const auto session = ltt_session::find_session(ua_sess->tracing_id);
+ ASSERT_LOCKED(session->_lock);
+ ASSERT_SESSION_LIST_LOCKED();
+
/* Metadata already exists for this registry or it was closed previously */
if (locked_registry->_metadata_key || locked_registry->_metadata_closed) {
ret = 0;
*/
locked_registry->_metadata_key = metadata->key;
- /* Guaranteed to exist; will not throw. */
- session = ltt_session::find_session(ua_sess->tracing_id);
- ASSERT_LOCKED(session->_lock);
- ASSERT_SESSION_LIST_LOCKED();
-
/*
* Ask the metadata channel creation to the consumer. The metadata object
* will be created by the consumer and kept their. However, the stream is
*
* Return LTTNG_OK on success or else an LTTng error code.
*/
-enum lttng_error_code ust_app_rotate_session(struct ltt_session *session)
+enum lttng_error_code ust_app_rotate_session(const ltt_session::locked_ref& session)
{
int ret;
enum lttng_error_code cmd_ret = LTTNG_OK;
*
* Return LTTNG_OK on success or else an LTTng error code.
*/
-enum lttng_error_code ust_app_clear_session(struct ltt_session *session)
+enum lttng_error_code ust_app_clear_session(const ltt_session::locked_ref& session)
{
int ret;
enum lttng_error_code cmd_ret = LTTNG_OK;
* daemon as the same "offset" in a metadata stream will no longer point
* to the same content.
*/
-enum lttng_error_code ust_app_open_packets(struct ltt_session *session)
+enum lttng_error_code ust_app_open_packets(const ltt_session::locked_ref& session)
{
enum lttng_error_code ret = LTTNG_OK;
struct lttng_ht_iter iter;