diff options
author | Vijay Bellur <vbellur@redhat.com> | 2015-04-06 12:55:13 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-03 11:05:13 -0700 |
commit | 8e76a10bb4d598a6a7d1ca43465f285233e12d5f (patch) | |
tree | bcb5531fe9972196ed54cb0b37cc62f8a5a3bc0b | |
parent | ee4b5ce0ef140e2ee98e7f061450b18ff2b53367 (diff) |
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: 1216310
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/10268
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: http://review.gluster.org/10443
Tested-by: NetBSD Build System
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.c | 25 |
1 files changed, 19 insertions, 6 deletions
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; } |