From ba7a80d22d4664bcbe420bd011ea60ee00d15ab1 Mon Sep 17 00:00:00 2001
From: Krishnan Parthasarathi <kparthas@redhat.com>
Date: Fri, 22 May 2015 00:37:58 +0530
Subject: [PATCH 27/57] socket: throttle only connected transport
BUG: 1203901
Change-Id: I2352c6661ae5aee8cf06e572ec0462b76901d46f
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/10887
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Shyam Ranganathan <srangana@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50386
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
rpc/rpc-transport/socket/src/socket.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 82a84dd..e30e231 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -3572,8 +3572,21 @@ socket_throttle (rpc_transport_t *this, gf_boolean_t onoff)
will never read() any more data until throttling
is turned off.
*/
- priv->idx = event_select_on (this->ctx->event_pool, priv->sock,
- priv->idx, (int) !onoff, -1);
+ pthread_mutex_lock (&priv->lock);
+ {
+
+ /* Throttling is useless on a disconnected transport. In fact,
+ * it's dangerous since priv->idx and priv->sock are set to -1
+ * on a disconnected transport, which breaks epoll's event to
+ * registered fd mapping. */
+
+ if (priv->connected == 1)
+ priv->idx = event_select_on (this->ctx->event_pool,
+ priv->sock,
+ priv->idx, (int) !onoff,
+ -1);
+ }
+ pthread_mutex_unlock (&priv->lock);
return 0;
}
--
1.7.1