From 72c8b09640976ecf0c2a50dcf92a1b8648e723d4 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Fri, 5 Sep 2014 07:32:20 +0000 Subject: glusterd: Returning success from mgmt_v3 handler functions The mgmt_v3 handler functions already send the ret code as part of the *send_resp calls, and further propagating the ret code to the calling functions will lead to double deletion of the req object. Hence returning success from the mgmt_v3 handler functions. Change-Id: I1090e49c54a786daae5fd97b5c1fbcb5d819acba BUG: 1138577 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/8620 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c | 50 +++++++++++++++++++---- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'xlators/mgmt/glusterd/src') diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c index c0c1cfcba18..fc9b987ece6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c @@ -178,13 +178,30 @@ glusterd_handle_mgmt_v3_lock_fn (rpcsvc_request_t *req) "is_synctasked", _gf_false); if (is_synctasked) { ret = glusterd_synctasked_mgmt_v3_lock (req, &lock_req, ctx); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to acquire mgmt_v3_locks"); + /* Ignore the return code, as it shouldn't be propagated + * from the handler function so as to avoid double + * deletion of the req + */ + ret = 0; + } + /* The above function does not take ownership of ctx. * Therefore we need to free the ctx explicitly. */ free_ctx = _gf_true; } else { + /* Shouldn't ignore the return code here, and it should + * be propagated from the handler function as in failure + * case it doesn't delete the req object + */ ret = glusterd_op_state_machine_mgmt_v3_lock (req, &lock_req, ctx); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to acquire mgmt_v3_locks"); } out: @@ -324,8 +341,8 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); - return ret; + /* Return 0 from handler to avoid double deletion of req obj */ + return 0; } static int @@ -449,8 +466,8 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); - return ret; + /* Return 0 from handler to avoid double deletion of req obj */ + return 0; } static int @@ -573,8 +590,8 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); - return ret; + /* Return 0 from handler to avoid double deletion of req obj */ + return 0; } static int @@ -699,8 +716,8 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); - return ret; + /* Return 0 from handler to avoid double deletion of req obj */ + return 0; } static int @@ -844,13 +861,30 @@ glusterd_handle_mgmt_v3_unlock_fn (rpcsvc_request_t *req) "is_synctasked", _gf_false); if (is_synctasked) { ret = glusterd_syctasked_mgmt_v3_unlock (req, &lock_req, ctx); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to release mgmt_v3_locks"); + /* Ignore the return code, as it shouldn't be propagated + * from the handler function so as to avoid double + * deletion of the req + */ + ret = 0; + } + /* The above function does not take ownership of ctx. * Therefore we need to free the ctx explicitly. */ free_ctx = _gf_true; } else { + /* Shouldn't ignore the return code here, and it should + * be propagated from the handler function as in failure + * case it doesn't delete the req object + */ ret = glusterd_op_state_machine_mgmt_v3_unlock (req, &lock_req, ctx); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to release mgmt_v3_locks"); } out: -- cgit