From 9886d568a7a8839bf3acc81cb1111fa372ac5270 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 8 Jul 2016 10:46:46 +0530 Subject: rpc/socket: pthread resources are not cleaned up A socket_connect failure creates a new pthread which is not a detached thread. As no pthread_join is called, the thread resources are not cleaned up causing a memory leak. Now, socket_connect creates a detached thread to handle failure. Change-Id: Idbf25d312f91464ae20c97d501b628bfdec7cf0c BUG: 1343374 Signed-off-by: N Balachandran Reviewed-on: http://review.gluster.org/14875 Smoke: Gluster Build System Reviewed-by: Atin Mukherjee NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy --- rpc/rpc-transport/socket/src/socket.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'rpc/rpc-transport/socket/src/socket.c') diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 7229d0e3461..e4f72cd8bdc 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -3142,11 +3142,13 @@ err: arg->this = THIS; arg->trans = this; arg->refd = refd; - th_ret = pthread_create (&th_id, NULL, socket_connect_error_cbk, - arg); + th_ret = gf_thread_create_detached (&th_id, + socket_connect_error_cbk, + arg); if (th_ret) { - gf_log (this->name, GF_LOG_ERROR, "pthread_create" - "failed: %s", strerror(errno)); + /* Error will be logged by gf_thread_create_attached */ + gf_log (this->name, GF_LOG_ERROR, "Thread creation " + "failed"); GF_FREE (arg); GF_ASSERT (0); } -- cgit