diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2016-01-06 17:33:45 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2016-01-06 17:33:45 -0800 |
commit | 320bee0e623f4d7cf7568db60bdcdd93a7556bed (patch) | |
tree | ec2109a3d848df4bf0a921e5d26c5d7fd99ee5d6 /src | |
parent | de2163b37a26378261e20c34742d083967147dfc (diff) |
Review feedback
Diffstat (limited to 'src')
-rw-r--r-- | src/core/client_config/lb_policies/pick_first.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 620b83d195..9beaeba2b4 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -55,10 +55,11 @@ typedef struct { grpc_closure connectivity_changed; - /** mutex protecting remaining members */ - gpr_mu mu; /** the selected channel (a grpc_connected_subchannel) */ gpr_atm selected; + + /** mutex protecting remaining members */ + gpr_mu mu; /** have we started picking? */ int started_picking; /** are we shut down? */ @@ -174,11 +175,15 @@ int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_pollset *pollset, grpc_connected_subchannel **target, grpc_closure *on_complete) { pick_first_lb_policy *p = (pick_first_lb_policy *)pol; pending_pick *pp; + + /* Check atomically for a selected channel */ grpc_connected_subchannel *selected = GET_SELECTED(p); if (selected != NULL) { *target = selected; return 1; } + + /* No subchannel selected yet, so acquire lock and then attempt again */ gpr_mu_lock(&p->mu); selected = GET_SELECTED(p); if (selected) { |