aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/resource_quota.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-03-30 12:28:46 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-03-30 12:28:46 -0700
commit78a4207af59442aa9595df2509b6a6c6d90bde47 (patch)
treed6896dadc35b434dcc66837542e29497832c78c1 /src/core/lib/iomgr/resource_quota.c
parentd89bf42e205c2011127d46de399400fb55d9916a (diff)
parent97d401128bf00254ab626b86dfebef4289e6369c (diff)
Merge branch 'atomic-timers' into dynamic_tcp_sizing
Diffstat (limited to 'src/core/lib/iomgr/resource_quota.c')
-rw-r--r--src/core/lib/iomgr/resource_quota.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c
index 511ffdcdf1..8dcd80d001 100644
--- a/src/core/lib/iomgr/resource_quota.c
+++ b/src/core/lib/iomgr/resource_quota.c
@@ -279,11 +279,17 @@ static void rq_step_sched(grpc_exec_ctx *exec_ctx,
/* update the atomically available resource estimate - use no barriers since
timeliness of delivery really doesn't matter much */
static void rq_update_estimate(grpc_resource_quota *resource_quota) {
+ gpr_atm memory_usage_estimation = MEMORY_USAGE_ESTIMATION_MAX;
+ if (resource_quota->size != 0) {
+ memory_usage_estimation =
+ GPR_CLAMP((gpr_atm)((1.0 -
+ ((double)resource_quota->free_pool) /
+ ((double)resource_quota->size)) *
+ MEMORY_USAGE_ESTIMATION_MAX),
+ 0, MEMORY_USAGE_ESTIMATION_MAX);
+ }
gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation,
- (gpr_atm)((1.0 -
- ((double)resource_quota->free_pool) /
- ((double)resource_quota->size)) *
- MEMORY_USAGE_ESTIMATION_MAX));
+ memory_usage_estimation);
}
/* returns true if all allocations are completed */