X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=f222ebdb6215cd14c7d05cf983e214a2cce63664;hb=695f70446965aeac8b1118bb08d572630c96114d;hp=3efda83c194149bedcf68a083db077897297e4dd;hpb=412d7227e69ec845e44c49082a417f9454d9b55d;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 3efda83c1..f222ebdb6 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -27,10 +27,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -93,7 +93,7 @@ static uint64_t get_next_session_id(void) } static void copy_channel_attr_to_ustctl( - struct ustctl_consumer_channel_attr *attr, + struct lttng_ust_ctl_consumer_channel_attr *attr, struct lttng_ust_abi_channel_attr *uattr) { /* Copy event attributes since the layout is different. */ @@ -290,7 +290,7 @@ void delete_ust_app_ctx(int sock, struct ust_app_ctx *ua_ctx, if (ua_ctx->obj) { pthread_mutex_lock(&app->sock_lock); - ret = ustctl_release_object(sock, ua_ctx->obj); + ret = lttng_ust_ctl_release_object(sock, ua_ctx->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app sock %d release ctx obj handle %d failed with ret %d", @@ -318,7 +318,7 @@ void delete_ust_app_event(int sock, struct ust_app_event *ua_event, free(ua_event->exclusion); if (ua_event->obj != NULL) { pthread_mutex_lock(&app->sock_lock); - ret = ustctl_release_object(sock, ua_event->obj); + ret = lttng_ust_ctl_release_object(sock, ua_event->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app sock %d release event obj failed with ret %d", @@ -359,7 +359,7 @@ static void delete_ust_app_event_notifier_rule(int sock, if (ua_event_notifier_rule->obj != NULL) { pthread_mutex_lock(&app->sock_lock); - ret = ustctl_release_object(sock, ua_event_notifier_rule->obj); + ret = lttng_ust_ctl_release_object(sock, ua_event_notifier_rule->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("Failed to release event notifier object: app = '%s' (ppid %d), ret = %d", @@ -388,7 +388,7 @@ static int release_ust_app_stream(int sock, struct ust_app_stream *stream, if (stream->obj) { pthread_mutex_lock(&app->sock_lock); - ret = ustctl_release_object(sock, stream->obj); + ret = lttng_ust_ctl_release_object(sock, stream->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app sock %d release stream obj failed with ret %d", @@ -564,7 +564,7 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan, ret = lttng_ht_del(app->ust_objd, &iter); assert(!ret); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_release_object(sock, ua_chan->obj); + ret = lttng_ust_ctl_release_object(sock, ua_chan->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app sock %d release channel obj failed with ret %d", @@ -581,7 +581,7 @@ int ust_app_register_done(struct ust_app *app) int ret; pthread_mutex_lock(&app->sock_lock); - ret = ustctl_register_done(app->sock); + ret = lttng_ust_ctl_register_done(app->sock); pthread_mutex_unlock(&app->sock_lock); return ret; } @@ -596,7 +596,7 @@ int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data } else { sock = -1; } - ret = ustctl_release_object(sock, data); + ret = lttng_ust_ctl_release_object(sock, data); if (app) { pthread_mutex_unlock(&app->sock_lock); } @@ -929,7 +929,7 @@ void delete_ust_app_session(int sock, struct ust_app_session *ua_sess, if (ua_sess->handle != -1) { pthread_mutex_lock(&app->sock_lock); - ret = ustctl_release_handle(sock, ua_sess->handle); + ret = lttng_ust_ctl_release_handle(sock, ua_sess->handle); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app sock %d release session handle failed with ret %d", @@ -1022,7 +1022,7 @@ void delete_ust_app(struct ust_app *app) ERR("Error unregistering app from event notifier error accounting"); } - ustctl_release_object(sock, app->event_notifier_group.object); + lttng_ust_ctl_release_object(sock, app->event_notifier_group.object); free(app->event_notifier_group.object); } @@ -1165,7 +1165,7 @@ struct ust_app_channel *alloc_ust_app_channel(const char *name, /* Copy attributes */ if (attr) { - /* Translate from lttng_ust_channel to ustctl_consumer_channel_attr. */ + /* Translate from lttng_ust_channel to lttng_ust_ctl_consumer_channel_attr. */ ua_chan->attr.subbuf_size = attr->subbuf_size; ua_chan->attr.num_subbuf = attr->num_subbuf; ua_chan->attr.overwrite = attr->overwrite; @@ -1266,11 +1266,16 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule( condition = lttng_trigger_get_condition(trigger); assert(condition); - assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(lttng_condition_get_type(condition) == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - assert(LTTNG_CONDITION_STATUS_OK == lttng_condition_on_event_get_rule(condition, &event_rule)); + assert(LTTNG_CONDITION_STATUS_OK == + lttng_condition_event_rule_matches_get_rule( + condition, &event_rule)); assert(event_rule); + ua_event_notifier_rule->error_counter_index = + lttng_condition_event_rule_matches_get_error_counter_index(condition); /* Acquire the event notifier's reference to the trigger. */ lttng_trigger_get(trigger); @@ -1516,7 +1521,7 @@ int create_ust_channel_context(struct ust_app_channel *ua_chan, health_code_update(); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_add_context(app->sock, &ua_ctx->ctx, + ret = lttng_ust_ctl_add_context(app->sock, &ua_ctx->ctx, ua_chan->obj, &ua_ctx->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { @@ -1563,7 +1568,7 @@ static int set_ust_object_filter(struct ust_app *app, goto error; } pthread_mutex_lock(&app->sock_lock); - ret = ustctl_set_filter(app->sock, ust_bytecode, + ret = lttng_ust_ctl_set_filter(app->sock, ust_bytecode, ust_object); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { @@ -1617,7 +1622,7 @@ static int set_ust_capture(struct ust_app *app, ust_bytecode->seqnum = capture_seqnum; pthread_mutex_lock(&app->sock_lock); - ret = ustctl_set_capture(app->sock, ust_bytecode, + ret = lttng_ust_ctl_set_capture(app->sock, ust_bytecode, ust_object); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { @@ -1687,7 +1692,7 @@ static int set_ust_object_exclusions(struct ust_app *app, goto error; } pthread_mutex_lock(&app->sock_lock); - ret = ustctl_set_exclusion(app->sock, ust_exclusions, ust_object); + ret = lttng_ust_ctl_set_exclusion(app->sock, ust_exclusions, ust_object); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -1724,7 +1729,7 @@ static int disable_ust_object(struct ust_app *app, health_code_update(); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_disable(app->sock, object); + ret = lttng_ust_ctl_disable(app->sock, object); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -1761,7 +1766,7 @@ static int disable_ust_channel(struct ust_app *app, health_code_update(); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_disable(app->sock, ua_chan->obj); + ret = lttng_ust_ctl_disable(app->sock, ua_chan->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -1799,7 +1804,7 @@ static int enable_ust_channel(struct ust_app *app, health_code_update(); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_enable(app->sock, ua_chan->obj); + ret = lttng_ust_ctl_enable(app->sock, ua_chan->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -1839,7 +1844,7 @@ static int enable_ust_object( health_code_update(); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_enable(app->sock, ust_object); + ret = lttng_ust_ctl_enable(app->sock, ust_object); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -1932,7 +1937,7 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess, /* Create UST event on tracer */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj, + ret = lttng_ust_ctl_create_event(app->sock, &ua_event->attr, ua_chan->obj, &ua_event->obj); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { @@ -2017,9 +2022,6 @@ static int init_ust_event_notifier_from_event_rule( int loglevel = -1, ret = 0; const char *pattern; - /* For now only LTTNG_EVENT_RULE_TYPE_TRACEPOINT are supported. */ - assert(lttng_event_rule_get_type(rule) == - LTTNG_EVENT_RULE_TYPE_TRACEPOINT); memset(event_notifier, 0, sizeof(*event_notifier)); @@ -2037,13 +2039,16 @@ static int init_ust_event_notifier_from_event_rule( } else { const struct lttng_log_level_rule *log_level_rule; - status = lttng_event_rule_tracepoint_get_pattern(rule, &pattern); + assert(lttng_event_rule_get_type(rule) == + LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT); + + status = lttng_event_rule_user_tracepoint_get_name_pattern(rule, &pattern); if (status != LTTNG_EVENT_RULE_STATUS_OK) { /* At this point, this is a fatal error. */ abort(); } - status = lttng_event_rule_tracepoint_get_log_level_rule( + status = lttng_event_rule_user_tracepoint_get_log_level_rule( rule, &log_level_rule); if (status == LTTNG_EVENT_RULE_STATUS_UNSET) { ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL; @@ -2101,6 +2106,7 @@ static int create_ust_event_notifier(struct ust_app *app, const struct lttng_event_rule *event_rule = NULL; unsigned int capture_bytecode_count = 0, i; enum lttng_condition_status cond_status; + enum lttng_event_rule_type event_rule_type; health_code_update(); assert(app->event_notifier_group.object); @@ -2108,14 +2114,22 @@ static int create_ust_event_notifier(struct ust_app *app, condition = lttng_trigger_get_const_condition( ua_event_notifier_rule->trigger); assert(condition); - assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(lttng_condition_get_type(condition) == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - condition_status = lttng_condition_on_event_get_rule( + condition_status = lttng_condition_event_rule_matches_get_rule( condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); assert(event_rule); - assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_TRACEPOINT); + + event_rule_type = lttng_event_rule_get_type(event_rule); + assert(event_rule_type == LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT || + event_rule_type == LTTNG_EVENT_RULE_TYPE_JUL_LOGGING || + event_rule_type == + LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING || + event_rule_type == + LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING); init_ust_event_notifier_from_event_rule(event_rule, &event_notifier); event_notifier.event.token = ua_event_notifier_rule->token; @@ -2123,7 +2137,7 @@ static int create_ust_event_notifier(struct ust_app *app, /* Create UST event notifier against the tracer. */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_create_event_notifier(app->sock, &event_notifier, + ret = lttng_ust_ctl_create_event_notifier(app->sock, &event_notifier, app->event_notifier_group.object, &ua_event_notifier_rule->obj); pthread_mutex_unlock(&app->sock_lock); @@ -2174,13 +2188,13 @@ static int create_ust_event_notifier(struct ust_app *app, } /* Set the capture bytecodes. */ - cond_status = lttng_condition_on_event_get_capture_descriptor_count( + cond_status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &capture_bytecode_count); assert(cond_status == LTTNG_CONDITION_STATUS_OK); for (i = 0; i < capture_bytecode_count; i++) { const struct lttng_bytecode *capture_bytecode = - lttng_condition_on_event_get_capture_bytecode_at_index( + lttng_condition_event_rule_matches_get_capture_bytecode_at_index( condition, i); ret = set_ust_capture(app, capture_bytecode, i, @@ -2566,7 +2580,7 @@ error: * be NULL. * * Returns 0 on success or else a negative code which is either -ENOMEM or - * -ENOTCONN which is the default code if the ustctl_create_session fails. + * -ENOTCONN which is the default code if the lttng_ust_ctl_create_session fails. */ static int find_or_create_ust_app_session(struct ltt_ust_session *usess, struct ust_app *app, struct ust_app_session **ua_sess_ptr, @@ -2622,7 +2636,7 @@ static int find_or_create_ust_app_session(struct ltt_ust_session *usess, if (ua_sess->handle == -1) { pthread_mutex_lock(&app->sock_lock); - ret = ustctl_create_session(app->sock); + ret = lttng_ust_ctl_create_session(app->sock); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -2954,7 +2968,7 @@ static int do_consumer_create_channel(struct ltt_ust_session *usess, health_code_update(); /* - * Now get the channel from the consumer. This call wil populate the stream + * Now get the channel from the consumer. This call will populate the stream * list of that channel and set the ust objects. */ if (usess->consumer->enabled) { @@ -3007,7 +3021,7 @@ static int duplicate_stream_object(struct buffer_reg_stream *reg_stream, } /* Duplicate object for stream once the original is in the registry. */ - ret = ustctl_duplicate_ust_object_data(&stream->obj, + ret = lttng_ust_ctl_duplicate_ust_object_data(&stream->obj, reg_stream->obj.ust); if (ret < 0) { ERR("Duplicate stream obj from %p to %p failed with ret %d", @@ -3043,7 +3057,7 @@ static int duplicate_channel_object(struct buffer_reg_channel *buf_reg_chan, } /* Duplicate object for stream once the original is in the registry. */ - ret = ustctl_duplicate_ust_object_data(&ua_chan->obj, buf_reg_chan->obj.ust); + ret = lttng_ust_ctl_duplicate_ust_object_data(&ua_chan->obj, buf_reg_chan->obj.ust); if (ret < 0) { ERR("Duplicate channel obj from %p to %p failed with ret: %d", buf_reg_chan->obj.ust, ua_chan->obj, ret); @@ -3987,7 +4001,7 @@ int ust_app_version(struct ust_app *app) assert(app); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_tracer_version(app->sock, &app->version); + ret = lttng_ust_ctl_tracer_version(app->sock, &app->version); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) { @@ -4000,6 +4014,16 @@ int ust_app_version(struct ust_app *app) return ret; } +bool ust_app_supports_notifiers(const struct ust_app *app) +{ + return app->v_major >= 9; +} + +bool ust_app_supports_counters(const struct ust_app *app) +{ + return app->v_major >= 9; +} + /* * Setup the base event notifier group. * @@ -4016,12 +4040,17 @@ int ust_app_setup_event_notifier_group(struct ust_app *app) assert(app); + if (!ust_app_supports_notifiers(app)) { + ret = -ENOSYS; + goto error; + } + /* Get the write side of the pipe. */ event_pipe_write_fd = lttng_pipe_get_writefd( app->event_notifier_group.event_pipe); pthread_mutex_lock(&app->sock_lock); - ret = ustctl_create_event_notifier_group(app->sock, + ret = lttng_ust_ctl_create_event_notifier_group(app->sock, event_pipe_write_fd, &event_notifier_group); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { @@ -4063,17 +4092,40 @@ int ust_app_setup_event_notifier_group(struct ust_app *app) /* Assign handle only when the complete setup is valid. */ app->event_notifier_group.object = event_notifier_group; - event_notifier_error_accounting_status = event_notifier_error_accounting_register_app(app); - if (event_notifier_error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) { + event_notifier_error_accounting_status = + event_notifier_error_accounting_register_app(app); + switch (event_notifier_error_accounting_status) { + case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK: + break; + case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED: + DBG3("Failed to setup event notifier error accounting (application does not support notifier error accounting): app socket fd = %d, app name = '%s', app ppid = %d", + app->sock, app->name, (int) app->ppid); + ret = 0; + goto error_accounting; + case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD: + DBG3("Failed to setup event notifier error accounting (application is dead): app socket fd = %d, app name = '%s', app ppid = %d", + app->sock, app->name, (int) app->ppid); + ret = 0; + goto error_accounting; + default: ERR("Failed to setup event notifier error accounting for app"); ret = -1; - goto error; + goto error_accounting; } return ret; +error_accounting: + lttng_ret = notification_thread_command_remove_tracer_event_source( + the_notification_thread_handle, + lttng_pipe_get_readfd( + app->event_notifier_group.event_pipe)); + if (lttng_ret != LTTNG_OK) { + ERR("Failed to remove application tracer event source from notification thread"); + } + error: - ustctl_release_object(app->sock, app->event_notifier_group.object); + lttng_ust_ctl_release_object(app->sock, app->event_notifier_group.object); free(app->event_notifier_group.object); app->event_notifier_group.object = NULL; return ret; @@ -4233,7 +4285,7 @@ int ust_app_list_events(struct lttng_event **events) continue; } pthread_mutex_lock(&app->sock_lock); - handle = ustctl_tracepoint_list(app->sock); + handle = lttng_ust_ctl_tracepoint_list(app->sock); if (handle < 0) { if (handle != -EPIPE && handle != -LTTNG_UST_ERR_EXITING) { ERR("UST app list events getting handle failed for app pid %d", @@ -4243,7 +4295,7 @@ int ust_app_list_events(struct lttng_event **events) continue; } - while ((ret = ustctl_tracepoint_list_get(app->sock, handle, + while ((ret = lttng_ust_ctl_tracepoint_list_get(app->sock, handle, &uiter)) != -LTTNG_UST_ERR_NOENT) { /* Handle ustctl error. */ if (ret < 0) { @@ -4262,7 +4314,7 @@ int ust_app_list_events(struct lttng_event **events) break; } free(tmp_event); - release_ret = ustctl_release_handle(app->sock, handle); + release_ret = lttng_ust_ctl_release_handle(app->sock, handle); if (release_ret < 0 && release_ret != -LTTNG_UST_ERR_EXITING && release_ret != -EPIPE) { @@ -4289,7 +4341,7 @@ int ust_app_list_events(struct lttng_event **events) PERROR("realloc ust app events"); free(tmp_event); ret = -ENOMEM; - release_ret = ustctl_release_handle(app->sock, handle); + release_ret = lttng_ust_ctl_release_handle(app->sock, handle); if (release_ret < 0 && release_ret != -LTTNG_UST_ERR_EXITING && release_ret != -EPIPE) { @@ -4311,7 +4363,7 @@ int ust_app_list_events(struct lttng_event **events) tmp_event[count].enabled = -1; count++; } - ret = ustctl_release_handle(app->sock, handle); + ret = lttng_ust_ctl_release_handle(app->sock, handle); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) { ERR("Error releasing app handle for app %d with ret %d", app->sock, ret); @@ -4364,7 +4416,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) continue; } pthread_mutex_lock(&app->sock_lock); - handle = ustctl_tracepoint_field_list(app->sock); + handle = lttng_ust_ctl_tracepoint_field_list(app->sock); if (handle < 0) { if (handle != -EPIPE && handle != -LTTNG_UST_ERR_EXITING) { ERR("UST app list field getting handle failed for app pid %d", @@ -4374,7 +4426,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) continue; } - while ((ret = ustctl_tracepoint_field_list_get(app->sock, handle, + while ((ret = lttng_ust_ctl_tracepoint_field_list_get(app->sock, handle, &uiter)) != -LTTNG_UST_ERR_NOENT) { /* Handle ustctl error. */ if (ret < 0) { @@ -4393,7 +4445,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) break; } free(tmp_event); - release_ret = ustctl_release_handle(app->sock, handle); + release_ret = lttng_ust_ctl_release_handle(app->sock, handle); pthread_mutex_unlock(&app->sock_lock); if (release_ret < 0 && release_ret != -LTTNG_UST_ERR_EXITING && @@ -4420,7 +4472,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) PERROR("realloc ust app event fields"); free(tmp_event); ret = -ENOMEM; - release_ret = ustctl_release_handle(app->sock, handle); + release_ret = lttng_ust_ctl_release_handle(app->sock, handle); pthread_mutex_unlock(&app->sock_lock); if (release_ret && release_ret != -LTTNG_UST_ERR_EXITING && @@ -4448,7 +4500,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) tmp_event[count].event.enabled = -1; count++; } - ret = ustctl_release_handle(app->sock, handle); + ret = lttng_ust_ctl_release_handle(app->sock, handle); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -LTTNG_UST_ERR_EXITING && @@ -4991,7 +5043,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) skip_setup: /* This starts the UST tracing */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_start_session(app->sock, ua_sess->handle); + ret = lttng_ust_ctl_start_session(app->sock, ua_sess->handle); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -5020,7 +5072,7 @@ skip_setup: /* Quiescent wait after starting trace */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_wait_quiescent(app->sock); + ret = lttng_ust_ctl_wait_quiescent(app->sock); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app wait quiescent failed for app pid %d ret %d", @@ -5083,7 +5135,7 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app) /* This inhibits UST tracing */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_stop_session(app->sock, ua_sess->handle); + ret = lttng_ust_ctl_stop_session(app->sock, ua_sess->handle); pthread_mutex_unlock(&app->sock_lock); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -5106,7 +5158,7 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Quiescent wait after stopping trace */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_wait_quiescent(app->sock); + ret = lttng_ust_ctl_wait_quiescent(app->sock); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app wait quiescent failed for app pid %d ret %d", @@ -5456,7 +5508,7 @@ static int destroy_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Quiescent wait after stopping trace */ pthread_mutex_lock(&app->sock_lock); - ret = ustctl_wait_quiescent(app->sock); + ret = lttng_ust_ctl_wait_quiescent(app->sock); pthread_mutex_unlock(&app->sock_lock); if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app wait quiescent failed for app pid %d ret %d", @@ -5632,6 +5684,10 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) struct ust_app_event_notifier_rule *event_notifier_rule; unsigned int count, i; + if (!ust_app_supports_notifiers(app)) { + goto end; + } + /* * Currrently, registering or unregistering a trigger with an * event rule condition causes a full synchronization of the event @@ -5653,7 +5709,6 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) ret_code = notification_thread_command_list_triggers( the_notification_thread_handle, 0, &triggers); if (ret_code != LTTNG_OK) { - ret = -1; goto end; } @@ -5661,7 +5716,6 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) t_status = lttng_triggers_get_count(triggers, &count); if (t_status != LTTNG_TRIGGER_STATUS_OK) { - ret = -1; goto end; } @@ -5679,12 +5733,15 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) token = lttng_trigger_get_tracer_token(trigger); condition = lttng_trigger_get_condition(trigger); - if (lttng_condition_get_type(condition) != LTTNG_CONDITION_TYPE_ON_EVENT) { + if (lttng_condition_get_type(condition) != + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES) { /* Does not apply */ continue; } - condition_status = lttng_condition_on_event_borrow_rule_mutable(condition, &event_rule); + condition_status = + lttng_condition_event_rule_matches_borrow_rule_mutable( + condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); if (lttng_event_rule_get_domain_type(event_rule) == LTTNG_DOMAIN_KERNEL) { @@ -5950,7 +6007,7 @@ void ust_app_global_update_event_notifier_rules(struct ust_app *app) DBG2("UST application global event notifier rules update: app = '%s' (ppid: %d)", app->name, app->ppid); - if (!app->compatible) { + if (!app->compatible || !ust_app_supports_notifiers(app)) { return; } @@ -5991,20 +6048,6 @@ void ust_app_global_update_all_event_notifier_rules(void) rcu_read_unlock(); } -void ust_app_update_event_notifier_error_count(struct lttng_trigger *trigger) -{ - uint64_t error_count = 0; - enum event_notifier_error_accounting_status status; - struct lttng_condition *condition = lttng_trigger_get_condition(trigger); - - status = event_notifier_error_accounting_get_count(trigger, &error_count); - if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) { - ERR("Error getting trigger error count."); - } - - lttng_condition_on_event_set_error_count(condition, error_count); -} - /* * Add context to a specific channel for global UST domain. */ @@ -6073,7 +6116,7 @@ int ust_app_recv_registration(int sock, struct ust_register_msg *msg) assert(msg); - ret = ustctl_recv_reg_msg(sock, &msg->type, &msg->major, &msg->minor, + ret = lttng_ust_ctl_recv_reg_msg(sock, &msg->type, &msg->major, &msg->minor, &pid, &ppid, &uid, &gid, &msg->bits_per_long, &msg->uint8_t_alignment, @@ -6173,12 +6216,12 @@ error: * On success 0 is returned else a negative value. */ static int reply_ust_register_channel(int sock, int cobjd, - size_t nr_fields, struct ustctl_field *fields) + size_t nr_fields, struct lttng_ust_ctl_field *fields) { int ret, ret_code = 0; uint32_t chan_id; uint64_t chan_reg_key; - enum ustctl_channel_header type; + enum lttng_ust_ctl_channel_header type; struct ust_app *app; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; @@ -6233,7 +6276,7 @@ static int reply_ust_register_channel(int sock, int cobjd, * this channel to better guess header type for per-pid * buffers. */ - type = USTCTL_CHANNEL_HEADER_LARGE; + type = LTTNG_UST_CTL_CHANNEL_HEADER_LARGE; ust_reg_chan->nr_ctx_fields = nr_fields; ust_reg_chan->ctx_fields = fields; fields = NULL; @@ -6259,7 +6302,7 @@ reply: " with id %u, type: %d, ret: %d", chan_reg_key, chan_id, type, ret_code); - ret = ustctl_reply_register_channel(sock, chan_id, type, ret_code); + ret = lttng_ust_ctl_reply_register_channel(sock, chan_id, type, ret_code); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app reply channel failed with ret %d", ret); @@ -6290,7 +6333,7 @@ error_rcu_unlock: * On success 0 is returned else a negative value. */ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, - char *sig, size_t nr_fields, struct ustctl_field *fields, + char *sig, size_t nr_fields, struct lttng_ust_ctl_field *fields, int loglevel_value, char *model_emf_uri) { int ret, ret_code; @@ -6356,7 +6399,7 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, * application can be notified. In case of an error, it's important not to * return a negative error or else the application will get closed. */ - ret = ustctl_reply_register_event(sock, event_id, ret_code); + ret = lttng_ust_ctl_reply_register_event(sock, event_id, ret_code); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app reply event failed with ret %d", ret); @@ -6392,7 +6435,7 @@ error_rcu_unlock: * On success 0 is returned else a negative value. */ static int add_enum_ust_registry(int sock, int sobjd, char *name, - struct ustctl_enum_entry *entries, size_t nr_entries) + struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries) { int ret = 0, ret_code; struct ust_app *app; @@ -6444,7 +6487,7 @@ static int add_enum_ust_registry(int sock, int sobjd, char *name, * application can be notified. In case of an error, it's important not to * return a negative error or else the application will get closed. */ - ret = ustctl_reply_register_enum(sock, enum_id, ret_code); + ret = lttng_ust_ctl_reply_register_enum(sock, enum_id, ret_code); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app reply enum failed with ret %d", ret); @@ -6475,11 +6518,11 @@ error_rcu_unlock: int ust_app_recv_notify(int sock) { int ret; - enum ustctl_notify_cmd cmd; + enum lttng_ust_ctl_notify_cmd cmd; DBG3("UST app receiving notify from sock %d", sock); - ret = ustctl_recv_notify(sock, &cmd); + ret = lttng_ust_ctl_recv_notify(sock, &cmd); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app recv notify failed with ret %d", ret); @@ -6490,16 +6533,16 @@ int ust_app_recv_notify(int sock) } switch (cmd) { - case USTCTL_NOTIFY_CMD_EVENT: + case LTTNG_UST_CTL_NOTIFY_CMD_EVENT: { int sobjd, cobjd, loglevel_value; char name[LTTNG_UST_ABI_SYM_NAME_LEN], *sig, *model_emf_uri; size_t nr_fields; - struct ustctl_field *fields; + struct lttng_ust_ctl_field *fields; DBG2("UST app ustctl register event received"); - ret = ustctl_recv_register_event(sock, &sobjd, &cobjd, name, + ret = lttng_ust_ctl_recv_register_event(sock, &sobjd, &cobjd, name, &loglevel_value, &sig, &nr_fields, &fields, &model_emf_uri); if (ret < 0) { @@ -6525,15 +6568,15 @@ int ust_app_recv_notify(int sock) break; } - case USTCTL_NOTIFY_CMD_CHANNEL: + case LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL: { int sobjd, cobjd; size_t nr_fields; - struct ustctl_field *fields; + struct lttng_ust_ctl_field *fields; DBG2("UST app ustctl register channel received"); - ret = ustctl_recv_register_channel(sock, &sobjd, &cobjd, &nr_fields, + ret = lttng_ust_ctl_recv_register_channel(sock, &sobjd, &cobjd, &nr_fields, &fields); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -6557,16 +6600,16 @@ int ust_app_recv_notify(int sock) break; } - case USTCTL_NOTIFY_CMD_ENUM: + case LTTNG_UST_CTL_NOTIFY_CMD_ENUM: { int sobjd; char name[LTTNG_UST_ABI_SYM_NAME_LEN]; size_t nr_entries; - struct ustctl_enum_entry *entries; + struct lttng_ust_ctl_enum_entry *entries; DBG2("UST app ustctl register enum received"); - ret = ustctl_recv_register_enum(sock, &sobjd, name, + ret = lttng_ust_ctl_recv_register_enum(sock, &sobjd, name, &entries, &nr_entries); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { @@ -6732,7 +6775,7 @@ enum lttng_error_code ust_app_snapshot_record( memset(pathname, 0, sizeof(pathname)); ret = snprintf(pathname, sizeof(pathname), - DEFAULT_UST_TRACE_DIR "/" DEFAULT_UST_TRACE_UID_PATH, + DEFAULT_UST_TRACE_UID_PATH, reg->uid, reg->bits_per_long); if (ret < 0) { PERROR("snprintf snapshot path"); @@ -6796,7 +6839,7 @@ enum lttng_error_code ust_app_snapshot_record( /* Add the UST default trace dir to path. */ memset(pathname, 0, sizeof(pathname)); - ret = snprintf(pathname, sizeof(pathname), DEFAULT_UST_TRACE_DIR "/%s", + ret = snprintf(pathname, sizeof(pathname), "%s", ua_sess->path); if (ret < 0) { status = LTTNG_ERR_INVALID; @@ -7050,7 +7093,7 @@ int ust_app_regenerate_statedump(struct ltt_ust_session *usess, } pthread_mutex_lock(&app->sock_lock); - ret = ustctl_regenerate_statedump(app->sock, ua_sess->handle); + ret = lttng_ust_ctl_regenerate_statedump(app->sock, ua_sess->handle); pthread_mutex_unlock(&app->sock_lock); end_unlock: @@ -7118,11 +7161,6 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) struct buffer_reg_channel *buf_reg_chan; struct consumer_socket *socket; - if (!reg->registry->reg.ust->metadata_key) { - /* Skip since no metadata is present */ - continue; - } - /* Get consumer socket to use to push the metadata.*/ socket = consumer_find_socket_by_bitness(reg->bits_per_long, usess->consumer); @@ -7145,6 +7183,19 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) } } + /* + * The metadata channel might not be present. + * + * Consumer stream allocation can be done + * asynchronously and can fail on intermediary + * operations (i.e add context) and lead to data + * channels created with no metadata channel. + */ + if (!reg->registry->reg.ust->metadata_key) { + /* Skip since no metadata is present. */ + continue; + } + (void) push_metadata(reg->registry->reg.ust, usess->consumer); ret = consumer_rotate_channel(socket,