summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2019-02-26 18:04:18 +0530
committerAmar Tumballi <amarts@redhat.com>2019-03-20 13:24:44 +0000
commitf2f07591b2de9ba45bbc3eb4f601d1e9a327190b (patch)
tree1eb628f99b91246759e3bc1e9de1238c9fea2cc4 /cli/src
parent6d6a3b298ee81c6c7d93941365852c1bdb42c3c1 (diff)
rpc/transport: Missing a ref on dict while creating transport object
while creating rpc_tranpsort object, we store a dictionary without taking a ref on dict but it does an unref during the cleaning of the transport object. So the rpc layer expect the caller to take a ref on the dictionary before passing dict to rpc layer. This leads to a lot of confusion across the code base and leads to ref leaks. Semantically, this is not correct. It is the rpc layer responsibility to take a ref when storing it, and free during the cleanup. I'm listing down the total issues or leaks across the code base because of this confusion. These issues are currently present in the upstream master. 1) changelog_rpc_client_init 2) quota_enforcer_init 3) rpcsvc_create_listeners : when there are two transport, like tcp,rdma. 4) quotad_aggregator_init 5) glusterd: init 6) nfs3_init_state 7) server: init 8) client:init This patch does the cleanup according to the semantics. Change-Id: I46373af9630373eb375ee6de0e6f2bbe2a677425 updates: bz#1659708 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 0c019aabfa3..2fa95b40a25 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -670,9 +670,8 @@ cli_quotad_clnt_rpc_init(void)
global_quotad_rpc = rpc;
out:
- if (ret) {
- if (rpc_opts)
- dict_unref(rpc_opts);
+ if (rpc_opts) {
+ dict_unref(rpc_opts);
}
return rpc;
}
@@ -694,6 +693,10 @@ cli_rpc_init(struct cli_state *state)
this = THIS;
cli_rpc_prog = &cli_prog;
+ options = dict_new();
+ if (!options)
+ goto out;
+
/* If address family specified in CLI */
if (state->address_family) {
addr_family = state->address_family;
@@ -708,7 +711,7 @@ cli_rpc_init(struct cli_state *state)
"Connecting to glusterd using "
"sockfile %s",
state->glusterd_sock);
- ret = rpc_transport_unix_options_build(&options, state->glusterd_sock,
+ ret = rpc_transport_unix_options_build(options, state->glusterd_sock,
0);
if (ret)
goto out;
@@ -718,10 +721,6 @@ cli_rpc_init(struct cli_state *state)
"%s",
state->remote_host);
- options = dict_new();
- if (!options)
- goto out;
-
ret = dict_set_str(options, "remote-host", state->remote_host);
if (ret)
goto out;
@@ -740,7 +739,7 @@ cli_rpc_init(struct cli_state *state)
gf_log("cli", GF_LOG_DEBUG,
"Connecting to glusterd using "
"default socket");
- ret = rpc_transport_unix_options_build(&options,
+ ret = rpc_transport_unix_options_build(options,
DEFAULT_GLUSTERD_SOCKFILE, 0);
if (ret)
goto out;
@@ -758,6 +757,9 @@ cli_rpc_init(struct cli_state *state)
ret = rpc_clnt_start(rpc);
out:
+ if (options)
+ dict_unref(options);
+
if (ret) {
if (rpc)
rpc_clnt_unref(rpc);