From a4056292528db49a666422c7f8e0c032441cc83f Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Sun, 20 Oct 2013 08:45:18 -0700 Subject: rpcsvc: implement per-client RPC throttling Implement a limit on the total number of outstanding RPC requests from a given cient. Once the limit is reached the client socket is removed from POLL-IN event polling. Change-Id: I8071b8c89b78d02e830e6af5a540308199d6bdcd BUG: 1008301 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/6114 Reviewed-by: Santosh Pradhan Reviewed-by: Rajesh Joseph Reviewed-by: Harshavardhana Reviewed-by: Vijay Bellur Tested-by: Gluster Build System --- rpc/rpc-transport/socket/src/socket.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'rpc/rpc-transport') diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 8883ccbb4..93da3f296 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -3261,6 +3261,25 @@ out: } +static int +socket_throttle (rpc_transport_t *this, gf_boolean_t onoff) +{ + socket_private_t *priv = NULL; + + priv = this->private; + + /* The way we implement throttling is by taking off + POLLIN event from the polled flags. This way we + never get called with the POLLIN event and therefore + 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); + return 0; +} + + struct rpc_transport_ops tops = { .listen = socket_listen, .connect = socket_connect, @@ -3271,6 +3290,7 @@ struct rpc_transport_ops tops = { .get_peeraddr = socket_getpeeraddr, .get_myname = socket_getmyname, .get_myaddr = socket_getmyaddr, + .throttle = socket_throttle, }; int -- cgit