summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorZhou Zhengping <johnzzpcrystal@gmail.com>2016-07-10 09:10:49 -0400
committerJeff Darcy <jdarcy@redhat.com>2016-07-14 14:14:28 -0700
commitab56ec1e99cd76d45b52d841e6b0009f94a3268b (patch)
tree9b6170a831ddfd96fbed11c455ebb7f8d66a1e5f /rpc
parent8d3ef3322aa7fccff842e508a1bfd5be71e18849 (diff)
rpc: fix several problems in failure handle logic
Once dynstr is set into a dict by function dict_set_dynstr, its free operation will be called by this dict when the dict is destroyed. Signed-off-by: Zhou Zhengping <johnzzpcrystal@gmail.com> Change-Id: Idd2bd19a041bcb477e1c897428ca1740fb75c5f3 BUG: 1354141 Reviewed-on: http://review.gluster.org/14882 Tested-by: Zhou Zhengping <johnzzpcrystal@gmail.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpc-transport.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c
index e224dcc022e..1216b9fb3df 100644
--- a/rpc/rpc-lib/src/rpc-transport.c
+++ b/rpc/rpc-lib/src/rpc-transport.c
@@ -617,8 +617,10 @@ rpc_transport_unix_options_build (dict_t **options, char *filepath,
}
ret = dict_set_dynstr (dict, "transport.socket.connect-path", fpath);
- if (ret)
+ if (ret) {
+ GF_FREE (fpath);
goto out;
+ }
ret = dict_set_str (dict, "transport.address-family", "unix");
if (ret)
@@ -644,10 +646,8 @@ rpc_transport_unix_options_build (dict_t **options, char *filepath,
*options = dict;
out:
- if (ret) {
- GF_FREE (fpath);
- if (dict)
- dict_unref (dict);
+ if (ret && dict) {
+ dict_unref (dict);
}
return ret;
}
@@ -676,6 +676,7 @@ rpc_transport_inet_options_build (dict_t **options, const char *hostname,
ret = dict_set_dynstr (dict, "remote-host", host);
if (ret) {
+ GF_FREE (host);
gf_log (THIS->name, GF_LOG_WARNING,
"failed to set remote-host with %s", host);
goto out;
@@ -697,10 +698,8 @@ rpc_transport_inet_options_build (dict_t **options, const char *hostname,
*options = dict;
out:
- if (ret) {
- GF_FREE (host);
- if (dict)
- dict_unref (dict);
+ if (ret && dict) {
+ dict_unref (dict);
}
return ret;