aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.cc2
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.h4
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.h5
-rw-r--r--src/core/ext/filters/client_channel/parse_address.cc29
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc36
-rw-r--r--src/core/ext/filters/client_channel/subchannel.h15
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.cc32
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.h3
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc10
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc44
-rw-r--r--src/core/lib/iomgr/grpc_if_nametoindex.h30
-rw-r--r--src/core/lib/iomgr/grpc_if_nametoindex_posix.cc42
-rw-r--r--src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc38
-rw-r--r--src/core/lib/iomgr/port.h1
-rw-r--r--src/core/lib/surface/channel_init.h5
-rw-r--r--src/cpp/common/channel_filter.h5
-rw-r--r--src/python/grpcio/grpc/__init__.py2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi2
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py2
-rw-r--r--src/ruby/ext/grpc/rb_channel.c8
20 files changed, 192 insertions, 123 deletions
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.cc b/src/core/ext/filters/client_channel/client_channel_factory.cc
index 172e9f03c7..130bbe0418 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.cc
+++ b/src/core/ext/filters/client_channel/client_channel_factory.cc
@@ -30,7 +30,7 @@ void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory) {
}
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_client_channel_factory* factory, const grpc_subchannel_args* args) {
+ grpc_client_channel_factory* factory, const grpc_channel_args* args) {
return factory->vtable->create_subchannel(factory, args);
}
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h
index 601ec46b2a..91dec12282 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.h
+++ b/src/core/ext/filters/client_channel/client_channel_factory.h
@@ -49,7 +49,7 @@ struct grpc_client_channel_factory_vtable {
void (*ref)(grpc_client_channel_factory* factory);
void (*unref)(grpc_client_channel_factory* factory);
grpc_subchannel* (*create_subchannel)(grpc_client_channel_factory* factory,
- const grpc_subchannel_args* args);
+ const grpc_channel_args* args);
grpc_channel* (*create_client_channel)(grpc_client_channel_factory* factory,
const char* target,
grpc_client_channel_type type,
@@ -61,7 +61,7 @@ void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory);
/** Create a new grpc_subchannel */
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_client_channel_factory* factory, const grpc_subchannel_args* args);
+ grpc_client_channel_factory* factory, const grpc_channel_args* args);
/** Create a new grpc_channel */
grpc_channel* grpc_client_channel_factory_create_channel(
diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
index 6f31a643c1..1d0ecbe3f6 100644
--- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
+++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
@@ -509,12 +509,10 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
GRPC_ARG_SERVER_ADDRESS_LIST,
GRPC_ARG_INHIBIT_HEALTH_CHECKING};
// Create a subchannel for each address.
- grpc_subchannel_args sc_args;
for (size_t i = 0; i < addresses.size(); i++) {
// If there were any balancer addresses, we would have chosen grpclb
// policy, which does not use a SubchannelList.
GPR_ASSERT(!addresses[i].IsBalancer());
- memset(&sc_args, 0, sizeof(grpc_subchannel_args));
InlinedVector<grpc_arg, 4> args_to_add;
args_to_add.emplace_back(
grpc_create_subchannel_address_arg(&addresses[i].address()));
@@ -527,9 +525,8 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
&args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove),
args_to_add.data(), args_to_add.size());
gpr_free(args_to_add[0].value.string);
- sc_args.args = new_args;
grpc_subchannel* subchannel = grpc_client_channel_factory_create_subchannel(
- client_channel_factory, &sc_args);
+ client_channel_factory, new_args);
grpc_channel_args_destroy(new_args);
if (subchannel == nullptr) {
// Subchannel could not be created.
diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc
index 707beb8876..c5e1ed811b 100644
--- a/src/core/ext/filters/client_channel/parse_address.cc
+++ b/src/core/ext/filters/client_channel/parse_address.cc
@@ -19,6 +19,7 @@
#include <grpc/support/port_platform.h>
#include "src/core/ext/filters/client_channel/parse_address.h"
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils.h"
@@ -35,6 +36,11 @@
#include "src/core/lib/gpr/host_port.h"
#include "src/core/lib/gpr/string.h"
+#ifdef GRPC_POSIX_SOCKET
+#include <errno.h>
+#include <net/if.h>
+#endif
+
#ifdef GRPC_HAVE_UNIX_SOCKET
bool grpc_parse_unix(const grpc_uri* uri,
@@ -69,7 +75,12 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
// Split host and port.
char* host;
char* port;
- if (!gpr_split_host_port(hostport, &host, &port)) return false;
+ if (!gpr_split_host_port(hostport, &host, &port)) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
+ }
+ return false;
+ }
// Parse IP address.
memset(addr, 0, sizeof(*addr));
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in));
@@ -115,7 +126,12 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
// Split host and port.
char* host;
char* port;
- if (!gpr_split_host_port(hostport, &host, &port)) return false;
+ if (!gpr_split_host_port(hostport, &host, &port)) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
+ }
+ return false;
+ }
// Parse IP address.
memset(addr, 0, sizeof(*addr));
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in6));
@@ -150,10 +166,13 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
if (gpr_parse_bytes_to_uint32(host_end + 1,
strlen(host) - host_without_scope_len - 1,
&sin6_scope_id) == 0) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1);
+ if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) {
+ gpr_log(GPR_ERROR,
+ "Invalid interface name: '%s'. "
+ "Non-numeric and failed if_nametoindex.",
+ host_end + 1);
+ goto done;
}
- goto done;
}
// Handle "sin6_scope_id" being type "u_long". See grpc issue #10027.
in6->sin6_scope_id = sin6_scope_id;
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index 9077aa9753..640a052e91 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -64,18 +64,6 @@
#define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120
#define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2
-namespace {
-struct state_watcher {
- grpc_closure closure;
- grpc_subchannel* subchannel;
- grpc_connectivity_state connectivity_state;
- grpc_connectivity_state last_connectivity_state;
- grpc_core::OrphanablePtr<grpc_core::HealthCheckClient> health_check_client;
- grpc_closure health_check_closure;
- grpc_connectivity_state health_state;
-};
-} // namespace
-
typedef struct external_state_watcher {
grpc_subchannel* subchannel;
grpc_pollset_set* pollset_set;
@@ -101,9 +89,6 @@ struct grpc_subchannel {
keep the subchannel open */
gpr_atm ref_pair;
- /** non-transport related channel filters */
- const grpc_channel_filter** filters;
- size_t num_filters;
/** channel arguments */
grpc_channel_args* args;
@@ -384,7 +369,6 @@ static void subchannel_destroy(void* arg, grpc_error* error) {
c->channelz_subchannel->MarkSubchannelDestroyed();
c->channelz_subchannel.reset();
}
- gpr_free((void*)c->filters);
c->health_check_service_name.reset();
grpc_channel_args_destroy(c->args);
grpc_connectivity_state_destroy(&c->state_tracker);
@@ -553,7 +537,7 @@ struct HealthCheckParams {
} // namespace grpc_core
grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
- const grpc_subchannel_args* args) {
+ const grpc_channel_args* args) {
grpc_subchannel_key* key = grpc_subchannel_key_create(args);
grpc_subchannel* c = grpc_subchannel_index_find(key);
if (c) {
@@ -567,23 +551,13 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS);
c->connector = connector;
grpc_connector_ref(c->connector);
- c->num_filters = args->filter_count;
- if (c->num_filters > 0) {
- c->filters = static_cast<const grpc_channel_filter**>(
- gpr_malloc(sizeof(grpc_channel_filter*) * c->num_filters));
- memcpy((void*)c->filters, args->filters,
- sizeof(grpc_channel_filter*) * c->num_filters);
- } else {
- c->filters = nullptr;
- }
c->pollset_set = grpc_pollset_set_create();
grpc_resolved_address* addr =
static_cast<grpc_resolved_address*>(gpr_malloc(sizeof(*addr)));
- grpc_get_subchannel_address_arg(args->args, addr);
+ grpc_get_subchannel_address_arg(args, addr);
grpc_resolved_address* new_address = nullptr;
grpc_channel_args* new_args = nullptr;
- if (grpc_proxy_mappers_map_address(addr, args->args, &new_address,
- &new_args)) {
+ if (grpc_proxy_mappers_map_address(addr, args, &new_address, &new_args)) {
GPR_ASSERT(new_address != nullptr);
gpr_free(addr);
addr = new_address;
@@ -592,7 +566,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
grpc_arg new_arg = grpc_create_subchannel_address_arg(addr);
gpr_free(addr);
c->args = grpc_channel_args_copy_and_add_and_remove(
- new_args != nullptr ? new_args : args->args, keys_to_remove,
+ new_args != nullptr ? new_args : args, keys_to_remove,
GPR_ARRAY_SIZE(keys_to_remove), &new_arg, 1);
gpr_free(new_arg.value.string);
if (new_args != nullptr) grpc_channel_args_destroy(new_args);
@@ -605,7 +579,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
grpc_connectivity_state_init(&c->state_and_health_tracker, GRPC_CHANNEL_IDLE,
"subchannel");
grpc_core::BackOff::Options backoff_options;
- parse_args_for_backoff_values(args->args, &backoff_options,
+ parse_args_for_backoff_values(args, &backoff_options,
&c->min_connect_timeout_ms);
c->backoff.Init(backoff_options);
gpr_mu_init(&c->mu);
diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h
index 14f87f2c68..8c994c64f5 100644
--- a/src/core/ext/filters/client_channel/subchannel.h
+++ b/src/core/ext/filters/client_channel/subchannel.h
@@ -38,7 +38,6 @@
address. Provides a target for load balancing. */
typedef struct grpc_subchannel grpc_subchannel;
typedef struct grpc_subchannel_call grpc_subchannel_call;
-typedef struct grpc_subchannel_args grpc_subchannel_args;
typedef struct grpc_subchannel_key grpc_subchannel_key;
#ifndef NDEBUG
@@ -186,21 +185,9 @@ void grpc_subchannel_call_set_cleanup_closure(
grpc_call_stack* grpc_subchannel_call_get_call_stack(
grpc_subchannel_call* subchannel_call);
-struct grpc_subchannel_args {
- /* When updating this struct, also update subchannel_index.c */
-
- /** Channel filters for this channel - wrapped factories will likely
- want to mutate this */
- const grpc_channel_filter** filters;
- /** The number of filters in the above array */
- size_t filter_count;
- /** Channel arguments to be supplied to the newly created channel */
- const grpc_channel_args* args;
-};
-
/** create a subchannel given a connector */
grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
- const grpc_subchannel_args* args);
+ const grpc_channel_args* args);
/// Sets \a addr from \a args.
void grpc_get_subchannel_address_arg(const grpc_channel_args* args,
diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc
index aa8441f17b..d0ceda8312 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.cc
+++ b/src/core/ext/filters/client_channel/subchannel_index.cc
@@ -39,55 +39,37 @@ static gpr_mu g_mu;
static gpr_refcount g_refcount;
struct grpc_subchannel_key {
- grpc_subchannel_args args;
+ grpc_channel_args* args;
};
static bool g_force_creation = false;
static grpc_subchannel_key* create_key(
- const grpc_subchannel_args* args,
+ const grpc_channel_args* args,
grpc_channel_args* (*copy_channel_args)(const grpc_channel_args* args)) {
grpc_subchannel_key* k =
static_cast<grpc_subchannel_key*>(gpr_malloc(sizeof(*k)));
- k->args.filter_count = args->filter_count;
- if (k->args.filter_count > 0) {
- k->args.filters = static_cast<const grpc_channel_filter**>(
- gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count));
- memcpy(reinterpret_cast<grpc_channel_filter*>(k->args.filters),
- args->filters, sizeof(*k->args.filters) * k->args.filter_count);
- } else {
- k->args.filters = nullptr;
- }
- k->args.args = copy_channel_args(args->args);
+ k->args = copy_channel_args(args);
return k;
}
-grpc_subchannel_key* grpc_subchannel_key_create(
- const grpc_subchannel_args* args) {
+grpc_subchannel_key* grpc_subchannel_key_create(const grpc_channel_args* args) {
return create_key(args, grpc_channel_args_normalize);
}
static grpc_subchannel_key* subchannel_key_copy(grpc_subchannel_key* k) {
- return create_key(&k->args, grpc_channel_args_copy);
+ return create_key(k->args, grpc_channel_args_copy);
}
int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
const grpc_subchannel_key* b) {
// To pretend the keys are different, return a non-zero value.
if (GPR_UNLIKELY(g_force_creation)) return 1;
- int c = GPR_ICMP(a->args.filter_count, b->args.filter_count);
- if (c != 0) return c;
- if (a->args.filter_count > 0) {
- c = memcmp(a->args.filters, b->args.filters,
- a->args.filter_count * sizeof(*a->args.filters));
- if (c != 0) return c;
- }
- return grpc_channel_args_compare(a->args.args, b->args.args);
+ return grpc_channel_args_compare(a->args, b->args);
}
void grpc_subchannel_key_destroy(grpc_subchannel_key* k) {
- gpr_free(reinterpret_cast<grpc_channel_args*>(k->args.filters));
- grpc_channel_args_destroy(const_cast<grpc_channel_args*>(k->args.args));
+ grpc_channel_args_destroy(k->args);
gpr_free(k);
}
diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h
index c135613d26..429634bd54 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.h
+++ b/src/core/ext/filters/client_channel/subchannel_index.h
@@ -27,8 +27,7 @@
shared amongst channels */
/** Create a key that can be used to uniquely identify a subchannel */
-grpc_subchannel_key* grpc_subchannel_key_create(
- const grpc_subchannel_args* args);
+grpc_subchannel_key* grpc_subchannel_key_create(const grpc_channel_args* args);
/** Destroy a subchannel key */
void grpc_subchannel_key_destroy(grpc_subchannel_key* key);
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index e6c8c38260..a5bf1bf21d 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -40,14 +40,12 @@ static void client_channel_factory_unref(
grpc_client_channel_factory* cc_factory) {}
static grpc_subchannel* client_channel_factory_create_subchannel(
- grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
- grpc_subchannel_args final_sc_args;
- memcpy(&final_sc_args, args, sizeof(*args));
- final_sc_args.args = grpc_default_authority_add_if_not_present(args->args);
+ grpc_client_channel_factory* cc_factory, const grpc_channel_args* args) {
+ grpc_channel_args* new_args = grpc_default_authority_add_if_not_present(args);
grpc_connector* connector = grpc_chttp2_connector_create();
- grpc_subchannel* s = grpc_subchannel_create(connector, &final_sc_args);
+ grpc_subchannel* s = grpc_subchannel_create(connector, new_args);
grpc_connector_unref(connector);
- grpc_channel_args_destroy(const_cast<grpc_channel_args*>(final_sc_args.args));
+ grpc_channel_args_destroy(new_args);
return s;
}
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index 9612698e96..ddd538faa8 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -46,10 +46,10 @@ static void client_channel_factory_ref(
static void client_channel_factory_unref(
grpc_client_channel_factory* cc_factory) {}
-static grpc_subchannel_args* get_secure_naming_subchannel_args(
- const grpc_subchannel_args* args) {
+static grpc_channel_args* get_secure_naming_channel_args(
+ const grpc_channel_args* args) {
grpc_channel_credentials* channel_credentials =
- grpc_channel_credentials_find_in_args(args->args);
+ grpc_channel_credentials_find_in_args(args);
if (channel_credentials == nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: channel credentials missing for secure "
@@ -57,7 +57,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
return nullptr;
}
// Make sure security connector does not already exist in args.
- if (grpc_security_connector_find_in_args(args->args) != nullptr) {
+ if (grpc_security_connector_find_in_args(args) != nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: security connector already present in "
"channel args.");
@@ -65,19 +65,18 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
}
// To which address are we connecting? By default, use the server URI.
const grpc_arg* server_uri_arg =
- grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
+ grpc_channel_args_find(args, GRPC_ARG_SERVER_URI);
const char* server_uri_str = grpc_channel_arg_get_string(server_uri_arg);
GPR_ASSERT(server_uri_str != nullptr);
grpc_uri* server_uri =
grpc_uri_parse(server_uri_str, true /* supress errors */);
GPR_ASSERT(server_uri != nullptr);
const grpc_core::TargetAuthorityTable* target_authority_table =
- grpc_core::FindTargetAuthorityTableInArgs(args->args);
+ grpc_core::FindTargetAuthorityTableInArgs(args);
grpc_core::UniquePtr<char> authority;
if (target_authority_table != nullptr) {
// Find the authority for the target.
- const char* target_uri_str =
- grpc_get_subchannel_address_uri_arg(args->args);
+ const char* target_uri_str = grpc_get_subchannel_address_uri_arg(args);
grpc_uri* target_uri =
grpc_uri_parse(target_uri_str, false /* suppress errors */);
GPR_ASSERT(target_uri != nullptr);
@@ -100,15 +99,14 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
}
grpc_arg args_to_add[2];
size_t num_args_to_add = 0;
- if (grpc_channel_args_find(args->args, GRPC_ARG_DEFAULT_AUTHORITY) ==
- nullptr) {
+ if (grpc_channel_args_find(args, GRPC_ARG_DEFAULT_AUTHORITY) == nullptr) {
// If the channel args don't already contain GRPC_ARG_DEFAULT_AUTHORITY, add
// the arg, setting it to the value just obtained.
args_to_add[num_args_to_add++] = grpc_channel_arg_string_create(
const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY), authority.get());
}
grpc_channel_args* args_with_authority =
- grpc_channel_args_copy_and_add(args->args, args_to_add, num_args_to_add);
+ grpc_channel_args_copy_and_add(args, args_to_add, num_args_to_add);
grpc_uri_destroy(server_uri);
// Create the security connector using the credentials and target name.
grpc_channel_args* new_args_from_connector = nullptr;
@@ -137,29 +135,21 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_channel_args_destroy(new_args_from_connector);
}
grpc_channel_args_destroy(args_with_authority);
- grpc_subchannel_args* final_sc_args =
- static_cast<grpc_subchannel_args*>(gpr_malloc(sizeof(*final_sc_args)));
- memcpy(final_sc_args, args, sizeof(*args));
- final_sc_args->args = new_args;
- return final_sc_args;
+ return new_args;
}
static grpc_subchannel* client_channel_factory_create_subchannel(
- grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
- grpc_subchannel_args* subchannel_args =
- get_secure_naming_subchannel_args(args);
- if (subchannel_args == nullptr) {
- gpr_log(
- GPR_ERROR,
- "Failed to create subchannel arguments during subchannel creation.");
+ grpc_client_channel_factory* cc_factory, const grpc_channel_args* args) {
+ grpc_channel_args* new_args = get_secure_naming_channel_args(args);
+ if (new_args == nullptr) {
+ gpr_log(GPR_ERROR,
+ "Failed to create channel args during subchannel creation.");
return nullptr;
}
grpc_connector* connector = grpc_chttp2_connector_create();
- grpc_subchannel* s = grpc_subchannel_create(connector, subchannel_args);
+ grpc_subchannel* s = grpc_subchannel_create(connector, new_args);
grpc_connector_unref(connector);
- grpc_channel_args_destroy(
- const_cast<grpc_channel_args*>(subchannel_args->args));
- gpr_free(subchannel_args);
+ grpc_channel_args_destroy(new_args);
return s;
}
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex.h b/src/core/lib/iomgr/grpc_if_nametoindex.h
new file mode 100644
index 0000000000..ed9612dcb9
--- /dev/null
+++ b/src/core/lib/iomgr/grpc_if_nametoindex.h
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2015 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H
+#define GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H
+
+#include <grpc/support/port_platform.h>
+
+#include <stddef.h>
+
+/* Returns the interface index corresponding to the interface "name" provided.
+ * Returns non-zero upon success, and zero upon failure. */
+uint32_t grpc_if_nametoindex(char* name);
+
+#endif /* GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H */
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
new file mode 100644
index 0000000000..f1ba20dcec
--- /dev/null
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#if GRPC_IF_NAMETOINDEX == 1 && defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
+
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
+
+#include <errno.h>
+#include <net/if.h>
+
+#include <grpc/support/log.h>
+
+uint32_t grpc_if_nametoindex(char* name) {
+ uint32_t out = if_nametoindex(name);
+ if (out == 0) {
+ gpr_log(GPR_DEBUG, "if_nametoindex failed for name %s. errno %d", name,
+ errno);
+ }
+ return out;
+}
+
+#endif /* GRPC_IF_NAMETOINDEX == 1 && \
+ defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) */
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc b/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
new file mode 100644
index 0000000000..08644cccf3
--- /dev/null
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#if GRPC_IF_NAMETOINDEX == 0 || !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
+
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
+
+#include <grpc/support/log.h>
+
+uint32_t grpc_if_nametoindex(char* name) {
+ gpr_log(GPR_DEBUG,
+ "Not attempting to convert interface name %s to index for current "
+ "platform.",
+ name);
+ return 0;
+}
+
+#endif /* GRPC_IF_NAMETOINDEX == 0 || \
+ !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) */
diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h
index c8046b21dc..7b6ca1bc0e 100644
--- a/src/core/lib/iomgr/port.h
+++ b/src/core/lib/iomgr/port.h
@@ -184,6 +184,7 @@
#define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
#define GRPC_POSIX_SOCKET_EV_POLL 1
#define GRPC_POSIX_SOCKET_EV_EPOLL1 1
+#define GRPC_POSIX_SOCKET_IF_NAMETOINDEX 1
#define GRPC_POSIX_SOCKET_IOMGR 1
#define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
#define GRPC_POSIX_SOCKET_SOCKADDR 1
diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h
index f01852473b..d17a721606 100644
--- a/src/core/lib/surface/channel_init.h
+++ b/src/core/lib/surface/channel_init.h
@@ -45,6 +45,11 @@ void grpc_channel_init_init(void);
/// registration order (in the case of a tie).
/// Stages are registered against one of the pre-determined channel stack
/// types.
+/// If the channel stack type is GRPC_CLIENT_SUBCHANNEL, the caller should
+/// ensure that subchannels with different filter lists will always have
+/// different channel args. This requires setting a channel arg in case the
+/// registration function relies on some condition other than channel args to
+/// decide whether to add a filter or not.
void grpc_channel_init_register_stage(grpc_channel_stack_type type,
int priority,
grpc_channel_init_stage stage_fn,
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index 5e569c97e6..1a3295fc80 100644
--- a/src/cpp/common/channel_filter.h
+++ b/src/cpp/common/channel_filter.h
@@ -366,6 +366,11 @@ void ChannelFilterPluginShutdown();
/// The \a include_filter argument specifies a function that will be called
/// to determine at run-time whether or not to add the filter. If the
/// value is nullptr, the filter will be added unconditionally.
+/// If the channel stack type is GRPC_CLIENT_SUBCHANNEL, the caller should
+/// ensure that subchannels with different filter lists will always have
+/// different channel args. This requires setting a channel arg in case the
+/// registration function relies on some condition other than channel args to
+/// decide whether to add a filter or not.
template <typename ChannelDataType, typename CallDataType>
void RegisterChannelFilter(
const char* name, grpc_channel_stack_type stack_type, int priority,
diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py
index 70d7618e05..8613bc501f 100644
--- a/src/python/grpcio/grpc/__init__.py
+++ b/src/python/grpcio/grpc/__init__.py
@@ -24,7 +24,7 @@ from grpc._cython import cygrpc as _cygrpc
logging.getLogger(__name__).addHandler(logging.NullHandler())
try:
- from ._grpcio_metadata import __version__
+ from grpc._grpcio_metadata import __version__
except ImportError:
__version__ = "dev0"
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
index d72648a35d..ef74f61e04 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
@@ -149,6 +149,6 @@ cdef class Server:
grpc_server_destroy(self.c_server)
self.c_server = NULL
- def __dealloc(self):
+ def __dealloc__(self):
if self.c_server == NULL:
grpc_shutdown()
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 6a1fd676ca..06de23903c 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -102,6 +102,8 @@ CORE_SOURCE_FILES = [
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c
index 6d4b2293a2..5bde962f78 100644
--- a/src/ruby/ext/grpc/rb_channel.c
+++ b/src/ruby/ext/grpc/rb_channel.c
@@ -153,7 +153,7 @@ static void grpc_rb_channel_free(void* p) {
if (ch->bg_wrapped != NULL) {
/* assumption made here: it's ok to directly gpr_mu_lock the global
- * connection polling mutex becuse we're in a finalizer,
+ * connection polling mutex because we're in a finalizer,
* and we can count on this thread to not be interrupted or
* yield the gil. */
grpc_rb_channel_safe_destroy(ch->bg_wrapped);
@@ -292,7 +292,7 @@ static void* get_state_without_gil(void* arg) {
Indicates the current state of the channel, whose value is one of the
constants defined in GRPC::Core::ConnectivityStates.
- It also tries to connect if the chennel is idle in the second form. */
+ It also tries to connect if the channel is idle in the second form. */
static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
VALUE self) {
VALUE try_to_connect_param = Qfalse;
@@ -327,8 +327,8 @@ static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
void* success = (void*)0;
gpr_mu_lock(&global_connection_polling_mu);
- // its unsafe to do a "watch" after "channel polling abort" because the cq has
- // been shut down.
+ // it's unsafe to do a "watch" after "channel polling abort" because the cq
+ // has been shut down.
if (abort_channel_polling || stack->bg_wrapped->channel_destroyed) {
gpr_mu_unlock(&global_connection_polling_mu);
return (void*)0;