X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.cpp;h=8addb5edacabb5bd9ed2397ab81f276cf5b078fb;hb=63c3462c3dbd028a08f7a9b504c45e178371248d;hp=1cfb08f917e4ce304fdaeef705d50ee95b73b7ce;hpb=65cd3c0cfa205aa6f67ff974f561882d5eafdd89;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 1cfb08f91..8addb5eda 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -3461,11 +3461,7 @@ static int create_channel_per_uid(struct ust_app *app, /* 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) { @@ -3563,11 +3559,7 @@ static int create_channel_per_pid(struct ust_app *app, } 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) { @@ -6434,32 +6426,49 @@ static int handle_app_register_channel_notification(int sock, * that all apps provide the same typing for the context fields as a * sanity check. */ - lst::type::cuptr context_fields = lttng::make_unique(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( + 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: @@ -6556,12 +6565,16 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, const char *na 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( model_emf_uri.get()) : - nonstd::nullopt, + nonstd::nullopt, ua_sess->buffer_type, *app, event_id); ret_code = 0; } catch (const std::exception& ex) {