summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2015-05-22 00:37:58 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-06-04 04:22:02 -0700
commit0687f25ed4135f4829b7cfa69668934208d48f96 (patch)
tree833c3d3ce1f4a1fd706b2aac36151114dff04b0c /rpc
parentb27ab7737f76d2a65e790afe3872f16dc3e7e078 (diff)
socket: throttle only connected transport
BUG: 1227167 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-on: http://review.gluster.org/11038 Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c17
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 82a84dd5fcc..e30e2312815 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;
}