From d4fa2906b8e8a6de34c8e7b33b998fbc63f54cb1 Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Wed, 2 Jan 2019 12:29:53 +0530 Subject: glusterd: kill the process without releasing the cleanup mutex lock Problem: glusterd acquires a cleanup mutex lock before it starts cleanup process, so that any other thread which tries to acquire lock on any resource will be blocked on cleanup mutex lock. We don't want any thread to try to acquire any resource, once the cleanup is started. because other threads might try to acquire lock on resources which are already freed by the thread which is going though the cleanup phase. previously we were releasing the cleanup mutex lock before the process exit. As we are releasing the cleanup mutex lock, before the process can exit some other thread which is blocked on cleanup mutex lock is acquiring the cleanup mutex lock and trying to acquire some resources which are already freed as a part of cleanup. This is leading glusterd to crash. Solution: We should exit the process without releasing the cleanup mutex lock. Change-Id: Ibae1c62260f141019017f7a547519a5d38dc2bb6 fixes: bz#1654270 Signed-off-by: Sanju Rakonde --- glusterfsd/src/glusterfsd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 7753c629216..42731660485 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1593,11 +1593,10 @@ cleanup_and_exit(int signum) #endif trav = NULL; + /* NOTE: Only the least significant 8 bits i.e (signum & 255) + will be available to parent process on calling exit() */ + exit(abs(signum)); } - pthread_mutex_unlock(&ctx->cleanup_lock); - /* NOTE: Only the least significant 8 bits i.e (signum & 255) - will be available to parent process on calling exit() */ - exit(abs(signum)); } static void -- cgit