aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface/call.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-01-23 07:46:25 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-01-23 07:46:25 -0800
commitad980e3a613c4fa04001cca12c981703739a82e3 (patch)
treeaef3be1b7deba63253a5359d18c7b5712e0a0596 /src/core/lib/surface/call.c
parent0c3fdad486d2fb23e60e1a3bf261b1846c877148 (diff)
Memory fixes
Diffstat (limited to 'src/core/lib/surface/call.c')
-rw-r--r--src/core/lib/surface/call.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 63b0683df5..9852034fbb 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -989,12 +989,15 @@ static grpc_error *consolidate_batch_errors(batch_control *bctl) {
if (n == 0) {
return GRPC_ERROR_NONE;
} else if (n == 1) {
- return bctl->errors[0];
+ grpc_error *e = bctl->errors[0];
+ bctl->errors[0] = NULL;
+ return e;
} else {
grpc_error *error =
GRPC_ERROR_CREATE_REFERENCING("Call batch failed", bctl->errors, n);
for (size_t i = 0; i < n; i++) {
GRPC_ERROR_UNREF(bctl->errors[i]);
+ bctl->errors[i] = NULL;
}
return error;
}
@@ -1221,8 +1224,8 @@ static void validate_filtered_metadata(grpc_exec_ctx *exec_ctx,
static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl,
grpc_error *error) {
if (error == GRPC_ERROR_NONE) return;
- cancel_with_error(exec_ctx, bctl->call, GRPC_ERROR_REF(error));
int idx = (int)gpr_atm_no_barrier_fetch_add(&bctl->num_errors, 1);
+ if (idx > 0) cancel_with_error(exec_ctx, bctl->call, GRPC_ERROR_REF(error));
bctl->errors[idx] = error;
}
@@ -1258,7 +1261,7 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
receiving_stream_ready, call->saved_receiving_stream_ready_bctlp,
grpc_schedule_on_exec_ctx);
call->saved_receiving_stream_ready_bctlp = NULL;
- grpc_closure_sched(exec_ctx, saved_rsr_closure, error);
+ grpc_closure_sched(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error));
}
gpr_mu_unlock(&call->mu);