3604df
From b5ee02c228e4b0856d8479d436011eeab5ec57c5 Mon Sep 17 00:00:00 2001
3604df
From: Kaushal M <kaushal@redhat.com>
3604df
Date: Mon, 16 May 2016 15:15:49 +0530
3604df
Subject: [PATCH 136/141] rpc/socket: Close pipe on disconnection
3604df
3604df
Encrypted connections create a pipe, which isn't closed when the
3604df
connection disconnects. This leaks fds, and gluster eventually ends up
3604df
in a situation with fd starvation which leads to operation failures.
3604df
3604df
>Reviewed-on: http://review.gluster.org/14356
3604df
>Tested-by: MOHIT AGRAWAL <moagrawa@redhat.com>
3604df
>Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
3604df
3604df
Change-Id: I144e1f767cec8c6fc1aa46b00cd234129d2a4adc
3604df
BUG: 1381822
3604df
Signed-off-by: Kaushal M <kaushal@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/87981
3604df
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
3604df
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 rpc/rpc-transport/socket/src/socket.c |    9 ++++++++-
3604df
 1 files changed, 8 insertions(+), 1 deletions(-)
3604df
3604df
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
3604df
index 700157e..4244883 100644
3604df
--- a/rpc/rpc-transport/socket/src/socket.c
3604df
+++ b/rpc/rpc-transport/socket/src/socket.c
3604df
@@ -2567,10 +2567,17 @@ err:
3604df
         __socket_teardown_connection (this);
3604df
         sys_close (priv->sock);
3604df
         priv->sock = -1;
3604df
+
3604df
+        sys_close (priv->pipe[0]);
3604df
+        sys_close (priv->pipe[1]);
3604df
+        priv->pipe[0] = -1;
3604df
+        priv->pipe[1] = -1;
3604df
+
3604df
         priv->ot_state = OT_IDLE;
3604df
+
3604df
         pthread_mutex_unlock(&priv->lock);
3604df
-        rpc_transport_notify (this, RPC_TRANSPORT_DISCONNECT, this);
3604df
 
3604df
+        rpc_transport_notify (this, RPC_TRANSPORT_DISCONNECT, this);
3604df
 
3604df
         rpc_transport_unref (this);
3604df
 
3604df
-- 
3604df
1.7.1
3604df