summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-09-15 00:27:10 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-15 00:06:37 -0700
commitabf28c8fd12f662f32c1a81f84620f562de8f14b (patch)
treee3d91d68aa1795535b6b7899cb9b31bfc6b2eb4d /rpc/rpc-lib
parentcfbbf68f8af83521b41b40c07db48897b976b626 (diff)
memory leak fixes.
- free memory allocated by libc when decoding request arguments in server and reply in client. - free memory allocated to saved_frames during connection cleanup. - free memory allocated for transport name while creating listeners. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1438 (memory leaks) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1438
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c1
-rw-r--r--rpc/rpc-lib/src/rpc-transport.c14
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c3
3 files changed, 13 insertions, 5 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 79be1acaea8..de4087ad52b 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -1394,6 +1394,7 @@ rpc_clnt_destroy (struct rpc_clnt *rpc)
rpc_transport_destroy (rpc->conn.trans);
rpc_clnt_connection_cleanup (&rpc->conn);
rpc_clnt_reconnect_cleanup (&rpc->conn);
+ saved_frames_destroy (rpc->conn.saved_frames);
pthread_mutex_destroy (&rpc->lock);
pthread_mutex_destroy (&rpc->conn.lock);
GF_FREE (rpc);
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c
index 7acf04d027c..29f02811fdd 100644
--- a/rpc/rpc-lib/src/rpc-transport.c
+++ b/rpc/rpc-lib/src/rpc-transport.c
@@ -902,10 +902,6 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
goto fail;
}
- if (name) {
- GF_FREE (name);
- }
-
trans->ops = dlsym (handle, "tops");
if (trans->ops == NULL) {
gf_log ("rpc-transport", GF_LOG_ERROR,
@@ -962,6 +958,11 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
pthread_mutex_init (&trans->lock, NULL);
trans->xl = THIS;
return_trans = trans;
+
+ if (name) {
+ GF_FREE (name);
+ }
+
GF_FREE (vol_opt);
return return_trans;
@@ -978,6 +979,10 @@ fail:
GF_FREE (vol_opt);
}
+ if (name) {
+ GF_FREE (name);
+ }
+
return NULL;
}
@@ -1059,6 +1064,7 @@ rpc_transport_destroy (rpc_transport_t *this)
if (this->fini)
this->fini (this);
pthread_mutex_destroy (&this->lock);
+ GF_FREE (this->name);
GF_FREE (this);
fail:
return ret;
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 5f6f6b31053..030e23db74d 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -1902,7 +1902,7 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name)
goto out;
}
- ret = asprintf (&transport_name, "%s.%s", tmp, name);
+ ret = gf_asprintf (&transport_name, "%s.%s", tmp, name);
if (ret == -1) {
goto out;
}
@@ -1920,6 +1920,7 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name)
goto out;
}
+ GF_FREE (transport_name);
count++;
}