From 32c35e175ac362a9682b10600044a5fe17441176 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 6 Apr 2015 12:55:13 +0530 Subject: rpc: Perform throttling conditionally This change makes rpc's throttling to be performed only if attribute throttle is set in rpcsvc_t. Change-Id: I24620095570e206f5dc8fc6208fcf55cb22a1658 BUG: 1212385 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/10268 Tested-by: NetBSD Build System Reviewed-by: Niels de Vos Tested-by: Gluster Build System Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- rpc/rpc-lib/src/rpcsvc.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 0a4dc04c731..b395149e032 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -179,13 +179,25 @@ rpcsvc_can_outstanding_req_be_ignored (rpcsvc_request_t *req) int rpcsvc_request_outstanding (rpcsvc_request_t *req, int delta) { - int ret = 0; - int old_count = 0; - int new_count = 0; - int limit = 0; + int ret = -1; + int old_count = 0; + int new_count = 0; + int limit = 0; + gf_boolean_t throttle = _gf_false; + + if (!req) + goto out; + + throttle = rpcsvc_get_throttle (req->svc); + if (!throttle) { + ret = 0; + goto out; + } - if (rpcsvc_can_outstanding_req_be_ignored (req)) - return 0; + if (rpcsvc_can_outstanding_req_be_ignored (req)) { + ret = 0; + goto out; + } pthread_mutex_lock (&req->trans->lock); { @@ -206,6 +218,7 @@ rpcsvc_request_outstanding (rpcsvc_request_t *req, int delta) unlock: pthread_mutex_unlock (&req->trans->lock); +out: return ret; } -- cgit