X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=f8668d88c4be34c043e6aaa2c87c4eda6aa6c0ee;hp=d8546308deb2cc2fa77e7c1b698627626b881234;hb=bd6661538d573c0798439f2933474f677a857728;hpb=533a90fb2d8d6892b86261951658cab6150a8ed6 diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index d8546308d..f8668d88c 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -29,8 +29,8 @@ #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", @@ -1011,7 +1011,7 @@ void delete_ust_app(struct ust_app *app) app->event_notifier_group.event_pipe); ret_code = notification_thread_command_remove_tracer_event_source( - notification_thread_handle, + the_notification_thread_handle, event_notifier_read_fd); if (ret_code != LTTNG_OK) { ERR("Failed to remove application tracer event source from notification thread"); @@ -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) { @@ -2108,9 +2113,10 @@ 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); @@ -2123,7 +2129,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 +2180,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 +2572,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 +2628,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 +2960,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 +3013,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 +3049,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); @@ -3352,11 +3358,12 @@ static int create_channel_per_uid(struct ust_app *app, pthread_mutex_unlock(®_uid->registry->reg.ust->lock); notification_ret = notification_thread_command_add_channel( - notification_thread_handle, session->name, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), - ua_chan->name, - ua_chan->key, LTTNG_DOMAIN_UST, + the_notification_thread_handle, session->name, + lttng_credentials_get_uid( + &ua_sess->effective_credentials), + lttng_credentials_get_gid( + &ua_sess->effective_credentials), + ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST, ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf); if (notification_ret != LTTNG_OK) { ret = - (int) notification_ret; @@ -3453,11 +3460,12 @@ static int create_channel_per_pid(struct ust_app *app, pthread_mutex_unlock(®istry->lock); cmd_ret = notification_thread_command_add_channel( - notification_thread_handle, session->name, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), - ua_chan->name, - ua_chan->key, LTTNG_DOMAIN_UST, + the_notification_thread_handle, session->name, + lttng_credentials_get_uid( + &ua_sess->effective_credentials), + lttng_credentials_get_gid( + &ua_sess->effective_credentials), + ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST, ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf); if (cmd_ret != LTTNG_OK) { ret = - (int) cmd_ret; @@ -3850,9 +3858,11 @@ struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock) DBG3("UST app creating application for socket %d", sock); if ((msg->bits_per_long == 64 && - (uatomic_read(&ust_consumerd64_fd) == -EINVAL)) - || (msg->bits_per_long == 32 && - (uatomic_read(&ust_consumerd32_fd) == -EINVAL))) { + (uatomic_read(&the_ust_consumerd64_fd) == + -EINVAL)) || + (msg->bits_per_long == 32 && + (uatomic_read(&the_ust_consumerd32_fd) == + -EINVAL))) { ERR("Registration failed: application \"%s\" (pid: %d) has " "%d-bit long, but no consumerd for this size is available.\n", msg->name, msg->pid, msg->bits_per_long); @@ -3983,7 +3993,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) { @@ -4017,7 +4027,7 @@ int ust_app_setup_event_notifier_group(struct ust_app *app) 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) { @@ -4046,8 +4056,9 @@ int ust_app_setup_event_notifier_group(struct ust_app *app) lttng_fd_put(LTTNG_FD_APPS, 1); lttng_ret = notification_thread_command_add_tracer_event_source( - notification_thread_handle, - lttng_pipe_get_readfd(app->event_notifier_group.event_pipe), + the_notification_thread_handle, + lttng_pipe_get_readfd( + app->event_notifier_group.event_pipe), LTTNG_DOMAIN_UST); if (lttng_ret != LTTNG_OK) { ERR("Failed to add tracer event source to notification thread"); @@ -4058,18 +4069,36 @@ 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); + event_notifier_error_accounting_status = + event_notifier_error_accounting_register_app(app); if (event_notifier_error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) { + if (event_notifier_error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD) { + DBG3("Failed to setup event notifier error accounting (application is dead): app socket fd = %d", + app->sock); + ret = 0; + goto error_accounting; + } + 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; } @@ -4227,7 +4256,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", @@ -4237,7 +4266,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) { @@ -4256,7 +4285,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) { @@ -4283,7 +4312,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) { @@ -4305,7 +4334,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); @@ -4358,7 +4387,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", @@ -4368,7 +4397,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) { @@ -4387,7 +4416,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 && @@ -4414,7 +4443,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 && @@ -4442,7 +4471,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 && @@ -4985,7 +5014,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) { @@ -5014,7 +5043,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", @@ -5077,7 +5106,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) { @@ -5100,7 +5129,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", @@ -5450,7 +5479,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", @@ -5645,9 +5674,8 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) /* Get all triggers using uid 0 (root) */ ret_code = notification_thread_command_list_triggers( - notification_thread_handle, 0, &triggers); + the_notification_thread_handle, 0, &triggers); if (ret_code != LTTNG_OK) { - ret = -1; goto end; } @@ -5655,7 +5683,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; } @@ -5673,12 +5700,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) { @@ -5985,20 +6015,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. */ @@ -6067,7 +6083,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, @@ -6167,12 +6183,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; @@ -6227,7 +6243,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; @@ -6253,7 +6269,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); @@ -6284,7 +6300,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; @@ -6350,7 +6366,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); @@ -6386,7 +6402,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; @@ -6438,7 +6454,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); @@ -6469,11 +6485,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); @@ -6484,16 +6500,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) { @@ -6519,15 +6535,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) { @@ -6551,16 +6567,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) { @@ -6726,7 +6742,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"); @@ -6790,7 +6806,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; @@ -7044,7 +7060,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: @@ -7112,11 +7128,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); @@ -7139,6 +7150,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,