diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2012-10-22 15:30:49 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-02-03 12:35:09 -0800 |
commit | 9708bd1f922ca38973cba65b4890c67c2edc6e2b (patch) | |
tree | 7a8853809eb1244952718a77e9786d3392b7402a /xlators/mgmt/glusterd | |
parent | 6b262d20940b088a1d72ad5518cc4908a7316b5a (diff) |
glusterd: do dict unref after sending reply to cli
This patch channelizes dict unrefs of dictionaries created from the cli
req during volume ops to one common function - glusterd_to_cli() - which
is guaranteed to be called irrespective of whether the command succeeds
or fails.
This patch also removes extra unrefs at a few places.
Change-Id: Ic8ba7166387b5dfd1f5ae860539e1b7093a94662
BUG: 861044
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/4003
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 16 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-log-ops.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quota.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 5 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-syncop.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 13 |
11 files changed, 5 insertions, 49 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 19ae2ca2136..fe556afef41 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -528,8 +528,6 @@ out: cli_rsp = &rsp; glusterd_to_cli (req, cli_rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_cli_rsp, dict); - if (dict) - dict_unref (dict); ret = 0; //sent error to cli, prevent second reply } @@ -833,8 +831,6 @@ out: cli_rsp = &rsp; glusterd_to_cli (req, cli_rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_cli_rsp, dict); - if (dict) - dict_unref (dict); ret = 0; //sent error to cli, prevent second reply diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 9ded1ebea52..5a6369c4c71 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -147,15 +147,12 @@ out: glusterd_friend_sm (); glusterd_op_sm (); - if (ret) { if (err_str[0] == '\0') snprintf (err_str, sizeof (err_str), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 0993d276370..fb94bba8960 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -1130,9 +1130,6 @@ out: glusterd_to_cli (req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_cli_rsp, dict); - if (dict) - dict_unref (dict); - return ret; } @@ -1261,14 +1258,13 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req) out: glusterd_friend_sm (); glusterd_op_sm (); + if (ret) { if (err_str[0] == '\0') snprintf (err_str, sizeof (err_str), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } return ret; @@ -1460,9 +1456,6 @@ out: snprintf (msg, sizeof (msg), "Operation failed"); glusterd_to_cli (req, &cli_rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_cli_rsp, dict); - if (dict) - dict_unref (dict); - ret = 0; //sent error to cli, prevent second reply } @@ -2134,14 +2127,13 @@ out: glusterd_op_sm (); free (cli_req.dict.dict_val); + if (ret) { if (err_str[0] == '\0') snprintf (err_str, sizeof (err_str), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); @@ -2986,8 +2978,6 @@ out: "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } free (cli_req.dict.dict_val); @@ -3060,8 +3050,6 @@ out: "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } free (cli_req.dict.dict_val); diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c index fa576212af3..c88065c079e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c @@ -88,8 +88,6 @@ out: snprintf (msg, sizeof (msg), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, msg); - if (dict) - dict_unref (dict); } free (cli_req.dict.dict_val); diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index fcccf480598..2c457ace87a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3408,7 +3408,6 @@ glusterd_op_txn_complete () ret = 0; } - glusterd_op_free_ctx (op, ctx); if (op_errstr && (strcmp (op_errstr, ""))) GF_FREE (op_errstr); diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index b2379a510d3..09c4273df4a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -110,8 +110,6 @@ out: snprintf (msg, sizeof (msg), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, msg); - if (dict) - dict_unref (dict); } return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index f07bd952761..307cdf629dc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -453,8 +453,6 @@ out: snprintf (msg, sizeof (msg), "Operation failed"); ret = glusterd_op_send_cli_response (GD_OP_REBALANCE, ret, 0, req, dict, msg); - if (dict) - dict_unref (dict); } diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c index c4e26c13291..ec69b363763 100644 --- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c @@ -166,8 +166,6 @@ out: snprintf (msg, sizeof (msg), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, msg); - if (dict) - dict_unref (dict); } return ret; @@ -2012,8 +2010,5 @@ out: else ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_ACC, NULL); - if (dict) - dict_unref (dict); - glusterd_op_sm (); } diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index 835cc4ea827..fa0aa47c0c2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -857,7 +857,7 @@ out: if (req_dict) dict_unref (req_dict); - if (rsp_dict) + if (ret && rsp_dict) dict_unref (rsp_dict); if (op_errstr) @@ -882,8 +882,6 @@ glusterd_op_begin_synctask (rpcsvc_request_t *req, glusterd_op_t op, gd_sync_task_begin (dict, req); ret = 0; out: - if (dict) - dict_unref (dict); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index e3e77eb0a4c..97081355df2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -6323,6 +6323,8 @@ glusterd_to_cli (rpcsvc_request_t *req, gf_cli_rsp *arg, struct iovec *payload, glusterd_submit_reply (req, arg, payload, payloadcount, iobref, (xdrproc_t) xdrproc); + if (dict) + dict_unref (dict); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index b75b35dbdad..2aadce24342 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -205,9 +205,6 @@ out: cli_rsp = &rsp; glusterd_to_cli (req, cli_rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_cli_rsp, dict); - if (dict) - dict_unref (dict); - ret = 0; //Client response sent, prevent second response } @@ -284,8 +281,6 @@ out: snprintf (errstr, sizeof (errstr), "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, errstr); - if (dict) - dict_unref (dict); } return ret; @@ -359,8 +354,6 @@ out: "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } return ret; @@ -433,8 +426,6 @@ out: "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } return ret; @@ -523,8 +514,6 @@ out: "operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, op_errstr); - if (dict) - dict_unref (dict); } return ret; @@ -607,8 +596,6 @@ out: "Operation failed"); ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict, err_str); - if (dict) - dict_unref (dict); } free (cli_req.dict.dict_val); glusterd_friend_sm (); |