diff options
author | Vijay Pai <vpai@google.com> | 2015-07-21 14:12:55 -0700 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2015-07-21 14:12:55 -0700 |
commit | 86ba41370b18fd0446c1ff70411f39b480779d1b (patch) | |
tree | 94e8d887c981fcb3f1e4f16918cf30c7b81085f3 | |
parent | 61e647819c85ded55f1005c01a6e1dd408218186 (diff) | |
parent | 990f6427e8d9fabcff87fc21fcfce774d7500b2b (diff) |
Merge pull request #2556 from ctiller/one-thing-at-a-time
Fix TSAN reported failure
-rw-r--r-- | src/core/channel/client_channel.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 10e01ebbb4..c1aa580b2d 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -236,21 +236,6 @@ static void picked_target(void *arg, int iomgr_success) { } } -static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { - grpc_metadata_batch *initial_metadata; - grpc_transport_stream_op *op = &calld->waiting_op; - - GPR_ASSERT(op->bind_pollset); - GPR_ASSERT(op->send_ops); - GPR_ASSERT(op->send_ops->nops >= 1); - GPR_ASSERT(op->send_ops->ops[0].type == GRPC_OP_METADATA); - initial_metadata = &op->send_ops->ops[0].data.metadata; - - grpc_iomgr_closure_init(&calld->async_setup_task, picked_target, calld); - grpc_lb_policy_pick(lb_policy, op->bind_pollset, initial_metadata, - &calld->picked_channel, &calld->async_setup_task); -} - static grpc_iomgr_closure *merge_into_waiting_op( grpc_call_element *elem, grpc_transport_stream_op *new_op) { call_data *calld = elem->call_data; @@ -358,12 +343,23 @@ static void perform_transport_stream_op(grpc_call_element *elem, gpr_mu_lock(&chand->mu_config); lb_policy = chand->lb_policy; if (lb_policy) { + grpc_transport_stream_op *op = &calld->waiting_op; + grpc_pollset *bind_pollset = op->bind_pollset; + grpc_metadata_batch *initial_metadata = &op->send_ops->ops[0].data.metadata; GRPC_LB_POLICY_REF(lb_policy, "pick"); gpr_mu_unlock(&chand->mu_config); calld->state = CALL_WAITING_FOR_PICK; + + GPR_ASSERT(op->bind_pollset); + GPR_ASSERT(op->send_ops); + GPR_ASSERT(op->send_ops->nops >= 1); + GPR_ASSERT( + op->send_ops->ops[0].type == GRPC_OP_METADATA); gpr_mu_unlock(&calld->mu_state); - pick_target(lb_policy, calld); + grpc_iomgr_closure_init(&calld->async_setup_task, picked_target, calld); + grpc_lb_policy_pick(lb_policy, bind_pollset, initial_metadata, + &calld->picked_channel, &calld->async_setup_task); GRPC_LB_POLICY_UNREF(lb_policy, "pick"); } else if (chand->resolver != NULL) { |