From 6b58e8426a36bc544c06a599311999bf89ad04f2 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Wed, 3 Oct 2018 16:34:54 +0530 Subject: glusterd: ignore RPC events when glusterd is shutting down When glusterd receives a SIGTERM while it receives RPC connect/disconnect/destroy events, the thread might lead to a crash while accessing rcu_read_lock () as the clean up thread might have already freed up the resources. This is more observable when glusterd comes up with upgrade mode = on during upgrade process. The solution is to ignore these events if glusterd is already in the middle of cleanup_and_exit (). Fixes: bz#1635593 Change-Id: I12831d31c2f689d4deb038b83b9421bd5cce26d9 Signed-off-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-handler.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd/src') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 74238e71ad7..5714e44e1f4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -6349,6 +6349,8 @@ __glusterd_peer_rpc_notify(struct rpc_clnt *rpc, void *mydata, glusterd_peerctx_t *peerctx = NULL; gf_boolean_t quorum_action = _gf_false; glusterd_volinfo_t *volinfo = NULL; + glusterfs_ctx_t *ctx = NULL; + uuid_t uuid; peerctx = mydata; @@ -6369,7 +6371,15 @@ __glusterd_peer_rpc_notify(struct rpc_clnt *rpc, void *mydata, default: break; } - + ctx = this->ctx; + GF_VALIDATE_OR_GOTO(this->name, ctx, out); + if (ctx->cleanup_started) { + gf_log(this->name, GF_LOG_INFO, + "glusterd already received a SIGTERM, " + "dropping the event %d for peer %s", + event, peerctx->peername); + return 0; + } rcu_read_lock(); peerinfo = glusterd_peerinfo_find_by_generation(peerctx->peerinfo_gen); -- cgit