diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-05-22 00:37:58 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-31 10:04:36 -0700 |
commit | 894a517a12411c4dfbdeda6b9e90df26f5855d2e (patch) | |
tree | 930dcca35e5a5b1636d9b02f7848741f63b15be5 /rpc/rpc-transport | |
parent | 37cc99fc3a991241df49133902928bd789d95066 (diff) |
socket: throttle only connected transport
BUG: 1224016
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>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'rpc/rpc-transport')
-rw-r--r-- | 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 ece2bc8379a..e6ef7d2c220 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -3567,8 +3567,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; } |