Smarter pollset/pollset_set propagation

For some definition of "smart"... client_channel simply passes along
pollset/pollset_set, removing the need to instantiate a pollset_set in
the subchannel_call_holder: it's now up to the LB policies to handle the
pollset/pollset_set.
pull/6190/head
David Garcia Quintas 9 years ago
parent 879b3b9efa
commit d312a0b866
  1. 6
      BUILD
  2. 2
      Makefile
  3. 1
      binding.gyp
  4. 10
      build.yaml
  5. 2
      config.m4
  6. 3
      gRPC.podspec
  7. 2
      grpc.gemspec
  8. 2
      package.xml
  9. 18
      src/core/ext/client_config/client_channel.c
  10. 6
      src/core/ext/client_config/lb_policy.c
  11. 5
      src/core/ext/client_config/lb_policy.h
  12. 3
      src/core/ext/client_config/subchannel_call_holder.c
  13. 62
      src/core/ext/lb_policy/common.c
  14. 48
      src/core/ext/lb_policy/common.h
  15. 34
      src/core/ext/lb_policy/pick_first/pick_first.c
  16. 29
      src/core/ext/lb_policy/round_robin/round_robin.c
  17. 1
      src/python/grpcio/grpc_core_dependencies.py
  18. 2
      tools/doxygen/Doxyfile.core.internal
  19. 24
      tools/run_tests/sources_and_headers.json
  20. 3
      vsprojects/vcxproj/grpc/grpc.vcxproj
  21. 6
      vsprojects/vcxproj/grpc/grpc.vcxproj.filters
  22. 3
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
  23. 6
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters

@ -285,6 +285,7 @@ cc_library(
"src/core/ext/client_config/uri_parser.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/common.h",
"src/core/ext/census/aggregation.h",
"src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h",
@ -439,6 +440,7 @@ cc_library(
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c",
"src/core/ext/lb_policy/common.c",
"src/core/ext/lb_policy/pick_first/pick_first.c",
"src/core/ext/lb_policy/round_robin/round_robin.c",
"src/core/ext/resolver/dns/native/dns_resolver.c",
@ -616,6 +618,7 @@ cc_library(
"src/core/ext/client_config/uri_parser.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/common.h",
"src/core/ext/census/aggregation.h",
"src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h",
@ -752,6 +755,7 @@ cc_library(
"src/core/ext/resolver/sockaddr/sockaddr_resolver.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c",
"src/core/ext/lb_policy/common.c",
"src/core/ext/lb_policy/pick_first/pick_first.c",
"src/core/ext/lb_policy/round_robin/round_robin.c",
"src/core/ext/census/context.c",
@ -1451,6 +1455,7 @@ objc_library(
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c",
"src/core/ext/lb_policy/common.c",
"src/core/ext/lb_policy/pick_first/pick_first.c",
"src/core/ext/lb_policy/round_robin/round_robin.c",
"src/core/ext/resolver/dns/native/dns_resolver.c",
@ -1621,6 +1626,7 @@ objc_library(
"src/core/ext/client_config/uri_parser.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/common.h",
"src/core/ext/census/aggregation.h",
"src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h",

@ -2601,6 +2601,7 @@ LIBGRPC_SRC = \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
src/core/ext/lb_policy/common.c \
src/core/ext/lb_policy/pick_first/pick_first.c \
src/core/ext/lb_policy/round_robin/round_robin.c \
src/core/ext/resolver/dns/native/dns_resolver.c \
@ -2921,6 +2922,7 @@ LIBGRPC_UNSECURE_SRC = \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
src/core/ext/lb_policy/common.c \
src/core/ext/lb_policy/pick_first/pick_first.c \
src/core/ext/lb_policy/round_robin/round_robin.c \
src/core/ext/census/context.c \

@ -712,6 +712,7 @@
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
'src/core/ext/lb_policy/common.c',
'src/core/ext/lb_policy/pick_first/pick_first.c',
'src/core/ext/lb_policy/round_robin/round_robin.c',
'src/core/ext/resolver/dns/native/dns_resolver.c',

@ -356,6 +356,13 @@ filegroups:
- include/grpc/impl/codegen/status.h
uses:
- gpr_codegen
- name: grpc_lb_policy_common
headers:
- src/core/ext/lb_policy/common.h
src:
- src/core/ext/lb_policy/common.c
uses:
- grpc_base
- name: grpc_lb_policy_grpclb
headers:
- src/core/ext/lb_policy/grpclb/load_balancer_api.h
@ -367,6 +374,7 @@ filegroups:
- grpc_base
- grpc_client_config
- nanopb
- grpc_lb_policy_common
- name: grpc_lb_policy_pick_first
src:
- src/core/ext/lb_policy/pick_first/pick_first.c
@ -374,6 +382,7 @@ filegroups:
uses:
- grpc_base
- grpc_client_config
- grpc_lb_policy_common
- name: grpc_lb_policy_round_robin
src:
- src/core/ext/lb_policy/round_robin/round_robin.c
@ -381,6 +390,7 @@ filegroups:
uses:
- grpc_base
- grpc_client_config
- grpc_lb_policy_common
- name: grpc_resolver_dns_native
src:
- src/core/ext/resolver/dns/native/dns_resolver.c

@ -231,6 +231,7 @@ if test "$PHP_GRPC" != "no"; then
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
src/core/ext/lb_policy/common.c \
src/core/ext/lb_policy/pick_first/pick_first.c \
src/core/ext/lb_policy/round_robin/round_robin.c \
src/core/ext/resolver/dns/native/dns_resolver.c \
@ -552,6 +553,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/boringssl)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/census)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/client_config)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/lb_policy)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/lb_policy/grpclb)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/lb_policy/pick_first)

@ -291,6 +291,7 @@ Pod::Spec.new do |s|
'third_party/nanopb/pb_common.h',
'third_party/nanopb/pb_decode.h',
'third_party/nanopb/pb_encode.h',
'src/core/ext/lb_policy/common.h',
'src/core/ext/census/aggregation.h',
'src/core/ext/census/census_interface.h',
'src/core/ext/census/census_rpc_stats.h',
@ -476,6 +477,7 @@ Pod::Spec.new do |s|
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
'src/core/ext/lb_policy/common.c',
'src/core/ext/lb_policy/pick_first/pick_first.c',
'src/core/ext/lb_policy/round_robin/round_robin.c',
'src/core/ext/resolver/dns/native/dns_resolver.c',
@ -633,6 +635,7 @@ Pod::Spec.new do |s|
'third_party/nanopb/pb_common.h',
'third_party/nanopb/pb_decode.h',
'third_party/nanopb/pb_encode.h',
'src/core/ext/lb_policy/common.h',
'src/core/ext/census/aggregation.h',
'src/core/ext/census/census_interface.h',
'src/core/ext/census/census_rpc_stats.h',

@ -303,6 +303,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/nanopb/pb_common.h )
s.files += %w( third_party/nanopb/pb_decode.h )
s.files += %w( third_party/nanopb/pb_encode.h )
s.files += %w( src/core/ext/lb_policy/common.h )
s.files += %w( src/core/ext/census/aggregation.h )
s.files += %w( src/core/ext/census/census_interface.h )
s.files += %w( src/core/ext/census/census_rpc_stats.h )
@ -460,6 +461,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/nanopb/pb_common.c )
s.files += %w( third_party/nanopb/pb_decode.c )
s.files += %w( third_party/nanopb/pb_encode.c )
s.files += %w( src/core/ext/lb_policy/common.c )
s.files += %w( src/core/ext/lb_policy/pick_first/pick_first.c )
s.files += %w( src/core/ext/lb_policy/round_robin/round_robin.c )
s.files += %w( src/core/ext/resolver/dns/native/dns_resolver.c )

@ -306,6 +306,7 @@
<file baseinstalldir="/" name="third_party/nanopb/pb_common.h" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_decode.h" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_encode.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/common.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/aggregation.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/census_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/census_rpc_stats.h" role="src" />
@ -463,6 +464,7 @@
<file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_decode.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_encode.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/common.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/pick_first/pick_first.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/round_robin/round_robin.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/resolver/dns/native/dns_resolver.c" role="src" />

@ -368,9 +368,11 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp,
int r;
GRPC_LB_POLICY_REF(lb_policy, "cc_pick_subchannel");
gpr_mu_unlock(&chand->mu_config);
r = grpc_lb_policy_pick(exec_ctx, lb_policy, calld->pollset_set,
initial_metadata, initial_metadata_flags,
connected_subchannel, on_ready);
GPR_ASSERT((calld->pollset != NULL) + (calld->pollset_set != NULL) == 1);
r = grpc_lb_policy_pick(exec_ctx, lb_policy, calld->pollset,
calld->pollset_set, initial_metadata,
initial_metadata_flags, connected_subchannel,
on_ready);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "cc_pick_subchannel");
return r;
}
@ -453,14 +455,8 @@ static void cc_set_pollset_or_pollset_set(
GPR_ASSERT(pollset != NULL || pollset_set_alternative != NULL);
call_data *calld = elem->call_data;
if (pollset != NULL) {
calld->pollset = pollset;
grpc_pollset_set_add_pollset(exec_ctx, calld->pollset_set, pollset);
} else if (pollset_set_alternative != NULL) {
calld->pollset = NULL;
grpc_pollset_set_add_pollset_set(exec_ctx, calld->pollset_set,
pollset_set_alternative);
}
calld->pollset = pollset;
calld->pollset_set = pollset_set_alternative;
}
const grpc_channel_filter grpc_client_channel_filter = {

@ -99,12 +99,14 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
}
int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
grpc_pollset_set *pollset_set,
grpc_pollset *pollset,
grpc_pollset_set *pollset_set_alternative,
grpc_metadata_batch *initial_metadata,
uint32_t initial_metadata_flags,
grpc_connected_subchannel **target,
grpc_closure *on_complete) {
return policy->vtable->pick(exec_ctx, policy, pollset_set, initial_metadata,
return policy->vtable->pick(exec_ctx, policy, pollset,
pollset_set_alternative, initial_metadata,
initial_metadata_flags, target, on_complete);
}

@ -59,7 +59,7 @@ struct grpc_lb_policy_vtable {
/** implement grpc_lb_policy_pick */
int (*pick)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
grpc_pollset_set *pollset_set,
grpc_pollset *pollset, grpc_pollset_set *pollset_set_alternative,
grpc_metadata_batch *initial_metadata,
uint32_t initial_metadata_flags,
grpc_connected_subchannel **target, grpc_closure *on_complete);
@ -125,7 +125,8 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
\a target.
Picking can be asynchronous. Any IO should be done under \a pollset. */
int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
grpc_pollset_set *pollset_set,
grpc_pollset *pollset,
grpc_pollset_set *pollset_set_alternative,
grpc_metadata_batch *initial_metadata,
uint32_t initial_metadata_flags,
grpc_connected_subchannel **target,

@ -68,7 +68,7 @@ void grpc_subchannel_call_holder_init(
holder->waiting_ops_capacity = 0;
holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING;
holder->owning_call = owning_call;
holder->pollset_set = grpc_pollset_set_create();
holder->pollset_set = NULL;
}
void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx,
@ -82,7 +82,6 @@ void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx,
gpr_mu_destroy(&holder->mu);
GPR_ASSERT(holder->waiting_ops_count == 0);
gpr_free(holder->waiting_ops);
grpc_pollset_set_destroy(holder->pollset_set);
}
void grpc_subchannel_call_holder_perform_op(grpc_exec_ctx *exec_ctx,

@ -0,0 +1,62 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/support/log.h>
#include "src/core/ext/lb_policy/common.h"
void add_pollset_or_pollset_set_alternative(
grpc_exec_ctx *exec_ctx, grpc_pollset_set *interested_parties,
grpc_pollset *pollset, grpc_pollset_set *pollset_set_alternative) {
if (pollset != NULL) {
GPR_ASSERT(pollset_set_alternative == NULL);
grpc_pollset_set_add_pollset(exec_ctx, interested_parties, pollset);
} else {
GPR_ASSERT(pollset_set_alternative != NULL);
grpc_pollset_set_add_pollset_set(exec_ctx, interested_parties,
pollset_set_alternative);
}
}
void del_pollset_or_pollset_set_alternative(
grpc_exec_ctx *exec_ctx, grpc_pollset_set *interested_parties,
grpc_pollset *pollset, grpc_pollset_set *pollset_set_alternative) {
if (pollset != NULL) {
GPR_ASSERT(pollset_set_alternative == NULL);
grpc_pollset_set_del_pollset(exec_ctx, interested_parties, pollset);
} else {
GPR_ASSERT(pollset_set_alternative != NULL);
grpc_pollset_set_del_pollset_set(exec_ctx, interested_parties,
pollset_set_alternative);
}
}

@ -0,0 +1,48 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_LB_POLICY_COMMON_H
#define GRPC_CORE_EXT_LB_POLICY_COMMON_H
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_set.h"
void add_pollset_or_pollset_set_alternative(
grpc_exec_ctx *exec_ctx, grpc_pollset_set *interested_parties,
grpc_pollset *pollset, grpc_pollset_set *pollset_set_alternative);
void del_pollset_or_pollset_set_alternative(
grpc_exec_ctx *exec_ctx, grpc_pollset_set *interested_parties,
grpc_pollset *pollset, grpc_pollset_set *pollset_set_alternative);
#endif /* GRPC_CORE_EXT_LB_POLICY_COMMON_H */

@ -35,11 +35,13 @@
#include <grpc/support/alloc.h>
#include "src/core/ext/client_config/lb_policy_registry.h"
#include "src/core/ext/lb_policy/common.h"
#include "src/core/lib/transport/connectivity_state.h"
typedef struct pending_pick {
struct pending_pick *next;
grpc_pollset_set *pollset_set;
grpc_pollset *pollset;
grpc_pollset_set *pollset_set_alternative;
uint32_t initial_metadata_flags;
grpc_connected_subchannel **target;
grpc_closure *on_complete;
@ -118,8 +120,9 @@ static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
while (pp != NULL) {
pending_pick *next = pp->next;
*pp->target = NULL;
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(exec_ctx, p->base.interested_parties,
pp->pollset,
pp->pollset_set_alternative);
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
gpr_free(pp);
pp = next;
@ -136,8 +139,9 @@ static void pf_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
while (pp != NULL) {
pending_pick *next = pp->next;
if (pp->target == target) {
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(
exec_ctx, p->base.interested_parties, pp->pollset,
pp->pollset_set_alternative);
*target = NULL;
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
gpr_free(pp);
@ -162,8 +166,9 @@ static void pf_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
pending_pick *next = pp->next;
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(
exec_ctx, p->base.interested_parties, pp->pollset,
pp->pollset_set_alternative);
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
gpr_free(pp);
} else {
@ -196,7 +201,8 @@ static void pf_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
}
static int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_pollset_set *pollset_set,
grpc_pollset *pollset,
grpc_pollset_set *pollset_set_alternative,
grpc_metadata_batch *initial_metadata,
uint32_t initial_metadata_flags,
grpc_connected_subchannel **target,
@ -222,11 +228,12 @@ static int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
if (!p->started_picking) {
start_picking(exec_ctx, p);
}
grpc_pollset_set_add_pollset_set(exec_ctx, p->base.interested_parties,
pollset_set);
add_pollset_or_pollset_set_alternative(exec_ctx, p->base.interested_parties,
pollset, pollset_set_alternative);
pp = gpr_malloc(sizeof(*pp));
pp->next = p->pending_picks;
pp->pollset_set = pollset_set;
pp->pollset = pollset;
pp->pollset_set_alternative = pollset_set_alternative;
pp->target = target;
pp->initial_metadata_flags = initial_metadata_flags;
pp->on_complete = on_complete;
@ -306,8 +313,9 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
while ((pp = p->pending_picks)) {
p->pending_picks = pp->next;
*pp->target = selected;
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(
exec_ctx, p->base.interested_parties, pp->pollset,
pp->pollset_set_alternative);
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
gpr_free(pp);
}

@ -36,6 +36,7 @@
#include <grpc/support/alloc.h>
#include "src/core/ext/client_config/lb_policy_registry.h"
#include "src/core/ext/lb_policy/common.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/connectivity_state.h"
@ -48,7 +49,8 @@ int grpc_lb_round_robin_trace = 0;
* Once a pick is available, \a target is updated and \a on_complete called. */
typedef struct pending_pick {
struct pending_pick *next;
grpc_pollset_set *pollset_set;
grpc_pollset *pollset;
grpc_pollset_set *pollset_set_alternative;
uint32_t initial_metadata_flags;
grpc_connected_subchannel **target;
grpc_closure *on_complete;
@ -262,8 +264,9 @@ static void rr_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
while (pp != NULL) {
pending_pick *next = pp->next;
if (pp->target == target) {
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(
exec_ctx, p->base.interested_parties, pp->pollset,
pp->pollset_set_alternative);
*target = NULL;
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
gpr_free(pp);
@ -288,8 +291,9 @@ static void rr_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
pending_pick *next = pp->next;
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(
exec_ctx, p->base.interested_parties, pp->pollset,
pp->pollset_set_alternative);
*pp->target = NULL;
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
gpr_free(pp);
@ -329,7 +333,8 @@ static void rr_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
}
static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_pollset_set *pollset_set,
grpc_pollset *pollset,
grpc_pollset_set *pollset_set_alternative,
grpc_metadata_batch *initial_metadata,
uint32_t initial_metadata_flags,
grpc_connected_subchannel **target,
@ -353,11 +358,12 @@ static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
if (!p->started_picking) {
start_picking(exec_ctx, p);
}
grpc_pollset_set_add_pollset_set(exec_ctx, p->base.interested_parties,
pollset_set);
add_pollset_or_pollset_set_alternative(exec_ctx, p->base.interested_parties,
pollset, pollset_set_alternative);
pp = gpr_malloc(sizeof(*pp));
pp->next = p->pending_picks;
pp->pollset_set = pollset_set;
pp->pollset = pollset;
pp->pollset_set_alternative = pollset_set_alternative;
pp->target = target;
pp->on_complete = on_complete;
pp->initial_metadata_flags = initial_metadata_flags;
@ -406,8 +412,9 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
"[RR CONN CHANGED] TARGET <-- SUBCHANNEL %p (NODE %p)",
selected->subchannel, selected);
}
grpc_pollset_set_del_pollset_set(exec_ctx, p->base.interested_parties,
pp->pollset_set);
del_pollset_or_pollset_set_alternative(
exec_ctx, p->base.interested_parties, pp->pollset,
pp->pollset_set_alternative);
grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
gpr_free(pp);
}

@ -225,6 +225,7 @@ CORE_SOURCE_FILES = [
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
'src/core/ext/lb_policy/common.c',
'src/core/ext/lb_policy/pick_first/pick_first.c',
'src/core/ext/lb_policy/round_robin/round_robin.c',
'src/core/ext/resolver/dns/native/dns_resolver.c',

@ -918,6 +918,7 @@ third_party/nanopb/pb.h \
third_party/nanopb/pb_common.h \
third_party/nanopb/pb_decode.h \
third_party/nanopb/pb_encode.h \
src/core/ext/lb_policy/common.h \
src/core/ext/census/aggregation.h \
src/core/ext/census/census_interface.h \
src/core/ext/census/census_rpc_stats.h \
@ -1075,6 +1076,7 @@ src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
src/core/ext/lb_policy/common.c \
src/core/ext/lb_policy/pick_first/pick_first.c \
src/core/ext/lb_policy/round_robin/round_robin.c \
src/core/ext/resolver/dns/native/dns_resolver.c \

@ -5851,11 +5851,29 @@
"third_party": false,
"type": "filegroup"
},
{
"deps": [
"gpr",
"grpc_base"
],
"headers": [
"src/core/ext/lb_policy/common.h"
],
"language": "c",
"name": "grpc_lb_policy_common",
"src": [
"src/core/ext/lb_policy/common.c",
"src/core/ext/lb_policy/common.h"
],
"third_party": false,
"type": "filegroup"
},
{
"deps": [
"gpr",
"grpc_base",
"grpc_client_config",
"grpc_lb_policy_common",
"nanopb"
],
"headers": [
@ -5877,7 +5895,8 @@
"deps": [
"gpr",
"grpc_base",
"grpc_client_config"
"grpc_client_config",
"grpc_lb_policy_common"
],
"headers": [],
"language": "c",
@ -5892,7 +5911,8 @@
"deps": [
"gpr",
"grpc_base",
"grpc_client_config"
"grpc_client_config",
"grpc_lb_policy_common"
],
"headers": [],
"language": "c",

@ -427,6 +427,7 @@
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_common.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_decode.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_rpc_stats.h" />
@ -737,6 +738,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.c">

@ -454,6 +454,9 @@
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.c">
<Filter>third_party\nanopb</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.c">
<Filter>src\core\ext\lb_policy</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.c">
<Filter>src\core\ext\lb_policy\pick_first</Filter>
</ClCompile>
@ -974,6 +977,9 @@
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.h">
<Filter>third_party\nanopb</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.h">
<Filter>src\core\ext\lb_policy</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h">
<Filter>src\core\ext\census</Filter>
</ClInclude>

@ -402,6 +402,7 @@
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_common.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_decode.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_rpc_stats.h" />
@ -676,6 +677,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.c">

@ -400,6 +400,9 @@
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.c">
<Filter>third_party\nanopb</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.c">
<Filter>src\core\ext\lb_policy</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.c">
<Filter>src\core\ext\lb_policy\pick_first</Filter>
</ClCompile>
@ -866,6 +869,9 @@
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.h">
<Filter>third_party\nanopb</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\common.h">
<Filter>src\core\ext\lb_policy</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h">
<Filter>src\core\ext\census</Filter>
</ClInclude>

Loading…
Cancel
Save