From 61fd5c07791d82e830d7caac008247765437b7ca Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Wed, 2 Jan 2019 12:29:53 +0530 Subject: [PATCH 496/498] 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 upstream patch: https://review.gluster.org/#/c/glusterfs/+/21974/ Change-Id: Ibae1c62260f141019017f7a547519a5d38dc2bb6 BUG: 1654161 Signed-off-by: Sanju Rakonde Reviewed-on: https://code.engineering.redhat.com/gerrit/159635 Tested-by: RHGS Build Bot Reviewed-by: Atin Mukherjee --- glusterfsd/src/glusterfsd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 57effbd..990036c 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1446,11 +1446,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)); } -- 1.8.3.1