diff options
author | Amar Tumballi <amar@gluster.com> | 2010-08-05 10:15:25 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-08-06 03:37:01 -0700 |
commit | dc10948a186931f22df2b1d3b4053c0c6bcac1de (patch) | |
tree | 7db045a9fd4772b5f787d1278369bf7a1eb68b2d /rpc/rpc-lib | |
parent | f9f4c5722536faee3d9ecbd8b99ce138e724f401 (diff) |
fix memory-leak in case of disconnections in RPC server
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1227 (memory leak in rpcsvc_conn_alloc)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1227
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.c | 2 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.c | 50 |
2 files changed, 7 insertions, 45 deletions
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index 50379c14950..b8ef434503b 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -1171,6 +1171,8 @@ rpc_transport_destroy (rpc_transport_t *this) GF_VALIDATE_OR_GOTO("rpc_transport", this, fail); + rpc_transport_disconnect (this); + if (this->fini) this->fini (this); pthread_mutex_destroy (&this->lock); diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 5bb908cec0a..09ff68daa60 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -603,57 +603,17 @@ out: void rpcsvc_conn_destroy (rpcsvc_conn_t *conn) { - rpcsvc_notify_wrapper_t *wrapper = NULL; - rpcsvc_event_t event = 0; rpcsvc_listener_t *listener = NULL; - rpcsvc_t *svc = NULL; - rpcsvc_notify_wrapper_t *wrappers = NULL; - int i = 0, wrapper_count = 0; - if (!conn) + if (!conn || !conn->rxpool || !conn->listener) goto out; + if (conn->trans) + rpc_transport_destroy (conn->trans); + mem_pool_destroy (conn->rxpool); listener = conn->listener; - if (!listener) - goto out; - - event = (listener->conn == conn) ? RPCSVC_EVENT_LISTENER_DEAD - : RPCSVC_EVENT_DISCONNECT; - - svc = conn->svc; - if (!svc) - goto out; - - pthread_mutex_lock (&svc->rpclock); - { - wrappers = GF_CALLOC (svc->notify_count, sizeof (*wrapper), - gf_common_mt_rpcsvc_wrapper_t); - if (!wrappers) { - goto unlock; - } - - list_for_each_entry (wrapper, &conn->listener->list, - list) { - if (wrapper->notify) { - wrappers[i++] = *wrapper; - } - } - wrapper_count = i; - } -unlock: - pthread_mutex_unlock (&svc->rpclock); - - if (wrappers) { - for (i = 0; i < wrapper_count; i++) { - wrappers[i].notify (conn->svc, wrappers[i].data, - event, conn); - } - - GF_FREE (wrappers); - } - if (listener->conn == conn) { rpcsvc_listener_destroy (listener); } @@ -1232,7 +1192,7 @@ rpcsvc_notify (rpc_transport_t *trans, void *mydata, break; case RPC_TRANSPORT_DISCONNECT: - //rpcsvc_conn_deinit (conn); + rpcsvc_conn_deinit (conn); ret = 0; break; |