aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-03-29 16:18:19 -0700
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-03-29 16:18:19 -0700
commitc86460225b6df2a27775bd6cb730b4076626dc5d (patch)
treeecd7b00ff4787faf45766c4adeeba7f33a8a3c17 /src/core/lib
parent9a7bab5b76413f49fdeb35a2d40021ca3a0bdf04 (diff)
parent0c10db72c4427762000d36211b6740f40f4b8627 (diff)
Merge branch 'master' into cq_create_api_changes
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/iomgr/resource_quota.c14
-rw-r--r--src/core/lib/surface/call.c2
2 files changed, 11 insertions, 5 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 */
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 895a8a3b06..9342c5f8e9 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -625,7 +625,7 @@ static bool get_final_status_from(
void (*set_value)(grpc_status_code code, void *user_data),
void *set_value_user_data, grpc_slice *details) {
grpc_status_code code;
- grpc_slice slice;
+ grpc_slice slice = grpc_empty_slice();
grpc_error_get_status(error, call->send_deadline, &code, &slice, NULL);
if (code == GRPC_STATUS_OK && !allow_ok_status) {
return false;