X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=62971067ce00f9d1b000580b4a7a10b45121d7ac;hp=38aeaab60a9399796fbce28080686af087279803;hb=71e0a100af7369c2a56db35af7b864eeb5ca4f48;hpb=5c408ad8ef08a226c018702aca969536f36ac4e5 diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 38aeaab60..62971067c 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -2154,7 +2154,7 @@ error: * 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. */ -static int create_ust_app_session(struct ltt_ust_session *usess, +static int find_or_create_ust_app_session(struct ltt_ust_session *usess, struct ust_app *app, struct ust_app_session **ua_sess_ptr, int *is_created) { @@ -2847,6 +2847,7 @@ error: * Create and send to the application the created buffers with per UID buffers. * * This MUST be called with a RCU read side lock acquired. + * The session list lock and the session's lock must be acquired. * * Return 0 on success else a negative value. */ @@ -2939,6 +2940,8 @@ static int create_channel_per_uid(struct ust_app *app, session = session_find_by_id(ua_sess->tracing_id); assert(session); + assert(pthread_mutex_trylock(&session->lock)); + assert(session_trylock_list()); cmd_ret = notification_thread_command_add_channel( notification_thread_handle, session->name, ua_sess->euid, ua_sess->egid, @@ -2970,6 +2973,7 @@ error: * Create and send to the application the created buffers with per PID buffers. * * Called with UST app session lock held. + * The session list lock and the session's lock must be acquired. * * Return 0 on success else a negative value. */ @@ -3032,6 +3036,9 @@ static int create_channel_per_pid(struct ust_app *app, chan_reg->consumer_key = ua_chan->key; pthread_mutex_unlock(®istry->lock); + assert(pthread_mutex_trylock(&session->lock)); + assert(session_trylock_list()); + cmd_ret = notification_thread_command_add_channel( notification_thread_handle, session->name, ua_sess->euid, ua_sess->egid, @@ -4165,7 +4172,7 @@ int ust_app_create_channel_glb(struct ltt_ust_session *usess, * that if session exist, it will simply return a pointer to the ust * app session. */ - ret = create_ust_app_session(usess, app, &ua_sess, &created); + ret = find_or_create_ust_app_session(usess, app, &ua_sess, &created); if (ret < 0) { switch (ret) { case -ENOTCONN: @@ -5041,7 +5048,7 @@ void ust_app_global_create(struct ltt_ust_session *usess, struct ust_app *app) struct ust_app_ctx *ua_ctx; int is_created = 0; - ret = create_ust_app_session(usess, app, &ua_sess, &is_created); + ret = find_or_create_ust_app_session(usess, app, &ua_sess, &is_created); if (ret < 0) { /* Tracer is probably gone or ENOMEM. */ goto error; @@ -6334,7 +6341,9 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) reg->registry->reg.ust->metadata_key, LTTNG_DOMAIN_UST, session); if (ret < 0) { - ret = LTTNG_ERR_KERN_CONSUMER_FAIL; + ret = reg->bits_per_long == 32 ? + -LTTNG_ERR_UST_CONSUMER32_FAIL : + -LTTNG_ERR_UST_CONSUMER64_FAIL; goto error; } @@ -6353,7 +6362,9 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) reg_chan->consumer_key, LTTNG_DOMAIN_UST, session); if (ret < 0) { - ret = LTTNG_ERR_KERN_CONSUMER_FAIL; + ret = reg->bits_per_long == 32 ? + -LTTNG_ERR_UST_CONSUMER32_FAIL : + -LTTNG_ERR_UST_CONSUMER64_FAIL; goto error; } ret = consumer_rotate_channel(socket, @@ -6361,7 +6372,7 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) usess->uid, usess->gid, usess->consumer, pathname, /* is_metadata_channel */ false, - session->rotate_count, + session->current_archive_id, &session->rotate_pending_relay); if (ret < 0) { goto error; @@ -6375,7 +6386,7 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) usess->uid, usess->gid, usess->consumer, pathname, /* is_metadata_channel */ true, - session->rotate_count, + session->current_archive_id, &session->rotate_pending_relay); if (ret < 0) { goto error; @@ -6430,7 +6441,9 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) ret = rotate_add_channel_pending(registry->metadata_key, LTTNG_DOMAIN_UST, session); if (ret < 0) { - ret = LTTNG_ERR_KERN_CONSUMER_FAIL; + ret = app->bits_per_long == 32 ? + -LTTNG_ERR_UST_CONSUMER32_FAIL : + -LTTNG_ERR_UST_CONSUMER64_FAIL; goto error; } @@ -6441,14 +6454,16 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) ua_chan->key, LTTNG_DOMAIN_UST, session); if (ret < 0) { - ret = LTTNG_ERR_KERN_CONSUMER_FAIL; + ret = app->bits_per_long == 32 ? + -LTTNG_ERR_UST_CONSUMER32_FAIL : + -LTTNG_ERR_UST_CONSUMER64_FAIL; goto error; } ret = consumer_rotate_channel(socket, ua_chan->key, ua_sess->euid, ua_sess->egid, ua_sess->consumer, pathname, /* is_metadata_channel */ false, - session->rotate_count, + session->current_archive_id, &session->rotate_pending_relay); if (ret < 0) { goto error; @@ -6461,7 +6476,7 @@ int ust_app_rotate_session(struct ltt_session *session, bool *ust_active) ua_sess->euid, ua_sess->egid, ua_sess->consumer, pathname, /* is_metadata_channel */ true, - session->rotate_count, + session->current_archive_id, &session->rotate_pending_relay); if (ret < 0) { goto error;