{
int ret;
struct ust_app_notify_sock_obj *obj =
- caa_container_of(head, struct ust_app_notify_sock_obj, head);
+ lttng::utils::container_of(head, &ust_app_notify_sock_obj::head);
/* Must have a valid fd here. */
LTTNG_ASSERT(obj->fd >= 0);
static
void free_ust_app_event_notifier_rule_rcu(struct rcu_head *head)
{
- struct ust_app_event_notifier_rule *obj = caa_container_of(
- head, struct ust_app_event_notifier_rule, rcu_head);
+ struct ust_app_event_notifier_rule *obj = lttng::utils::container_of(
+ head, &ust_app_event_notifier_rule::rcu_head);
free(obj);
}
void delete_ust_app_channel_rcu(struct rcu_head *head)
{
struct ust_app_channel *ua_chan =
- caa_container_of(head, struct ust_app_channel, rcu_head);
+ lttng::utils::container_of(head, &ust_app_channel::rcu_head);
lttng_ht_destroy(ua_chan->ctx);
lttng_ht_destroy(ua_chan->events);
void delete_ust_app_session_rcu(struct rcu_head *head)
{
struct ust_app_session *ua_sess =
- caa_container_of(head, struct ust_app_session, rcu_head);
+ lttng::utils::container_of(head, &ust_app_session::rcu_head);
lttng_ht_destroy(ua_sess->channels);
free(ua_sess);
void delete_ust_app_rcu(struct rcu_head *head)
{
struct lttng_ht_node_ulong *node =
- caa_container_of(head, struct lttng_ht_node_ulong, head);
+ lttng::utils::container_of(head, <tng_ht_node_ulong::head);
struct ust_app *app =
- caa_container_of(node, struct ust_app, pid_n);
+ lttng::utils::container_of(node, &ust_app::pid_n);
DBG3("Call RCU deleting app PID %d", app->pid);
delete_ust_app(app);
goto error;
}
- return caa_container_of(node, struct ust_app, sock_n);
+ return lttng::utils::container_of(node, &ust_app::sock_n);
error:
return NULL;
goto error;
}
- return caa_container_of(node, struct ust_app, notify_sock_n);
+ return lttng::utils::container_of(node, &ust_app::notify_sock_n);
error:
return NULL;
goto end;
}
- event = caa_container_of(node, struct ust_app_event, node);
+ event = lttng::utils::container_of(node, &ust_app_event::node);
end:
return event;
goto end;
}
- event_notifier_rule = caa_container_of(
- node, struct ust_app_event_notifier_rule, node);
+ event_notifier_rule = lttng::utils::container_of(
+ node, &ust_app_event_notifier_rule::node);
end:
return event_notifier_rule;
}
goto error;
}
- return caa_container_of(node, struct ust_app_session, node);
+ return lttng::utils::container_of(node, &ust_app_session::node);
error:
return NULL;
goto end;
}
- app_ctx = caa_container_of(node, struct ust_app_ctx, node);
+ app_ctx = lttng::utils::container_of(node, &ust_app_ctx::node);
end:
return app_ctx;
goto error;
}
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
ret = enable_ust_channel(app, ua_sess, ua_chan);
if (ret < 0) {
/* Notify the notification subsystem of the channel's creation. */
notification_ret = notification_thread_command_add_channel(
- the_notification_thread_handle, session->name,
- lttng_credentials_get_uid(
- &ua_sess->effective_credentials),
- lttng_credentials_get_gid(
- &ua_sess->effective_credentials),
+ the_notification_thread_handle, session->id,
ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST,
ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
if (notification_ret != LTTNG_OK) {
}
cmd_ret = notification_thread_command_add_channel(
- the_notification_thread_handle, session->name,
- lttng_credentials_get_uid(
- &ua_sess->effective_credentials),
- lttng_credentials_get_gid(
- &ua_sess->effective_credentials),
+ the_notification_thread_handle, session->id,
ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST,
ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
if (cmd_ret != LTTNG_OK) {
lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
if (ua_chan_node != NULL) {
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
goto end;
}
DBG2("Found UST app by pid %d", pid);
- app = caa_container_of(node, struct ust_app, pid_n);
+ app = lttng::utils::container_of(node, &ust_app::pid_n);
error:
return app;
node = lttng_ht_iter_get_node_ulong(&ust_app_sock_iter);
LTTNG_ASSERT(node);
- lta = caa_container_of(node, struct ust_app, sock_n);
+ lta = lttng::utils::container_of(node, &ust_app::sock_n);
DBG("PID %d unregistering with sock %d", lta->pid, sock);
/*
/* If the session if found for the app, the channel must be there */
LTTNG_ASSERT(ua_chan_node);
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
/* The channel must not be already disabled */
LTTNG_ASSERT(ua_chan->enabled == 1);
"Skipping", uchan->name, usess->id, app->pid);
continue;
}
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
uevent->filter, uevent->attr.loglevel,
continue;
}
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
/* Get event node */
ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
/* If the channel is not found, there is a code flow error */
LTTNG_ASSERT(ua_chan_node);
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
ret = create_ust_app_event(ua_chan, uevent, app);
pthread_mutex_unlock(&ua_sess->lock);
/* Session is being or is deleted. */
goto end;
}
- ua_sess = caa_container_of(node, struct ust_app_session, node);
+ ua_sess = lttng::utils::container_of(node, &ust_app_session::node);
health_code_update();
destroy_app_session(app, ua_sess);
goto error;
}
- ua_sess = caa_container_of(node, struct ust_app_session, ust_objd_node);
+ ua_sess = lttng::utils::container_of(node, &ust_app_session::ust_objd_node);
error:
return ua_sess;
goto error;
}
- ua_chan = caa_container_of(node, struct ust_app_channel, ust_objd_node);
+ ua_chan = lttng::utils::container_of(node, &ust_app_channel::ust_objd_node);
error:
return ua_chan;
* that all apps provide the same typing for the context fields as a
* sanity check.
*/
- lst::type::cuptr context_fields = lttng::make_unique<lst::structure_type>(0,
- lsu::create_trace_fields_from_ust_ctl_fields(*locked_registry_session,
- ust_ctl_context_fields.get(), context_field_count));
+ try {
+ auto app_context_fields = lsu::create_trace_fields_from_ust_ctl_fields(
+ *locked_registry_session, ust_ctl_context_fields.get(),
+ context_field_count,
+ lst::field_location::root::EVENT_RECORD_COMMON_CONTEXT,
+ lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS);
+
+ if (!ust_reg_chan.is_registered()) {
+ lst::type::cuptr event_context = app_context_fields.size() ?
+ lttng::make_unique<lst::structure_type>(
+ 0, std::move(app_context_fields)) :
+ nullptr;
+
+ ust_reg_chan.set_event_context(std::move(event_context));
+ } else {
+ /*
+ * Validate that the context fields match between
+ * registry and newcoming application.
+ */
+ bool context_fields_match;
+ const auto *previous_event_context = ust_reg_chan.get_event_context();
- if (!ust_reg_chan.is_registered()) {
- ust_reg_chan.set_context(std::move(context_fields));
- } else {
- /*
- * Validate that the context fields match between
- * registry and newcoming application.
- */
- if (ust_reg_chan.get_context() != *context_fields) {
- ERR("Registering application channel due to context field mismatch: pid = %d, sock = %d",
- app->pid, app->sock);
- ret_code = -EINVAL;
- goto reply;
- }
- }
+ if (!previous_event_context) {
+ context_fields_match = app_context_fields.size() == 0;
+ } else {
+ const lst::structure_type app_event_context_struct(
+ 0, std::move(app_context_fields));
+
+ context_fields_match = *previous_event_context ==
+ app_event_context_struct;
+ }
- /* Append to metadata */
- if (!ust_reg_chan._metadata_dumped) {
- /*ret_code = ust_metadata_channel_statedump(registry, ust_reg_chan);*/
- if (ret_code) {
- ERR("Error appending channel metadata (errno = %d)", ret_code);
- goto reply;
+ if (!context_fields_match) {
+ ERR("Registering application channel due to context field mismatch: pid = %d, sock = %d",
+ app->pid, app->sock);
+ ret_code = -EINVAL;
+ goto reply;
+ }
}
+ } catch (std::exception& ex) {
+ ERR("Failed to handle application context: %s", ex.what());
+ ret_code = -EINVAL;
+ goto reply;
}
reply:
ret_code);
ret = lttng_ust_ctl_reply_register_channel(sock, chan_id,
- ust_reg_chan.header_type == lst::stream_class::header_type::COMPACT ?
+ ust_reg_chan.header_type_ == lst::stream_class::header_type::COMPACT ?
LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT :
LTTNG_UST_CTL_CHANNEL_HEADER_LARGE,
ret_code);
channel.add_event(sobjd, cobjd, name, signature.get(),
lsu::create_trace_fields_from_ust_ctl_fields(
*locked_registry, fields.get(),
- nr_fields),
+ nr_fields,
+ lst::field_location::root::
+ EVENT_RECORD_PAYLOAD,
+ lsu::ctl_field_quirks::
+ UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS),
loglevel_value,
model_emf_uri.get() ?
nonstd::optional<std::string>(
model_emf_uri.get()) :
- nonstd::nullopt,
+ nonstd::nullopt,
ua_sess->buffer_type, *app, event_id);
ret_code = 0;
} catch (const std::exception& ex) {
/* If the session is found for the app, the channel must be there */
LTTNG_ASSERT(ua_chan_node);
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+ ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
if (overwrite) {
uint64_t _lost;