diff options
author | Craig Tiller <ctiller@google.com> | 2017-02-17 06:49:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-17 06:49:46 -0800 |
commit | 46ca4f7d4eca6cb69a6d80ce35f58f2325cf945d (patch) | |
tree | fa6c5d046b0752daacc28b5e85983edc3cf19408 /src | |
parent | 2ad3d73f9557da88b5c8898b991ffb4a4d8d1e3e (diff) | |
parent | 37cbc3f5b30451254c99a85be36364bae74f2c70 (diff) |
Merge pull request #9754 from ctiller/call_cancel
Use special errors where appropriate in call cancellation: avoids many allocations in a semi-common case
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/surface/call.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 3352e427cd..48a1e586e1 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -481,7 +481,10 @@ void grpc_call_destroy(grpc_call *c) { c->destroy_called = 1; cancel = !c->received_final_op; gpr_mu_unlock(&c->mu); - if (cancel) grpc_call_cancel(c, NULL); + if (cancel) { + cancel_with_error(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, + GRPC_ERROR_CANCELLED); + } GRPC_CALL_INTERNAL_UNREF(&exec_ctx, c, "destroy"); grpc_exec_ctx_finish(&exec_ctx); GPR_TIMER_END("grpc_call_destroy", 0); @@ -490,8 +493,11 @@ void grpc_call_destroy(grpc_call *c) { grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved) { GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved)); GPR_ASSERT(!reserved); - return grpc_call_cancel_with_status(call, GRPC_STATUS_CANCELLED, "Cancelled", - NULL); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + cancel_with_error(&exec_ctx, call, STATUS_FROM_API_OVERRIDE, + GRPC_ERROR_CANCELLED); + grpc_exec_ctx_finish(&exec_ctx); + return GRPC_CALL_OK; } static void execute_op(grpc_exec_ctx *exec_ctx, grpc_call *call, |