From a6124120ae5ece38d39ebb0178c5877e5f940e80 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 5 Nov 2015 22:36:20 -0800 Subject: first part, secure channel only --- src/core/client_config/connector.h | 2 + .../client_config/default_initial_connect_string.c | 40 ++++++++++++++++ src/core/client_config/initial_connect_string.c | 53 ++++++++++++++++++++++ src/core/client_config/initial_connect_string.h | 51 +++++++++++++++++++++ src/core/client_config/subchannel.c | 7 +++ 5 files changed, 153 insertions(+) create mode 100644 src/core/client_config/default_initial_connect_string.c create mode 100644 src/core/client_config/initial_connect_string.c create mode 100644 src/core/client_config/initial_connect_string.h (limited to 'src/core/client_config') diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h index e9b8be4b53..a649f143ae 100644 --- a/src/core/client_config/connector.h +++ b/src/core/client_config/connector.h @@ -51,6 +51,8 @@ typedef struct { /** address to connect to */ const struct sockaddr *addr; size_t addr_len; + /** initial connect string to send */ + gpr_slice initial_connect_string; /** deadline for connection */ gpr_timespec deadline; /** channel arguments (to be passed to transport) */ diff --git a/src/core/client_config/default_initial_connect_string.c b/src/core/client_config/default_initial_connect_string.c new file mode 100644 index 0000000000..fa49d0d6fb --- /dev/null +++ b/src/core/client_config/default_initial_connect_string.c @@ -0,0 +1,40 @@ +/* + * + * Copyright 2015, 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 + +#include + +void grpc_set_default_initial_connect_string(struct sockaddr **addr, + size_t *addr_len, + gpr_slice *initial_str) {} diff --git a/src/core/client_config/initial_connect_string.c b/src/core/client_config/initial_connect_string.c new file mode 100644 index 0000000000..19afa1675a --- /dev/null +++ b/src/core/client_config/initial_connect_string.c @@ -0,0 +1,53 @@ +/* + * + * Copyright 2015, 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 "src/core/client_config/initial_connect_string.h" + +#include + +extern void grpc_set_default_initial_connect_string(struct sockaddr **addr, + size_t *addr_len, + gpr_slice *initial_str); + +static grpc_set_initial_connect_string_func g_set_initial_connect_string_func = + grpc_set_default_initial_connect_string; + +void grpc_test_set_initial_connect_string_function( + grpc_set_initial_connect_string_func func) { + g_set_initial_connect_string_func = func; +} + +void grpc_set_initial_connect_string(struct sockaddr **addr, size_t *addr_len, + gpr_slice *initial_str) { + g_set_initial_connect_string_func(addr, addr_len, initial_str); +} diff --git a/src/core/client_config/initial_connect_string.h b/src/core/client_config/initial_connect_string.h new file mode 100644 index 0000000000..64da9cc971 --- /dev/null +++ b/src/core/client_config/initial_connect_string.h @@ -0,0 +1,51 @@ +/* + * + * Copyright 2015, 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_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H + +#include + +#include + +typedef void (*grpc_set_initial_connect_string_func)(struct sockaddr **addr, + size_t *addr_len, + gpr_slice *initial_str); +void grpc_test_set_initial_connect_string_function( + grpc_set_initial_connect_string_func func); + +/** Set a string to be sent once connected. Optionally reset addr. */ +void grpc_set_initial_connect_string(struct sockaddr **addr, size_t *addr_len, + gpr_slice *connect_string); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H */ diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 0401dd3868..f13bc0736e 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -40,6 +40,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/client_channel.h" #include "src/core/channel/connected_channel.h" +#include "src/core/client_config/initial_connect_string.h" #include "src/core/iomgr/timer.h" #include "src/core/transport/connectivity_state.h" #include "src/core/surface/channel.h" @@ -85,6 +86,8 @@ struct grpc_subchannel { /** address to connect to */ struct sockaddr *addr; size_t addr_len; + /** initial string to send to peer */ + gpr_slice initial_connect_string; /** metadata context */ grpc_mdctx *mdctx; /** master channel - the grpc_channel instance that ultimately owns @@ -261,6 +264,7 @@ static void subchannel_destroy(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { gpr_free((void *)c->filters); grpc_channel_args_destroy(c->args); gpr_free(c->addr); + gpr_slice_unref(c->initial_connect_string); grpc_mdctx_unref(c->mdctx); grpc_connectivity_state_destroy(exec_ctx, &c->state_tracker); grpc_connector_unref(exec_ctx, c->connector); @@ -299,6 +303,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, c->addr = gpr_malloc(args->addr_len); memcpy(c->addr, args->addr, args->addr_len); c->addr_len = args->addr_len; + grpc_set_initial_connect_string(&c->addr, &c->addr_len, + &c->initial_connect_string); c->args = grpc_channel_args_copy(args->args); c->mdctx = args->mdctx; c->master = args->master; @@ -343,6 +349,7 @@ static void continue_connect(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { args.addr_len = c->addr_len; args.deadline = compute_connect_deadline(c); args.channel_args = c->args; + args.initial_connect_string = c->initial_connect_string; grpc_connector_connect(exec_ctx, c->connector, &args, &c->connecting_result, &c->connected); -- cgit v1.2.3 From 30e1727583538401b05e15e61930af396d391704 Mon Sep 17 00:00:00 2001 From: yang-g Date: Sat, 7 Nov 2015 01:11:12 -0800 Subject: msan and windows fix --- src/core/client_config/initial_connect_string.h | 3 +-- src/core/iomgr/pollset_posix.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/client_config') diff --git a/src/core/client_config/initial_connect_string.h b/src/core/client_config/initial_connect_string.h index 64da9cc971..b6dca7134a 100644 --- a/src/core/client_config/initial_connect_string.h +++ b/src/core/client_config/initial_connect_string.h @@ -34,9 +34,8 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H -#include - #include +#include "src/core/iomgr/sockaddr.h" typedef void (*grpc_set_initial_connect_string_func)(struct sockaddr **addr, size_t *addr_len, diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 6f478ccacb..a8e620ea1e 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -194,6 +194,7 @@ void grpc_pollset_init(grpc_pollset *pollset) { pollset->in_flight_cbs = 0; pollset->shutting_down = 0; pollset->called_shutdown = 0; + pollset->kicked_without_pollers = 0; pollset->idle_jobs.head = pollset->idle_jobs.tail = NULL; become_basic_pollset(pollset, NULL); } -- cgit v1.2.3 From 9e52a2dd81d1a1bda0aa78100d915816b0deebfd Mon Sep 17 00:00:00 2001 From: yang-g Date: Sat, 7 Nov 2015 09:08:26 -0800 Subject: header fix for windows --- src/core/client_config/default_initial_connect_string.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core/client_config') diff --git a/src/core/client_config/default_initial_connect_string.c b/src/core/client_config/default_initial_connect_string.c index fa49d0d6fb..6a4e23e6f2 100644 --- a/src/core/client_config/default_initial_connect_string.c +++ b/src/core/client_config/default_initial_connect_string.c @@ -31,9 +31,8 @@ * */ -#include - #include +#include "src/core/iomgr/sockaddr.h" void grpc_set_default_initial_connect_string(struct sockaddr **addr, size_t *addr_len, -- cgit v1.2.3