From: Jérémie Galarneau Date: Thu, 5 May 2022 19:00:10 +0000 (-0400) Subject: sessiond: Replace uses of session_trylock_list by a dedicated assert macro X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=3130a40c184a9315f0a4ca9a235273277fdcabde;p=deliverable%2Flttng-tools.git sessiond: Replace uses of session_trylock_list by a dedicated assert macro Signed-off-by: Jérémie Galarneau Change-Id: I925a2f4052149b3a9ff91a80c7541dc8ed226c70 --- diff --git a/src/bin/lttng-sessiond/kernel-consumer.cpp b/src/bin/lttng-sessiond/kernel-consumer.cpp index 844f53541..ece50de11 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.cpp +++ b/src/bin/lttng-sessiond/kernel-consumer.cpp @@ -169,8 +169,8 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, rcu_read_lock(); session = session_find_by_id(ksession->id); LTTNG_ASSERT(session); - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); status = notification_thread_command_add_channel( the_notification_thread_handle, session->name, diff --git a/src/bin/lttng-sessiond/session.hpp b/src/bin/lttng-sessiond/session.hpp index 0fad8132c..ad451336a 100644 --- a/src/bin/lttng-sessiond/session.hpp +++ b/src/bin/lttng-sessiond/session.hpp @@ -22,6 +22,8 @@ #include "trace-kernel.hpp" #include "consumer.hpp" +#define ASSERT_SESSION_LIST_LOCKED() LTTNG_ASSERT(session_trylock_list()) + struct ltt_ust_session; typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session, diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index fcc4267ad..2fc3b6f4f 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -3411,8 +3411,8 @@ static int create_channel_per_uid(struct ust_app *app, session = session_find_by_id(ua_sess->tracing_id); LTTNG_ASSERT(session); - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); /* * Create the buffers on the consumer side. This call populates the @@ -3527,9 +3527,8 @@ static int create_channel_per_pid(struct ust_app *app, session = session_find_by_id(ua_sess->tracing_id); LTTNG_ASSERT(session); - - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); /* Create and get channel on the consumer side. */ ret = do_consumer_create_channel(usess, ua_sess, ua_chan, @@ -3874,9 +3873,8 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess, session = session_find_by_id(ua_sess->tracing_id); LTTNG_ASSERT(session); - - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); /* * Ask the metadata channel creation to the consumer. The metadata object