From a0fbf69e7c7689466549db8815f2d87f5c16f664 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 3 Sep 2010 04:01:02 +0000 Subject: mgmt/glusterd: clear op ctx after cli response Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1513 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1513 --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 23 ++++++++++++----------- xlators/mgmt/glusterd/src/glusterd-op-sm.h | 3 ++- xlators/mgmt/glusterd/src/glusterd3_1-mops.c | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index dbeb07ff5..734910134 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -2868,7 +2868,8 @@ out: int32_t glusterd_op_send_cli_response (int32_t op, int32_t op_ret, - int32_t op_errno, rpcsvc_request_t *req) + int32_t op_errno, rpcsvc_request_t *req, + void *op_ctx) { int32_t ret = -1; gd_serialize_t sfunc = NULL; @@ -2959,14 +2960,9 @@ glusterd_op_send_cli_response (int32_t op, int32_t op_ret, case GD_MGMT_CLI_REPLACE_BRICK: { gf1_cli_replace_brick_rsp rsp = {0,}; - ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK); - if (!ctx) { - gf_log ("", GF_LOG_ERROR, - "Operation Context is not present"); - ret = -1; - goto out; - } - if (dict_get_str (ctx, "status-reply", &rsp.status)) + ctx = op_ctx; + if (ctx && + dict_get_str (ctx, "status-reply", &rsp.status)) rsp.status = ""; rsp.op_ret = op_ret; rsp.op_errno = op_errno; @@ -3021,6 +3017,8 @@ glusterd_op_txn_complete () int32_t op_errno = 0; int32_t cli_op = 0; rpcsvc_request_t *req = NULL; + void *ctx = NULL; + gf_boolean_t ctx_free = _gf_false; priv = THIS->private; GF_ASSERT (priv); @@ -3050,14 +3048,17 @@ glusterd_op_txn_complete () glusterd_op_clear_pending_op (op); glusterd_op_clear_commit_op (op); glusterd_op_clear_op (op); - glusterd_op_clear_ctx (op); + ctx = glusterd_op_get_ctx (op); + ctx_free = glusterd_op_get_ctx_free (op); glusterd_op_clear_ctx_free (op); } out: pthread_mutex_unlock (&opinfo.lock); ret = glusterd_op_send_cli_response (cli_op, op_ret, - op_errno, req); + op_errno, req, ctx); + if (ctx_free && ctx && (op != -1)) + glusterd_op_clear_ctx (op); gf_log ("glusterd", GF_LOG_NORMAL, "Returning %d", ret); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h index 554169aee..0d7c1cccb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h @@ -207,7 +207,8 @@ glusterd_op_set_cli_op (gf_mgmt_procnum op); int32_t glusterd_op_send_cli_response (int32_t op, int32_t op_ret, - int32_t op_errno, rpcsvc_request_t *req); + int32_t op_errno, rpcsvc_request_t *req, + void *ctx); int32_t glusterd_op_get_op (); diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c index 0376f4be1..e4525b930 100644 --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c @@ -1233,7 +1233,7 @@ out: be 0, and we should not point to any RPC errors, because otherwise rpcsvc.c will send an error reply for the same request, which causes double replies */ - ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req); + ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req, NULL); if (!ret) req->rpc_err = SUCCESS; } -- cgit