From e6e1c9e7a1d5c57121822c77cee36c441fc315ba Mon Sep 17 00:00:00 2001
From: "Mark D. Roth" <roth@google.com>
Date: Wed, 30 Nov 2016 12:33:21 -0800
Subject: [PATCH] Fix link problem for insecure target.

---
 .../ext/transport/chttp2/client/chttp2_connector.c     | 10 +++++-----
 .../ext/transport/chttp2/client/chttp2_connector.h     |  8 ++++++--
 .../transport/chttp2/client/insecure/channel_create.c  |  3 ++-
 .../chttp2/client/secure/secure_channel_create.c       |  9 ++++++++-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.c b/src/core/ext/transport/chttp2/client/chttp2_connector.c
index 6341682ade..5f9ef5a32b 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.c
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.c
@@ -222,7 +222,9 @@ static const grpc_connector_vtable chttp2_connector_vtable = {
 
 grpc_connector *grpc_chttp2_connector_create(
     grpc_exec_ctx *exec_ctx, const char* server_name,
-    grpc_channel_security_connector* security_connector) {
+    void (*create_handshakers)(grpc_exec_ctx* exec_ctx, void* user_data,
+                               grpc_handshake_manager* handshake_mgr),
+    void* user_data) {
   chttp2_connector *c = gpr_malloc(sizeof(*c));
   memset(c, 0, sizeof(*c));
   c->base.vtable = &chttp2_connector_vtable;
@@ -236,10 +238,8 @@ grpc_connector *grpc_chttp2_connector_create(
         grpc_http_connect_handshaker_create(proxy_name, server_name));
     gpr_free(proxy_name);
   }
-  if (security_connector != NULL) {
-// FIXME: this function call is not linked in for the insecure target!
-    grpc_channel_security_connector_create_handshakers(
-        exec_ctx, security_connector, c->handshake_mgr);
+  if (create_handshakers != NULL) {
+    create_handshakers(exec_ctx, user_data, c->handshake_mgr);
   }
   return &c->base;
 }
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.h b/src/core/ext/transport/chttp2/client/chttp2_connector.h
index 5a85d8fa7c..fc8c8e1369 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.h
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.h
@@ -35,10 +35,14 @@
 #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H
 
 #include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/security/transport/security_connector.h"
+#include "src/core/lib/channel/handshaker.h"
 
+/// If \a create_handshakers is non-NULL, it will be called with
+/// \a user_data to add handshakers.
 grpc_connector *grpc_chttp2_connector_create(
     grpc_exec_ctx *exec_ctx, const char* server_name,
-    grpc_channel_security_connector* security_connector);
+    void (*create_handshakers)(grpc_exec_ctx* exec_ctx, void* user_data,
+                               grpc_handshake_manager* handshake_mgr),
+    void* user_data);
 
 #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c
index 5bb0f83f69..fa8353c794 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c
@@ -53,7 +53,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
     grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
     const grpc_subchannel_args *args) {
   grpc_connector *connector = grpc_chttp2_connector_create(
-      exec_ctx, args->server_name, NULL /* security_connector */);
+      exec_ctx, args->server_name, NULL /* create_handshakers */,
+      NULL /* user_data */);
   grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
   grpc_connector_unref(exec_ctx, connector);
   return s;
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
index a5cc1633ae..928bc0b352 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
@@ -68,13 +68,20 @@ static void client_channel_factory_unref(
   }
 }
 
+static void create_handshakers(grpc_exec_ctx* exec_ctx,
+                               void* security_connector,
+                               grpc_handshake_manager* handshake_mgr) {
+  grpc_channel_security_connector_create_handshakers(
+      exec_ctx, security_connector, handshake_mgr);
+}
+
 static grpc_subchannel *client_channel_factory_create_subchannel(
     grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
     const grpc_subchannel_args *args) {
   client_channel_factory *f = (client_channel_factory *)cc_factory;
   grpc_connector *connector =
       grpc_chttp2_connector_create(exec_ctx, args->server_name,
-                                   f->security_connector);
+                                   create_handshakers, f->security_connector);
   grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
   grpc_connector_unref(exec_ctx, connector);
   return s;
-- 
GitLab