Enforce locking assumptions during channel creation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 May 2018 18:35:24 +0000 (14:35 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 May 2018 18:35:24 +0000 (14:35 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/session.h
src/bin/lttng-sessiond/ust-app.c

index 01cdfdc00b670757e5fc46c842cdd5293aafc6b5..16431ca15ca19d3cd3260ee99e6a4c5163232d35 100644 (file)
@@ -134,6 +134,14 @@ void session_lock_list(void)
        pthread_mutex_lock(&ltt_session_list.lock);
 }
 
+/*
+ * Try to acquire session list lock
+ */
+int session_trylock_list(void)
+{
+       return pthread_mutex_trylock(&ltt_session_list.lock);
+}
+
 /*
  * Release session list lock
  */
index 3ace323bab4a9ac18fd0a6d654498b7117f1bc14..92e7a11ad430dfe7c05a7a9ce28f4a66ddebb278 100644 (file)
@@ -212,6 +212,7 @@ int session_destroy(struct ltt_session *session);
 
 void session_lock(struct ltt_session *session);
 void session_lock_list(void);
+int session_trylock_list(void);
 void session_unlock(struct ltt_session *session);
 void session_unlock_list(void);
 
index 8120b6df21188ea88331bba2a7c27c883d9b410d..62971067ce00f9d1b000580b4a7a10b45121d7ac 100644 (file)
@@ -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(&registry->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,
This page took 0.029997 seconds and 4 git commands to generate.