diff options
author | 2015-02-05 21:41:23 -0800 | |
---|---|---|
committer | 2015-02-05 21:41:23 -0800 | |
commit | 8b976d0c244e516c2195c699bf396cf1dac2baa5 (patch) | |
tree | f6e3a69f2fb200cb3d036844cf691eebbd7eb36f /src/core/channel/client_channel.c | |
parent | c230a7451dbfc0627bdd3173118a91b075856619 (diff) |
Fixes
Diffstat (limited to 'src/core/channel/client_channel.c')
-rw-r--r-- | src/core/channel/client_channel.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 507b91b8a6..c2c23f5156 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -210,11 +210,30 @@ static void remove_waiting_child(channel_data *chand, call_data *calld) { chand->waiting_child_count = new_count; } +static void send_up_cancelled_ops(grpc_call_element *elem) { + grpc_call_op finish_op; + channel_data *chand = elem->channel_data; + /* send up a synthesized status */ + finish_op.type = GRPC_RECV_METADATA; + finish_op.dir = GRPC_CALL_UP; + finish_op.flags = 0; + finish_op.data.metadata = grpc_mdelem_ref(chand->cancel_status); + finish_op.done_cb = do_nothing; + finish_op.user_data = NULL; + grpc_call_next_op(elem, &finish_op); + /* send up a finish */ + finish_op.type = GRPC_RECV_FINISH; + finish_op.dir = GRPC_CALL_UP; + finish_op.flags = 0; + finish_op.done_cb = do_nothing; + finish_op.user_data = NULL; + grpc_call_next_op(elem, &finish_op); +} + static void cancel_rpc(grpc_call_element *elem, grpc_call_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; grpc_call_element *child_elem; - grpc_call_op finish_op; gpr_mu_lock(&chand->mu); switch (calld->state) { @@ -225,27 +244,15 @@ static void cancel_rpc(grpc_call_element *elem, grpc_call_op *op) { return; /* early out */ case CALL_WAITING: remove_waiting_child(chand, calld); + gpr_mu_unlock(&chand->mu); + send_up_cancelled_ops(elem); calld->s.waiting.on_complete(calld->s.waiting.on_complete_user_data, GRPC_OP_ERROR); - /* fallthrough intended */ + return; /* early out */ case CALL_CREATED: calld->state = CALL_CANCELLED; gpr_mu_unlock(&chand->mu); - /* send up a synthesized status */ - finish_op.type = GRPC_RECV_METADATA; - finish_op.dir = GRPC_CALL_UP; - finish_op.flags = 0; - finish_op.data.metadata = grpc_mdelem_ref(chand->cancel_status); - finish_op.done_cb = do_nothing; - finish_op.user_data = NULL; - grpc_call_next_op(elem, &finish_op); - /* send up a finish */ - finish_op.type = GRPC_RECV_FINISH; - finish_op.dir = GRPC_CALL_UP; - finish_op.flags = 0; - finish_op.done_cb = do_nothing; - finish_op.user_data = NULL; - grpc_call_next_op(elem, &finish_op); + send_up_cancelled_ops(elem); return; /* early out */ case CALL_CANCELLED: gpr_mu_unlock(&chand->mu); |