From 41eba3545c46c4cd0b9fcf6fc87284adc64ebcf5 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Thu, 9 Mar 2017 12:49:27 -0500 Subject: glusterfsd+libglusterfs: add null checks during attach It's possible (though unlikely) that we could get a brick-attach request while we're not ready to process it (ctx->active not set yet). Add code to guard against this possibility, and return appropriate error indicators. Backport of: > 90b2b9b29f552fe9ab53de5c4123003522399e6d > BUG: 1430860 > Reviewed-on: https://review.gluster.org/16883 Change-Id: Icb3bc52ce749258a3f03cbbbdf4c2320c5c541a0 BUG: 1422769 Signed-off-by: Jeff Darcy Reviewed-on: https://review.gluster.org/16888 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- glusterfsd/src/glusterfsd-mgmt.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 89eaa29db25..ee61b963dcb 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -824,9 +824,9 @@ out: int glusterfs_handle_attach (rpcsvc_request_t *req) { - int32_t ret = -1; - gd1_mgmt_brick_op_req xlator_req = {0,}; - xlator_t *this = NULL; + int32_t ret = -1; + gd1_mgmt_brick_op_req xlator_req = {0,}; + xlator_t *this = NULL; GF_ASSERT (req); this = THIS; @@ -838,15 +838,24 @@ glusterfs_handle_attach (rpcsvc_request_t *req) if (ret < 0) { /*failed to decode msg;*/ req->rpc_err = GARBAGE_ARGS; - goto out; + return -1; } - gf_log (this->name, GF_LOG_INFO, "got attach for %s", xlator_req.name); - glusterfs_graph_attach (this->ctx->active, xlator_req.name); - glusterfs_autoscale_threads (this->ctx, 1); + if (this->ctx->active) { + gf_log (this->name, GF_LOG_INFO, + "got attach for %s", xlator_req.name); + ret = glusterfs_graph_attach (this->ctx->active, + xlator_req.name); + if (ret == 0) { + glusterfs_autoscale_threads (this->ctx, 1); + } + } else { + gf_log (this->name, GF_LOG_WARNING, + "got attach for %s but no active graph", + xlator_req.name); + } -out: - glusterfs_translator_info_response_send (req, 0, NULL, NULL); + glusterfs_translator_info_response_send (req, ret, NULL, NULL); free (xlator_req.input.input_val); free (xlator_req.name); -- cgit