X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=c902b21768bb3c6dd2e4e059cc6e76b52be84bcd;hb=86ba1e22ecd54f1e8b6c7d049a06adf06cb3e24b;hp=d249762a4299ea8123e13240c786b243928c66d4;hpb=b623cb6a788d9e666d9a93658ab04b06458863ef;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index d249762a4..c902b2176 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -2022,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)); @@ -2042,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; @@ -2106,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); @@ -2121,7 +2122,14 @@ static int create_ust_event_notifier(struct ust_app *app, 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; @@ -3005,7 +3013,7 @@ static int duplicate_stream_object(struct buffer_reg_stream *reg_stream, assert(reg_stream); assert(stream); - /* Reserve the amount of file descriptor we need. */ + /* Duplicating a stream requires 2 new fds. Reserve them. */ ret = lttng_fd_get(LTTNG_FD_APPS, 2); if (ret < 0) { ERR("Exhausted number of available FD upon duplicate stream"); @@ -3041,7 +3049,7 @@ static int duplicate_channel_object(struct buffer_reg_channel *buf_reg_chan, assert(buf_reg_chan); assert(ua_chan); - /* Need two fds for the channel. */ + /* Duplicating a channel requires 1 new fd. Reserve it. */ ret = lttng_fd_get(LTTNG_FD_APPS, 1); if (ret < 0) { ERR("Exhausted number of available FD upon duplicate channel"); @@ -4006,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. * @@ -4022,6 +4040,11 @@ 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); @@ -4071,14 +4094,20 @@ int ust_app_setup_event_notifier_group(struct ust_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; - } - + 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_accounting; @@ -5655,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 @@ -5870,14 +5903,16 @@ void ust_app_synchronize(struct ltt_ust_session *usess, ret = find_or_create_ust_app_session(usess, app, &ua_sess, NULL); if (ret < 0) { /* Tracer is probably gone or ENOMEM. */ - goto error; + if (ua_sess) { + destroy_app_session(app, ua_sess); + } + goto end; } assert(ua_sess); pthread_mutex_lock(&ua_sess->lock); if (ua_sess->deleted) { - pthread_mutex_unlock(&ua_sess->lock); - goto end; + goto deleted_session; } rcu_read_lock(); @@ -5895,23 +5930,15 @@ void ust_app_synchronize(struct ltt_ust_session *usess, */ ret = create_ust_app_metadata(ua_sess, app, usess->consumer); if (ret < 0) { - goto error_unlock; + ERR("Metadata creation failed for app sock %d for session id %" PRIu64, + app->sock, usess->id); } rcu_read_unlock(); -end: - pthread_mutex_unlock(&ua_sess->lock); - /* Everything went well at this point. */ - return; - -error_unlock: - rcu_read_unlock(); +deleted_session: pthread_mutex_unlock(&ua_sess->lock); -error: - if (ua_sess) { - destroy_app_session(app, ua_sess); - } +end: return; } @@ -5974,7 +6001,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; } @@ -6742,7 +6769,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"); @@ -6806,7 +6833,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;