From 022541e7a5ccb09a92e469d87d8e5fe9fc9d7512 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sat, 25 Jul 2015 16:24:05 -0400 Subject: [PATCH] Fix: RCU read-side lock released too early in destroy_agent_app MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/agent-thread.c | 4 ++-- src/bin/lttng-sessiond/agent.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng-sessiond/agent-thread.c b/src/bin/lttng-sessiond/agent-thread.c index 4c1457fe0..dbbdfde4a 100644 --- a/src/bin/lttng-sessiond/agent-thread.c +++ b/src/bin/lttng-sessiond/agent-thread.c @@ -89,13 +89,13 @@ static void destroy_agent_app(int sock) rcu_read_lock(); app = agent_find_app_by_sock(sock); assert(app); - rcu_read_unlock(); - /* RCU read side lock is taken in this function call. */ + /* RCU read side lock is assumed to be held by this function. */ agent_delete_app(app); /* The application is freed in a RCU call but the socket is closed here. */ agent_destroy_app(app); + rcu_read_unlock(); } /* diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index 8992d2d80..1bf490f5a 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -677,6 +677,8 @@ void agent_add_app(struct agent_app *app) /* * Delete agent application from the global hash table. + * + * rcu_read_lock() must be held by the caller. */ void agent_delete_app(struct agent_app *app) { @@ -688,9 +690,7 @@ void agent_delete_app(struct agent_app *app) DBG3("Agent deleting app pid: %d and sock: %d", app->pid, app->sock->fd); iter.iter.node = &app->node.node; - rcu_read_lock(); ret = lttng_ht_del(agent_apps_ht_by_sock, &iter); - rcu_read_unlock(); assert(!ret); } -- 2.34.1