diff options
author | David G. Quintas <dgq@google.com> | 2016-12-13 21:53:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-13 21:53:07 -0800 |
commit | 3fd9dc04aa458dc9c32f5e7d88aac5747964065c (patch) | |
tree | 1803d68f2e0cde03365e506816e2d60e62836ca0 | |
parent | 7b1b2cc2aad07238afc95273c783cda8426856aa (diff) | |
parent | 68a9e38c56bb76e31de1d10b900c34474a1be4c0 (diff) |
Merge pull request #9089 from dgquintas/short_deadlines_sans_tests
Short deadlines: set Status on deadline
-rw-r--r-- | src/core/ext/client_channel/client_channel.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index 1fcff4388a..4b3d8951d7 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -683,9 +683,15 @@ static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, "Failed to create subchannel", &error, 1)); } else if (GET_CALL(calld) == CANCELLED_CALL) { /* already cancelled before subchannel became ready */ - fail_locked(exec_ctx, calld, - GRPC_ERROR_CREATE_REFERENCING( - "Cancelled before creating subchannel", &error, 1)); + grpc_error *cancellation_error = GRPC_ERROR_CREATE_REFERENCING( + "Cancelled before creating subchannel", &error, 1); + /* if due to deadline, attach the deadline exceeded status to the error */ + if (gpr_time_cmp(calld->deadline, gpr_now(GPR_CLOCK_MONOTONIC)) < 0) { + cancellation_error = + grpc_error_set_int(cancellation_error, GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_DEADLINE_EXCEEDED); + } + fail_locked(exec_ctx, calld, cancellation_error); } else { /* Create call on subchannel. */ grpc_subchannel_call *subchannel_call = NULL; @@ -809,7 +815,6 @@ static bool pick_subchannel(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, initial_metadata_flags &= ~GRPC_INITIAL_METADATA_WAIT_FOR_READY; } } - // TODO(dgq): make this deadline configurable somehow. const grpc_lb_policy_pick_args inputs = { initial_metadata, initial_metadata_flags, &calld->lb_token_mdelem, gpr_inf_future(GPR_CLOCK_MONOTONIC)}; |