X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Faction-executor.c;fp=src%2Fbin%2Flttng-sessiond%2Faction-executor.c;h=a259933521517c358bd2ab2aa9be32b53c1f8756;hp=79c8677143ea3a829cb0a0581c3f2e513de0db33;hb=e1bbf98908a6399f39a9a8bc95bd8b59cecaa816;hpb=b03a81fbbc65c1cf2e9abc67c56465137c788322 diff --git a/src/bin/lttng-sessiond/action-executor.c b/src/bin/lttng-sessiond/action-executor.c index 79c867714..a25993352 100644 --- a/src/bin/lttng-sessiond/action-executor.c +++ b/src/bin/lttng-sessiond/action-executor.c @@ -1076,17 +1076,26 @@ static int add_action_to_subitem_array(struct lttng_action *action, * simplicity and consistency. */ if (session_name != NULL) { - struct ltt_session *session = NULL; + uint64_t session_id; - session_lock_list(); - session = session_find_by_name(session_name); - if (session) { + /* + * Instantaneous sampling of the session id if present. + * + * This method is preferred over `sessiond_find_by_name` then + * fetching the session'd id since `sessiond_find_by_name` + * requires the session list lock to be taken. + * + * Taking the session list lock can lead to a deadlock + * between the action executor and the notification thread + * (caller of add_action_to_subitem_array). It is okay if the + * session state changes between the enqueuing time and the + * execution time. The execution context is validated at + * execution time. + */ + if (sample_session_id_by_name(session_name, &session_id)) { LTTNG_OPTIONAL_SET(&subitem.context.session_id, - session->id); - session_put(session); + session_id); } - - session_unlock_list(); } /* Get a reference to the action. */