From abf28c8fd12f662f32c1a81f84620f562de8f14b Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 15 Sep 2010 00:27:10 +0000 Subject: 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 Signed-off-by: Vijay Bellur BUG: 1438 (memory leaks) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1438 --- rpc/rpc-lib/src/rpc-clnt.c | 1 + rpc/rpc-lib/src/rpc-transport.c | 14 ++++++++++---- rpc/rpc-lib/src/rpcsvc.c | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'rpc') 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++; } -- cgit