From ef8ef3b8f3c6226de34d311de8ec9918dfcc6ba9 Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Fri, 9 Dec 2016 23:03:33 -0800
Subject: [PATCH 001/167] Tests for pollset_set.
---
Makefile | 36 ++
build.yaml | 14 +
test/core/iomgr/pollset_set_test.c | 472 +++++++++++++++++++++++
tools/run_tests/sources_and_headers.json | 17 +
tools/run_tests/tests.json | 18 +
5 files changed, 557 insertions(+)
create mode 100644 test/core/iomgr/pollset_set_test.c
diff --git a/Makefile b/Makefile
index 3a228b4414f..3f4430da9ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1023,6 +1023,7 @@ no_server_test: $(BINDIR)/$(CONFIG)/no_server_test
percent_decode_fuzzer: $(BINDIR)/$(CONFIG)/percent_decode_fuzzer
percent_encode_fuzzer: $(BINDIR)/$(CONFIG)/percent_encode_fuzzer
percent_encoding_test: $(BINDIR)/$(CONFIG)/percent_encoding_test
+pollset_set_test: $(BINDIR)/$(CONFIG)/pollset_set_test
resolve_address_test: $(BINDIR)/$(CONFIG)/resolve_address_test
resource_quota_test: $(BINDIR)/$(CONFIG)/resource_quota_test
secure_channel_create_test: $(BINDIR)/$(CONFIG)/secure_channel_create_test
@@ -1354,6 +1355,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/murmur_hash_test \
$(BINDIR)/$(CONFIG)/no_server_test \
$(BINDIR)/$(CONFIG)/percent_encoding_test \
+ $(BINDIR)/$(CONFIG)/pollset_set_test \
$(BINDIR)/$(CONFIG)/resolve_address_test \
$(BINDIR)/$(CONFIG)/resource_quota_test \
$(BINDIR)/$(CONFIG)/secure_channel_create_test \
@@ -1749,6 +1751,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/no_server_test || ( echo test no_server_test failed ; exit 1 )
$(E) "[RUN] Testing percent_encoding_test"
$(Q) $(BINDIR)/$(CONFIG)/percent_encoding_test || ( echo test percent_encoding_test failed ; exit 1 )
+ $(E) "[RUN] Testing pollset_set_test"
+ $(Q) $(BINDIR)/$(CONFIG)/pollset_set_test || ( echo test pollset_set_test failed ; exit 1 )
$(E) "[RUN] Testing resolve_address_test"
$(Q) $(BINDIR)/$(CONFIG)/resolve_address_test || ( echo test resolve_address_test failed ; exit 1 )
$(E) "[RUN] Testing resource_quota_test"
@@ -10603,6 +10607,38 @@ endif
endif
+POLLSET_SET_TEST_SRC = \
+ test/core/iomgr/pollset_set_test.c \
+
+POLLSET_SET_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(POLLSET_SET_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/pollset_set_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/pollset_set_test: $(POLLSET_SET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(POLLSET_SET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/pollset_set_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/iomgr/pollset_set_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_pollset_set_test: $(POLLSET_SET_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(POLLSET_SET_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
RESOLVE_ADDRESS_TEST_SRC = \
test/core/iomgr/resolve_address_test.c \
diff --git a/build.yaml b/build.yaml
index 2555abce0c6..ef2dde591e7 100644
--- a/build.yaml
+++ b/build.yaml
@@ -2429,6 +2429,20 @@ targets:
- grpc
- gpr_test_util
- gpr
+- name: pollset_set_test
+ build: test
+ language: c
+ src:
+ - test/core/iomgr/pollset_set_test.c
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
+ exclude_iomgrs:
+ - uv
+ platforms:
+ - linux
- name: resolve_address_test
build: test
language: c
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
new file mode 100644
index 00000000000..af971c0784e
--- /dev/null
+++ b/test/core/iomgr/pollset_set_test.c
@@ -0,0 +1,472 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+/* This test only relevant on linux systems */
+#ifdef GRPC_POSIX_SOCKET
+#include "src/core/lib/iomgr/ev_posix.h"
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include "src/core/lib/iomgr/iomgr.h"
+#include "test/core/util/test_config.h"
+
+/*******************************************************************************
+ * test_pollset_set
+ */
+
+typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set;
+
+void init_test_pollset_sets(test_pollset_set pollset_sets[], int num_pss) {
+ int i;
+ for (i = 0; i < num_pss; i++) {
+ pollset_sets[i].pss = grpc_pollset_set_create();
+ }
+}
+
+void cleanup_test_pollset_sets(test_pollset_set pollset_sets[], int num_pss) {
+ int i;
+ for (i = 0; i < num_pss; i++) {
+ grpc_pollset_set_destroy(pollset_sets[i].pss);
+ pollset_sets[i].pss = NULL;
+ }
+}
+
+/*******************************************************************************
+ * test_pollset
+ */
+
+typedef struct test_pollset {
+ grpc_pollset *ps;
+ gpr_mu *mu;
+} test_pollset;
+
+static void init_test_pollsets(test_pollset pollsets[], int num_pollsets) {
+ int i;
+ for (i = 0; i < num_pollsets; i++) {
+ pollsets[i].ps = gpr_malloc(grpc_pollset_size());
+ grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu);
+ }
+}
+
+static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
+ grpc_error *error) {
+ grpc_pollset_destroy(p);
+}
+
+static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
+ test_pollset pollsets[], int num_pollsets) {
+ grpc_closure destroyed;
+ int i;
+
+ for (i = 0; i < num_pollsets; i++) {
+ grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].ps);
+ grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed);
+
+ grpc_exec_ctx_flush(exec_ctx);
+ gpr_free(pollsets[i].ps);
+ pollsets[i].ps = NULL;
+ }
+}
+
+/*******************************************************************************
+ * test_fd
+ */
+
+typedef struct test_fd {
+ grpc_fd *fd;
+ grpc_wakeup_fd wakeup_fd;
+
+ bool is_on_readable_called; /* Is on_readable closure is called ? */
+ grpc_closure on_readable; /* Closure to call when this fd is readable */
+} test_fd;
+
+void on_readable(grpc_exec_ctx *exec_ctx, void *tfd, grpc_error *error) {
+ ((test_fd *)tfd)->is_on_readable_called = true;
+}
+
+static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) {
+ tfd->is_on_readable_called = false;
+
+ grpc_closure_init(&tfd->on_readable, on_readable, tfd);
+ grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
+}
+
+static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd tfds[],
+ int num_fds) {
+ int i;
+
+ for (i = 0; i < num_fds; i++) {
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
+ tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
+ "test_fd");
+ reset_test_fd(exec_ctx, &tfds[i]);
+ }
+}
+
+static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
+ int num_fds) {
+ int release_fd;
+ int i;
+
+ for (i = 0; i < num_fds; i++) {
+ grpc_fd_shutdown(exec_ctx, tfds[i].fd);
+ grpc_exec_ctx_flush(exec_ctx);
+
+ /* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
+ * calls close() on the underlying fd. In our case, we are using
+ * grpc_wakeup_fd and we would like to destroy it ourselves (by calling
+ * grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the
+ * underlying fd, call it with a non-NULL 'release_fd' parameter */
+ grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd, "test_fd_cleanup");
+ grpc_exec_ctx_flush(exec_ctx);
+
+ grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd);
+ }
+}
+
+static void make_test_fds_readable(test_fd tfds[], int num_fds) {
+ int i;
+ for (i = 0; i < num_fds; i++) {
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd));
+ }
+}
+
+static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd tfds[],
+ int num_fds) {
+ int i;
+ for (i = 0; i < num_fds; i++) {
+ /* Verify that the on_readable callback was called */
+ GPR_ASSERT(tfds[i].is_on_readable_called);
+
+ /* Reset the tfd[i] structure */
+ GPR_ASSERT(GRPC_ERROR_NONE ==
+ grpc_wakeup_fd_consume_wakeup(&tfds[i].wakeup_fd));
+ reset_test_fd(exec_ctx, &tfds[i]);
+ }
+}
+
+/*******************************************************************************
+ * Main tests
+ */
+
+/* Test some typical scenarios in pollset_set */
+static void pollset_set_test_basic() {
+ /* We construct the following structure for this test:
+ *
+ * +---> FD0 (Added before PSS1, PS1 and PS2 are added to PSS0)
+ * |
+ * +---> FD5 (Added after PSS1, PS1 and PS2 are added to PSS0)
+ * |
+ * |
+ * | +---> FD1 (Added before PSS1 is added to PSS0)
+ * | |
+ * | +---> FD6 (Added after PSS1 is added to PSS0)
+ * | |
+ * +---> PSS1--+ +--> FD2 (Added before PS0 is added to PSS1)
+ * | | |
+ * | +---> PS0---+
+ * | |
+ * PSS0---+ +--> FD7 (Added after PS0 is added to PSS1)
+ * |
+ * |
+ * | +---> FD3 (Added before PS1 is added to PSS0)
+ * | |
+ * +---> PS1---+
+ * | |
+ * | +---> FD8 (Added after PS1 added to PSS0)
+ * |
+ * |
+ * | +---> FD4 (Added before PS2 is added to PSS0)
+ * | |
+ * +---> PS2---+
+ * |
+ * +---> FD9 (Added after PS2 is added to PSS0)
+ */
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ int i;
+ grpc_pollset_worker *worker;
+ gpr_timespec deadline;
+
+ test_fd tfds[10];
+ test_pollset pollsets[3];
+ test_pollset_set pollset_sets[2];
+ int num_fds = sizeof(tfds) / sizeof(tfds[0]);
+ int num_ps = sizeof(pollsets) / sizeof(pollsets[0]);
+ int num_pss = sizeof(pollset_sets) / sizeof(pollset_sets[0]);
+
+ init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_pollsets(pollsets, num_ps);
+ init_test_pollset_sets(pollset_sets, num_pss);
+
+ /* Construct the pollset_set/pollset/fd tree (see diagram above) */
+
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+
+ grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[2].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[3].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[4].fd);
+
+ grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
+ pollset_sets[1].pss);
+
+ grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
+
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
+
+ grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[7].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[8].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[9].fd);
+
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ /* Test that if any FD in the above structure is readable, it is observable by
+ * doing grpc_pollset_work on any pollset
+ *
+ * For every pollset, do the following:
+ * - (Ensure that all FDs are in reset state)
+ * - Make all FDs readable
+ * - Call grpc_pollset_work() on the pollset
+ * - Flush the exec_ctx
+ * - Verify that on_readable call back was called for all FDs (and
+ * reset the FDs)
+ * */
+ for (i = 0; i < num_ps; i++) {
+ make_test_fds_readable(tfds, num_fds);
+
+ gpr_mu_lock(pollsets[i].mu);
+ deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(2);
+ GPR_ASSERT(GRPC_ERROR_NONE ==
+ grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker,
+ gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ gpr_mu_unlock(pollsets[i].mu);
+
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ verify_readable_and_reset(&exec_ctx, tfds, num_fds);
+ grpc_exec_ctx_flush(&exec_ctx);
+ }
+
+ /* Test tear down */
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
+
+ grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
+ pollset_sets[1].pss);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ cleanup_test_fds(&exec_ctx, tfds, num_fds);
+ cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+/* Same FD added multiple times to the pollset_set tree */
+void pollset_set_test_dup_fds() {
+ /* We construct the following structure for this test:
+ *
+ * +---> FD0
+ * |
+ * |
+ * PSS0---+
+ * | +---> FD0 (also under PSS0)
+ * | |
+ * +---> PSS1--+ +--> FD1 (also under PSS1)
+ * | |
+ * +---> PS ---+
+ * | |
+ * | +--> FD2
+ * +---> FD1
+ */
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_worker *worker;
+ gpr_timespec deadline;
+
+ test_fd tfds[3];
+ test_pollset pollset;
+ test_pollset_set pollset_sets[2];
+ int num_fds = sizeof(tfds) / sizeof(tfds[0]);
+ int num_ps = 1;
+ int num_pss = sizeof(pollset_sets) / sizeof(pollset_sets[0]);
+
+ init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_pollsets(&pollset, num_ps);
+ init_test_pollset_sets(pollset_sets, num_pss);
+
+ /* Construct the structure */
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+
+ grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[1].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[2].fd);
+
+ grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
+ pollset_sets[1].pss);
+
+ /* Test. Make all FDs readable and make sure that can be observed by doing a
+ * grpc_pollset_work on the pollset 'PS' */
+ make_test_fds_readable(tfds, num_fds);
+
+ gpr_mu_lock(pollset.mu);
+ deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(2);
+ GPR_ASSERT(GRPC_ERROR_NONE ==
+ grpc_pollset_work(&exec_ctx, pollset.ps, &worker,
+ gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ gpr_mu_unlock(pollset.mu);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ verify_readable_and_reset(&exec_ctx, tfds, num_fds);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ /* Tear down */
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+
+ grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
+ pollset_sets[1].pss);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ cleanup_test_fds(&exec_ctx, tfds, num_fds);
+ cleanup_test_pollsets(&exec_ctx, &pollset, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+/* Pollset_set with an empty pollset */
+void pollset_set_test_empty_pollset() {
+ /* We construct the following structure for this test:
+ *
+ * +---> PS0 (EMPTY)
+ * |
+ * +---> FD0
+ * |
+ * PSS0---+
+ * | +---> FD1
+ * | |
+ * +---> PS1--+
+ * |
+ * +---> FD2
+ */
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_worker *worker;
+ gpr_timespec deadline;
+
+ test_fd tfds[3];
+ test_pollset pollsets[2];
+ test_pollset_set pollset_set;
+ int num_fds = sizeof(tfds) / sizeof(tfds[0]);
+ int num_ps = sizeof(pollsets) / sizeof(pollsets[0]);
+ int num_pss = 1;
+
+ init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_pollsets(pollsets, num_ps);
+ init_test_pollset_sets(&pollset_set, num_pss);
+
+ /* Construct the structure */
+ grpc_pollset_set_add_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[1].fd);
+ grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[2].fd);
+
+ grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
+
+ /* Test. Make all FDs readable and make sure that can be observed by doing
+ * grpc_pollset_work on the empty pollset 'PS0' */
+ make_test_fds_readable(tfds, num_fds);
+
+ gpr_mu_lock(pollsets[0].mu);
+ deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(2);
+ GPR_ASSERT(GRPC_ERROR_NONE ==
+ grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker,
+ gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ gpr_mu_unlock(pollsets[0].mu);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ verify_readable_and_reset(&exec_ctx, tfds, num_fds);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ /* Tear down */
+ grpc_pollset_set_del_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
+ grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
+ grpc_exec_ctx_flush(&exec_ctx);
+
+ cleanup_test_fds(&exec_ctx, tfds, num_fds);
+ cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
+ cleanup_test_pollset_sets(&pollset_set, num_pss);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+int main(int argc, char **argv) {
+ const char *poll_strategy = NULL;
+ grpc_test_init(argc, argv);
+ grpc_iomgr_init();
+
+ poll_strategy = grpc_get_poll_strategy_name();
+ if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) {
+ pollset_set_test_basic();
+ pollset_set_test_dup_fds();
+ pollset_set_test_empty_pollset();
+ } else {
+ gpr_log(GPR_INFO,
+ "Skipping the test. The test is only relevant for 'epoll' "
+ "strategy. and the current strategy is: '%s'",
+ poll_strategy);
+ }
+
+ grpc_iomgr_shutdown();
+ return 0;
+}
+#else /* defined(GRPC_LINUX_EPOLL) */
+int main(int argc, char **argv) { return 0; }
+#endif /* !defined(GRPC_LINUX_EPOLL) */
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index 9dd5a1c85f0..3e61487ac65 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -1676,6 +1676,23 @@
"third_party": false,
"type": "target"
},
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c",
+ "name": "pollset_set_test",
+ "src": [
+ "test/core/iomgr/pollset_set_test.c"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
{
"deps": [
"gpr",
diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json
index 8d1e9b45683..d96fa419224 100644
--- a/tools/run_tests/tests.json
+++ b/tools/run_tests/tests.json
@@ -1697,6 +1697,24 @@
"windows"
]
},
+ {
+ "args": [],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "gtest": false,
+ "language": "c",
+ "name": "pollset_set_test",
+ "platforms": [
+ "linux"
+ ]
+ },
{
"args": [],
"ci_platforms": [
From 9c0e9f1403c6d35b1ffdddb8cd1fb71f43648242 Mon Sep 17 00:00:00 2001
From: Jeremie Girault
Date: Tue, 4 Oct 2016 13:26:30 +0200
Subject: [PATCH 002/167] fix build on sierra by adding OSATOMIC_USE_INLINED=1
flag to compiler
---
Makefile | 2 +-
build.yaml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 8f7328ae285..5128fac3f57 100644
--- a/Makefile
+++ b/Makefile
@@ -351,7 +351,7 @@ CXXFLAGS += -std=c++11
else
CXXFLAGS += -std=c++0x
endif
-CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
+CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1
LDFLAGS += -g
CPPFLAGS += $(CPPFLAGS_$(CONFIG))
diff --git a/build.yaml b/build.yaml
index de9d253ef1c..1217bb5912c 100644
--- a/build.yaml
+++ b/build.yaml
@@ -3794,7 +3794,7 @@ defaults:
CPPFLAGS: -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM
-D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
global:
- CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
+ CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1
LDFLAGS: -g
zlib:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration
From 740ae63a8a816369b18b8ac9602a9acc7cc0b30d Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Fri, 21 Oct 2016 13:59:14 -0700
Subject: [PATCH 003/167] Packet coalescing transport layer and end2end test
changes
---
.../cronet/transport/cronet_api_dummy.c | 3 +-
.../cronet/transport/cronet_transport.c | 146 ++++++---
.../CoreCronetEnd2EndTests.m | 4 +
src/objective-c/tests/Podfile | 1 +
.../tests/Tests.xcodeproj/project.pbxproj | 1 +
test/core/end2end/end2end_nosec_tests.c | 10 +
test/core/end2end/end2end_tests.c | 8 +
test/core/end2end/tests/packet_coalescing.c | 288 ++++++++++++++++++
.../objective_c/Cronet/cronet_c_for_grpc.h | 115 ++++---
9 files changed, 496 insertions(+), 80 deletions(-)
create mode 100644 test/core/end2end/tests/packet_coalescing.c
diff --git a/src/core/ext/transport/cronet/transport/cronet_api_dummy.c b/src/core/ext/transport/cronet/transport/cronet_api_dummy.c
index 687026c9fde..38755604b97 100644
--- a/src/core/ext/transport/cronet/transport/cronet_api_dummy.c
+++ b/src/core/ext/transport/cronet/transport/cronet_api_dummy.c
@@ -77,9 +77,8 @@ int cronet_bidirectional_stream_write(cronet_bidirectional_stream* stream,
return 0;
}
-int cronet_bidirectional_stream_cancel(cronet_bidirectional_stream* stream) {
+void cronet_bidirectional_stream_cancel(cronet_bidirectional_stream* stream) {
GPR_ASSERT(0);
- return 0;
}
#endif /* GRPC_COMPILE_WITH_CRONET */
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c
index afc59f4b12a..4063dcaefcb 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.c
@@ -86,7 +86,7 @@ enum e_op_id {
/* Cronet callbacks. See cronet_c_for_grpc.h for documentation for each. */
-static void on_request_headers_sent(cronet_bidirectional_stream *);
+static void on_stream_ready(cronet_bidirectional_stream *);
static void on_response_headers_received(
cronet_bidirectional_stream *,
const cronet_bidirectional_stream_header_array *, const char *);
@@ -99,7 +99,7 @@ static void on_succeeded(cronet_bidirectional_stream *);
static void on_failed(cronet_bidirectional_stream *, int);
static void on_canceled(cronet_bidirectional_stream *);
static cronet_bidirectional_stream_callback cronet_callbacks = {
- on_request_headers_sent,
+ on_stream_ready,
on_response_headers_received,
on_read_completed,
on_write_completed,
@@ -151,6 +151,11 @@ struct op_state {
bool state_callback_received[OP_NUM_OPS];
bool fail_state;
bool flush_read;
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ bool flush_cronet_when_ready;
+ bool pending_write_for_trailer;
+#endif
+ bool unprocessed_send_message;
grpc_error *cancel_error;
/* data structure for storing data coming from server */
struct read_state rs;
@@ -273,6 +278,9 @@ static void add_to_storage(struct stream_obj *s, grpc_transport_stream_op *op) {
new_op->next = storage->head;
storage->head = new_op;
storage->num_pending_ops++;
+ if (op->send_message) {
+ s->state.unprocessed_send_message = true;
+ }
CRONET_LOG(GPR_DEBUG, "adding new op %p. %d in the queue.", new_op,
storage->num_pending_ops);
gpr_mu_unlock(&s->mu);
@@ -405,8 +413,8 @@ static void on_succeeded(cronet_bidirectional_stream *stream) {
/*
Cronet callback
*/
-static void on_request_headers_sent(cronet_bidirectional_stream *stream) {
- CRONET_LOG(GPR_DEBUG, "W: on_request_headers_sent(%p)", stream);
+static void on_stream_ready(cronet_bidirectional_stream *stream) {
+ CRONET_LOG(GPR_DEBUG, "W: on_stream_ready(%p)", stream);
stream_obj *s = (stream_obj *)stream->annotation;
gpr_mu_lock(&s->mu);
s->state.state_op_done[OP_SEND_INITIAL_METADATA] = true;
@@ -416,6 +424,14 @@ static void on_request_headers_sent(cronet_bidirectional_stream *stream) {
gpr_free(s->header_array.headers);
s->header_array.headers = NULL;
}
+/* Send the initial metadata on wire if there is no SEND_MESSAGE or
+ * SEND_TRAILING_METADATA ops pending */
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ if (s->state.flush_cronet_when_ready) {
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
+ cronet_bidirectional_stream_flush(stream);
+ }
+#endif
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
}
@@ -551,6 +567,10 @@ static void on_response_trailers_received(
CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_write (%p, 0)", s->cbs);
s->state.state_callback_received[OP_SEND_MESSAGE] = false;
cronet_bidirectional_stream_write(s->cbs, "", 0, true);
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
+ cronet_bidirectional_stream_flush(s->cbs);
+#endif
s->state.state_op_done[OP_SEND_TRAILING_METADATA] = true;
gpr_mu_unlock(&s->mu);
@@ -598,7 +618,7 @@ static void convert_metadata_to_cronet_headers(
curr = curr->next;
num_headers_available++;
}
- /* Allocate enough memory. It is freed in the on_request_headers_sent callback
+ /* Allocate enough memory. It is freed in the on_stream_ready callback
*/
cronet_bidirectional_stream_header *headers =
(cronet_bidirectional_stream_header *)gpr_malloc(
@@ -740,12 +760,16 @@ static bool op_can_be_run(grpc_transport_stream_op *curr_op,
else if (!stream_state->state_callback_received[OP_SEND_INITIAL_METADATA])
result = false;
/* we haven't sent message yet */
- else if (curr_op->send_message &&
+ else if (stream_state->unprocessed_send_message &&
!stream_state->state_op_done[OP_SEND_MESSAGE])
result = false;
/* we haven't got on_write_completed for the send yet */
else if (stream_state->state_op_done[OP_SEND_MESSAGE] &&
- !stream_state->state_callback_received[OP_SEND_MESSAGE])
+ !stream_state->state_callback_received[OP_SEND_MESSAGE]
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ && !stream_state->pending_write_for_trailer
+#endif
+ )
result = false;
} else if (op_id == OP_CANCEL_ERROR) {
/* already executed */
@@ -831,6 +855,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
s->cbs = cronet_bidirectional_stream_create(s->curr_ct.engine, s->curr_gs,
&cronet_callbacks);
CRONET_LOG(GPR_DEBUG, "%p = cronet_bidirectional_stream_create()", s->cbs);
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ cronet_bidirectional_stream_disable_auto_flush(s->cbs, true);
+ cronet_bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
+#endif
char *url = NULL;
const char *method = "POST";
s->header_array.headers = NULL;
@@ -843,30 +871,17 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
cronet_bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array,
false);
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true;
- result = ACTION_TAKEN_WITH_CALLBACK;
- } else if (stream_op->recv_initial_metadata &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_RECV_INITIAL_METADATA)) {
- CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas);
- if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
- grpc_exec_ctx_sched(exec_ctx, stream_op->recv_initial_metadata_ready,
- GRPC_ERROR_CANCELLED, NULL);
- } else if (stream_state->state_callback_received[OP_FAILED]) {
- grpc_exec_ctx_sched(
- exec_ctx, stream_op->recv_initial_metadata_ready,
- make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."), NULL);
- } else {
- grpc_chttp2_incoming_metadata_buffer_publish(
- &oas->s->state.rs.initial_metadata, stream_op->recv_initial_metadata);
- grpc_exec_ctx_sched(exec_ctx, stream_op->recv_initial_metadata_ready,
- GRPC_ERROR_NONE, NULL);
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ if (!stream_op->send_message && !stream_op->send_trailing_metadata) {
+ s->state.flush_cronet_when_ready = true;
}
- stream_state->state_op_done[OP_RECV_INITIAL_METADATA] = true;
- result = ACTION_TAKEN_NO_CALLBACK;
+#endif
+ result = ACTION_TAKEN_WITH_CALLBACK;
} else if (stream_op->send_message &&
op_can_be_run(stream_op, stream_state, &oas->state,
OP_SEND_MESSAGE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_MESSAGE", oas);
+ stream_state->unprocessed_send_message = false;
if (stream_state->state_callback_received[OP_FAILED]) {
result = NO_ACTION_POSSIBLE;
CRONET_LOG(GPR_DEBUG, "Stream is either cancelled or failed.");
@@ -897,13 +912,63 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
cronet_bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
(int)write_buffer_size, false);
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ if (!stream_op->send_trailing_metadata) {
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)",
+ s->cbs);
+ cronet_bidirectional_stream_flush(s->cbs);
+ result = ACTION_TAKEN_WITH_CALLBACK;
+ } else {
+ stream_state->pending_write_for_trailer = true;
+ result = ACTION_TAKEN_NO_CALLBACK;
+ }
+#else
result = ACTION_TAKEN_WITH_CALLBACK;
+#endif
} else {
result = NO_ACTION_POSSIBLE;
}
}
stream_state->state_op_done[OP_SEND_MESSAGE] = true;
oas->state.state_op_done[OP_SEND_MESSAGE] = true;
+ } else if (stream_op->send_trailing_metadata &&
+ op_can_be_run(stream_op, stream_state, &oas->state,
+ OP_SEND_TRAILING_METADATA)) {
+ CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_TRAILING_METADATA", oas);
+ if (stream_state->state_callback_received[OP_FAILED]) {
+ result = NO_ACTION_POSSIBLE;
+ CRONET_LOG(GPR_DEBUG, "Stream is either cancelled or failed.");
+ } else {
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_write (%p, 0)",
+ s->cbs);
+ stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
+ cronet_bidirectional_stream_write(s->cbs, "", 0, true);
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
+ cronet_bidirectional_stream_flush(s->cbs);
+#endif
+ result = ACTION_TAKEN_WITH_CALLBACK;
+ }
+ stream_state->state_op_done[OP_SEND_TRAILING_METADATA] = true;
+ } else if (stream_op->recv_initial_metadata &&
+ op_can_be_run(stream_op, stream_state, &oas->state,
+ OP_RECV_INITIAL_METADATA)) {
+ CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas);
+ if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
+ grpc_exec_ctx_sched(exec_ctx, stream_op->recv_initial_metadata_ready,
+ GRPC_ERROR_CANCELLED, NULL);
+ } else if (stream_state->state_callback_received[OP_FAILED]) {
+ grpc_exec_ctx_sched(
+ exec_ctx, stream_op->recv_initial_metadata_ready,
+ make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."), NULL);
+ } else {
+ grpc_chttp2_incoming_metadata_buffer_publish(
+ &oas->s->state.rs.initial_metadata, stream_op->recv_initial_metadata);
+ grpc_exec_ctx_sched(exec_ctx, stream_op->recv_initial_metadata_ready,
+ GRPC_ERROR_NONE, NULL);
+ }
+ stream_state->state_op_done[OP_RECV_INITIAL_METADATA] = true;
+ result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_op->recv_message &&
op_can_be_run(stream_op, stream_state, &oas->state,
OP_RECV_MESSAGE)) {
@@ -962,6 +1027,16 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_NONE, NULL);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
+
+ /* Extra read to trigger on_succeed */
+ stream_state->rs.read_buffer = stream_state->rs.grpc_header_bytes;
+ stream_state->rs.remaining_bytes = GRPC_HEADER_SIZE_IN_BYTES;
+ stream_state->rs.received_bytes = 0;
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_read(%p)", s->cbs);
+ stream_state->state_op_done[OP_READ_REQ_MADE] =
+ true; /* Indicates that at least one read request has been made */
+ cronet_bidirectional_stream_read(s->cbs, stream_state->rs.read_buffer,
+ stream_state->rs.remaining_bytes);
result = ACTION_TAKEN_NO_CALLBACK;
}
} else if (stream_state->rs.remaining_bytes == 0) {
@@ -1020,21 +1095,6 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
}
stream_state->state_op_done[OP_RECV_TRAILING_METADATA] = true;
result = ACTION_TAKEN_NO_CALLBACK;
- } else if (stream_op->send_trailing_metadata &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_SEND_TRAILING_METADATA)) {
- CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_TRAILING_METADATA", oas);
- if (stream_state->state_callback_received[OP_FAILED]) {
- result = NO_ACTION_POSSIBLE;
- CRONET_LOG(GPR_DEBUG, "Stream is either cancelled or failed.");
- } else {
- CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_write (%p, 0)",
- s->cbs);
- stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
- cronet_bidirectional_stream_write(s->cbs, "", 0, true);
- result = ACTION_TAKEN_WITH_CALLBACK;
- }
- stream_state->state_op_done[OP_SEND_TRAILING_METADATA] = true;
} else if (stream_op->cancel_error &&
op_can_be_run(stream_op, stream_state, &oas->state,
OP_CANCEL_ERROR)) {
@@ -1117,6 +1177,10 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
sizeof(s->state.state_callback_received));
s->state.fail_state = s->state.flush_read = false;
s->state.cancel_error = NULL;
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ s->state.flush_cronet_when_ready = s->state.pending_write_for_trailer = false;
+#endif
+ s->state.unprocessed_send_message = false;
gpr_mu_init(&s->mu);
return 0;
}
diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
index 4ba7badd866..fe9a7c2247b 100644
--- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
+++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
@@ -346,6 +346,10 @@ static char *roots_filename;
[self testIndividualCase:"no_op"];
}
+- (void)testPacketCoalescing {
+ [self testIndividualCase:"packet_coalescing"];
+}
+
- (void)testPayload {
[self testIndividualCase:"payload"];
}
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 5785b976f2d..d1ef0886fe4 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -92,6 +92,7 @@ post_install do |installer|
# GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
# function" warning
config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
+ config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
end
end
diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
index c4a6567ae0e..8455e71b026 100644
--- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
+++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
@@ -1296,6 +1296,7 @@
"$(inherited)",
"GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1",
"GRPC_COMPILE_WITH_CRONET=1",
+ "GRPC_CRONET_WITH_PACKET_COALESCING=1",
);
INFOPLIST_FILE = InteropTestsRemoteWithCronet/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c
index 663489082f9..86d6ab9c9a7 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.c
@@ -103,6 +103,8 @@ extern void no_logging(grpc_end2end_test_config config);
extern void no_logging_pre_init(void);
extern void no_op(grpc_end2end_test_config config);
extern void no_op_pre_init(void);
+extern void packet_coalescing(grpc_end2end_test_config config);
+extern void packet_coalescing_pre_init(void);
extern void payload(grpc_end2end_test_config config);
extern void payload_pre_init(void);
extern void ping(grpc_end2end_test_config config);
@@ -135,6 +137,8 @@ extern void streaming_error_response(grpc_end2end_test_config config);
extern void streaming_error_response_pre_init(void);
extern void trailing_metadata(grpc_end2end_test_config config);
extern void trailing_metadata_pre_init(void);
+extern void packet_coalescing(grpc_end2end_test_config config);
+extern void packet_coalescing_pre_init(void);
void grpc_end2end_tests_pre_init(void) {
GPR_ASSERT(!g_pre_init_called);
@@ -169,6 +173,7 @@ void grpc_end2end_tests_pre_init(void) {
network_status_change_pre_init();
no_logging_pre_init();
no_op_pre_init();
+ packet_coalescing_pre_init();
payload_pre_init();
ping_pre_init();
ping_pong_streaming_pre_init();
@@ -224,6 +229,7 @@ void grpc_end2end_tests(int argc, char **argv,
network_status_change(config);
no_logging(config);
no_op(config);
+ packet_coalescing(config);
payload(config);
ping(config);
ping_pong_streaming(config);
@@ -364,6 +370,10 @@ void grpc_end2end_tests(int argc, char **argv,
no_op(config);
continue;
}
+ if (0 == strcmp("packet_coalescing", argv[i])) {
+ packet_coalescing(config);
+ continue;
+ }
if (0 == strcmp("payload", argv[i])) {
payload(config);
continue;
diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c
index 25c7c62fde5..66908bab606 100644
--- a/test/core/end2end/end2end_tests.c
+++ b/test/core/end2end/end2end_tests.c
@@ -105,6 +105,8 @@ extern void no_logging(grpc_end2end_test_config config);
extern void no_logging_pre_init(void);
extern void no_op(grpc_end2end_test_config config);
extern void no_op_pre_init(void);
+extern void packet_coalescing(grpc_end2end_test_config config);
+extern void packet_coalescing_pre_init(void);
extern void payload(grpc_end2end_test_config config);
extern void payload_pre_init(void);
extern void ping(grpc_end2end_test_config config);
@@ -172,6 +174,7 @@ void grpc_end2end_tests_pre_init(void) {
network_status_change_pre_init();
no_logging_pre_init();
no_op_pre_init();
+ packet_coalescing_pre_init();
payload_pre_init();
ping_pre_init();
ping_pong_streaming_pre_init();
@@ -228,6 +231,7 @@ void grpc_end2end_tests(int argc, char **argv,
network_status_change(config);
no_logging(config);
no_op(config);
+ packet_coalescing(config);
payload(config);
ping(config);
ping_pong_streaming(config);
@@ -372,6 +376,10 @@ void grpc_end2end_tests(int argc, char **argv,
no_op(config);
continue;
}
+ if (0 == strcmp("packet_coalescing", argv[i])) {
+ packet_coalescing(config);
+ continue;
+ }
if (0 == strcmp("payload", argv[i])) {
payload(config);
continue;
diff --git a/test/core/end2end/tests/packet_coalescing.c b/test/core/end2end/tests/packet_coalescing.c
new file mode 100644
index 00000000000..d560c57da80
--- /dev/null
+++ b/test/core/end2end/tests/packet_coalescing.c
@@ -0,0 +1,288 @@
+/*
+ *
+ * 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 "test/core/end2end/end2end_tests.h"
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include "test/core/end2end/cq_verifier.h"
+
+extern void gpr_default_log(gpr_log_func_args *args);
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char *test_name,
+ grpc_channel_args *client_args,
+ grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_time(int n) {
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+}
+
+static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+static bool coalesced_message_and_eos;
+
+static void log_processor(gpr_log_func_args *args) {
+ const int file_len = (int)strlen(args->file);
+ const char suffix1[] = "secure_endpoint.c";
+ const int suffix1_len = sizeof(suffix1) - 1;
+ const char suffix2[] = "tcp_posix.c";
+ const int suffix2_len = sizeof(suffix2) - 1;
+ const char prefix[] = "READ";
+ const int prefix_len = sizeof(prefix) - 1;
+ if (((file_len >= suffix1_len &&
+ 0 == strcmp(suffix1, &args->file[file_len - suffix1_len])) ||
+ (file_len >= suffix2_len &&
+ 0 == strcmp(suffix2, &args->file[file_len - suffix2_len]))) &&
+ 0 == strncmp(prefix, args->message, (size_t)prefix_len) &&
+ strstr(args->message,
+ "00 00 10 00 01 00 00 00 01 00 00 00 00 0b 68 65 6c 6c 6f 20 77 "
+ "6f 72 6c 64")) {
+ fprintf(stderr, "%s, %s\n", args->file, args->message);
+ coalesced_message_and_eos = true;
+ }
+}
+
+/* Request/response with metadata and payload.*/
+static void test_request_response_with_metadata_and_payload(
+ grpc_end2end_test_config config) {
+ grpc_call *c;
+ grpc_call *s;
+ grpc_slice request_payload_slice =
+ grpc_slice_from_copied_string("hello world");
+ grpc_byte_buffer *request_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_timespec deadline = five_seconds_time();
+ grpc_metadata meta_c[2] = {
+ {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}},
+ {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}};
+ grpc_metadata meta_s[2] = {
+ {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}},
+ {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}};
+ grpc_end2end_test_fixture f = begin_test(
+ config, "test_request_response_with_metadata_and_payload", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ char *details = NULL;
+ size_t details_capacity = 0;
+ int was_cancelled = 2;
+ coalesced_message_and_eos = false;
+
+ c = grpc_channel_create_call(
+ f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo",
+ get_host_override_string("foo.test.google.fr:1234", config), deadline,
+ NULL);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 2;
+ op->data.send_initial_metadata.metadata = meta_c;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ error =
+ grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+ CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 2;
+ op->data.send_initial_metadata.metadata = meta_s;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &request_payload_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_OK;
+ op->data.send_status_from_server.status_details = "xyz";
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_OK);
+ GPR_ASSERT(0 == strcmp(details, "xyz"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
+ validate_host_override_string("foo.test.google.fr:1234", call_details.host,
+ config);
+ GPR_ASSERT(was_cancelled == 0);
+ GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
+ GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1"));
+ GPR_ASSERT(contains_metadata(&request_metadata_recv, "key2", "val2"));
+ GPR_ASSERT(coalesced_message_and_eos);
+
+ gpr_free(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_destroy(c);
+ grpc_call_destroy(s);
+
+ cq_verifier_destroy(cqv);
+
+ grpc_byte_buffer_destroy(request_payload);
+ grpc_byte_buffer_destroy(request_payload_recv);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void packet_coalescing(grpc_end2end_test_config config) {
+ /* The test case does not support the fixture socketpair_one_byte_at_a_time */
+ if (0 == strcmp(config.name, "chttp2/socketpair_one_byte_at_a_time")) {
+ return;
+ }
+ gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
+ grpc_tracer_set_enabled("all", 1);
+ gpr_set_log_function(log_processor);
+ test_request_response_with_metadata_and_payload(config);
+ gpr_set_log_function(gpr_default_log);
+ grpc_tracer_set_enabled("all", 0);
+}
+
+void packet_coalescing_pre_init(void) {}
diff --git a/third_party/objective_c/Cronet/cronet_c_for_grpc.h b/third_party/objective_c/Cronet/cronet_c_for_grpc.h
index 15a511aebd0..3d58a8370ef 100644
--- a/third_party/objective_c/Cronet/cronet_c_for_grpc.h
+++ b/third_party/objective_c/Cronet/cronet_c_for_grpc.h
@@ -5,6 +5,8 @@
#ifndef COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_
#define COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_
+#define CRONET_EXPORT __attribute__((visibility("default")))
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -15,12 +17,10 @@ extern "C" {
/* Opaque object representing Cronet Engine. Created and configured outside
* of this API to facilitate sharing with other components */
-typedef struct cronet_engine { void* obj; } cronet_engine;
-
-void cronet_engine_add_quic_hint(cronet_engine* engine,
- const char* host,
- int port,
- int alternate_port);
+typedef struct cronet_engine {
+ void* obj;
+ void* annotation;
+} cronet_engine;
/* Cronet Bidirectional Stream API */
@@ -45,11 +45,12 @@ typedef struct cronet_bidirectional_stream_header_array {
/* Set of callbacks used to receive callbacks from bidirectional stream. */
typedef struct cronet_bidirectional_stream_callback {
- /* Invoked when request headers are sent. Indicates that stream has initiated
- * the request. Consumer may call cronet_bidirectional_stream_write() to start
- * writing data.
+ /* Invoked when the stream is ready for reading and writing.
+ * Consumer may call cronet_bidirectional_stream_read() to start reading data.
+ * Consumer may call cronet_bidirectional_stream_write() to start writing
+ * data.
*/
- void (*on_request_headers_sent)(cronet_bidirectional_stream* stream);
+ void (*on_stream_ready)(cronet_bidirectional_stream* stream);
/* Invoked when initial response headers are received.
* Consumer must call cronet_bidirectional_stream_read() to start reading.
@@ -67,20 +68,19 @@ typedef struct cronet_bidirectional_stream_callback {
* It may be invoked after on_response_trailers_received()}, if there was
* pending read data before trailers were received.
*
- * If count is 0, it means the remote side has signaled that it will send no
- * more data; future calls to cronet_bidirectional_stream_read() will result
- * in the on_data_read() callback or on_succeded() callback if
+ * If |bytes_read| is 0, it means the remote side has signaled that it will
+ * send no more data; future calls to cronet_bidirectional_stream_read()
+ * will result in the on_data_read() callback or on_succeded() callback if
* cronet_bidirectional_stream_write() was invoked with end_of_stream set to
* true.
*/
void (*on_read_completed)(cronet_bidirectional_stream* stream,
char* data,
- int count);
+ int bytes_read);
/**
* Invoked when all data passed to cronet_bidirectional_stream_write() is
- * sent.
- * To continue writing, call cronet_bidirectional_stream_write().
+ * sent. To continue writing, call cronet_bidirectional_stream_write().
*/
void (*on_write_completed)(cronet_bidirectional_stream* stream,
const char* data);
@@ -117,7 +117,7 @@ typedef struct cronet_bidirectional_stream_callback {
void (*on_canceled)(cronet_bidirectional_stream* stream);
} cronet_bidirectional_stream_callback;
-/* Create a new stream object that uses |engine| and |callback|. All stream
+/* Creates a new stream object that uses |engine| and |callback|. All stream
* tasks are performed asynchronously on the |engine| network thread. |callback|
* methods are invoked synchronously on the |engine| network thread, but must
* not run tasks on the current thread to prevent blocking networking operations
@@ -129,6 +129,7 @@ typedef struct cronet_bidirectional_stream_callback {
*
* Both |calback| and |engine| must remain valid until stream is destroyed.
*/
+CRONET_EXPORT
cronet_bidirectional_stream* cronet_bidirectional_stream_create(
cronet_engine* engine,
void* annotation,
@@ -136,15 +137,40 @@ cronet_bidirectional_stream* cronet_bidirectional_stream_create(
/* TBD: The following methods return int. Should it be a custom type? */
-/* Destroy stream object. Destroy could be called from any thread, including
+/* Destroys stream object. Destroy could be called from any thread, including
* network thread, but is posted, so |stream| is valid until calling task is
* complete.
*/
+CRONET_EXPORT
int cronet_bidirectional_stream_destroy(cronet_bidirectional_stream* stream);
-/* Start the stream by sending request to |url| using |method| and |headers|. If
- * |end_of_stream| is true, then no data is expected to be written.
+/**
+ * Disables or enables auto flush. By default, data is flushed after
+ * every cronet_bidirectional_stream_write(). If the auto flush is disabled,
+ * the client should explicitly call cronet_bidirectional_stream_flush to flush
+ * the data.
+ */
+CRONET_EXPORT void cronet_bidirectional_stream_disable_auto_flush(
+ cronet_bidirectional_stream* stream,
+ bool disable_auto_flush);
+
+/**
+ * Delays sending request headers until cronet_bidirectional_stream_flush()
+ * is called. This flag is currently only respected when QUIC is negotiated.
+ * When true, QUIC will send request header frame along with data frame(s)
+ * as a single packet when possible.
+ */
+CRONET_EXPORT
+void cronet_bidirectional_stream_delay_request_headers_until_flush(
+ cronet_bidirectional_stream* stream,
+ bool delay_headers_until_flush);
+
+/* Starts the stream by sending request to |url| using |method| and |headers|.
+ * If |end_of_stream| is true, then no data is expected to be written. The
+ * |method| is HTTP verb, with PUT having a special meaning to mark idempotent
+ * request, which could use QUIC 0-RTT.
*/
+CRONET_EXPORT
int cronet_bidirectional_stream_start(
cronet_bidirectional_stream* stream,
const char* url,
@@ -153,46 +179,61 @@ int cronet_bidirectional_stream_start(
const cronet_bidirectional_stream_header_array* headers,
bool end_of_stream);
-/* Read response data into |buffer| of |capacity| length. Must only be called at
- * most once in response to each invocation of the
- * on_response_headers_received() and on_read_completed() methods of the
- * cronet_bidirectional_stream_callback.
- * Each call will result in an invocation of one of the callback's
- * on_read_completed method if data is read, its on_succeeded() method if
- * the stream is closed, or its on_failed() method if there's an error.
+/* Reads response data into |buffer| of |capacity| length. Must only be called
+ * at most once in response to each invocation of the
+ * on_stream_ready()/on_response_headers_received() and on_read_completed()
+ * methods of the cronet_bidirectional_stream_callback.
+ * Each call will result in an invocation of the callback's
+ * on_read_completed() method if data is read, or its on_failed() method if
+ * there's an error. The callback's on_succeeded() method is also invoked if
+ * there is no more data to read and |end_of_stream| was previously sent.
*/
+CRONET_EXPORT
int cronet_bidirectional_stream_read(cronet_bidirectional_stream* stream,
char* buffer,
int capacity);
-/* Read response data into |buffer| of |capacity| length. Must only be called at
- * most once in response to each invocation of the
- * on_response_headers_received() and on_read_completed() methods of the
- * cronet_bidirectional_stream_callback.
- * Each call will result in an invocation of one of the callback's
- * on_read_completed method if data is read, its on_succeeded() method if
- * the stream is closed, or its on_failed() method if there's an error.
+/* Writes request data from |buffer| of |buffer_length| length. If auto flush is
+ * disabled, data will be sent only after cronet_bidirectional_stream_flush() is
+ * called.
+ * Each call will result in an invocation the callback's on_write_completed()
+ * method if data is sent, or its on_failed() method if there's an error.
+ * The callback's on_succeeded() method is also invoked if |end_of_stream| is
+ * set and all response data has been read.
*/
+CRONET_EXPORT
int cronet_bidirectional_stream_write(cronet_bidirectional_stream* stream,
const char* buffer,
- int count,
+ int buffer_length,
bool end_of_stream);
+/**
+ * Flushes pending writes. This method should not be called before invocation of
+ * on_stream_ready() method of the cronet_bidirectional_stream_callback.
+ * For each previously called cronet_bidirectional_stream_write()
+ * a corresponding on_write_completed() callback will be invoked when the buffer
+ * is sent.
+ */
+CRONET_EXPORT
+void cronet_bidirectional_stream_flush(cronet_bidirectional_stream* stream);
+
/* Cancels the stream. Can be called at any time after
* cronet_bidirectional_stream_start(). The on_canceled() method of
* cronet_bidirectional_stream_callback will be invoked when cancelation
* is complete and no further callback methods will be invoked. If the
* stream has completed or has not started, calling
* cronet_bidirectional_stream_cancel() has no effect and on_canceled() will not
- * be invoked. At most one callback method may be invoked after
+ * be invoked. At most one callback method may be invoked after
* cronet_bidirectional_stream_cancel() has completed.
*/
-int cronet_bidirectional_stream_cancel(cronet_bidirectional_stream* stream);
+CRONET_EXPORT
+void cronet_bidirectional_stream_cancel(cronet_bidirectional_stream* stream);
/* Returns true if the |stream| was successfully started and is now done
* (succeeded, canceled, or failed).
* Returns false if the |stream| stream is not yet started or is in progress.
*/
+CRONET_EXPORT
bool cronet_bidirectional_stream_is_done(cronet_bidirectional_stream* stream);
#ifdef __cplusplus
From 8803ae8c3a643f35d15c9269872d3c1fd2cc8409 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Tue, 3 Jan 2017 21:16:05 -0800
Subject: [PATCH 004/167] build changes
---
Makefile | 2 +
test/core/end2end/end2end_nosec_tests.c | 2 -
test/core/end2end/gen_build_yaml.py | 3 +-
.../generated/sources_and_headers.json | 2 +
tools/run_tests/generated/tests.json | 738 +++++++++++++++++-
.../end2end_nosec_tests.vcxproj | 2 +
.../end2end_nosec_tests.vcxproj.filters | 3 +
.../tests/end2end_tests/end2end_tests.vcxproj | 2 +
.../end2end_tests.vcxproj.filters | 3 +
9 files changed, 745 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 8f7328ae285..66e992ef09a 100644
--- a/Makefile
+++ b/Makefile
@@ -7199,6 +7199,7 @@ LIBEND2END_TESTS_SRC = \
test/core/end2end/tests/network_status_change.c \
test/core/end2end/tests/no_logging.c \
test/core/end2end/tests/no_op.c \
+ test/core/end2end/tests/packet_coalescing.c \
test/core/end2end/tests/payload.c \
test/core/end2end/tests/ping.c \
test/core/end2end/tests/ping_pong_streaming.c \
@@ -7285,6 +7286,7 @@ LIBEND2END_NOSEC_TESTS_SRC = \
test/core/end2end/tests/network_status_change.c \
test/core/end2end/tests/no_logging.c \
test/core/end2end/tests/no_op.c \
+ test/core/end2end/tests/packet_coalescing.c \
test/core/end2end/tests/payload.c \
test/core/end2end/tests/ping.c \
test/core/end2end/tests/ping_pong_streaming.c \
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c
index 86d6ab9c9a7..0581607e808 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.c
@@ -137,8 +137,6 @@ extern void streaming_error_response(grpc_end2end_test_config config);
extern void streaming_error_response_pre_init(void);
extern void trailing_metadata(grpc_end2end_test_config config);
extern void trailing_metadata_pre_init(void);
-extern void packet_coalescing(grpc_end2end_test_config config);
-extern void packet_coalescing_pre_init(void);
void grpc_end2end_tests_pre_init(void) {
GPR_ASSERT(!g_pre_init_called);
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 201a92a1fdc..3ae2b2cb9c9 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -91,6 +91,7 @@ LOWCPU = 0.1
# maps test names to options
END2END_TESTS = {
+ 'authority_not_supported': default_test_options,
'bad_hostname': default_test_options,
'binary_metadata': default_test_options,
'resource_quota_server': default_test_options._replace(large_writes=True,
@@ -125,6 +126,7 @@ END2END_TESTS = {
'network_status_change': default_test_options,
'no_logging': default_test_options._replace(traceable=False),
'no_op': default_test_options,
+ 'packet_coalescing': default_test_options,
'payload': default_test_options,
'load_reporting_hook': default_test_options,
'ping_pong_streaming': default_test_options,
@@ -142,7 +144,6 @@ END2END_TESTS = {
'simple_request': default_test_options,
'streaming_error_response': default_test_options,
'trailing_metadata': default_test_options,
- 'authority_not_supported': default_test_options,
}
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 6ae269cc20d..a96856c1ab9 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -6347,6 +6347,7 @@
"test/core/end2end/tests/network_status_change.c",
"test/core/end2end/tests/no_logging.c",
"test/core/end2end/tests/no_op.c",
+ "test/core/end2end/tests/packet_coalescing.c",
"test/core/end2end/tests/payload.c",
"test/core/end2end/tests/ping.c",
"test/core/end2end/tests/ping_pong_streaming.c",
@@ -6416,6 +6417,7 @@
"test/core/end2end/tests/network_status_change.c",
"test/core/end2end/tests/no_logging.c",
"test/core/end2end/tests/no_op.c",
+ "test/core/end2end/tests/packet_coalescing.c",
"test/core/end2end/tests/payload.c",
"test/core/end2end/tests/ping.c",
"test/core/end2end/tests/ping_pong_streaming.c",
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index b76263b8b98..0ba2f2a6f48 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -5712,6 +5712,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_census_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -6795,6 +6818,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_compress_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -7847,6 +7893,28 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fakesec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -8843,6 +8911,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fd_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -9880,6 +9971,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -10837,6 +10951,25 @@
"linux"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+pipe_test",
+ "platforms": [
+ "linux"
+ ]
+ },
{
"args": [
"payload"
@@ -11810,6 +11943,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+trace_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -12922,6 +13078,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_http_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -14021,6 +14201,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_load_reporting_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -15133,6 +15336,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_oauth2_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -16165,6 +16392,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -17151,7 +17402,7 @@
},
{
"args": [
- "payload"
+ "packet_coalescing"
],
"ci_platforms": [
"windows",
@@ -17175,7 +17426,7 @@
},
{
"args": [
- "ping_pong_streaming"
+ "payload"
],
"ci_platforms": [
"windows",
@@ -17199,7 +17450,7 @@
},
{
"args": [
- "registered_call"
+ "ping_pong_streaming"
],
"ci_platforms": [
"windows",
@@ -17223,14 +17474,14 @@
},
{
"args": [
- "request_with_flags"
+ "registered_call"
],
"ci_platforms": [
"windows",
"linux",
"posix"
],
- "cpu_cost": 0.1,
+ "cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [
"uv"
@@ -17247,14 +17498,14 @@
},
{
"args": [
- "request_with_payload"
+ "request_with_flags"
],
"ci_platforms": [
"windows",
"linux",
"posix"
],
- "cpu_cost": 1.0,
+ "cpu_cost": 0.1,
"exclude_configs": [],
"exclude_iomgrs": [
"uv"
@@ -17271,7 +17522,7 @@
},
{
"args": [
- "resource_quota_server"
+ "request_with_payload"
],
"ci_platforms": [
"windows",
@@ -17295,7 +17546,31 @@
},
{
"args": [
- "server_finishes_request"
+ "resource_quota_server"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
+ "server_finishes_request"
],
"ci_platforms": [
"windows",
@@ -18109,6 +18384,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair+trace_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -19149,6 +19448,32 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [
+ "msan"
+ ],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_1byte_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -20202,6 +20527,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -21285,6 +21633,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_cert_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -22301,6 +22672,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -23303,6 +23698,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_uds_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -24363,6 +24781,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_census_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -25423,6 +25864,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_compress_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -26412,6 +26876,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fd_nosec_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -27426,6 +27913,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -28364,6 +28874,25 @@
"linux"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+pipe_nosec_test",
+ "platforms": [
+ "linux"
+ ]
+ },
{
"args": [
"payload"
@@ -29314,6 +29843,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+trace_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -30402,6 +30954,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_http_proxy_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -31478,6 +32054,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_load_reporting_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -32470,6 +33069,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_proxy_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -33430,6 +34053,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -34366,6 +35013,30 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair+trace_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -35380,6 +36051,32 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [
+ "msan"
+ ],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_1byte_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
@@ -36385,6 +37082,29 @@
"posix"
]
},
+ {
+ "args": [
+ "packet_coalescing"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_uds_nosec_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
{
"args": [
"payload"
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
index 4fb8f8f4a15..196d924287f 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
@@ -215,6 +215,8 @@
+
+
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
index ff82a4dd43c..73801e36354 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
@@ -97,6 +97,9 @@
test\core\end2end\tests
+
+ test\core\end2end\tests
+
test\core\end2end\tests
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
index 0b7d7c2e752..7b1701005db 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
@@ -217,6 +217,8 @@
+
+
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
index e641930e64a..2b707651768 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
@@ -100,6 +100,9 @@
test\core\end2end\tests
+
+ test\core\end2end\tests
+
test\core\end2end\tests
From dc739bd659384252ae31234a439f1abcd7a512ff Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Thu, 5 Jan 2017 21:04:40 -0800
Subject: [PATCH 005/167] Remove packet coalescing testing on chttp2
---
Makefile | 2 -
.../CoreCronetEnd2EndTests.m | 9 +-
test/core/end2end/end2end_nosec_tests.c | 8 -
test/core/end2end/end2end_tests.c | 8 -
test/core/end2end/gen_build_yaml.py | 1 -
test/core/end2end/tests/packet_coalescing.c | 4 -
.../generated/sources_and_headers.json | 2 -
tools/run_tests/generated/tests.json | 736 +-----------------
.../end2end_nosec_tests.vcxproj | 2 -
.../end2end_nosec_tests.vcxproj.filters | 3 -
.../tests/end2end_tests/end2end_tests.vcxproj | 2 -
.../end2end_tests.vcxproj.filters | 3 -
12 files changed, 16 insertions(+), 764 deletions(-)
diff --git a/Makefile b/Makefile
index 66e992ef09a..8f7328ae285 100644
--- a/Makefile
+++ b/Makefile
@@ -7199,7 +7199,6 @@ LIBEND2END_TESTS_SRC = \
test/core/end2end/tests/network_status_change.c \
test/core/end2end/tests/no_logging.c \
test/core/end2end/tests/no_op.c \
- test/core/end2end/tests/packet_coalescing.c \
test/core/end2end/tests/payload.c \
test/core/end2end/tests/ping.c \
test/core/end2end/tests/ping_pong_streaming.c \
@@ -7286,7 +7285,6 @@ LIBEND2END_NOSEC_TESTS_SRC = \
test/core/end2end/tests/network_status_change.c \
test/core/end2end/tests/no_logging.c \
test/core/end2end/tests/no_op.c \
- test/core/end2end/tests/packet_coalescing.c \
test/core/end2end/tests/payload.c \
test/core/end2end/tests/ping.c \
test/core/end2end/tests/ping_pong_streaming.c \
diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
index fe9a7c2247b..315d9424845 100644
--- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
+++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
@@ -168,6 +168,9 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_secure_fullstack},
};
+extern void packet_coalescing(grpc_end2end_test_config config);
+extern void packet_coalescing_pre_init(void);
+
static char *roots_filename;
@interface CoreCronetEnd2EndTests : XCTestCase
@@ -347,7 +350,11 @@ static char *roots_filename;
}
- (void)testPacketCoalescing {
- [self testIndividualCase:"packet_coalescing"];
+ // Directly invoke the test function since the test is for Cronet only and thus not included in
+ // end2end_tests.c
+ // TODO (mxyan): Do the same to all test cases so that this file will no longer depend on
+ // end2end_tests.c
+ packet_coalescing(configs[0]);
}
- (void)testPayload {
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c
index 0581607e808..663489082f9 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.c
@@ -103,8 +103,6 @@ extern void no_logging(grpc_end2end_test_config config);
extern void no_logging_pre_init(void);
extern void no_op(grpc_end2end_test_config config);
extern void no_op_pre_init(void);
-extern void packet_coalescing(grpc_end2end_test_config config);
-extern void packet_coalescing_pre_init(void);
extern void payload(grpc_end2end_test_config config);
extern void payload_pre_init(void);
extern void ping(grpc_end2end_test_config config);
@@ -171,7 +169,6 @@ void grpc_end2end_tests_pre_init(void) {
network_status_change_pre_init();
no_logging_pre_init();
no_op_pre_init();
- packet_coalescing_pre_init();
payload_pre_init();
ping_pre_init();
ping_pong_streaming_pre_init();
@@ -227,7 +224,6 @@ void grpc_end2end_tests(int argc, char **argv,
network_status_change(config);
no_logging(config);
no_op(config);
- packet_coalescing(config);
payload(config);
ping(config);
ping_pong_streaming(config);
@@ -368,10 +364,6 @@ void grpc_end2end_tests(int argc, char **argv,
no_op(config);
continue;
}
- if (0 == strcmp("packet_coalescing", argv[i])) {
- packet_coalescing(config);
- continue;
- }
if (0 == strcmp("payload", argv[i])) {
payload(config);
continue;
diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c
index 66908bab606..25c7c62fde5 100644
--- a/test/core/end2end/end2end_tests.c
+++ b/test/core/end2end/end2end_tests.c
@@ -105,8 +105,6 @@ extern void no_logging(grpc_end2end_test_config config);
extern void no_logging_pre_init(void);
extern void no_op(grpc_end2end_test_config config);
extern void no_op_pre_init(void);
-extern void packet_coalescing(grpc_end2end_test_config config);
-extern void packet_coalescing_pre_init(void);
extern void payload(grpc_end2end_test_config config);
extern void payload_pre_init(void);
extern void ping(grpc_end2end_test_config config);
@@ -174,7 +172,6 @@ void grpc_end2end_tests_pre_init(void) {
network_status_change_pre_init();
no_logging_pre_init();
no_op_pre_init();
- packet_coalescing_pre_init();
payload_pre_init();
ping_pre_init();
ping_pong_streaming_pre_init();
@@ -231,7 +228,6 @@ void grpc_end2end_tests(int argc, char **argv,
network_status_change(config);
no_logging(config);
no_op(config);
- packet_coalescing(config);
payload(config);
ping(config);
ping_pong_streaming(config);
@@ -376,10 +372,6 @@ void grpc_end2end_tests(int argc, char **argv,
no_op(config);
continue;
}
- if (0 == strcmp("packet_coalescing", argv[i])) {
- packet_coalescing(config);
- continue;
- }
if (0 == strcmp("payload", argv[i])) {
payload(config);
continue;
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 3ae2b2cb9c9..78779908a94 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -126,7 +126,6 @@ END2END_TESTS = {
'network_status_change': default_test_options,
'no_logging': default_test_options._replace(traceable=False),
'no_op': default_test_options,
- 'packet_coalescing': default_test_options,
'payload': default_test_options,
'load_reporting_hook': default_test_options,
'ping_pong_streaming': default_test_options,
diff --git a/test/core/end2end/tests/packet_coalescing.c b/test/core/end2end/tests/packet_coalescing.c
index d560c57da80..336f765a13f 100644
--- a/test/core/end2end/tests/packet_coalescing.c
+++ b/test/core/end2end/tests/packet_coalescing.c
@@ -273,10 +273,6 @@ static void test_request_response_with_metadata_and_payload(
}
void packet_coalescing(grpc_end2end_test_config config) {
- /* The test case does not support the fixture socketpair_one_byte_at_a_time */
- if (0 == strcmp(config.name, "chttp2/socketpair_one_byte_at_a_time")) {
- return;
- }
gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
grpc_tracer_set_enabled("all", 1);
gpr_set_log_function(log_processor);
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index a96856c1ab9..6ae269cc20d 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -6347,7 +6347,6 @@
"test/core/end2end/tests/network_status_change.c",
"test/core/end2end/tests/no_logging.c",
"test/core/end2end/tests/no_op.c",
- "test/core/end2end/tests/packet_coalescing.c",
"test/core/end2end/tests/payload.c",
"test/core/end2end/tests/ping.c",
"test/core/end2end/tests/ping_pong_streaming.c",
@@ -6417,7 +6416,6 @@
"test/core/end2end/tests/network_status_change.c",
"test/core/end2end/tests/no_logging.c",
"test/core/end2end/tests/no_op.c",
- "test/core/end2end/tests/packet_coalescing.c",
"test/core/end2end/tests/payload.c",
"test/core/end2end/tests/ping.c",
"test/core/end2end/tests/ping_pong_streaming.c",
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 0ba2f2a6f48..b76263b8b98 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -5712,29 +5712,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_census_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -6818,29 +6795,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_compress_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -7893,28 +7847,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_fakesec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -8911,29 +8843,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_fd_test",
- "platforms": [
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -9971,29 +9880,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_full_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -10951,25 +10837,6 @@
"linux"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_full+pipe_test",
- "platforms": [
- "linux"
- ]
- },
{
"args": [
"payload"
@@ -11943,29 +11810,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_full+trace_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -13078,30 +12922,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_http_proxy_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -14201,29 +14021,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_load_reporting_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -15336,30 +15133,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_oauth2_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -16392,30 +16165,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_proxy_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -17402,7 +17151,7 @@
},
{
"args": [
- "packet_coalescing"
+ "payload"
],
"ci_platforms": [
"windows",
@@ -17426,7 +17175,7 @@
},
{
"args": [
- "payload"
+ "ping_pong_streaming"
],
"ci_platforms": [
"windows",
@@ -17450,7 +17199,7 @@
},
{
"args": [
- "ping_pong_streaming"
+ "registered_call"
],
"ci_platforms": [
"windows",
@@ -17474,14 +17223,14 @@
},
{
"args": [
- "registered_call"
+ "request_with_flags"
],
"ci_platforms": [
"windows",
"linux",
"posix"
],
- "cpu_cost": 1.0,
+ "cpu_cost": 0.1,
"exclude_configs": [],
"exclude_iomgrs": [
"uv"
@@ -17498,14 +17247,14 @@
},
{
"args": [
- "request_with_flags"
+ "request_with_payload"
],
"ci_platforms": [
"windows",
"linux",
"posix"
],
- "cpu_cost": 0.1,
+ "cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [
"uv"
@@ -17522,31 +17271,7 @@
},
{
"args": [
- "request_with_payload"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_sockpair_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "resource_quota_server"
+ "resource_quota_server"
],
"ci_platforms": [
"windows",
@@ -18384,30 +18109,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_sockpair+trace_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -19448,32 +19149,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [
- "msan"
- ],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_sockpair_1byte_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -20527,29 +20202,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -21633,29 +21285,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -22672,30 +22301,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_proxy_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -23698,29 +23303,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_uds_test",
- "platforms": [
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -24781,29 +24363,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_census_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -25864,29 +25423,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_compress_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -26876,29 +26412,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_fd_nosec_test",
- "platforms": [
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -27913,29 +27426,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_full_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -28874,25 +28364,6 @@
"linux"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_full+pipe_nosec_test",
- "platforms": [
- "linux"
- ]
- },
{
"args": [
"payload"
@@ -29843,29 +29314,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_full+trace_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -30954,30 +30402,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_http_proxy_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -32054,29 +31478,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_load_reporting_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -33069,30 +32470,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_proxy_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -34053,30 +33430,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_sockpair_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -35013,30 +34366,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_sockpair+trace_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -36051,32 +35380,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [
- "msan"
- ],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_sockpair_1byte_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
@@ -37082,29 +36385,6 @@
"posix"
]
},
- {
- "args": [
- "packet_coalescing"
- ],
- "ci_platforms": [
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_uds_nosec_test",
- "platforms": [
- "linux",
- "mac",
- "posix"
- ]
- },
{
"args": [
"payload"
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
index 196d924287f..4fb8f8f4a15 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
@@ -215,8 +215,6 @@
-
-
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
index 73801e36354..ff82a4dd43c 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
@@ -97,9 +97,6 @@
test\core\end2end\tests
-
- test\core\end2end\tests
-
test\core\end2end\tests
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
index 7b1701005db..0b7d7c2e752 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
@@ -217,8 +217,6 @@
-
-
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
index 2b707651768..e641930e64a 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
@@ -100,9 +100,6 @@
test\core\end2end\tests
-
- test\core\end2end\tests
-
test\core\end2end\tests
From 0542d11ea8ab3ffde3458fbf7daf7a2af93b19fa Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Mon, 9 Jan 2017 15:07:11 -0800
Subject: [PATCH 006/167] Re-ran generate_projects.sh
---
tools/doxygen/Doxyfile.c++ | 42 +++++++++++-----------
tools/doxygen/Doxyfile.c++.internal | 40 ++++++++++-----------
tools/doxygen/Doxyfile.core | 38 ++++++++++----------
tools/doxygen/Doxyfile.core.internal | 54 ++++++++++++++--------------
4 files changed, 87 insertions(+), 87 deletions(-)
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index 2c16f6f24a0..bb620f6b4a0 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -848,34 +848,34 @@ include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_generic.h \
include/grpc/impl/codegen/sync_posix.h \
include/grpc/impl/codegen/sync_windows.h \
+doc/command_line_tool.md \
+doc/statuscodes.md \
+doc/interop-test-descriptions.md \
doc/fail_fast.md \
+doc/server-reflection.md \
+doc/c-style-guide.md \
+doc/load-balancing.md \
+doc/compression_cookbook.md \
+doc/connectivity-semantics-and-api.md \
+doc/PROTOCOL-HTTP2.md \
+doc/health-checking.md \
+doc/binary-logging.md \
+doc/stress_test_framework.md \
+doc/negative-http2-interop-test-descriptions.md \
doc/compression.md \
+doc/server_reflection_tutorial.md \
+doc/cpp-style-guide.md \
doc/environment_variables.md \
-doc/stress_test_framework.md \
doc/PROTOCOL-WEB.md \
-doc/cpp-style-guide.md \
-doc/http-grpc-status-mapping.md \
-doc/wait-for-ready.md \
-doc/command_line_tool.md \
-doc/c-style-guide.md \
-doc/server_reflection_tutorial.md \
-doc/health-checking.md \
-doc/connection-backoff-interop-test-description.md \
-doc/epoll-polling-engine.md \
doc/naming.md \
-doc/binary-logging.md \
-doc/connectivity-semantics-and-api.md \
+doc/epoll-polling-engine.md \
doc/connection-backoff.md \
-doc/compression_cookbook.md \
-doc/PROTOCOL-HTTP2.md \
-doc/load-balancing.md \
-doc/negative-http2-interop-test-descriptions.md \
-doc/server-reflection.md \
-doc/interop-test-descriptions.md \
-doc/statuscodes.md \
+doc/connection-backoff-interop-test-description.md \
doc/g_stands_for.md \
-doc/cpp/perf_notes.md \
-doc/cpp/pending_api_cleanups.md
+doc/http-grpc-status-mapping.md \
+doc/wait-for-ready.md \
+doc/cpp/pending_api_cleanups.md \
+doc/cpp/perf_notes.md
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 89915d7b08e..a8dd34820da 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -894,34 +894,34 @@ src/cpp/util/status.cc \
src/cpp/util/string_ref.cc \
src/cpp/util/time_cc.cc \
src/cpp/codegen/codegen_init.cc \
+doc/command_line_tool.md \
+doc/statuscodes.md \
+doc/interop-test-descriptions.md \
doc/fail_fast.md \
+doc/server-reflection.md \
+doc/c-style-guide.md \
+doc/load-balancing.md \
+doc/compression_cookbook.md \
+doc/connectivity-semantics-and-api.md \
+doc/PROTOCOL-HTTP2.md \
+doc/health-checking.md \
+doc/binary-logging.md \
+doc/stress_test_framework.md \
+doc/negative-http2-interop-test-descriptions.md \
doc/compression.md \
+doc/server_reflection_tutorial.md \
+doc/cpp-style-guide.md \
doc/environment_variables.md \
-doc/stress_test_framework.md \
doc/PROTOCOL-WEB.md \
-doc/cpp-style-guide.md \
-doc/http-grpc-status-mapping.md \
-doc/wait-for-ready.md \
-doc/command_line_tool.md \
-doc/c-style-guide.md \
-doc/server_reflection_tutorial.md \
-doc/health-checking.md \
-doc/connection-backoff-interop-test-description.md \
-doc/epoll-polling-engine.md \
doc/naming.md \
-doc/binary-logging.md \
-doc/connectivity-semantics-and-api.md \
+doc/epoll-polling-engine.md \
doc/connection-backoff.md \
-doc/compression_cookbook.md \
-doc/PROTOCOL-HTTP2.md \
-doc/load-balancing.md \
-doc/negative-http2-interop-test-descriptions.md \
-doc/server-reflection.md \
-doc/interop-test-descriptions.md \
-doc/statuscodes.md \
+doc/connection-backoff-interop-test-description.md \
doc/g_stands_for.md \
-doc/cpp/perf_notes.md \
+doc/http-grpc-status-mapping.md \
+doc/wait-for-ready.md \
doc/cpp/pending_api_cleanups.md \
+doc/cpp/perf_notes.md \
src/cpp/README.md
# This tag can be used to specify the character encoding of the source files
diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core
index e7fc1dbc573..562f3fdc2ee 100644
--- a/tools/doxygen/Doxyfile.core
+++ b/tools/doxygen/Doxyfile.core
@@ -826,32 +826,32 @@ include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_generic.h \
include/grpc/impl/codegen/sync_posix.h \
include/grpc/impl/codegen/sync_windows.h \
+doc/command_line_tool.md \
+doc/statuscodes.md \
+doc/interop-test-descriptions.md \
doc/fail_fast.md \
+doc/server-reflection.md \
+doc/c-style-guide.md \
+doc/load-balancing.md \
+doc/compression_cookbook.md \
+doc/connectivity-semantics-and-api.md \
+doc/PROTOCOL-HTTP2.md \
+doc/health-checking.md \
+doc/binary-logging.md \
+doc/stress_test_framework.md \
+doc/negative-http2-interop-test-descriptions.md \
doc/compression.md \
+doc/server_reflection_tutorial.md \
+doc/cpp-style-guide.md \
doc/environment_variables.md \
-doc/stress_test_framework.md \
doc/PROTOCOL-WEB.md \
-doc/cpp-style-guide.md \
-doc/http-grpc-status-mapping.md \
-doc/wait-for-ready.md \
-doc/command_line_tool.md \
-doc/c-style-guide.md \
-doc/server_reflection_tutorial.md \
-doc/health-checking.md \
-doc/connection-backoff-interop-test-description.md \
-doc/epoll-polling-engine.md \
doc/naming.md \
-doc/binary-logging.md \
-doc/connectivity-semantics-and-api.md \
+doc/epoll-polling-engine.md \
doc/connection-backoff.md \
-doc/compression_cookbook.md \
-doc/PROTOCOL-HTTP2.md \
-doc/load-balancing.md \
-doc/negative-http2-interop-test-descriptions.md \
-doc/server-reflection.md \
-doc/interop-test-descriptions.md \
-doc/statuscodes.md \
+doc/connection-backoff-interop-test-description.md \
doc/g_stands_for.md \
+doc/http-grpc-status-mapping.md \
+doc/wait-for-ready.md \
doc/core/pending_api_cleanups.md
# This tag can be used to specify the character encoding of the source files
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 8b60152009b..7b647d2ed8d 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -1281,52 +1281,52 @@ src/core/lib/support/tmpfile_msys.c \
src/core/lib/support/tmpfile_posix.c \
src/core/lib/support/tmpfile_windows.c \
src/core/lib/support/wrap_memcpy.c \
+doc/command_line_tool.md \
+doc/statuscodes.md \
+doc/interop-test-descriptions.md \
doc/fail_fast.md \
+doc/server-reflection.md \
+doc/c-style-guide.md \
+doc/load-balancing.md \
+doc/compression_cookbook.md \
+doc/connectivity-semantics-and-api.md \
+doc/PROTOCOL-HTTP2.md \
+doc/health-checking.md \
+doc/binary-logging.md \
+doc/stress_test_framework.md \
+doc/negative-http2-interop-test-descriptions.md \
doc/compression.md \
+doc/server_reflection_tutorial.md \
+doc/cpp-style-guide.md \
doc/environment_variables.md \
-doc/stress_test_framework.md \
doc/PROTOCOL-WEB.md \
-doc/cpp-style-guide.md \
-doc/http-grpc-status-mapping.md \
-doc/wait-for-ready.md \
-doc/command_line_tool.md \
-doc/c-style-guide.md \
-doc/server_reflection_tutorial.md \
-doc/health-checking.md \
-doc/connection-backoff-interop-test-description.md \
-doc/epoll-polling-engine.md \
doc/naming.md \
-doc/binary-logging.md \
-doc/connectivity-semantics-and-api.md \
+doc/epoll-polling-engine.md \
doc/connection-backoff.md \
-doc/compression_cookbook.md \
-doc/PROTOCOL-HTTP2.md \
-doc/load-balancing.md \
-doc/negative-http2-interop-test-descriptions.md \
-doc/server-reflection.md \
-doc/interop-test-descriptions.md \
-doc/statuscodes.md \
+doc/connection-backoff-interop-test-description.md \
doc/g_stands_for.md \
+doc/http-grpc-status-mapping.md \
+doc/wait-for-ready.md \
doc/core/pending_api_cleanups.md \
src/core/README.md \
src/core/ext/README.md \
src/core/ext/transport/README.md \
src/core/ext/transport/chttp2/README.md \
-src/core/ext/transport/chttp2/client/secure/README.md \
-src/core/ext/transport/chttp2/client/insecure/README.md \
src/core/ext/transport/chttp2/transport/README.md \
-src/core/ext/transport/chttp2/server/secure/README.md \
src/core/ext/transport/chttp2/server/insecure/README.md \
+src/core/ext/transport/chttp2/server/secure/README.md \
+src/core/ext/transport/chttp2/client/insecure/README.md \
+src/core/ext/transport/chttp2/client/secure/README.md \
+src/core/ext/census/README.md \
+src/core/ext/census/gen/README.md \
src/core/ext/client_channel/README.md \
src/core/ext/resolver/README.md \
-src/core/ext/resolver/sockaddr/README.md \
src/core/ext/resolver/dns/native/README.md \
-src/core/ext/census/README.md \
-src/core/ext/census/gen/README.md \
+src/core/ext/resolver/sockaddr/README.md \
src/core/lib/README.md \
-src/core/lib/tsi/README.md \
-src/core/lib/channel/README.md \
src/core/lib/transport/README.md \
+src/core/lib/channel/README.md \
+src/core/lib/tsi/README.md \
src/core/lib/iomgr/README.md \
src/core/lib/surface/README.md
From 2b939832d50fe6823df2658c53fd3fb9003fdfd0 Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Thu, 19 Jan 2017 13:12:11 -0800
Subject: [PATCH 007/167] update
---
BUILD | 5 ++
build.yaml | 5 ++
src/core/ext/census/trace_label.h | 59 +++++++++++++
src/core/ext/census/trace_propagation.h | 62 +++++++++++++
src/core/ext/census/trace_status.h | 45 ++++++++++
src/core/ext/census/trace_string.h | 47 ++++++++++
src/core/ext/census/tracing.c | 43 ++++++---
src/core/ext/census/tracing.h | 113 ++++++++++++++++++++++++
8 files changed, 367 insertions(+), 12 deletions(-)
create mode 100644 src/core/ext/census/trace_label.h
create mode 100644 src/core/ext/census/trace_propagation.h
create mode 100644 src/core/ext/census/trace_status.h
create mode 100644 src/core/ext/census/trace_string.h
create mode 100644 src/core/ext/census/tracing.h
diff --git a/BUILD b/BUILD
index 54192514cc7..10d93d1f9cd 100644
--- a/BUILD
+++ b/BUILD
@@ -284,6 +284,11 @@ grpc_cc_library(
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h",
"src/core/ext/census/trace_context.h",
+ "src/core/ext/census/trace_label.h",
+ "src/core/ext/census/trace_propagation.h",
+ "src/core/ext/census/trace_status.h",
+ "src/core/ext/census/trace_string.h",
+ "src/core/ext/census/tracing.h",
],
external_deps = [
"nanopb",
diff --git a/build.yaml b/build.yaml
index eaf64e860f1..0b490268c69 100644
--- a/build.yaml
+++ b/build.yaml
@@ -31,6 +31,11 @@ filegroups:
- src/core/ext/census/resource.h
- src/core/ext/census/rpc_metric_id.h
- src/core/ext/census/trace_context.h
+ - src/core/ext/census/trace_label.h
+ - src/core/ext/census/trace_propagation.h
+ - src/core/ext/census/trace_status.h
+ - src/core/ext/census/trace_string.h
+ - src/core/ext/census/tracing.h
src:
- src/core/ext/census/base_resources.c
- src/core/ext/census/context.c
diff --git a/src/core/ext/census/trace_label.h b/src/core/ext/census/trace_label.h
new file mode 100644
index 00000000000..b58543b7d8c
--- /dev/null
+++ b/src/core/ext/census/trace_label.h
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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_CENSUS_TRACE_LABEL_H
+#define GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
+
+#include "src/core/ext/census/trace_string.h"
+
+/* Trace label (key/value pair) stores a label name and the label value. */
+typedef struct trace_label {
+ trace_string key;
+ enum label_type {
+ /* A string value */
+ LABEL_STRING = 1,
+ /* An integer value. */
+ LABEL_INT = 2,
+ /* A boolean value. */
+ LABEL_BOOL = 3,
+ } value_type;
+
+ union value {
+ trace_string label_str;
+ int64_t label_int;
+ bool label_bool;
+ } value;
+ size_t val_len;
+} trace_label;
+
+#endif
diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h
new file mode 100644
index 00000000000..093492c3e8e
--- /dev/null
+++ b/src/core/ext/census/trace_propagation.h
@@ -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.
+ *
+ */
+
+#ifndef GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
+#define GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
+
+#include "src/core/ext/census/tracing.h"
+
+/* Encoding and decoding functions for receiving and sending propagating data
+ over the wire. Only RPC libraries should be calling these
+ functions. These functions return the number of bytes encoded/decoded
+ (0 if a failure has occurred). buf_size indicates the size of the
+ input/output buffer. trace_span_context is a struct that includes the
+ trace ID, span ID, and a set of option flags (is_sampled, etc.). */
+
+/* Converts a span context to a binary byte buffer. */
+size_t trace_span_context_to_binary(const trace_span_context *ctxt, char *buf,
+ size_t buf_size);
+
+/* Reads a binary byte buffer and populates a span context structure. */
+size_t binary_to_trace_span_context(const char *buf, size_t buf_size,
+ trace_span_context *ctxt);
+
+/* Converts a span context to a http format buffer. */
+size_t trace_span_context_to_http_format(const trace_span_context *ctxt,
+ char *buf, size_t buf_size);
+
+/* Reads a http format buffer and populates a span context structure. */
+size_t http_format_to_trace_span_context(const char *buf, size_t buf_size,
+ trace_span_context *ctxt);
+
+#endif
diff --git a/src/core/ext/census/trace_status.h b/src/core/ext/census/trace_status.h
new file mode 100644
index 00000000000..a4bd4116c30
--- /dev/null
+++ b/src/core/ext/census/trace_status.h
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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_CENSUS_TRACE_STATUS_H
+#define GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
+
+#include "src/core/ext/census/trace_string.h"
+
+/* Stores a status code and status message for a trace. */
+typedef struct trace_status {
+ int errorCode;
+ trace_string errorMessage;
+} trace_status;
+
+#endif
diff --git a/src/core/ext/census/trace_string.h b/src/core/ext/census/trace_string.h
new file mode 100644
index 00000000000..0f71056c3bc
--- /dev/null
+++ b/src/core/ext/census/trace_string.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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_CENSUS_TRACE_STRING_H
+#define GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
+
+#include
+
+/* String struct for tracing messages. Since this is a C API, we do not have
+ access to a string class. This is intended for use by higher level
+ languages which wrap around the C API, as most of them have a string class.
+ This will also be more efficient when copying, as we have an explicitly
+ specified length. Also, grpc_slice has reference counting which allows for
+ interning. */
+typedef struct trace_string { grpc_slice string_slice; } trace_string;
+
+#endif
diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c
index 9371fffc8d7..8d22f43eed5 100644
--- a/src/core/ext/census/tracing.c
+++ b/src/core/ext/census/tracing.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,21 +31,40 @@
*
*/
-//#include "src/core/ext/census/tracing.h"
-
+#include "src/core/ext/census/tracing.h"
#include
-#include
+#include
+#include
+#include
+#include "src/core/ext/census/mlog.h"
-/* TODO(aveitch): These are all placeholder implementations. */
+void trace_start_span(const trace_span_context *span_ctxt,
+ const trace_string name, const start_span_options *opts,
+ trace_span_context *new_span_ctxt,
+ bool has_remote_parent) {
+ // Noop implementation.
+}
-int census_trace_mask(const census_context *context) {
- abort();
- return CENSUS_TRACE_MASK_NONE;
+void trace_add_span_annotation(const trace_string description,
+ const trace_label *labels, const size_t n_labels,
+ trace_span_context *span_ctxt) {
+ // Noop implementation.
}
-void census_set_trace_mask(int trace_mask) { abort(); }
+void trace_add_span_network_event_annotation(const trace_string description,
+ const trace_label *labels,
+ const size_t n_labels,
+ const gpr_timespec timestamp,
+ bool sent, uint64_t id,
+ trace_span_context *span_ctxt) {
+ // Noop implementation.
+}
+
+void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
+ trace_span_context *span_ctxt) {
+ // Noop implementation.
+}
-void census_trace_print(census_context *context, uint32_t type,
- const char *buffer, size_t n) {
- abort();
+void trace_end_span(const trace_status *status, trace_span_context *span_ctxt) {
+ // Noop implementation.
}
diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h
new file mode 100644
index 00000000000..5be39e377ac
--- /dev/null
+++ b/src/core/ext/census/tracing.h
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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_CENSUS_TRACING_H
+#define GRPC_CORE_EXT_CENSUS_TRACING_H
+
+#include
+#include
+#include "src/core/ext/census/trace_context.h"
+#include "src/core/ext/census/trace_label.h"
+#include "src/core/ext/census/trace_status.h"
+
+/* The tracing level. */
+public
+enum TraceLevel {
+ /* Annotations on this context will be silently discarded. */
+ NO_TRACING = 0,
+ /* Annotations will not be saved to a persistent store. They will be
+ available via local APIs only. It is not propagated to the child. */
+ TRANSIENT_TRACING = 1,
+ /* Annotations are recorded for the entire distributed trace and they are
+ saved to a persistent store. It is propagated to the child. */
+ PERSISTENT_TRACING = 2,
+}
+
+typedef struct trace_span_context {
+ /* Trace span context stores Span ID, Trace ID, and option flags. */
+ uint64_t trace_id_hi;
+ uint64_t trace_id_lo;
+ uint64_t span_id;
+ uint32_t span_options;
+} trace_span_context;
+
+typedef struct start_span_options {
+ /* If set, this will override the Span.local_start_time for the Span. */
+ gpr_timespec local_start_timestamp;
+
+ /* If set, the Spans are linked to the created Span. */
+ trace_span_context *linked_spans;
+ /* The number of linked spans. */
+ size_t n_linked_spans;
+} start_span_options;
+
+/* Create a new child Span (or root if parent is NULL), with parent being the
+ designated Span. The child span will have the provided name and starting
+ span options (optional). The bool has_remote_parent marks whether the
+ context refers to a remote parent span or not. */
+void trace_start_span(const trace_span_context *span_ctxt,
+ const trace_string name, const start_span_options *opts,
+ trace_span_context *new_span_ctxt,
+ bool has_remote_parent);
+
+/* Add a new Annotation to the Span. The description corresponds to
+ Span->annotations[].description. */
+void trace_add_span_annotation(const trace_string description,
+ const trace_label *labels, const size_t n_labels,
+ trace_span_context *span_ctxt);
+
+/* Add a new NetworkEvent annotation to a Span. This function is only intended
+ to be used by RPC systems (either client or server), not by higher level
+ applications. The timestamp type will be system-defined, the sent argument
+ designates whether this is a network send event (client request, server
+ reply)or receive (server request, client reply). The id argument corresponds
+ to Span.Annotation.NetworkEvent.id from the data model, and serves to uniquely
+ identify each network message. */
+void trace_add_span_network_event(const trace_string description,
+ const trace_label *labels,
+ const size_t n_labels,
+ const gpr_timespec timestamp, bool sent,
+ uint64_t id, trace_span_context *span_ctxt);
+
+/* Add a set of labels to the Span. These will correspond to the field
+Span.labels in the data model. */
+void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
+ trace_span_context *span_ctxt);
+
+/* Mark the end of Span Execution with the given status. Only the timing of the
+first EndSpan call for a given Span will be recorded, and implementations are
+free to ignore all further calls using the Span. EndSpanOptions can
+optionally be NULL. */
+void trace_end_span(const trace_status *status, trace_span_context *span_ctxt);
+
+#endif
From 548d59f305b43d22ca1ef03c5fa82576f32d469a Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Thu, 19 Jan 2017 16:41:37 -0800
Subject: [PATCH 008/167] update
---
src/core/ext/census/tracing.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h
index 5be39e377ac..0632b841bd1 100644
--- a/src/core/ext/census/tracing.h
+++ b/src/core/ext/census/tracing.h
@@ -41,7 +41,6 @@
#include "src/core/ext/census/trace_status.h"
/* The tracing level. */
-public
enum TraceLevel {
/* Annotations on this context will be silently discarded. */
NO_TRACING = 0,
@@ -51,7 +50,7 @@ enum TraceLevel {
/* Annotations are recorded for the entire distributed trace and they are
saved to a persistent store. It is propagated to the child. */
PERSISTENT_TRACING = 2,
-}
+};
typedef struct trace_span_context {
/* Trace span context stores Span ID, Trace ID, and option flags. */
From 645e30a9311af1721bd8b02b533953c2c38d8263 Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Fri, 20 Jan 2017 10:59:15 -0800
Subject: [PATCH 009/167] Fix compilation errors after latest merge with master
---
test/core/iomgr/pollset_set_test.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index af971c0784e..335e3662e6d 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -95,7 +95,8 @@ static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
int i;
for (i = 0; i < num_pollsets; i++) {
- grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].ps);
+ grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].ps,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed);
grpc_exec_ctx_flush(exec_ctx);
@@ -123,7 +124,8 @@ void on_readable(grpc_exec_ctx *exec_ctx, void *tfd, grpc_error *error) {
static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) {
tfd->is_on_readable_called = false;
- grpc_closure_init(&tfd->on_readable, on_readable, tfd);
+ grpc_closure_init(&tfd->on_readable, on_readable, tfd,
+ grpc_schedule_on_exec_ctx);
grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
}
@@ -449,6 +451,7 @@ void pollset_set_test_empty_pollset() {
int main(int argc, char **argv) {
const char *poll_strategy = NULL;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_iomgr_init();
@@ -464,7 +467,8 @@ int main(int argc, char **argv) {
poll_strategy);
}
- grpc_iomgr_shutdown();
+ grpc_iomgr_shutdown(&exec_ctx);
+ grpc_exec_ctx_finish(&exec_ctx);
return 0;
}
#else /* defined(GRPC_LINUX_EPOLL) */
From 0e5b67f4a2405654a99cac5d5b54816f9339c4fa Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Fri, 20 Jan 2017 14:02:18 -0800
Subject: [PATCH 010/167] update
---
gRPC-Core.podspec | 12 +++++++++++-
grpc.gemspec | 5 +++++
package.xml | 5 +++++
third_party/gflags | 2 +-
tools/doxygen/Doxyfile.core.internal | 5 +++++
.../run_tests/generated/sources_and_headers.json | 14 ++++++++++++--
vsprojects/vcxproj/grpc/grpc.vcxproj | 5 +++++
vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 15 +++++++++++++++
.../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 5 +++++
.../grpc_unsecure/grpc_unsecure.vcxproj.filters | 15 +++++++++++++++
10 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 1eb178931dc..1dd2ad46b22 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -432,6 +432,11 @@ Pod::Spec.new do |s|
'src/core/ext/census/resource.h',
'src/core/ext/census/rpc_metric_id.h',
'src/core/ext/census/trace_context.h',
+ 'src/core/ext/census/trace_label.h',
+ 'src/core/ext/census/trace_propagation.h',
+ 'src/core/ext/census/trace_status.h',
+ 'src/core/ext/census/trace_string.h',
+ 'src/core/ext/census/tracing.h',
'src/core/lib/surface/init.c',
'src/core/lib/channel/channel_args.c',
'src/core/lib/channel/channel_stack.c',
@@ -843,7 +848,12 @@ Pod::Spec.new do |s|
'src/core/ext/census/mlog.h',
'src/core/ext/census/resource.h',
'src/core/ext/census/rpc_metric_id.h',
- 'src/core/ext/census/trace_context.h'
+ 'src/core/ext/census/trace_context.h',
+ 'src/core/ext/census/trace_label.h',
+ 'src/core/ext/census/trace_propagation.h',
+ 'src/core/ext/census/trace_status.h',
+ 'src/core/ext/census/trace_string.h',
+ 'src/core/ext/census/tracing.h'
end
s.subspec 'Cronet-Interface' do |ss|
diff --git a/grpc.gemspec b/grpc.gemspec
index cfc0c35aa3e..ecc96bc2fea 100755
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -349,6 +349,11 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/census/resource.h )
s.files += %w( src/core/ext/census/rpc_metric_id.h )
s.files += %w( src/core/ext/census/trace_context.h )
+ s.files += %w( src/core/ext/census/trace_label.h )
+ s.files += %w( src/core/ext/census/trace_propagation.h )
+ s.files += %w( src/core/ext/census/trace_status.h )
+ s.files += %w( src/core/ext/census/trace_string.h )
+ s.files += %w( src/core/ext/census/tracing.h )
s.files += %w( src/core/lib/surface/init.c )
s.files += %w( src/core/lib/channel/channel_args.c )
s.files += %w( src/core/lib/channel/channel_stack.c )
diff --git a/package.xml b/package.xml
index aa1894f4086..cac087ad6c6 100644
--- a/package.xml
+++ b/package.xml
@@ -358,6 +358,11 @@
+
+
+
+
+
diff --git a/third_party/gflags b/third_party/gflags
index f8a0efe03aa..05b155ff591 160000
--- a/third_party/gflags
+++ b/third_party/gflags
@@ -1 +1 @@
-Subproject commit f8a0efe03aa69b3336d8e228b37d4ccb17324b88
+Subproject commit 05b155ff59114735ec8cd089f669c4c3d8f59029
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index ffe83a2ddb3..019a0784b5b 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -884,7 +884,12 @@ src/core/ext/census/resource.h \
src/core/ext/census/rpc_metric_id.h \
src/core/ext/census/trace_context.c \
src/core/ext/census/trace_context.h \
+src/core/ext/census/trace_label.h \
+src/core/ext/census/trace_propagation.h \
+src/core/ext/census/trace_status.h \
+src/core/ext/census/trace_string.h \
src/core/ext/census/tracing.c \
+src/core/ext/census/tracing.h \
src/core/ext/client_channel/README.md \
src/core/ext/client_channel/channel_connectivity.c \
src/core/ext/client_channel/client_channel.c \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index c57b17611be..51946bf02f7 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -6551,7 +6551,12 @@
"src/core/ext/census/mlog.h",
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h",
- "src/core/ext/census/trace_context.h"
+ "src/core/ext/census/trace_context.h",
+ "src/core/ext/census/trace_label.h",
+ "src/core/ext/census/trace_propagation.h",
+ "src/core/ext/census/trace_status.h",
+ "src/core/ext/census/trace_string.h",
+ "src/core/ext/census/tracing.h"
],
"is_filegroup": true,
"language": "c",
@@ -6582,7 +6587,12 @@
"src/core/ext/census/rpc_metric_id.h",
"src/core/ext/census/trace_context.c",
"src/core/ext/census/trace_context.h",
- "src/core/ext/census/tracing.c"
+ "src/core/ext/census/trace_label.h",
+ "src/core/ext/census/trace_propagation.h",
+ "src/core/ext/census/trace_status.h",
+ "src/core/ext/census/trace_string.h",
+ "src/core/ext/census/tracing.c",
+ "src/core/ext/census/tracing.h"
],
"third_party": false,
"type": "filegroup"
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj
index c159db63f55..15198621ca2 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj
@@ -481,6 +481,11 @@
+
+
+
+
+
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
index 1e099f3285e..c7bdd43a4d7 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
@@ -1292,6 +1292,21 @@
src\core\ext\census
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
index dcb943a3a11..5db67a1a4c2 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
@@ -447,6 +447,11 @@
+
+
+
+
+
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
index ac84e0188c8..d60461a2bb3 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
@@ -1133,6 +1133,21 @@
src\core\ext\census
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
+
+ src\core\ext\census
+
From 7e87c3292927e2c4fa0a0adeaf614cdd0cc4710b Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Mon, 23 Jan 2017 14:11:23 -0800
Subject: [PATCH 011/167] generate_projects.sh
---
CMakeLists.txt | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ca0b805429..c10773fc02a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6919,6 +6919,30 @@ target_link_libraries(percent_encoding_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(pollset_set_test
+ test/core/iomgr/pollset_set_test.c
+)
+
+target_include_directories(pollset_set_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+)
+
+target_link_libraries(pollset_set_test
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(resolve_address_test
test/core/iomgr/resolve_address_test.c
)
From b0bd22dfc7116975245c6d15fcc9485a25885845 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Fri, 20 Jan 2017 17:06:23 -0800
Subject: [PATCH 012/167] Test packet coalescing using TLS endpoint
---
.../tests/CronetUnitTests/CronetUnitTests.m | 228 +++++++++++++++++-
1 file changed, 225 insertions(+), 3 deletions(-)
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index dbd28076ddb..dcd7f2fa8db 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -50,6 +50,9 @@
#import "src/core/lib/support/string.h"
#import "src/core/lib/support/tmpfile.h"
#import "test/core/util/test_config.h"
+#import "test/core/end2end/data/ssl_test_data.h"
+
+#import
static void drain_cq(grpc_completion_queue *cq) {
grpc_event ev;
@@ -77,20 +80,70 @@ static void drain_cq(grpc_completion_queue *cq) {
grpc_init();
[Cronet setHttp2Enabled:YES];
+ [Cronet setSslKeyLogFileName:@"Documents/key"];
+ [Cronet enableTestCertVerifierForTesting];
NSURL *url = [[[NSFileManager defaultManager]
URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] lastObject];
NSLog(@"Documents directory: %@", url);
[Cronet start];
[Cronet startNetLogToFile:@"Documents/cronet_netlog.json" logBytes:YES];
+
+ init_ssl();
}
+ (void)tearDown {
grpc_shutdown();
+ cleanup_ssl();
[super tearDown];
}
+void init_ssl(void) {
+ SSL_load_error_strings();
+ OpenSSL_add_ssl_algorithms();
+}
+
+void cleanup_ssl(void) {
+ EVP_cleanup();
+}
+
+int alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen,
+ const unsigned char *in, unsigned int inlen, void *arg) {
+ // Always select "h2" as the ALPN protocol to be used
+ *out = (const unsigned char*)"h2";
+ *outlen = 2;
+ return SSL_TLSEXT_ERR_OK;
+}
+
+void init_ctx(SSL_CTX *ctx) {
+ // Install server certificate
+ BIO *pem = BIO_new_mem_buf((void*)test_server1_cert, (int)strlen(test_server1_cert));
+ X509 *cert = PEM_read_bio_X509_AUX(pem, NULL, NULL, "");
+ SSL_CTX_use_certificate(ctx, cert);
+ X509_free(cert);
+ BIO_free(pem);
+
+ // Install server private key
+ pem = BIO_new_mem_buf((void *)test_server1_key, (int)strlen(test_server1_key));
+ EVP_PKEY *key = PEM_read_bio_PrivateKey(pem, NULL, NULL, "");
+ SSL_CTX_use_PrivateKey(ctx, key);
+ EVP_PKEY_free(key);
+ BIO_free(pem);
+
+ // Select cipher suite
+ SSL_CTX_set_cipher_list(ctx, "ECDHE-RSA-AES128-GCM-SHA256");
+
+ // Select ALPN protocol
+ SSL_CTX_set_alpn_select_cb(ctx, alpn_cb, NULL);
+}
+
+unsigned int parse_h2_length(const char *field) {
+ return ((unsigned int)(unsigned char)(field[0])) * 65536 +
+ ((unsigned int)(unsigned char)(field[1])) * 256 +
+ ((unsigned int)(unsigned char)(field[2]));
+}
+
- (void)testInternalError {
grpc_call *c;
grpc_slice request_payload_slice =
@@ -106,7 +159,7 @@ static void drain_cq(grpc_completion_queue *cq) {
char *addr;
gpr_join_host_port(&addr, "127.0.0.1", port);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
- cronet_engine *cronetEngine = [Cronet getGlobalEngine];
+ stream_engine *cronetEngine = [Cronet getGlobalEngine];
grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr,
NULL, NULL);
@@ -174,14 +227,19 @@ static void drain_cq(grpc_completion_queue *cq) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
int sl = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(sl >= 0);
+
+ // Make and TCP endpoint to accept the connection
struct sockaddr_in s_addr;
memset(&s_addr, 0, sizeof(s_addr));
s_addr.sin_family = AF_INET;
s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
s_addr.sin_port = htons(port);
- bind(sl, (struct sockaddr*)&s_addr, sizeof(s_addr));
- listen(sl, 5);
+ GPR_ASSERT(0 == bind(sl, (struct sockaddr*)&s_addr, sizeof(s_addr)));
+ GPR_ASSERT(0 == listen(sl, 5));
int s = accept(sl, NULL, NULL);
+ GPR_ASSERT(s >= 0);
+
+ // Close the connection after 1 second to trigger Cronet's on_failed()
sleep(1);
close(s);
close(sl);
@@ -211,4 +269,168 @@ static void drain_cq(grpc_completion_queue *cq) {
grpc_completion_queue_destroy(cq);
}
+- (void)testPacketCoalescing {
+ grpc_call *c;
+ grpc_slice request_payload_slice =
+ grpc_slice_from_copied_string("hello world");
+ grpc_byte_buffer *request_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5);
+ grpc_metadata meta_c[2] = {
+ {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}},
+ {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}};
+
+ int port = grpc_pick_unused_port_or_die();
+ char *addr;
+ gpr_join_host_port(&addr, "127.0.0.1", port);
+ grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
+ stream_engine *cronetEngine = [Cronet getGlobalEngine];
+ grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr,
+ NULL, NULL);
+
+ cq_verifier *cqv = cq_verifier_create(cq);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ char *details = NULL;
+ size_t details_capacity = 0;
+
+ c = grpc_channel_create_call(
+ client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo",
+ NULL, deadline, NULL);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 2;
+ op->data.send_initial_metadata.metadata = meta_c;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &response_payload_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void*)1, NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ int sl = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(sl >= 0);
+ struct sockaddr_in s_addr;
+ memset(&s_addr, 0, sizeof(s_addr));
+ s_addr.sin_family = AF_INET;
+ s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ s_addr.sin_port = htons(port);
+ GPR_ASSERT(0 == bind(sl, (struct sockaddr*)&s_addr, sizeof(s_addr)));
+ GPR_ASSERT(0 == listen(sl, 5));
+ int s = accept(sl, NULL, NULL);
+ GPR_ASSERT(s >= 0);
+ struct timeval tv;
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+
+ // Make an TLS endpoint to receive Cronet's transmission
+ SSL_CTX *ctx = SSL_CTX_new(TLSv1_2_server_method());
+ init_ctx(ctx);
+ SSL *ssl = SSL_new(ctx);
+ SSL_set_fd(ssl, s);
+ SSL_accept(ssl);
+
+ const char magic[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
+
+ char buf[4096];
+ long len;
+ bool coalesced = false;
+ while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
+ NSLog(@"Read len: %ld", len);
+
+ // Analyze the HTTP/2 frames in the same TLS PDU to identify if
+ // coalescing is successful
+ unsigned int p = 0;
+ while (p < len) {
+ if (len - p >= 24 && 0 == memcmp(&buf[p], magic, 24)) {
+ p += 24;
+ continue;
+ }
+
+ if (buf[p+3] == 0 && // Type is DATA
+ parse_h2_length(&buf[p]) == 0x10 && // Length is correct
+ (buf[p+4] & 1) != 0 && // EOS bit is set
+ 0 == memcmp("hello world", &buf[p+14], 11)) { // Message is correct
+ coalesced = true;
+ break;
+ }
+ p += (parse_h2_length(&buf[p]) + 9);
+ }
+ if (coalesced) {
+ break;
+ }
+ }
+
+ XCTAssert(coalesced);
+ SSL_free(ssl);
+ SSL_CTX_free(ctx);
+ close(s);
+ close(sl);
+ });
+
+ CQ_EXPECT_COMPLETION(cqv, (void*)1, 1);
+ cq_verify(cqv);
+
+ gpr_free(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_destroy(c);
+
+ cq_verifier_destroy(cqv);
+
+ grpc_byte_buffer_destroy(request_payload);
+ grpc_byte_buffer_destroy(response_payload_recv);
+
+ grpc_channel_destroy(client);
+ grpc_completion_queue_shutdown(cq);
+ drain_cq(cq);
+ grpc_completion_queue_destroy(cq);
+}
+
@end
From 60ab7ef00ac0a988ee2672c636d946c964e6fa41 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Mon, 23 Jan 2017 23:00:35 -0800
Subject: [PATCH 013/167] Dynamically enable/disable packet coalecsing and test
it
---
include/grpc/grpc_cronet.h | 2 +
.../client/secure/cronet_channel_create.c | 6 ++
.../cronet/transport/cronet_transport.c | 72 +++++++++----------
.../tests/CronetUnitTests/CronetUnitTests.m | 13 +++-
src/objective-c/tests/Podfile | 1 -
5 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/include/grpc/grpc_cronet.h b/include/grpc/grpc_cronet.h
index 295e0f55e80..566c34a388d 100644
--- a/include/grpc/grpc_cronet.h
+++ b/include/grpc/grpc_cronet.h
@@ -44,6 +44,8 @@ GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
void *engine, const char *target, const grpc_channel_args *args,
void *reserved);
+GRPCAPI void grpc_cronet_use_packet_coalescing(bool use_coalescing);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
index 477cf07f45d..2e40020ae05 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
@@ -51,6 +51,8 @@ typedef struct cronet_transport {
extern grpc_transport_vtable grpc_cronet_vtable;
+bool grpc_cronet_packet_coalescing_enabled = true;
+
GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
void *engine, const char *target, const grpc_channel_args *args,
void *reserved) {
@@ -67,3 +69,7 @@ GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
return grpc_channel_create(&exec_ctx, target, args,
GRPC_CLIENT_DIRECT_CHANNEL, (grpc_transport *)ct);
}
+
+GRPCAPI void grpc_cronet_use_packet_coalescing(bool use_coalescing) {
+ grpc_cronet_packet_coalescing_enabled = use_coalescing;
+}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c
index 447f3f31ec1..5429eb32e3c 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.c
@@ -61,6 +61,8 @@
/* TODO (makdharma): Hook up into the wider tracing mechanism */
int grpc_cronet_trace = 0;
+extern bool grpc_cronet_packet_coalescing_enabled;
+
enum e_op_result {
ACTION_TAKEN_WITH_CALLBACK,
ACTION_TAKEN_NO_CALLBACK,
@@ -150,12 +152,13 @@ struct op_state {
bool state_callback_received[OP_NUM_OPS];
bool fail_state;
bool flush_read;
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
bool flush_cronet_when_ready;
bool pending_write_for_trailer;
-#endif
bool unprocessed_send_message;
grpc_error *cancel_error;
+
+ /* Whether packet coalescing is enabled */
+ bool packet_coalescing_enabled;
/* data structure for storing data coming from server */
struct read_state rs;
/* data structure for storing data going to the server */
@@ -425,12 +428,10 @@ static void on_stream_ready(bidirectional_stream *stream) {
}
/* Send the initial metadata on wire if there is no SEND_MESSAGE or
* SEND_TRAILING_METADATA ops pending */
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- if (s->state.flush_cronet_when_ready) {
+ if (s->state.packet_coalescing_enabled && s->state.flush_cronet_when_ready) {
CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
bidirectional_stream_flush(stream);
}
-#endif
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
}
@@ -568,10 +569,10 @@ static void on_response_trailers_received(
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, 0)", s->cbs);
s->state.state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
-#endif
+ if (s->state.packet_coalescing_enabled) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+ }
s->state.state_op_done[OP_SEND_TRAILING_METADATA] = true;
gpr_mu_unlock(&s->mu);
@@ -768,11 +769,9 @@ static bool op_can_be_run(grpc_transport_stream_op *curr_op,
result = false;
/* we haven't got on_write_completed for the send yet */
else if (stream_state->state_op_done[OP_SEND_MESSAGE] &&
- !stream_state->state_callback_received[OP_SEND_MESSAGE]
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- && !stream_state->pending_write_for_trailer
-#endif
- )
+ !stream_state->state_callback_received[OP_SEND_MESSAGE] &&
+ !(stream_state->packet_coalescing_enabled &&
+ stream_state->pending_write_for_trailer))
result = false;
} else if (op_id == OP_CANCEL_ERROR) {
/* already executed */
@@ -858,10 +857,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
s->cbs = bidirectional_stream_create(s->curr_ct.engine, s->curr_gs,
&cronet_callbacks);
CRONET_LOG(GPR_DEBUG, "%p = bidirectional_stream_create()", s->cbs);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- bidirectional_stream_disable_auto_flush(s->cbs, true);
- bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
-#endif
+ if (stream_state->packet_coalescing_enabled) {
+ bidirectional_stream_disable_auto_flush(s->cbs, true);
+ bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
+ }
char *url = NULL;
const char *method = "POST";
s->header_array.headers = NULL;
@@ -872,11 +871,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_start(%p, %s)", s->cbs, url);
bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array, false);
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true;
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- if (!stream_op->send_message && !stream_op->send_trailing_metadata) {
+ if (stream_state->packet_coalescing_enabled && !stream_op->send_message &&
+ !stream_op->send_trailing_metadata) {
s->state.flush_cronet_when_ready = true;
}
-#endif
result = ACTION_TAKEN_WITH_CALLBACK;
} else if (stream_op->send_message &&
op_can_be_run(stream_op, stream_state, &oas->state,
@@ -913,19 +911,18 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
(int)write_buffer_size, false);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- if (!stream_op->send_trailing_metadata) {
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)",
- s->cbs);
- bidirectional_stream_flush(s->cbs);
- result = ACTION_TAKEN_WITH_CALLBACK;
+ if (stream_state->packet_coalescing_enabled) {
+ if (!stream_op->send_trailing_metadata) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+ result = ACTION_TAKEN_WITH_CALLBACK;
+ } else {
+ stream_state->pending_write_for_trailer = true;
+ result = ACTION_TAKEN_NO_CALLBACK;
+ }
} else {
- stream_state->pending_write_for_trailer = true;
- result = ACTION_TAKEN_NO_CALLBACK;
+ result = ACTION_TAKEN_WITH_CALLBACK;
}
-#else
- result = ACTION_TAKEN_WITH_CALLBACK;
-#endif
} else {
result = NO_ACTION_POSSIBLE;
}
@@ -944,10 +941,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
s->cbs);
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
-#endif
+ if (stream_state->packet_coalescing_enabled) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+ }
result = ACTION_TAKEN_WITH_CALLBACK;
}
stream_state->state_op_done[OP_SEND_TRAILING_METADATA] = true;
@@ -1176,10 +1173,9 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
sizeof(s->state.state_callback_received));
s->state.fail_state = s->state.flush_read = false;
s->state.cancel_error = NULL;
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
s->state.flush_cronet_when_ready = s->state.pending_write_for_trailer = false;
-#endif
s->state.unprocessed_send_message = false;
+ s->state.packet_coalescing_enabled = grpc_cronet_packet_coalescing_enabled;
gpr_mu_init(&s->mu);
return 0;
}
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index dcd7f2fa8db..9bbf3cdb113 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -269,7 +269,9 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
-- (void)testPacketCoalescing {
+- (void)PacketCoalescing:(bool)use_coalescing {
+ grpc_cronet_use_packet_coalescing(use_coalescing);
+
grpc_call *c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
@@ -379,7 +381,7 @@ unsigned int parse_h2_length(const char *field) {
long len;
bool coalesced = false;
while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
- NSLog(@"Read len: %ld", len);
+ gpr_log(GPR_DEBUG, "Read len: %ld", len);
// Analyze the HTTP/2 frames in the same TLS PDU to identify if
// coalescing is successful
@@ -404,7 +406,7 @@ unsigned int parse_h2_length(const char *field) {
}
}
- XCTAssert(coalesced);
+ XCTAssert(coalesced == use_coalescing);
SSL_free(ssl);
SSL_CTX_free(ctx);
close(s);
@@ -433,4 +435,9 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
+- (void)testPacketCoalescing {
+ [self PacketCoalescing:false];
+ [self PacketCoalescing:true];
+}
+
@end
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 462c6a8e0eb..3760330be9a 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -97,7 +97,6 @@ post_install do |installer|
# GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
# function" warning
config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
- config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
end
end
From 8d1d95d07cdb7e8fa78ab93399fcf3742fcee63f Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Mon, 23 Jan 2017 23:01:10 -0800
Subject: [PATCH 014/167] Clean up old packet coalescing tests
---
.../CoreCronetEnd2EndTests.m | 11 -
test/core/end2end/tests/packet_coalescing.c | 284 ------------------
2 files changed, 295 deletions(-)
delete mode 100644 test/core/end2end/tests/packet_coalescing.c
diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
index 9af38fd9b22..01612a84b28 100644
--- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
+++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
@@ -170,9 +170,6 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_secure_fullstack},
};
-extern void packet_coalescing(grpc_end2end_test_config config);
-extern void packet_coalescing_pre_init(void);
-
static char *roots_filename;
@interface CoreCronetEnd2EndTests : XCTestCase
@@ -351,14 +348,6 @@ static char *roots_filename;
[self testIndividualCase:"no_op"];
}
-- (void)testPacketCoalescing {
- // Directly invoke the test function since the test is for Cronet only and thus not included in
- // end2end_tests.c
- // TODO (mxyan): Do the same to all test cases so that this file will no longer depend on
- // end2end_tests.c
- packet_coalescing(configs[0]);
-}
-
- (void)testPayload {
[self testIndividualCase:"payload"];
}
diff --git a/test/core/end2end/tests/packet_coalescing.c b/test/core/end2end/tests/packet_coalescing.c
deleted file mode 100644
index 336f765a13f..00000000000
--- a/test/core/end2end/tests/packet_coalescing.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- *
- * 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 "test/core/end2end/end2end_tests.h"
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include "test/core/end2end/cq_verifier.h"
-
-extern void gpr_default_log(gpr_log_func_args *args);
-
-static void *tag(intptr_t t) { return (void *)t; }
-
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
- grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_server(&f, server_args);
- config.init_client(&f, client_args);
- return f;
-}
-
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
-}
-
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
-
-static void drain_cq(grpc_completion_queue *cq) {
- grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
-}
-
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- if (!f->server) return;
- grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
- GPR_ASSERT(grpc_completion_queue_pluck(
- f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
- f->server = NULL;
-}
-
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
- f->client = NULL;
-}
-
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
-
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
-}
-
-static bool coalesced_message_and_eos;
-
-static void log_processor(gpr_log_func_args *args) {
- const int file_len = (int)strlen(args->file);
- const char suffix1[] = "secure_endpoint.c";
- const int suffix1_len = sizeof(suffix1) - 1;
- const char suffix2[] = "tcp_posix.c";
- const int suffix2_len = sizeof(suffix2) - 1;
- const char prefix[] = "READ";
- const int prefix_len = sizeof(prefix) - 1;
- if (((file_len >= suffix1_len &&
- 0 == strcmp(suffix1, &args->file[file_len - suffix1_len])) ||
- (file_len >= suffix2_len &&
- 0 == strcmp(suffix2, &args->file[file_len - suffix2_len]))) &&
- 0 == strncmp(prefix, args->message, (size_t)prefix_len) &&
- strstr(args->message,
- "00 00 10 00 01 00 00 00 01 00 00 00 00 0b 68 65 6c 6c 6f 20 77 "
- "6f 72 6c 64")) {
- fprintf(stderr, "%s, %s\n", args->file, args->message);
- coalesced_message_and_eos = true;
- }
-}
-
-/* Request/response with metadata and payload.*/
-static void test_request_response_with_metadata_and_payload(
- grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
- grpc_slice request_payload_slice =
- grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
- grpc_metadata meta_c[2] = {
- {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}},
- {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}};
- grpc_metadata meta_s[2] = {
- {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}},
- {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}};
- grpc_end2end_test_fixture f = begin_test(
- config, "test_request_response_with_metadata_and_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
- grpc_op ops[6];
- grpc_op *op;
- grpc_metadata_array initial_metadata_recv;
- grpc_metadata_array trailing_metadata_recv;
- grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_call_details call_details;
- grpc_status_code status;
- grpc_call_error error;
- char *details = NULL;
- size_t details_capacity = 0;
- int was_cancelled = 2;
- coalesced_message_and_eos = false;
-
- c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo",
- get_host_override_string("foo.test.google.fr:1234", config), deadline,
- NULL);
- GPR_ASSERT(c);
-
- grpc_metadata_array_init(&initial_metadata_recv);
- grpc_metadata_array_init(&trailing_metadata_recv);
- grpc_metadata_array_init(&request_metadata_recv);
- grpc_call_details_init(&call_details);
-
- memset(ops, 0, sizeof(ops));
- op = ops;
- op->op = GRPC_OP_SEND_INITIAL_METADATA;
- op->data.send_initial_metadata.count = 2;
- op->data.send_initial_metadata.metadata = meta_c;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_SEND_MESSAGE;
- op->data.send_message = request_payload;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_INITIAL_METADATA;
- op->data.recv_initial_metadata = &initial_metadata_recv;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
- op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
- op->data.recv_status_on_client.status = &status;
- op->data.recv_status_on_client.status_details = &details;
- op->data.recv_status_on_client.status_details_capacity = &details_capacity;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- error =
- grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.cq, f.cq, tag(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
- cq_verify(cqv);
-
- memset(ops, 0, sizeof(ops));
- op = ops;
- op->op = GRPC_OP_SEND_INITIAL_METADATA;
- op->data.send_initial_metadata.count = 2;
- op->data.send_initial_metadata.metadata = meta_s;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_MESSAGE;
- op->data.recv_message = &request_payload_recv;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
- cq_verify(cqv);
-
- memset(ops, 0, sizeof(ops));
- op = ops;
- op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
- op->data.recv_close_on_server.cancelled = &was_cancelled;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
- op->data.send_status_from_server.trailing_metadata_count = 0;
- op->data.send_status_from_server.status = GRPC_STATUS_OK;
- op->data.send_status_from_server.status_details = "xyz";
- op->flags = 0;
- op->reserved = NULL;
- op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
- CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
- cq_verify(cqv);
-
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- validate_host_override_string("foo.test.google.fr:1234", call_details.host,
- config);
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key2", "val2"));
- GPR_ASSERT(coalesced_message_and_eos);
-
- gpr_free(details);
- grpc_metadata_array_destroy(&initial_metadata_recv);
- grpc_metadata_array_destroy(&trailing_metadata_recv);
- grpc_metadata_array_destroy(&request_metadata_recv);
- grpc_call_details_destroy(&call_details);
-
- grpc_call_destroy(c);
- grpc_call_destroy(s);
-
- cq_verifier_destroy(cqv);
-
- grpc_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(request_payload_recv);
-
- end_test(&f);
- config.tear_down_data(&f);
-}
-
-void packet_coalescing(grpc_end2end_test_config config) {
- gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
- grpc_tracer_set_enabled("all", 1);
- gpr_set_log_function(log_processor);
- test_request_response_with_metadata_and_payload(config);
- gpr_set_log_function(gpr_default_log);
- grpc_tracer_set_enabled("all", 0);
-}
-
-void packet_coalescing_pre_init(void) {}
From 9078535c0a8f2192a3c48362aa17fdba6c8951ab Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Tue, 24 Jan 2017 13:02:45 -0800
Subject: [PATCH 015/167] updated headers.
---
src/core/ext/census/tracing.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c
index 8d22f43eed5..566d539e6ef 100644
--- a/src/core/ext/census/tracing.c
+++ b/src/core/ext/census/tracing.c
@@ -32,10 +32,11 @@
*/
#include "src/core/ext/census/tracing.h"
+
#include
#include
#include
-#include
+#include "third_party/boringssl/include/openssl/rand.h"
#include "src/core/ext/census/mlog.h"
void trace_start_span(const trace_span_context *span_ctxt,
From c09e61bbda22d81e49e961a3af89bc9e4ad3c589 Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Tue, 24 Jan 2017 16:46:31 -0800
Subject: [PATCH 016/167] update
---
BUILD | 1 +
src/core/ext/census/tracing.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/BUILD b/BUILD
index 10d93d1f9cd..507f7abfbb8 100644
--- a/BUILD
+++ b/BUILD
@@ -292,6 +292,7 @@ grpc_cc_library(
],
external_deps = [
"nanopb",
+ "submodule_boringssl",
],
language = "c",
public_hdrs = [
diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c
index 566d539e6ef..f02aefc3d7d 100644
--- a/src/core/ext/census/tracing.c
+++ b/src/core/ext/census/tracing.c
@@ -36,7 +36,7 @@
#include
#include
#include
-#include "third_party/boringssl/include/openssl/rand.h"
+#include "third_party/boringssl-with-bazel/src/include/openssl/rand.h"
#include "src/core/ext/census/mlog.h"
void trace_start_span(const trace_span_context *span_ctxt,
From b0b86d7504dc7cf25d2616927196203c8ee41373 Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Wed, 25 Jan 2017 13:45:54 -0800
Subject: [PATCH 017/167] updated to correctly build with Bazel.
---
BUILD | 2 +-
src/core/ext/census/tracing.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/BUILD b/BUILD
index 507f7abfbb8..b4835696324 100644
--- a/BUILD
+++ b/BUILD
@@ -292,7 +292,7 @@ grpc_cc_library(
],
external_deps = [
"nanopb",
- "submodule_boringssl",
+ "libssl",
],
language = "c",
public_hdrs = [
diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c
index f02aefc3d7d..8b74628f4fb 100644
--- a/src/core/ext/census/tracing.c
+++ b/src/core/ext/census/tracing.c
@@ -36,7 +36,7 @@
#include
#include
#include
-#include "third_party/boringssl-with-bazel/src/include/openssl/rand.h"
+#include
#include "src/core/ext/census/mlog.h"
void trace_start_span(const trace_span_context *span_ctxt,
From 113267be684063fd4e8db5e83954d6ba1d520b53 Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Wed, 25 Jan 2017 14:37:19 -0800
Subject: [PATCH 018/167] Address code review comments
---
test/core/iomgr/pollset_set_test.c | 53 +++++++++++-------------------
1 file changed, 20 insertions(+), 33 deletions(-)
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index 335e3662e6d..e0675bd9d2c 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -32,9 +32,8 @@
*/
#include "src/core/lib/iomgr/port.h"
-/* This test only relevant on linux systems */
-#ifdef GRPC_POSIX_SOCKET
-#include "src/core/lib/iomgr/ev_posix.h"
+/* This test only relevant on linux systems where epoll is available */
+#ifdef GRPC_LINUX_EPOLL
#include
#include
@@ -43,6 +42,7 @@
#include
#include
+#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "test/core/util/test_config.h"
@@ -52,16 +52,14 @@
typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set;
-void init_test_pollset_sets(test_pollset_set pollset_sets[], int num_pss) {
- int i;
- for (i = 0; i < num_pss; i++) {
+void init_test_pollset_sets(test_pollset_set *pollset_sets, int num_pss) {
+ for (int i = 0; i < num_pss; i++) {
pollset_sets[i].pss = grpc_pollset_set_create();
}
}
-void cleanup_test_pollset_sets(test_pollset_set pollset_sets[], int num_pss) {
- int i;
- for (i = 0; i < num_pss; i++) {
+void cleanup_test_pollset_sets(test_pollset_set *pollset_sets, int num_pss) {
+ for (int i = 0; i < num_pss; i++) {
grpc_pollset_set_destroy(pollset_sets[i].pss);
pollset_sets[i].pss = NULL;
}
@@ -76,9 +74,8 @@ typedef struct test_pollset {
gpr_mu *mu;
} test_pollset;
-static void init_test_pollsets(test_pollset pollsets[], int num_pollsets) {
- int i;
- for (i = 0; i < num_pollsets; i++) {
+static void init_test_pollsets(test_pollset *pollsets, int num_pollsets) {
+ for (int i = 0; i < num_pollsets; i++) {
pollsets[i].ps = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu);
}
@@ -90,11 +87,9 @@ static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
}
static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
- test_pollset pollsets[], int num_pollsets) {
+ test_pollset *pollsets, int num_pollsets) {
grpc_closure destroyed;
- int i;
-
- for (i = 0; i < num_pollsets; i++) {
+ for (int i = 0; i < num_pollsets; i++) {
grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].ps,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed);
@@ -129,11 +124,8 @@ static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) {
grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
}
-static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd tfds[],
- int num_fds) {
- int i;
-
- for (i = 0; i < num_fds; i++) {
+static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, int num_fds) {
+ for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
"test_fd");
@@ -144,9 +136,8 @@ static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd tfds[],
static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
int num_fds) {
int release_fd;
- int i;
- for (i = 0; i < num_fds; i++) {
+ for (int i = 0; i < num_fds; i++) {
grpc_fd_shutdown(exec_ctx, tfds[i].fd);
grpc_exec_ctx_flush(exec_ctx);
@@ -162,17 +153,15 @@ static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
}
}
-static void make_test_fds_readable(test_fd tfds[], int num_fds) {
- int i;
- for (i = 0; i < num_fds; i++) {
+static void make_test_fds_readable(test_fd *tfds, int num_fds) {
+ for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd));
}
}
-static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd tfds[],
+static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds,
int num_fds) {
- int i;
- for (i = 0; i < num_fds; i++) {
+ for (int i = 0; i < num_fds; i++) {
/* Verify that the on_readable callback was called */
GPR_ASSERT(tfds[i].is_on_readable_called);
@@ -221,7 +210,6 @@ static void pollset_set_test_basic() {
* +---> FD9 (Added after PS2 is added to PSS0)
*/
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- int i;
grpc_pollset_worker *worker;
gpr_timespec deadline;
@@ -272,7 +260,7 @@ static void pollset_set_test_basic() {
* - Verify that on_readable call back was called for all FDs (and
* reset the FDs)
* */
- for (i = 0; i < num_ps; i++) {
+ for (int i = 0; i < num_ps; i++) {
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollsets[i].mu);
@@ -450,12 +438,11 @@ void pollset_set_test_empty_pollset() {
}
int main(int argc, char **argv) {
- const char *poll_strategy = NULL;
+ const char *poll_strategy = grpc_get_poll_strategy_name();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_iomgr_init();
- poll_strategy = grpc_get_poll_strategy_name();
if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) {
pollset_set_test_basic();
pollset_set_test_dup_fds();
From 9930e4b39486b3eb62609c67b87d7bc80f63e50d Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Wed, 25 Jan 2017 14:48:20 -0800
Subject: [PATCH 019/167] Code review comments
---
test/core/iomgr/pollset_set_test.c | 38 +++++++++++++++++-------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index e0675bd9d2c..3e8dcb4f9c9 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -41,6 +41,7 @@
#include
#include
+#include
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr.h"
@@ -52,13 +53,14 @@
typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set;
-void init_test_pollset_sets(test_pollset_set *pollset_sets, int num_pss) {
+void init_test_pollset_sets(test_pollset_set *pollset_sets, const int num_pss) {
for (int i = 0; i < num_pss; i++) {
pollset_sets[i].pss = grpc_pollset_set_create();
}
}
-void cleanup_test_pollset_sets(test_pollset_set *pollset_sets, int num_pss) {
+void cleanup_test_pollset_sets(test_pollset_set *pollset_sets,
+ const int num_pss) {
for (int i = 0; i < num_pss; i++) {
grpc_pollset_set_destroy(pollset_sets[i].pss);
pollset_sets[i].pss = NULL;
@@ -74,7 +76,7 @@ typedef struct test_pollset {
gpr_mu *mu;
} test_pollset;
-static void init_test_pollsets(test_pollset *pollsets, int num_pollsets) {
+static void init_test_pollsets(test_pollset *pollsets, const int num_pollsets) {
for (int i = 0; i < num_pollsets; i++) {
pollsets[i].ps = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu);
@@ -87,7 +89,8 @@ static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
}
static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
- test_pollset *pollsets, int num_pollsets) {
+ test_pollset *pollsets,
+ const int num_pollsets) {
grpc_closure destroyed;
for (int i = 0; i < num_pollsets; i++) {
grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].ps,
@@ -124,7 +127,8 @@ static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) {
grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
}
-static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, int num_fds) {
+static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
+ const int num_fds) {
for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
@@ -134,7 +138,7 @@ static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, int num_fds) {
}
static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
- int num_fds) {
+ const int num_fds) {
int release_fd;
for (int i = 0; i < num_fds; i++) {
@@ -153,14 +157,14 @@ static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
}
}
-static void make_test_fds_readable(test_fd *tfds, int num_fds) {
+static void make_test_fds_readable(test_fd *tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd));
}
}
static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds,
- int num_fds) {
+ const int num_fds) {
for (int i = 0; i < num_fds; i++) {
/* Verify that the on_readable callback was called */
GPR_ASSERT(tfds[i].is_on_readable_called);
@@ -216,9 +220,9 @@ static void pollset_set_test_basic() {
test_fd tfds[10];
test_pollset pollsets[3];
test_pollset_set pollset_sets[2];
- int num_fds = sizeof(tfds) / sizeof(tfds[0]);
- int num_ps = sizeof(pollsets) / sizeof(pollsets[0]);
- int num_pss = sizeof(pollset_sets) / sizeof(pollset_sets[0]);
+ const int num_fds = GPR_ARRAY_SIZE(tfds);
+ const int num_ps = GPR_ARRAY_SIZE(pollsets);
+ const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
init_test_fds(&exec_ctx, tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
@@ -321,9 +325,9 @@ void pollset_set_test_dup_fds() {
test_fd tfds[3];
test_pollset pollset;
test_pollset_set pollset_sets[2];
- int num_fds = sizeof(tfds) / sizeof(tfds[0]);
- int num_ps = 1;
- int num_pss = sizeof(pollset_sets) / sizeof(pollset_sets[0]);
+ const int num_fds = GPR_ARRAY_SIZE(tfds);
+ const int num_ps = 1;
+ const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
init_test_fds(&exec_ctx, tfds, num_fds);
init_test_pollsets(&pollset, num_ps);
@@ -394,9 +398,9 @@ void pollset_set_test_empty_pollset() {
test_fd tfds[3];
test_pollset pollsets[2];
test_pollset_set pollset_set;
- int num_fds = sizeof(tfds) / sizeof(tfds[0]);
- int num_ps = sizeof(pollsets) / sizeof(pollsets[0]);
- int num_pss = 1;
+ const int num_fds = GPR_ARRAY_SIZE(tfds);
+ const int num_ps = GPR_ARRAY_SIZE(pollsets);
+ const int num_pss = 1;
init_test_fds(&exec_ctx, tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
From 2685ffa738113a00c103525b6bc4bc91e8b4b7a2 Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Thu, 26 Jan 2017 18:41:14 -0800
Subject: [PATCH 020/167] update.
---
src/core/ext/census/trace_label.h | 6 ++++--
src/core/ext/census/trace_propagation.h | 13 +++++++------
src/core/ext/census/trace_status.h | 2 +-
src/core/ext/census/trace_string.h | 5 ++++-
src/core/ext/census/tracing.h | 22 +++++++++++++++++-----
5 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/src/core/ext/census/trace_label.h b/src/core/ext/census/trace_label.h
index b58543b7d8c..0e4a8d885f1 100644
--- a/src/core/ext/census/trace_label.h
+++ b/src/core/ext/census/trace_label.h
@@ -36,10 +36,13 @@
#include "src/core/ext/census/trace_string.h"
-/* Trace label (key/value pair) stores a label name and the label value. */
+/* Trace label (key/value pair) stores a label name and the label value. The
+ value can be one of trace_string/int64_t/bool. */
typedef struct trace_label {
trace_string key;
enum label_type {
+ /* Unknown value for debugging/error purposes */
+ LABEL_UNKNOWN = 0,
/* A string value */
LABEL_STRING = 1,
/* An integer value. */
@@ -53,7 +56,6 @@ typedef struct trace_label {
int64_t label_int;
bool label_bool;
} value;
- size_t val_len;
} trace_label;
#endif
diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h
index 093492c3e8e..75c4ebaa398 100644
--- a/src/core/ext/census/trace_propagation.h
+++ b/src/core/ext/census/trace_propagation.h
@@ -36,7 +36,7 @@
#include "src/core/ext/census/tracing.h"
-/* Encoding and decoding functions for receiving and sending propagating data
+/* Encoding and decoding functions for receiving and sending trace contexts
over the wire. Only RPC libraries should be calling these
functions. These functions return the number of bytes encoded/decoded
(0 if a failure has occurred). buf_size indicates the size of the
@@ -44,18 +44,19 @@
trace ID, span ID, and a set of option flags (is_sampled, etc.). */
/* Converts a span context to a binary byte buffer. */
-size_t trace_span_context_to_binary(const trace_span_context *ctxt, char *buf,
- size_t buf_size);
+size_t trace_span_context_to_binary(const trace_span_context *ctxt,
+ uint8_t *buf, size_t buf_size);
/* Reads a binary byte buffer and populates a span context structure. */
-size_t binary_to_trace_span_context(const char *buf, size_t buf_size,
+size_t binary_to_trace_span_context(const uint8_t *buf, size_t buf_size,
trace_span_context *ctxt);
-/* Converts a span context to a http format buffer. */
+/* Converts a span context to an http metadata compatible string. */
size_t trace_span_context_to_http_format(const trace_span_context *ctxt,
char *buf, size_t buf_size);
-/* Reads a http format buffer and populates a span context structure. */
+/* Reads an http metadata compatible string and populates a span context
+ structure. */
size_t http_format_to_trace_span_context(const char *buf, size_t buf_size,
trace_span_context *ctxt);
diff --git a/src/core/ext/census/trace_status.h b/src/core/ext/census/trace_status.h
index a4bd4116c30..adc0ebd0c02 100644
--- a/src/core/ext/census/trace_status.h
+++ b/src/core/ext/census/trace_status.h
@@ -38,7 +38,7 @@
/* Stores a status code and status message for a trace. */
typedef struct trace_status {
- int errorCode;
+ int64_t errorCode;
trace_string errorMessage;
} trace_status;
diff --git a/src/core/ext/census/trace_string.h b/src/core/ext/census/trace_string.h
index 0f71056c3bc..8e77ee9f7ed 100644
--- a/src/core/ext/census/trace_string.h
+++ b/src/core/ext/census/trace_string.h
@@ -42,6 +42,9 @@
This will also be more efficient when copying, as we have an explicitly
specified length. Also, grpc_slice has reference counting which allows for
interning. */
-typedef struct trace_string { grpc_slice string_slice; } trace_string;
+typedef struct trace_string {
+ char *string;
+ size_t length;
+} trace_string;
#endif
diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h
index 0632b841bd1..c2b947ae407 100644
--- a/src/core/ext/census/tracing.h
+++ b/src/core/ext/census/tracing.h
@@ -40,23 +40,31 @@
#include "src/core/ext/census/trace_label.h"
#include "src/core/ext/census/trace_status.h"
+/* This is the low level tracing API that other languages will interface with.
+ This is not intended to be accessed by the end-user, therefore it has been
+ designed with performance in mind rather than ease of use. */
+
/* The tracing level. */
enum TraceLevel {
/* Annotations on this context will be silently discarded. */
NO_TRACING = 0,
/* Annotations will not be saved to a persistent store. They will be
- available via local APIs only. It is not propagated to the child. */
+ available via local APIs only. This setting is not propagated to child
+ spans. */
TRANSIENT_TRACING = 1,
/* Annotations are recorded for the entire distributed trace and they are
- saved to a persistent store. It is propagated to the child. */
+ saved to a persistent store. This setting is propagated to child spans. */
PERSISTENT_TRACING = 2,
};
typedef struct trace_span_context {
/* Trace span context stores Span ID, Trace ID, and option flags. */
+ /* Trace ID is 128 bits split into 2 64-bit chunks (hi and lo). */
uint64_t trace_id_hi;
uint64_t trace_id_lo;
+ /* Span ID is 64 bits. */
uint64_t span_id;
+ /* Span-options is 32-bit value which contains flag options. */
uint32_t span_options;
} trace_span_context;
@@ -64,7 +72,10 @@ typedef struct start_span_options {
/* If set, this will override the Span.local_start_time for the Span. */
gpr_timespec local_start_timestamp;
- /* If set, the Spans are linked to the created Span. */
+ /* Linked spans can be used to identify spans that are linked to this span in
+ a different trace. This can be used (for example) in batching operations,
+ where a single batch handler processes multiple requests from different
+ traces. If set, points to a list of Spans are linked to the created Span.*/
trace_span_context *linked_spans;
/* The number of linked spans. */
size_t n_linked_spans;
@@ -79,8 +90,9 @@ void trace_start_span(const trace_span_context *span_ctxt,
trace_span_context *new_span_ctxt,
bool has_remote_parent);
-/* Add a new Annotation to the Span. The description corresponds to
- Span->annotations[].description. */
+/* Add a new Annotation to the Span. Annotations consist of a description
+ (trace_string) and a set of n labels (trace_label). This can be populated
+ with arbitrary user data. */
void trace_add_span_annotation(const trace_string description,
const trace_label *labels, const size_t n_labels,
trace_span_context *span_ctxt);
From 7d5a560192da155e28181e1e67c4905a88ad8d65 Mon Sep 17 00:00:00 2001
From: Vizerai
Date: Fri, 27 Jan 2017 14:12:57 -0800
Subject: [PATCH 021/167] gflags 2.2.0
---
third_party/gflags | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/third_party/gflags b/third_party/gflags
index 05b155ff591..f8a0efe03aa 160000
--- a/third_party/gflags
+++ b/third_party/gflags
@@ -1 +1 @@
-Subproject commit 05b155ff59114735ec8cd089f669c4c3d8f59029
+Subproject commit f8a0efe03aa69b3336d8e228b37d4ccb17324b88
From 608982d1fc1cf84e2907e948ac4b9cba75d3e782 Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Mon, 30 Jan 2017 10:45:39 -0800
Subject: [PATCH 022/167] fix grpc_fd_shutdown invocation after latest merge
---
test/core/iomgr/pollset_set_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index 3e8dcb4f9c9..f1a56ecafb9 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -142,7 +142,7 @@ static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
int release_fd;
for (int i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd);
+ grpc_fd_shutdown(exec_ctx, tfds[i].fd, GRPC_ERROR_CREATE("fd cleanup"));
grpc_exec_ctx_flush(exec_ctx);
/* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
From f7af2a9a0517ada19e0ce1a092ca064985f604e5 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 31 Jan 2017 15:08:31 -0800
Subject: [PATCH 023/167] Update latency profiler to use (more appropriate)
microbenchmarks
---
src/core/lib/slice/slice_intern.c | 6 +-
test/cpp/microbenchmarks/bm_fullstack.cc | 4 +
.../latency_profile/run_latency_profile.sh | 61 +---------
tools/profiling/microbenchmark/bm.py | 109 ++++++++++++++++++
4 files changed, 119 insertions(+), 61 deletions(-)
create mode 100755 tools/profiling/microbenchmark/bm.py
diff --git a/src/core/lib/slice/slice_intern.c b/src/core/lib/slice/slice_intern.c
index 7cbd17bffd8..32adc4df97d 100644
--- a/src/core/lib/slice/slice_intern.c
+++ b/src/core/lib/slice/slice_intern.c
@@ -215,7 +215,9 @@ bool grpc_slice_is_interned(grpc_slice slice) {
}
grpc_slice grpc_slice_intern(grpc_slice slice) {
+ GPR_TIMER_BEGIN("grpc_slice_intern", 0);
if (GRPC_IS_STATIC_METADATA_STRING(slice)) {
+ GPR_TIMER_END("grpc_slice_intern", 0);
return slice;
}
@@ -225,6 +227,7 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)];
if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT &&
grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) {
+ GPR_TIMER_END("grpc_slice_intern", 0);
return grpc_static_slice_table[ent.idx];
}
}
@@ -247,7 +250,7 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
/* and treat this as if we were never here... sshhh */
} else {
gpr_mu_unlock(&shard->mu);
- GPR_TIMER_END("grpc_mdstr_from_buffer", 0);
+ GPR_TIMER_END("grpc_slice_intern", 0);
return materialize(s);
}
}
@@ -275,6 +278,7 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
gpr_mu_unlock(&shard->mu);
+ GPR_TIMER_END("grpc_slice_intern", 0);
return materialize(s);
}
diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc
index c3e96c572c8..589b319eb70 100644
--- a/test/cpp/microbenchmarks/bm_fullstack.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack.cc
@@ -57,6 +57,7 @@ extern "C" {
#include "test/core/util/passthru_endpoint.h"
#include "test/core/util/port.h"
}
+#include "src/core/lib/profiling/timers.h"
#include "src/cpp/client/create_channel_internal.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
@@ -402,6 +403,7 @@ static void BM_UnaryPingPong(benchmark::State& state) {
std::unique_ptr stub(
EchoTestService::NewStub(fixture->channel()));
while (state.KeepRunning()) {
+ GPR_TIMER_SCOPE("BenchmarkCycle", 0);
recv_response.Clear();
ClientContext cli_ctx;
ClientContextMutator cli_ctx_mut(&cli_ctx);
@@ -470,6 +472,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
}
response_rw.Read(&recv_request, tag(0));
while (state.KeepRunning()) {
+ GPR_TIMER_SCOPE("BenchmarkCycle", 0);
request_rw->Write(send_request, tag(1));
while (true) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -527,6 +530,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
}
request_rw->Read(&recv_response, tag(0));
while (state.KeepRunning()) {
+ GPR_TIMER_SCOPE("BenchmarkCycle", 0);
response_rw.Write(send_response, tag(1));
while (true) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
diff --git a/tools/profiling/latency_profile/run_latency_profile.sh b/tools/profiling/latency_profile/run_latency_profile.sh
index 618db202dc4..7ebe308e0a0 100755
--- a/tools/profiling/latency_profile/run_latency_profile.sh
+++ b/tools/profiling/latency_profile/run_latency_profile.sh
@@ -28,55 +28,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# format argument via
-# $ echo '{...}' | python -mjson.tool
-read -r -d '' SCENARIOS_JSON_ARG <<'EOF'
-{
- "scenarios": [
- {
- "benchmark_seconds": 5,
- "client_config": {
- "client_channels": 1,
- "client_type": "SYNC_CLIENT",
- "histogram_params": {
- "max_possible": 60000000000.0,
- "resolution": 0.01
- },
- "load_params": {
- "closed_loop": {}
- },
- "outstanding_rpcs_per_channel": 1,
- "payload_config": {
- "simple_params": {
- "req_size": 0,
- "resp_size": 0
- }
- },
- "rpc_type": "UNARY",
- "security_params": {
- "server_host_override": "foo.test.google.fr",
- "use_test_ca": true
- }
- },
- "name": "cpp_protobuf_sync_unary_ping_pong_secure",
- "num_clients": 1,
- "num_servers": 1,
- "server_config": {
- "core_limit": 1,
- "security_params": {
- "server_host_override": "foo.test.google.fr",
- "use_test_ca": true
- },
- "server_type": "SYNC_SERVER"
- },
- "spawn_local_worker_count": 2,
- "warmup_seconds": 5
- }
- ]
-}
-
-EOF
-
set -ex
cd $(dirname $0)/../../..
@@ -93,14 +44,4 @@ else
PYTHON=python2.7
fi
-make CONFIG=basicprof -j$CPUS qps_json_driver
-
-mkdir -p reports
-bins/basicprof/qps_json_driver --scenarios_json="$SCENARIOS_JSON_ARG"
-
-echo 'Latency profile for: ' > reports/index.html
-echo "
${SCENARIOS_JSON_ARG}
" >> reports/index.html
-echo '
' >> reports/index.html
-$PYTHON tools/profiling/latency_profile/profile_analyzer.py \
- --source=latency_trace.txt --fmt=simple >> reports/index.html
-echo ' ' >> reports/index.html
+$PYTHON tools/profiling/microbenchmark/bm.py bm_fullstack
diff --git a/tools/profiling/microbenchmark/bm.py b/tools/profiling/microbenchmark/bm.py
new file mode 100755
index 00000000000..064bb7af1b4
--- /dev/null
+++ b/tools/profiling/microbenchmark/bm.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python2.7
+# Copyright 2017, 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.
+
+import multiprocessing
+import os
+import subprocess
+import sys
+
+flamegraph_dir = os.path.join(os.path.expanduser('~'), 'FlameGraph')
+
+def fnize(s):
+ out = ''
+ for c in s:
+ if c in '<>, /':
+ if len(out) and out[-1] == '_': continue
+ out += '_'
+ else:
+ out += c
+ return out
+
+os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
+if not os.path.exists('reports'):
+ os.makedirs('reports')
+
+# index html
+index_html = """
+
+
+Microbenchmark Results
+
+
+"""
+
+def heading(name):
+ global index_html
+ index_html += "%s \n" % name
+
+def link(txt, tgt):
+ global index_html
+ index_html += "%s
\n" % (tgt, txt)
+
+for bm_name in sys.argv[1:]:
+ # generate latency profiles
+ heading('Latency Profiles: %s' % bm_name)
+ subprocess.check_call(
+ ['make', bm_name,
+ 'CONFIG=basicprof', '-j', '%d' % multiprocessing.cpu_count()])
+ for line in subprocess.check_output(['bins/basicprof/%s' % bm_name,
+ '--benchmark_list_tests']).splitlines():
+ link(line, 'reports/%s.txt' % fnize(line))
+ with open('reports/%s.txt' % fnize(line), 'w') as f:
+ f.write(subprocess.check_output(['bins/basicprof/%s' % bm_name,
+ '--benchmark_filter=^%s$' % line]))
+ f.write('\n***********************************************************\n')
+ f.write(subprocess.check_output([
+ sys.executable, 'tools/profiling/latency_profile/profile_analyzer.py',
+ '--source', 'latency_trace.txt', '--fmt', 'simple']))
+
+ # generate flamegraphs
+ heading('Flamegraphs: %s' % bm_name)
+ subprocess.check_call(
+ ['make', bm_name,
+ 'CONFIG=mutrace', '-j', '%d' % multiprocessing.cpu_count()])
+ for line in subprocess.check_output(['bins/mutrace/%s' % bm_name,
+ '--benchmark_list_tests']).splitlines():
+ subprocess.check_call(['sudo', 'perf', 'record', '-g', '-F', '99',
+ 'bins/mutrace/%s' % bm_name,
+ '--benchmark_filter=^%s$' % line,
+ '--benchmark_min_time=20'])
+ with open('/tmp/bm.perf', 'w') as f:
+ f.write(subprocess.check_output(['sudo', 'perf', 'script']))
+ with open('/tmp/bm.folded', 'w') as f:
+ f.write(subprocess.check_output([
+ '%s/stackcollapse-perf.pl' % flamegraph_dir, '/tmp/bm.perf']))
+ link(line, 'reports/%s.svg' % fnize(line))
+ with open('reports/%s.svg' % fnize(line), 'w') as f:
+ f.write(subprocess.check_output([
+ '%s/flamegraph.pl' % flamegraph_dir, '/tmp/bm.folded']))
+
+index_html += "\n\n"
+with open('reports/index.html', 'w') as f:
+ w.write(index_html)
From 7240b54ddb1a10fc4400c81bede0ac0390aa6e0f Mon Sep 17 00:00:00 2001
From: David Garcia Quintas
Date: Tue, 31 Jan 2017 16:00:49 -0800
Subject: [PATCH 024/167] make grpc-encoding:identity implicit
---
src/core/lib/channel/compress_filter.c | 10 ++++++----
test/core/end2end/bad_server_response_test.c | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c
index c860d60d881..22781c78399 100644
--- a/src/core/lib/channel/compress_filter.c
+++ b/src/core/lib/channel/compress_filter.c
@@ -105,7 +105,6 @@ static grpc_error *process_send_initial_metadata(
static grpc_error *process_send_initial_metadata(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_metadata_batch *initial_metadata) {
- grpc_error *error;
call_data *calld = elem->call_data;
channel_data *channeld = elem->channel_data;
/* Parse incoming request for compression. If any, it'll be available
@@ -144,10 +143,13 @@ static grpc_error *process_send_initial_metadata(
calld->has_compression_algorithm = 1; /* GPR_TRUE */
}
+ grpc_error *error = GRPC_ERROR_NONE;
/* hint compression algorithm */
- error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->compression_algorithm_storage,
- grpc_compression_encoding_mdelem(calld->compression_algorithm));
+ if (calld->compression_algorithm != GRPC_COMPRESS_NONE) {
+ error = grpc_metadata_batch_add_tail(
+ exec_ctx, initial_metadata, &calld->compression_algorithm_storage,
+ grpc_compression_encoding_mdelem(calld->compression_algorithm));
+ }
if (error != GRPC_ERROR_NONE) return error;
diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c
index d5f428eb829..9cfe0cebe01 100644
--- a/test/core/end2end/bad_server_response_test.c
+++ b/test/core/end2end/bad_server_response_test.c
@@ -82,7 +82,7 @@
#define HTTP1_DETAIL_MSG "Trying to connect an http1.x server"
/* TODO(zyc) Check the content of incomming data instead of using this length */
-#define EXPECTED_INCOMING_DATA_LENGTH (size_t)310
+#define EXPECTED_INCOMING_DATA_LENGTH (size_t)300
struct rpc_state {
char *target;
@@ -135,7 +135,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes",
state.incoming_data_length, EXPECTED_INCOMING_DATA_LENGTH);
- if (state.incoming_data_length > EXPECTED_INCOMING_DATA_LENGTH) {
+ if (state.incoming_data_length >= EXPECTED_INCOMING_DATA_LENGTH) {
handle_write(exec_ctx);
} else {
grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
From eb5ee45eec0c6f88bcf649f383060f3dc34f2084 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Wed, 1 Feb 2017 11:57:33 -0800
Subject: [PATCH 025/167] Revert "Dynamically enable/disable packet coalecsing
and test it"
This reverts commit 60ab7ef00ac0a988ee2672c636d946c964e6fa41.
---
include/grpc/grpc_cronet.h | 2 -
.../client/secure/cronet_channel_create.c | 6 --
.../cronet/transport/cronet_transport.c | 72 ++++++++++---------
.../tests/CronetUnitTests/CronetUnitTests.m | 13 +---
src/objective-c/tests/Podfile | 1 +
5 files changed, 42 insertions(+), 52 deletions(-)
diff --git a/include/grpc/grpc_cronet.h b/include/grpc/grpc_cronet.h
index 566c34a388d..295e0f55e80 100644
--- a/include/grpc/grpc_cronet.h
+++ b/include/grpc/grpc_cronet.h
@@ -44,8 +44,6 @@ GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
void *engine, const char *target, const grpc_channel_args *args,
void *reserved);
-GRPCAPI void grpc_cronet_use_packet_coalescing(bool use_coalescing);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
index 2e40020ae05..477cf07f45d 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
@@ -51,8 +51,6 @@ typedef struct cronet_transport {
extern grpc_transport_vtable grpc_cronet_vtable;
-bool grpc_cronet_packet_coalescing_enabled = true;
-
GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
void *engine, const char *target, const grpc_channel_args *args,
void *reserved) {
@@ -69,7 +67,3 @@ GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
return grpc_channel_create(&exec_ctx, target, args,
GRPC_CLIENT_DIRECT_CHANNEL, (grpc_transport *)ct);
}
-
-GRPCAPI void grpc_cronet_use_packet_coalescing(bool use_coalescing) {
- grpc_cronet_packet_coalescing_enabled = use_coalescing;
-}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c
index 5429eb32e3c..447f3f31ec1 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.c
@@ -61,8 +61,6 @@
/* TODO (makdharma): Hook up into the wider tracing mechanism */
int grpc_cronet_trace = 0;
-extern bool grpc_cronet_packet_coalescing_enabled;
-
enum e_op_result {
ACTION_TAKEN_WITH_CALLBACK,
ACTION_TAKEN_NO_CALLBACK,
@@ -152,13 +150,12 @@ struct op_state {
bool state_callback_received[OP_NUM_OPS];
bool fail_state;
bool flush_read;
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
bool flush_cronet_when_ready;
bool pending_write_for_trailer;
+#endif
bool unprocessed_send_message;
grpc_error *cancel_error;
-
- /* Whether packet coalescing is enabled */
- bool packet_coalescing_enabled;
/* data structure for storing data coming from server */
struct read_state rs;
/* data structure for storing data going to the server */
@@ -428,10 +425,12 @@ static void on_stream_ready(bidirectional_stream *stream) {
}
/* Send the initial metadata on wire if there is no SEND_MESSAGE or
* SEND_TRAILING_METADATA ops pending */
- if (s->state.packet_coalescing_enabled && s->state.flush_cronet_when_ready) {
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ if (s->state.flush_cronet_when_ready) {
CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
bidirectional_stream_flush(stream);
}
+#endif
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
}
@@ -569,10 +568,10 @@ static void on_response_trailers_received(
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, 0)", s->cbs);
s->state.state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
- if (s->state.packet_coalescing_enabled) {
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
- }
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+#endif
s->state.state_op_done[OP_SEND_TRAILING_METADATA] = true;
gpr_mu_unlock(&s->mu);
@@ -769,9 +768,11 @@ static bool op_can_be_run(grpc_transport_stream_op *curr_op,
result = false;
/* we haven't got on_write_completed for the send yet */
else if (stream_state->state_op_done[OP_SEND_MESSAGE] &&
- !stream_state->state_callback_received[OP_SEND_MESSAGE] &&
- !(stream_state->packet_coalescing_enabled &&
- stream_state->pending_write_for_trailer))
+ !stream_state->state_callback_received[OP_SEND_MESSAGE]
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ && !stream_state->pending_write_for_trailer
+#endif
+ )
result = false;
} else if (op_id == OP_CANCEL_ERROR) {
/* already executed */
@@ -857,10 +858,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
s->cbs = bidirectional_stream_create(s->curr_ct.engine, s->curr_gs,
&cronet_callbacks);
CRONET_LOG(GPR_DEBUG, "%p = bidirectional_stream_create()", s->cbs);
- if (stream_state->packet_coalescing_enabled) {
- bidirectional_stream_disable_auto_flush(s->cbs, true);
- bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
- }
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ bidirectional_stream_disable_auto_flush(s->cbs, true);
+ bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
+#endif
char *url = NULL;
const char *method = "POST";
s->header_array.headers = NULL;
@@ -871,10 +872,11 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_start(%p, %s)", s->cbs, url);
bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array, false);
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true;
- if (stream_state->packet_coalescing_enabled && !stream_op->send_message &&
- !stream_op->send_trailing_metadata) {
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ if (!stream_op->send_message && !stream_op->send_trailing_metadata) {
s->state.flush_cronet_when_ready = true;
}
+#endif
result = ACTION_TAKEN_WITH_CALLBACK;
} else if (stream_op->send_message &&
op_can_be_run(stream_op, stream_state, &oas->state,
@@ -911,18 +913,19 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
(int)write_buffer_size, false);
- if (stream_state->packet_coalescing_enabled) {
- if (!stream_op->send_trailing_metadata) {
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
- result = ACTION_TAKEN_WITH_CALLBACK;
- } else {
- stream_state->pending_write_for_trailer = true;
- result = ACTION_TAKEN_NO_CALLBACK;
- }
- } else {
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ if (!stream_op->send_trailing_metadata) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)",
+ s->cbs);
+ bidirectional_stream_flush(s->cbs);
result = ACTION_TAKEN_WITH_CALLBACK;
+ } else {
+ stream_state->pending_write_for_trailer = true;
+ result = ACTION_TAKEN_NO_CALLBACK;
}
+#else
+ result = ACTION_TAKEN_WITH_CALLBACK;
+#endif
} else {
result = NO_ACTION_POSSIBLE;
}
@@ -941,10 +944,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
s->cbs);
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
- if (stream_state->packet_coalescing_enabled) {
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
- }
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+#endif
result = ACTION_TAKEN_WITH_CALLBACK;
}
stream_state->state_op_done[OP_SEND_TRAILING_METADATA] = true;
@@ -1173,9 +1176,10 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
sizeof(s->state.state_callback_received));
s->state.fail_state = s->state.flush_read = false;
s->state.cancel_error = NULL;
+#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
s->state.flush_cronet_when_ready = s->state.pending_write_for_trailer = false;
+#endif
s->state.unprocessed_send_message = false;
- s->state.packet_coalescing_enabled = grpc_cronet_packet_coalescing_enabled;
gpr_mu_init(&s->mu);
return 0;
}
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index 9bbf3cdb113..dcd7f2fa8db 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -269,9 +269,7 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
-- (void)PacketCoalescing:(bool)use_coalescing {
- grpc_cronet_use_packet_coalescing(use_coalescing);
-
+- (void)testPacketCoalescing {
grpc_call *c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
@@ -381,7 +379,7 @@ unsigned int parse_h2_length(const char *field) {
long len;
bool coalesced = false;
while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
- gpr_log(GPR_DEBUG, "Read len: %ld", len);
+ NSLog(@"Read len: %ld", len);
// Analyze the HTTP/2 frames in the same TLS PDU to identify if
// coalescing is successful
@@ -406,7 +404,7 @@ unsigned int parse_h2_length(const char *field) {
}
}
- XCTAssert(coalesced == use_coalescing);
+ XCTAssert(coalesced);
SSL_free(ssl);
SSL_CTX_free(ctx);
close(s);
@@ -435,9 +433,4 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
-- (void)testPacketCoalescing {
- [self PacketCoalescing:false];
- [self PacketCoalescing:true];
-}
-
@end
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 3760330be9a..462c6a8e0eb 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -97,6 +97,7 @@ post_install do |installer|
# GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
# function" warning
config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
+ config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
end
end
From 191d52c4c1246b7fb80a901186fa39f101738815 Mon Sep 17 00:00:00 2001
From: David Garcia Quintas
Date: Wed, 1 Feb 2017 12:46:05 -0800
Subject: [PATCH 026/167] Renamed define for better readability
---
test/core/end2end/bad_server_response_test.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c
index 9cfe0cebe01..39a98e84ca9 100644
--- a/test/core/end2end/bad_server_response_test.c
+++ b/test/core/end2end/bad_server_response_test.c
@@ -82,7 +82,9 @@
#define HTTP1_DETAIL_MSG "Trying to connect an http1.x server"
/* TODO(zyc) Check the content of incomming data instead of using this length */
-#define EXPECTED_INCOMING_DATA_LENGTH (size_t)300
+/* The 'bad' server will start sending responses after reading this amount of
+ * data from the client. */
+#define SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD (size_t)200
struct rpc_state {
char *target;
@@ -134,8 +136,10 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
}
gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes",
- state.incoming_data_length, EXPECTED_INCOMING_DATA_LENGTH);
- if (state.incoming_data_length >= EXPECTED_INCOMING_DATA_LENGTH) {
+ state.incoming_data_length,
+ SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD);
+ if (state.incoming_data_length >=
+ SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD) {
handle_write(exec_ctx);
} else {
grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
From 0a2fae9aedeef98b39c5f825cb28b5ca32ecc6a2 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Wed, 1 Feb 2017 14:49:03 -0800
Subject: [PATCH 027/167] Dynamically enable packet coalescing by channel args
---
BUILD | 1 +
build.yaml | 1 +
gRPC-Core.podspec | 3 +-
include/grpc/impl/codegen/grpc_types.h | 4 +
.../client/secure/cronet_channel_create.c | 13 +-
.../cronet/transport/cronet_transport.c | 181 +++++++++++-------
.../cronet/transport/cronet_transport.h | 43 +++++
.../tests/CronetUnitTests/CronetUnitTests.m | 20 +-
src/objective-c/tests/Podfile | 1 -
templates/gRPC-Core.podspec.template | 3 +-
.../generated/sources_and_headers.json | 4 +-
11 files changed, 186 insertions(+), 88 deletions(-)
create mode 100644 src/core/ext/transport/cronet/transport/cronet_transport.h
diff --git a/BUILD b/BUILD
index 54192514cc7..e5c2d20d25f 100644
--- a/BUILD
+++ b/BUILD
@@ -1028,6 +1028,7 @@ grpc_cc_library(
],
hdrs = [
"third_party/Cronet/bidirectional_stream_c.h",
+ "src/core/ext/transport/cronet/transport/cronet_transport.h",
],
language = "c",
public_hdrs = [
diff --git a/build.yaml b/build.yaml
index 23e2659ea1e..63c05b76c6c 100644
--- a/build.yaml
+++ b/build.yaml
@@ -684,6 +684,7 @@ filegroups:
- include/grpc/grpc_security.h
- include/grpc/grpc_security_constants.h
headers:
+ - src/core/ext/transport/cronet/transport/cronet_transport.h
- third_party/Cronet/bidirectional_stream_c.h
src:
- src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 1eb178931dc..57816d066d9 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -848,7 +848,8 @@ Pod::Spec.new do |s|
s.subspec 'Cronet-Interface' do |ss|
ss.header_mappings_dir = 'include/grpc'
- ss.source_files = 'include/grpc/grpc_cronet.h'
+ ss.source_files = 'include/grpc/grpc_cronet.h',
+ 'src/core/ext/transport/cronet/transport/cronet_transport.h'
end
s.subspec 'Cronet-Implementation' do |ss|
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index ee8101aab8d..74be7d0ccfc 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -217,6 +217,10 @@ typedef struct {
#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name"
/** The grpc_socket_mutator instance that set the socket options. A pointer. */
#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
+/** If non-zero, Cronet transport will coalesce packets to fewer frames when
+ * possible. */
+#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
+ "grpc.use_cronet_packet_coalescing"
/** \} */
/** Result of a grpc call. If the caller satisfies the prerequisites of a
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
index 477cf07f45d..b6e9e845df3 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
@@ -39,6 +39,7 @@
#include
#include
+#include "src/core/ext/transport/cronet/transport/cronet_transport.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/transport_impl.h"
@@ -54,16 +55,14 @@ extern grpc_transport_vtable grpc_cronet_vtable;
GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
void *engine, const char *target, const grpc_channel_args *args,
void *reserved) {
- cronet_transport *ct = gpr_malloc(sizeof(cronet_transport));
- ct->base.vtable = &grpc_cronet_vtable;
- ct->engine = engine;
- ct->host = gpr_malloc(strlen(target) + 1);
- strcpy(ct->host, target);
gpr_log(GPR_DEBUG,
"grpc_create_cronet_transport: stream_engine = %p, target=%s", engine,
- ct->host);
+ target);
+
+ grpc_transport *ct =
+ grpc_create_cronet_transport(engine, target, args, reserved);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
return grpc_channel_create(&exec_ctx, target, args,
- GRPC_CLIENT_DIRECT_CHANNEL, (grpc_transport *)ct);
+ GRPC_CLIENT_DIRECT_CHANNEL, ct);
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c
index 447f3f31ec1..cba5365badc 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.c
@@ -112,6 +112,7 @@ struct grpc_cronet_transport {
grpc_transport base; /* must be first element in this structure */
stream_engine *engine;
char *host;
+ bool use_packet_coalescing;
};
typedef struct grpc_cronet_transport grpc_cronet_transport;
@@ -150,10 +151,8 @@ struct op_state {
bool state_callback_received[OP_NUM_OPS];
bool fail_state;
bool flush_read;
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
bool flush_cronet_when_ready;
bool pending_write_for_trailer;
-#endif
bool unprocessed_send_message;
grpc_error *cancel_error;
/* data structure for storing data coming from server */
@@ -178,7 +177,7 @@ struct op_storage {
struct stream_obj {
struct op_and_state *oas;
grpc_transport_stream_op *curr_op;
- grpc_cronet_transport curr_ct;
+ grpc_cronet_transport *curr_ct;
grpc_stream *curr_gs;
bidirectional_stream *cbs;
bidirectional_stream_header_array header_array;
@@ -415,6 +414,7 @@ static void on_succeeded(bidirectional_stream *stream) {
static void on_stream_ready(bidirectional_stream *stream) {
CRONET_LOG(GPR_DEBUG, "W: on_stream_ready(%p)", stream);
stream_obj *s = (stream_obj *)stream->annotation;
+ grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
gpr_mu_lock(&s->mu);
s->state.state_op_done[OP_SEND_INITIAL_METADATA] = true;
s->state.state_callback_received[OP_SEND_INITIAL_METADATA] = true;
@@ -425,12 +425,12 @@ static void on_stream_ready(bidirectional_stream *stream) {
}
/* Send the initial metadata on wire if there is no SEND_MESSAGE or
* SEND_TRAILING_METADATA ops pending */
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- if (s->state.flush_cronet_when_ready) {
- CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(stream);
+ if (t->use_packet_coalescing) {
+ if (s->state.flush_cronet_when_ready) {
+ CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(stream);
+ }
}
-#endif
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
}
@@ -540,6 +540,7 @@ static void on_response_trailers_received(
CRONET_LOG(GPR_DEBUG, "R: on_response_trailers_received(%p,%p)", stream,
trailers);
stream_obj *s = (stream_obj *)stream->annotation;
+ grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
gpr_mu_lock(&s->mu);
memset(&s->state.rs.trailing_metadata, 0,
sizeof(s->state.rs.trailing_metadata));
@@ -568,10 +569,10 @@ static void on_response_trailers_received(
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, 0)", s->cbs);
s->state.state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
-#endif
+ if (t->use_packet_coalescing) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+ }
s->state.state_op_done[OP_SEND_TRAILING_METADATA] = true;
gpr_mu_unlock(&s->mu);
@@ -695,8 +696,10 @@ static bool header_has_authority(grpc_linked_mdelem *head) {
executed. This is the heart of the state machine.
*/
static bool op_can_be_run(grpc_transport_stream_op *curr_op,
- struct op_state *stream_state,
- struct op_state *op_state, enum e_op_id op_id) {
+ struct stream_obj *s, struct op_state *op_state,
+ enum e_op_id op_id) {
+ struct op_state *stream_state = &s->state;
+ grpc_cronet_transport *t = s->curr_ct;
bool result = true;
/* When call is canceled, every op can be run, except under following
conditions
@@ -768,11 +771,9 @@ static bool op_can_be_run(grpc_transport_stream_op *curr_op,
result = false;
/* we haven't got on_write_completed for the send yet */
else if (stream_state->state_op_done[OP_SEND_MESSAGE] &&
- !stream_state->state_callback_received[OP_SEND_MESSAGE]
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- && !stream_state->pending_write_for_trailer
-#endif
- )
+ !stream_state->state_callback_received[OP_SEND_MESSAGE] &&
+ !(t->use_packet_coalescing &&
+ stream_state->pending_write_for_trailer))
result = false;
} else if (op_id == OP_CANCEL_ERROR) {
/* already executed */
@@ -845,42 +846,41 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
struct op_and_state *oas) {
grpc_transport_stream_op *stream_op = &oas->op;
struct stream_obj *s = oas->s;
+ grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
struct op_state *stream_state = &s->state;
enum e_op_result result = NO_ACTION_POSSIBLE;
if (stream_op->send_initial_metadata &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_SEND_INITIAL_METADATA)) {
+ op_can_be_run(stream_op, s, &oas->state, OP_SEND_INITIAL_METADATA)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_INITIAL_METADATA", oas);
/* Start new cronet stream. It is destroyed in on_succeeded, on_canceled,
* on_failed */
GPR_ASSERT(s->cbs == NULL);
GPR_ASSERT(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]);
- s->cbs = bidirectional_stream_create(s->curr_ct.engine, s->curr_gs,
+ s->cbs = bidirectional_stream_create(t->engine, s->curr_gs,
&cronet_callbacks);
CRONET_LOG(GPR_DEBUG, "%p = bidirectional_stream_create()", s->cbs);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- bidirectional_stream_disable_auto_flush(s->cbs, true);
- bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
-#endif
+ if (t->use_packet_coalescing) {
+ bidirectional_stream_disable_auto_flush(s->cbs, true);
+ bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
+ }
char *url = NULL;
const char *method = "POST";
s->header_array.headers = NULL;
convert_metadata_to_cronet_headers(
- stream_op->send_initial_metadata->list.head, s->curr_ct.host, &url,
+ stream_op->send_initial_metadata->list.head, t->host, &url,
&s->header_array.headers, &s->header_array.count, &method);
s->header_array.capacity = s->header_array.count;
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_start(%p, %s)", s->cbs, url);
bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array, false);
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true;
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- if (!stream_op->send_message && !stream_op->send_trailing_metadata) {
- s->state.flush_cronet_when_ready = true;
+ if (t->use_packet_coalescing) {
+ if (!stream_op->send_message && !stream_op->send_trailing_metadata) {
+ s->state.flush_cronet_when_ready = true;
+ }
}
-#endif
result = ACTION_TAKEN_WITH_CALLBACK;
} else if (stream_op->send_message &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_SEND_MESSAGE)) {
+ op_can_be_run(stream_op, s, &oas->state, OP_SEND_MESSAGE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_MESSAGE", oas);
stream_state->unprocessed_send_message = false;
if (stream_state->state_callback_received[OP_FAILED]) {
@@ -913,19 +913,18 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
(int)write_buffer_size, false);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- if (!stream_op->send_trailing_metadata) {
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)",
- s->cbs);
- bidirectional_stream_flush(s->cbs);
- result = ACTION_TAKEN_WITH_CALLBACK;
+ if (t->use_packet_coalescing) {
+ if (!stream_op->send_trailing_metadata) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+ result = ACTION_TAKEN_WITH_CALLBACK;
+ } else {
+ stream_state->pending_write_for_trailer = true;
+ result = ACTION_TAKEN_NO_CALLBACK;
+ }
} else {
- stream_state->pending_write_for_trailer = true;
- result = ACTION_TAKEN_NO_CALLBACK;
+ result = ACTION_TAKEN_WITH_CALLBACK;
}
-#else
- result = ACTION_TAKEN_WITH_CALLBACK;
-#endif
} else {
result = NO_ACTION_POSSIBLE;
}
@@ -933,7 +932,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_op_done[OP_SEND_MESSAGE] = true;
oas->state.state_op_done[OP_SEND_MESSAGE] = true;
} else if (stream_op->send_trailing_metadata &&
- op_can_be_run(stream_op, stream_state, &oas->state,
+ op_can_be_run(stream_op, s, &oas->state,
OP_SEND_TRAILING_METADATA)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_TRAILING_METADATA", oas);
if (stream_state->state_callback_received[OP_FAILED]) {
@@ -944,15 +943,15 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
s->cbs);
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
- bidirectional_stream_flush(s->cbs);
-#endif
+ if (t->use_packet_coalescing) {
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
+ bidirectional_stream_flush(s->cbs);
+ }
result = ACTION_TAKEN_WITH_CALLBACK;
}
stream_state->state_op_done[OP_SEND_TRAILING_METADATA] = true;
} else if (stream_op->recv_initial_metadata &&
- op_can_be_run(stream_op, stream_state, &oas->state,
+ op_can_be_run(stream_op, s, &oas->state,
OP_RECV_INITIAL_METADATA)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
@@ -971,8 +970,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_op_done[OP_RECV_INITIAL_METADATA] = true;
result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_op->recv_message &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_RECV_MESSAGE)) {
+ op_can_be_run(stream_op, s, &oas->state, OP_RECV_MESSAGE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_MESSAGE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
CRONET_LOG(GPR_DEBUG, "Stream is cancelled.");
@@ -1084,7 +1082,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
result = ACTION_TAKEN_NO_CALLBACK;
}
} else if (stream_op->recv_trailing_metadata &&
- op_can_be_run(stream_op, stream_state, &oas->state,
+ op_can_be_run(stream_op, s, &oas->state,
OP_RECV_TRAILING_METADATA)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_TRAILING_METADATA", oas);
if (oas->s->state.rs.trailing_metadata_valid) {
@@ -1096,8 +1094,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_op_done[OP_RECV_TRAILING_METADATA] = true;
result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_op->cancel_error &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_CANCEL_ERROR)) {
+ op_can_be_run(stream_op, s, &oas->state, OP_CANCEL_ERROR)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_CANCEL_ERROR", oas);
CRONET_LOG(GPR_DEBUG, "W: bidirectional_stream_cancel(%p)", s->cbs);
if (s->cbs) {
@@ -1111,8 +1108,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->cancel_error = GRPC_ERROR_REF(stream_op->cancel_error);
}
} else if (stream_op->on_complete &&
- op_can_be_run(stream_op, stream_state, &oas->state,
- OP_ON_COMPLETE)) {
+ op_can_be_run(stream_op, s, &oas->state, OP_ON_COMPLETE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_ON_COMPLETE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
grpc_closure_sched(exec_ctx, stream_op->on_complete,
@@ -1176,10 +1172,12 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
sizeof(s->state.state_callback_received));
s->state.fail_state = s->state.flush_read = false;
s->state.cancel_error = NULL;
-#ifdef GRPC_CRONET_WITH_PACKET_COALESCING
s->state.flush_cronet_when_ready = s->state.pending_write_for_trailer = false;
-#endif
s->state.unprocessed_send_message = false;
+
+ s->curr_gs = gs;
+ s->curr_ct = (grpc_cronet_transport *)gt;
+
gpr_mu_init(&s->mu);
return 0;
}
@@ -1195,8 +1193,6 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
grpc_stream *gs, grpc_transport_stream_op *op) {
CRONET_LOG(GPR_DEBUG, "perform_stream_op");
stream_obj *s = (stream_obj *)gs;
- s->curr_gs = gs;
- memcpy(&s->curr_ct, gt, sizeof(grpc_cronet_transport));
add_to_storage(s, op);
if (op->send_initial_metadata &&
header_has_authority(op->send_initial_metadata->list.head)) {
@@ -1244,14 +1240,55 @@ static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx,
static void perform_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
grpc_transport_op *op) {}
-const grpc_transport_vtable grpc_cronet_vtable = {sizeof(stream_obj),
- "cronet_http",
- init_stream,
- set_pollset_do_nothing,
- set_pollset_set_do_nothing,
- perform_stream_op,
- perform_op,
- destroy_stream,
- destroy_transport,
- get_peer,
- get_endpoint};
+static const grpc_transport_vtable grpc_cronet_vtable = {
+ sizeof(stream_obj),
+ "cronet_http",
+ init_stream,
+ set_pollset_do_nothing,
+ set_pollset_set_do_nothing,
+ perform_stream_op,
+ perform_op,
+ destroy_stream,
+ destroy_transport,
+ get_peer,
+ get_endpoint};
+
+grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
+ const grpc_channel_args *args,
+ void *reserved) {
+ grpc_cronet_transport *ct = gpr_malloc(sizeof(grpc_cronet_transport));
+ if (!ct) {
+ goto error;
+ }
+ ct->base.vtable = &grpc_cronet_vtable;
+ ct->engine = engine;
+ ct->host = gpr_malloc(strlen(target) + 1);
+ if (!ct->host) {
+ goto error;
+ }
+ strcpy(ct->host, target);
+
+ ct->use_packet_coalescing = true;
+ for (size_t i = 0; i < args->num_args; i++) {
+ if (0 == strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) {
+ if (args->args[i].type != GRPC_ARG_INTEGER) {
+ gpr_log(GPR_ERROR, "%s ignored: it must be an integer",
+ GRPC_ARG_USE_CRONET_PACKET_COALESCING);
+ } else {
+ ct->use_packet_coalescing = (args->args[i].value.integer != 0);
+ }
+ }
+ }
+
+ return &ct->base;
+
+error:
+ if (ct) {
+ if (ct->host) {
+ gpr_free(ct->host);
+ }
+ gpr_free(ct);
+ }
+
+ return NULL;
+}
\ No newline at end of file
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.h b/src/core/ext/transport/cronet/transport/cronet_transport.h
new file mode 100644
index 00000000000..169ce31fd7d
--- /dev/null
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.h
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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_TRANSPORT_CRONET_TRANSPORT_CRONET_TRANSPORT_H
+#define GRPC_CORE_EXT_TRANSPORT_CRONET_TRANSPORT_CRONET_TRANSPORT_H
+
+#include "src/core/lib/transport/transport.h"
+
+grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
+ const grpc_channel_args *args,
+ void *reserved);
+
+#endif /* GRPC_CORE_EXT_TRANSPORT_CRONET_TRANSPORT_CRONET_TRANSPORT_H */
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index dcd7f2fa8db..d06fe7767fa 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -269,7 +269,12 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
-- (void)testPacketCoalescing {
+- (void)PacketCoalescing:(bool)use_coalescing {
+ grpc_arg arg;
+ arg.key = GRPC_ARG_USE_CRONET_PACKET_COALESCING;
+ arg.type = GRPC_ARG_INTEGER;
+ arg.value.integer = use_coalescing ? 1:0;
+ grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
grpc_call *c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
@@ -285,8 +290,8 @@ unsigned int parse_h2_length(const char *field) {
gpr_join_host_port(&addr, "127.0.0.1", port);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
stream_engine *cronetEngine = [Cronet getGlobalEngine];
- grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr,
- NULL, NULL);
+ grpc_channel *client =
+ grpc_cronet_secure_channel_create(cronetEngine, addr, args, NULL);
cq_verifier *cqv = cq_verifier_create(cq);
grpc_op ops[6];
@@ -379,7 +384,7 @@ unsigned int parse_h2_length(const char *field) {
long len;
bool coalesced = false;
while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
- NSLog(@"Read len: %ld", len);
+ gpr_log(GPR_DEBUG, "Read len: %ld", len);
// Analyze the HTTP/2 frames in the same TLS PDU to identify if
// coalescing is successful
@@ -404,7 +409,7 @@ unsigned int parse_h2_length(const char *field) {
}
}
- XCTAssert(coalesced);
+ XCTAssert(coalesced == use_coalescing);
SSL_free(ssl);
SSL_CTX_free(ctx);
close(s);
@@ -433,4 +438,9 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
+- (void)testPacketCoalescing {
+ [self PacketCoalescing:true];
+ [self PacketCoalescing:false];
+}
+
@end
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 462c6a8e0eb..3760330be9a 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -97,7 +97,6 @@ post_install do |installer|
# GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
# function" warning
config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
- config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
end
end
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index 1b97d18f163..0738b7221b5 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -161,7 +161,8 @@
s.subspec 'Cronet-Interface' do |ss|
ss.header_mappings_dir = 'include/grpc'
- ss.source_files = 'include/grpc/grpc_cronet.h'
+ ss.source_files = 'include/grpc/grpc_cronet.h',
+ 'src/core/ext/transport/cronet/transport/cronet_transport.h'
end
s.subspec 'Cronet-Implementation' do |ss|
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 9bc82486d2b..7f594110197 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -7873,6 +7873,7 @@
"include/grpc/grpc_cronet.h",
"include/grpc/grpc_security.h",
"include/grpc/grpc_security_constants.h",
+ "src/core/ext/transport/cronet/transport/cronet_transport.h",
"third_party/Cronet/bidirectional_stream_c.h"
],
"is_filegroup": true,
@@ -7884,7 +7885,8 @@
"include/grpc/grpc_security_constants.h",
"src/core/ext/transport/cronet/client/secure/cronet_channel_create.c",
"src/core/ext/transport/cronet/transport/cronet_api_dummy.c",
- "src/core/ext/transport/cronet/transport/cronet_transport.c"
+ "src/core/ext/transport/cronet/transport/cronet_transport.c",
+ "src/core/ext/transport/cronet/transport/cronet_transport.h"
],
"third_party": false,
"type": "filegroup"
From 1a5f90fa8a1a9c647e151575fa9651ae1715045f Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Wed, 1 Feb 2017 15:46:21 -0800
Subject: [PATCH 028/167] Fix and clang-format Cronet unit tests
---
.../tests/CronetUnitTests/CronetUnitTests.m | 283 +++++++++---------
1 file changed, 146 insertions(+), 137 deletions(-)
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index a50bf4728f8..9589926d8b5 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -32,13 +32,13 @@
*/
#import
-#import
#import
+#import
#import
-#import
-#import
#import
+#import
+#import
#import "test/core/end2end/cq_verifier.h"
#import "test/core/util/port.h"
@@ -49,19 +49,19 @@
#import "src/core/lib/support/env.h"
#import "src/core/lib/support/string.h"
#import "src/core/lib/support/tmpfile.h"
-#import "test/core/util/test_config.h"
#import "test/core/end2end/data/ssl_test_data.h"
+#import "test/core/util/test_config.h"
#import
static void drain_cq(grpc_completion_queue *cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), NULL);
+ ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5),
+ NULL);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-
@interface CronetUnitTests : XCTestCase
@end
@@ -71,8 +71,8 @@ static void drain_cq(grpc_completion_queue *cq) {
+ (void)setUp {
[super setUp];
-/*** FILE *roots_file;
- size_t roots_size = strlen(test_root_cert);*/
+ /*** FILE *roots_file;
+ size_t roots_size = strlen(test_root_cert);*/
char *argv[] = {"CoreCronetEnd2EndTests"};
grpc_test_init(1, argv);
@@ -83,8 +83,8 @@ static void drain_cq(grpc_completion_queue *cq) {
[Cronet setSslKeyLogFileName:@"Documents/key"];
[Cronet enableTestCertVerifierForTesting];
NSURL *url = [[[NSFileManager defaultManager]
- URLsForDirectory:NSDocumentDirectory
- inDomains:NSUserDomainMask] lastObject];
+ URLsForDirectory:NSDocumentDirectory
+ inDomains:NSUserDomainMask] lastObject];
NSLog(@"Documents directory: %@", url);
[Cronet start];
[Cronet startNetLogToFile:@"Documents/cronet_netlog.json" logBytes:YES];
@@ -104,28 +104,28 @@ void init_ssl(void) {
OpenSSL_add_ssl_algorithms();
}
-void cleanup_ssl(void) {
- EVP_cleanup();
-}
+void cleanup_ssl(void) { EVP_cleanup(); }
int alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen, void *arg) {
// Always select "h2" as the ALPN protocol to be used
- *out = (const unsigned char*)"h2";
+ *out = (const unsigned char *)"h2";
*outlen = 2;
return SSL_TLSEXT_ERR_OK;
}
void init_ctx(SSL_CTX *ctx) {
// Install server certificate
- BIO *pem = BIO_new_mem_buf((void*)test_server1_cert, (int)strlen(test_server1_cert));
+ BIO *pem = BIO_new_mem_buf((void *)test_server1_cert,
+ (int)strlen(test_server1_cert));
X509 *cert = PEM_read_bio_X509_AUX(pem, NULL, NULL, "");
SSL_CTX_use_certificate(ctx, cert);
X509_free(cert);
BIO_free(pem);
// Install server private key
- pem = BIO_new_mem_buf((void *)test_server1_key, (int)strlen(test_server1_key));
+ pem =
+ BIO_new_mem_buf((void *)test_server1_key, (int)strlen(test_server1_key));
EVP_PKEY *key = PEM_read_bio_PrivateKey(pem, NULL, NULL, "");
SSL_CTX_use_PrivateKey(ctx, key);
EVP_PKEY_free(key);
@@ -139,29 +139,34 @@ void init_ctx(SSL_CTX *ctx) {
}
unsigned int parse_h2_length(const char *field) {
- return ((unsigned int)(unsigned char)(field[0])) * 65536 +
- ((unsigned int)(unsigned char)(field[1])) * 256 +
- ((unsigned int)(unsigned char)(field[2]));
+ return ((unsigned int)(unsigned char)(field[0])) * 65536 +
+ ((unsigned int)(unsigned char)(field[1])) * 256 +
+ ((unsigned int)(unsigned char)(field[2]));
}
- (void)testInternalError {
grpc_call *c;
grpc_slice request_payload_slice =
- grpc_slice_from_copied_string("hello world");
+ grpc_slice_from_copied_string("hello world");
grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
- grpc_metadata meta_c[2] = {
- {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}},
- {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}};
+ grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"),
+ grpc_slice_from_static_string("val1"),
+ 0,
+ {{NULL, NULL, NULL, NULL}}},
+ {grpc_slice_from_static_string("key2"),
+ grpc_slice_from_static_string("val2"),
+ 0,
+ {{NULL, NULL, NULL, NULL}}}};
int port = grpc_pick_unused_port_or_die();
char *addr;
gpr_join_host_port(&addr, "127.0.0.1", port);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
stream_engine *cronetEngine = [Cronet getGlobalEngine];
- grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr,
- NULL, NULL);
+ grpc_channel *client =
+ grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL);
cq_verifier *cqv = cq_verifier_create(cq);
grpc_op ops[6];
@@ -173,12 +178,11 @@ unsigned int parse_h2_length(const char *field) {
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
- char *details = NULL;
- size_t details_capacity = 0;
+ grpc_slice details;
- c = grpc_channel_create_call(
- client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo",
- NULL, deadline, NULL);
+ c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_slice_from_static_string("/foo"), NULL,
+ deadline, NULL);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -217,40 +221,40 @@ unsigned int parse_h2_length(const char *field) {
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
- op->data.recv_status_on_client.status_details_capacity = &details_capacity;
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void*)1, NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void *)1, NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- int sl = socket(AF_INET, SOCK_STREAM, 0);
- GPR_ASSERT(sl >= 0);
-
- // Make and TCP endpoint to accept the connection
- struct sockaddr_in s_addr;
- memset(&s_addr, 0, sizeof(s_addr));
- s_addr.sin_family = AF_INET;
- s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- s_addr.sin_port = htons(port);
- GPR_ASSERT(0 == bind(sl, (struct sockaddr*)&s_addr, sizeof(s_addr)));
- GPR_ASSERT(0 == listen(sl, 5));
- int s = accept(sl, NULL, NULL);
- GPR_ASSERT(s >= 0);
-
- // Close the connection after 1 second to trigger Cronet's on_failed()
- sleep(1);
- close(s);
- close(sl);
- });
-
- CQ_EXPECT_COMPLETION(cqv, (void*)1, 1);
+ dispatch_async(
+ dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ int sl = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(sl >= 0);
+
+ // Make and TCP endpoint to accept the connection
+ struct sockaddr_in s_addr;
+ memset(&s_addr, 0, sizeof(s_addr));
+ s_addr.sin_family = AF_INET;
+ s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ s_addr.sin_port = htons(port);
+ GPR_ASSERT(0 == bind(sl, (struct sockaddr *)&s_addr, sizeof(s_addr)));
+ GPR_ASSERT(0 == listen(sl, 5));
+ int s = accept(sl, NULL, NULL);
+ GPR_ASSERT(s >= 0);
+
+ // Close the connection after 1 second to trigger Cronet's on_failed()
+ sleep(1);
+ close(s);
+ close(sl);
+ });
+
+ CQ_EXPECT_COMPLETION(cqv, (void *)1, 1);
cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
- gpr_free(details);
+ grpc_slice_unref(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
grpc_metadata_array_destroy(&request_metadata_recv);
@@ -262,7 +266,7 @@ unsigned int parse_h2_length(const char *field) {
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload_recv);
-
+
grpc_channel_destroy(client);
grpc_completion_queue_shutdown(cq);
drain_cq(cq);
@@ -273,17 +277,22 @@ unsigned int parse_h2_length(const char *field) {
grpc_arg arg;
arg.key = GRPC_ARG_USE_CRONET_PACKET_COALESCING;
arg.type = GRPC_ARG_INTEGER;
- arg.value.integer = use_coalescing ? 1:0;
+ arg.value.integer = use_coalescing ? 1 : 0;
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
grpc_call *c;
grpc_slice request_payload_slice =
- grpc_slice_from_copied_string("hello world");
+ grpc_slice_from_copied_string("hello world");
grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5);
- grpc_metadata meta_c[2] = {
- {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}},
- {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}};
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
+ grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"),
+ grpc_slice_from_static_string("val1"),
+ 0,
+ {{NULL, NULL, NULL, NULL}}},
+ {grpc_slice_from_static_string("key2"),
+ grpc_slice_from_static_string("val2"),
+ 0,
+ {{NULL, NULL, NULL, NULL}}}};
int port = grpc_pick_unused_port_or_die();
char *addr;
@@ -303,12 +312,11 @@ unsigned int parse_h2_length(const char *field) {
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
- char *details = NULL;
- size_t details_capacity = 0;
+ grpc_slice details;
- c = grpc_channel_create_call(
- client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo",
- NULL, deadline, NULL);
+ c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_slice_from_static_string("/foo"), NULL,
+ deadline, NULL);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -325,7 +333,7 @@ unsigned int parse_h2_length(const char *field) {
op->reserved = NULL;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
- op->data.send_message = request_payload;
+ op->data.send_message.send_message = request_payload;
op->flags = 0;
op->reserved = NULL;
op++;
@@ -334,12 +342,12 @@ unsigned int parse_h2_length(const char *field) {
op->reserved = NULL;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
- op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
op->reserved = NULL;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
- op->data.recv_message = &response_payload_recv;
+ op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
op->reserved = NULL;
op++;
@@ -347,79 +355,80 @@ unsigned int parse_h2_length(const char *field) {
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
- op->data.recv_status_on_client.status_details_capacity = &details_capacity;
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void*)1, NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void *)1, NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- int sl = socket(AF_INET, SOCK_STREAM, 0);
- GPR_ASSERT(sl >= 0);
- struct sockaddr_in s_addr;
- memset(&s_addr, 0, sizeof(s_addr));
- s_addr.sin_family = AF_INET;
- s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- s_addr.sin_port = htons(port);
- GPR_ASSERT(0 == bind(sl, (struct sockaddr*)&s_addr, sizeof(s_addr)));
- GPR_ASSERT(0 == listen(sl, 5));
- int s = accept(sl, NULL, NULL);
- GPR_ASSERT(s >= 0);
- struct timeval tv;
- tv.tv_sec = 2;
- tv.tv_usec = 0;
- setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
-
- // Make an TLS endpoint to receive Cronet's transmission
- SSL_CTX *ctx = SSL_CTX_new(TLSv1_2_server_method());
- init_ctx(ctx);
- SSL *ssl = SSL_new(ctx);
- SSL_set_fd(ssl, s);
- SSL_accept(ssl);
-
- const char magic[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
-
- char buf[4096];
- long len;
- bool coalesced = false;
- while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
- gpr_log(GPR_DEBUG, "Read len: %ld", len);
-
- // Analyze the HTTP/2 frames in the same TLS PDU to identify if
- // coalescing is successful
- unsigned int p = 0;
- while (p < len) {
- if (len - p >= 24 && 0 == memcmp(&buf[p], magic, 24)) {
- p += 24;
- continue;
+ dispatch_async(
+ dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ int sl = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(sl >= 0);
+ struct sockaddr_in s_addr;
+ memset(&s_addr, 0, sizeof(s_addr));
+ s_addr.sin_family = AF_INET;
+ s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ s_addr.sin_port = htons(port);
+ GPR_ASSERT(0 == bind(sl, (struct sockaddr *)&s_addr, sizeof(s_addr)));
+ GPR_ASSERT(0 == listen(sl, 5));
+ int s = accept(sl, NULL, NULL);
+ GPR_ASSERT(s >= 0);
+ struct timeval tv;
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+
+ // Make an TLS endpoint to receive Cronet's transmission
+ SSL_CTX *ctx = SSL_CTX_new(TLSv1_2_server_method());
+ init_ctx(ctx);
+ SSL *ssl = SSL_new(ctx);
+ SSL_set_fd(ssl, s);
+ SSL_accept(ssl);
+
+ const char magic[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
+
+ char buf[4096];
+ long len;
+ bool coalesced = false;
+ while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
+ gpr_log(GPR_DEBUG, "Read len: %ld", len);
+
+ // Analyze the HTTP/2 frames in the same TLS PDU to identify if
+ // coalescing is successful
+ unsigned int p = 0;
+ while (p < len) {
+ if (len - p >= 24 && 0 == memcmp(&buf[p], magic, 24)) {
+ p += 24;
+ continue;
+ }
+
+ if (buf[p + 3] == 0 && // Type is DATA
+ parse_h2_length(&buf[p]) == 0x10 && // Length is correct
+ (buf[p + 4] & 1) != 0 && // EOS bit is set
+ 0 == memcmp("hello world", &buf[p + 14],
+ 11)) { // Message is correct
+ coalesced = true;
+ break;
+ }
+ p += (parse_h2_length(&buf[p]) + 9);
+ }
+ if (coalesced) {
+ break;
+ }
}
- if (buf[p+3] == 0 && // Type is DATA
- parse_h2_length(&buf[p]) == 0x10 && // Length is correct
- (buf[p+4] & 1) != 0 && // EOS bit is set
- 0 == memcmp("hello world", &buf[p+14], 11)) { // Message is correct
- coalesced = true;
- break;
- }
- p += (parse_h2_length(&buf[p]) + 9);
- }
- if (coalesced) {
- break;
- }
- }
-
- XCTAssert(coalesced == use_coalescing);
- SSL_free(ssl);
- SSL_CTX_free(ctx);
- close(s);
- close(sl);
- });
-
- CQ_EXPECT_COMPLETION(cqv, (void*)1, 1);
+ XCTAssert(coalesced == use_coalescing);
+ SSL_free(ssl);
+ SSL_CTX_free(ctx);
+ close(s);
+ close(sl);
+ });
+
+ CQ_EXPECT_COMPLETION(cqv, (void *)1, 1);
cq_verify(cqv);
- gpr_free(details);
+ grpc_slice_unref(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
grpc_metadata_array_destroy(&request_metadata_recv);
@@ -431,7 +440,7 @@ unsigned int parse_h2_length(const char *field) {
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload_recv);
-
+
grpc_channel_destroy(client);
grpc_completion_queue_shutdown(cq);
drain_cq(cq);
From 4c94e52f003b9beb999b2a9b73386f4746f55ffc Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Wed, 1 Feb 2017 15:46:39 -0800
Subject: [PATCH 029/167] bug fix for creating Cronet transport context
---
.../cronet/transport/cronet_transport.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c
index 1be6550bd3a..fac0a7a234f 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.c
@@ -1287,13 +1287,15 @@ grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
strcpy(ct->host, target);
ct->use_packet_coalescing = true;
- for (size_t i = 0; i < args->num_args; i++) {
- if (0 == strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) {
- if (args->args[i].type != GRPC_ARG_INTEGER) {
- gpr_log(GPR_ERROR, "%s ignored: it must be an integer",
- GRPC_ARG_USE_CRONET_PACKET_COALESCING);
- } else {
- ct->use_packet_coalescing = (args->args[i].value.integer != 0);
+ if (args) {
+ for (size_t i = 0; i < args->num_args; i++) {
+ if (0 == strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) {
+ if (args->args[i].type != GRPC_ARG_INTEGER) {
+ gpr_log(GPR_ERROR, "%s ignored: it must be an integer",
+ GRPC_ARG_USE_CRONET_PACKET_COALESCING);
+ } else {
+ ct->use_packet_coalescing = (args->args[i].value.integer != 0);
+ }
}
}
}
From 2ee9751cbbe57d2b4bfece8926d8b3112388c4eb Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Wed, 1 Feb 2017 16:00:50 -0800
Subject: [PATCH 030/167] clang-format
---
.../cronet/transport/cronet_transport.c | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c
index fac0a7a234f..01a03533daf 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.c
@@ -425,8 +425,8 @@ static void on_stream_ready(bidirectional_stream *stream) {
gpr_free(s->header_array.headers);
s->header_array.headers = NULL;
}
-/* Send the initial metadata on wire if there is no SEND_MESSAGE or
- * SEND_TRAILING_METADATA ops pending */
+ /* Send the initial metadata on wire if there is no SEND_MESSAGE or
+ * SEND_TRAILING_METADATA ops pending */
if (t->use_packet_coalescing) {
if (s->state.flush_cronet_when_ready) {
CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_flush (%p)", s->cbs);
@@ -868,8 +868,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
* on_failed */
GPR_ASSERT(s->cbs == NULL);
GPR_ASSERT(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]);
- s->cbs = bidirectional_stream_create(t->engine, s->curr_gs,
- &cronet_callbacks);
+ s->cbs =
+ bidirectional_stream_create(t->engine, s->curr_gs, &cronet_callbacks);
CRONET_LOG(GPR_DEBUG, "%p = bidirectional_stream_create()", s->cbs);
if (t->use_packet_coalescing) {
bidirectional_stream_disable_auto_flush(s->cbs, true);
@@ -957,8 +957,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
result = NO_ACTION_POSSIBLE;
CRONET_LOG(GPR_DEBUG, "Stream is either cancelled or failed.");
} else {
- CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, 0)",
- s->cbs);
+ CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, 0)", s->cbs);
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, "", 0, true);
if (t->use_packet_coalescing) {
@@ -969,8 +968,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
}
stream_state->state_op_done[OP_SEND_TRAILING_METADATA] = true;
} else if (stream_op->recv_initial_metadata &&
- op_can_be_run(stream_op, s, &oas->state,
- OP_RECV_INITIAL_METADATA)) {
+ op_can_be_run(stream_op, s, &oas->state,
+ OP_RECV_INITIAL_METADATA)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
grpc_closure_sched(exec_ctx, stream_op->recv_initial_metadata_ready,
@@ -980,10 +979,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_NONE);
} else {
grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &oas->s->state.rs.initial_metadata,
- stream_op->recv_initial_metadata);
+ exec_ctx, &oas->s->state.rs.initial_metadata,
+ stream_op->recv_initial_metadata);
grpc_closure_sched(exec_ctx, stream_op->recv_initial_metadata_ready,
- GRPC_ERROR_NONE);
+ GRPC_ERROR_NONE);
}
stream_state->state_op_done[OP_RECV_INITIAL_METADATA] = true;
result = ACTION_TAKEN_NO_CALLBACK;
@@ -1052,7 +1051,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->state_op_done[OP_READ_REQ_MADE] =
true; /* Indicates that at least one read request has been made */
bidirectional_stream_read(s->cbs, stream_state->rs.read_buffer,
- stream_state->rs.remaining_bytes);
+ stream_state->rs.remaining_bytes);
result = ACTION_TAKEN_NO_CALLBACK;
}
} else if (stream_state->rs.remaining_bytes == 0) {
@@ -1289,7 +1288,8 @@ grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
ct->use_packet_coalescing = true;
if (args) {
for (size_t i = 0; i < args->num_args; i++) {
- if (0 == strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) {
+ if (0 ==
+ strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) {
if (args->args[i].type != GRPC_ARG_INTEGER) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer",
GRPC_ARG_USE_CRONET_PACKET_COALESCING);
From 5862f76bd14be059b1ffcd27d72548adede7e7b3 Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla
Date: Wed, 1 Feb 2017 17:00:13 -0800
Subject: [PATCH 031/167] GRPC_TIMEOUT_MILLIS_TO_DEADLINE now renamed to
grpc_timeout_milliseconds_to_deadline
---
test/core/iomgr/pollset_set_test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index f1a56ecafb9..40fa8586020 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -268,7 +268,7 @@ static void pollset_set_test_basic() {
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollsets[i].mu);
- deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(2);
+ deadline = grpc_timeout_milliseconds_to_deadline(2);
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline));
@@ -350,7 +350,7 @@ void pollset_set_test_dup_fds() {
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollset.mu);
- deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(2);
+ deadline = grpc_timeout_milliseconds_to_deadline(2);
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_pollset_work(&exec_ctx, pollset.ps, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline));
@@ -419,7 +419,7 @@ void pollset_set_test_empty_pollset() {
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollsets[0].mu);
- deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(2);
+ deadline = grpc_timeout_milliseconds_to_deadline(2);
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline));
From 39401798c36dbd29eef41e0ff06239435502c821 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Thu, 2 Feb 2017 12:22:07 -0800
Subject: [PATCH 032/167] Fix links
---
tools/profiling/microbenchmark/bm.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/profiling/microbenchmark/bm.py b/tools/profiling/microbenchmark/bm.py
index 064bb7af1b4..a9277379c7b 100755
--- a/tools/profiling/microbenchmark/bm.py
+++ b/tools/profiling/microbenchmark/bm.py
@@ -74,7 +74,7 @@ for bm_name in sys.argv[1:]:
'CONFIG=basicprof', '-j', '%d' % multiprocessing.cpu_count()])
for line in subprocess.check_output(['bins/basicprof/%s' % bm_name,
'--benchmark_list_tests']).splitlines():
- link(line, 'reports/%s.txt' % fnize(line))
+ link(line, '%s.txt' % fnize(line))
with open('reports/%s.txt' % fnize(line), 'w') as f:
f.write(subprocess.check_output(['bins/basicprof/%s' % bm_name,
'--benchmark_filter=^%s$' % line]))
@@ -99,7 +99,7 @@ for bm_name in sys.argv[1:]:
with open('/tmp/bm.folded', 'w') as f:
f.write(subprocess.check_output([
'%s/stackcollapse-perf.pl' % flamegraph_dir, '/tmp/bm.perf']))
- link(line, 'reports/%s.svg' % fnize(line))
+ link(line, '%s.svg' % fnize(line))
with open('reports/%s.svg' % fnize(line), 'w') as f:
f.write(subprocess.check_output([
'%s/flamegraph.pl' % flamegraph_dir, '/tmp/bm.folded']))
From 95ca017ce85ecdabe6e39275acfe9db736f97735 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Thu, 2 Feb 2017 12:27:11 -0800
Subject: [PATCH 033/167] Fix perf cmdline
---
tools/profiling/microbenchmark/bm.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/profiling/microbenchmark/bm.py b/tools/profiling/microbenchmark/bm.py
index a9277379c7b..b4f0de841fd 100755
--- a/tools/profiling/microbenchmark/bm.py
+++ b/tools/profiling/microbenchmark/bm.py
@@ -90,7 +90,7 @@ for bm_name in sys.argv[1:]:
'CONFIG=mutrace', '-j', '%d' % multiprocessing.cpu_count()])
for line in subprocess.check_output(['bins/mutrace/%s' % bm_name,
'--benchmark_list_tests']).splitlines():
- subprocess.check_call(['sudo', 'perf', 'record', '-g', '-F', '99',
+ subprocess.check_call(['sudo', 'perf', 'record', '-g', '-c', '1000',
'bins/mutrace/%s' % bm_name,
'--benchmark_filter=^%s$' % line,
'--benchmark_min_time=20'])
From 7dc4ea66f0688c30aa7ddd865074a808fd20f076 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Thu, 2 Feb 2017 16:08:05 -0800
Subject: [PATCH 034/167] Make the microbenchmark profile gatherer run some in
parallel
---
src/core/lib/profiling/basic_timers.c | 18 ++-
.../latency_profile/profile_analyzer.py | 18 ++-
.../python_utils/start_port_server.py | 128 ++++++++++++++++++
.../bm.py => run_tests/run_microbenchmark.py} | 36 +++--
tools/run_tests/run_tests.py | 94 +------------
5 files changed, 182 insertions(+), 112 deletions(-)
create mode 100644 tools/run_tests/python_utils/start_port_server.py
rename tools/{profiling/microbenchmark/bm.py => run_tests/run_microbenchmark.py} (78%)
diff --git a/src/core/lib/profiling/basic_timers.c b/src/core/lib/profiling/basic_timers.c
index bdf9af2339c..c4f27728227 100644
--- a/src/core/lib/profiling/basic_timers.c
+++ b/src/core/lib/profiling/basic_timers.c
@@ -44,6 +44,8 @@
#include
#include
+#include "src/core/lib/support/env.h"
+
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;
typedef struct gpr_timer_entry {
@@ -74,7 +76,7 @@ typedef struct gpr_timer_log_list {
static __thread gpr_timer_log *g_thread_log;
static gpr_once g_once_init = GPR_ONCE_INIT;
static FILE *output_file;
-static const char *output_filename = "latency_trace.txt";
+static const char *output_filename_or_null = NULL;
static pthread_mutex_t g_mu;
static pthread_cond_t g_cv;
static gpr_timer_log_list g_in_progress_logs;
@@ -85,6 +87,16 @@ static __thread int g_thread_id;
static int g_next_thread_id;
static int g_writing_enabled = 1;
+static const char *output_filename() {
+ if (output_filename_or_null == NULL) {
+ output_filename_or_null = gpr_getenv("LATENCY_TRACE");
+ if (output_filename_or_null == NULL) {
+ output_filename_or_null = "latency_trace.txt";
+ }
+ }
+ return output_filename_or_null;
+}
+
static int timer_log_push_back(gpr_timer_log_list *list, gpr_timer_log *log) {
if (list->head == NULL) {
list->head = list->tail = log;
@@ -134,7 +146,7 @@ static void timer_log_remove(gpr_timer_log_list *list, gpr_timer_log *log) {
static void write_log(gpr_timer_log *log) {
size_t i;
if (output_file == NULL) {
- output_file = fopen(output_filename, "w");
+ output_file = fopen(output_filename(), "w");
}
for (i = 0; i < log->num_entries; i++) {
gpr_timer_entry *entry = &(log->log[i]);
@@ -198,7 +210,7 @@ static void finish_writing(void) {
}
void gpr_timers_set_log_filename(const char *filename) {
- output_filename = filename;
+ output_filename_or_null = filename;
}
static void init_output() {
diff --git a/tools/profiling/latency_profile/profile_analyzer.py b/tools/profiling/latency_profile/profile_analyzer.py
index 48b8e9b950f..2087cd2793e 100755
--- a/tools/profiling/latency_profile/profile_analyzer.py
+++ b/tools/profiling/latency_profile/profile_analyzer.py
@@ -34,6 +34,7 @@ import hashlib
import itertools
import json
import math
+import sys
import tabulate
import time
@@ -49,6 +50,7 @@ TIME_FROM_LAST_IMPORTANT = object()
argp = argparse.ArgumentParser(description='Process output of basic_prof builds')
argp.add_argument('--source', default='latency_trace.txt', type=str)
argp.add_argument('--fmt', choices=tabulate.tabulate_formats, default='simple')
+argp.add_argument('--out', default='-', type=str)
args = argp.parse_args()
class LineItem(object):
@@ -246,16 +248,20 @@ FORMAT = [
('TO_SCOPE_END', time_format(TIME_TO_SCOPE_END)),
]
+out = sys.stdout
+if args.out != '-':
+ out = open(args.out, 'w')
+
if args.fmt == 'html':
- print ''
- print ''
- print 'Profile Report '
- print ''
+ print >>out, ''
+ print >>out, ''
+ print >>out, 'Profile Report '
+ print >>out, ''
accounted_for = 0
for cs in call_stacks:
if args.fmt in BANNER:
- print BANNER[args.fmt] % {
+ print >>out, BANNER[args.fmt] % {
'count': cs.count,
}
header, _ = zip(*FORMAT)
@@ -265,7 +271,7 @@ for cs in call_stacks:
for _, fn in FORMAT:
fields.append(fn(line))
table.append(fields)
- print tabulate.tabulate(table, header, tablefmt=args.fmt)
+ print >>out, tabulate.tabulate(table, header, tablefmt=args.fmt)
accounted_for += cs.count
if accounted_for > .99 * total_stacks:
break
diff --git a/tools/run_tests/python_utils/start_port_server.py b/tools/run_tests/python_utils/start_port_server.py
new file mode 100644
index 00000000000..4103eb0534b
--- /dev/null
+++ b/tools/run_tests/python_utils/start_port_server.py
@@ -0,0 +1,128 @@
+# 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.
+
+from __future__ import print_function
+
+from six.moves import urllib
+import os
+import subprocess
+import tempfile
+import sys
+import time
+
+def start_port_server(port_server_port):
+ # check if a compatible port server is running
+ # if incompatible (version mismatch) ==> start a new one
+ # if not running ==> start a new one
+ # otherwise, leave it up
+ try:
+ version = int(urllib.request.urlopen(
+ 'http://localhost:%d/version_number' % port_server_port,
+ timeout=10).read())
+ print('detected port server running version %d' % version)
+ running = True
+ except Exception as e:
+ print('failed to detect port server: %s' % sys.exc_info()[0])
+ print(e.strerror)
+ running = False
+ if running:
+ current_version = int(subprocess.check_output(
+ [sys.executable, os.path.abspath('tools/run_tests/python_utils/port_server.py'),
+ 'dump_version']))
+ print('my port server is version %d' % current_version)
+ running = (version >= current_version)
+ if not running:
+ print('port_server version mismatch: killing the old one')
+ urllib.request.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read()
+ time.sleep(1)
+ if not running:
+ fd, logfile = tempfile.mkstemp()
+ os.close(fd)
+ print('starting port_server, with log file %s' % logfile)
+ args = [sys.executable, os.path.abspath('tools/run_tests/python_utils/port_server.py'),
+ '-p', '%d' % port_server_port, '-l', logfile]
+ env = dict(os.environ)
+ env['BUILD_ID'] = 'pleaseDontKillMeJenkins'
+ if platform_string() == 'windows':
+ # Working directory of port server needs to be outside of Jenkins
+ # workspace to prevent file lock issues.
+ tempdir = tempfile.mkdtemp()
+ port_server = subprocess.Popen(
+ args,
+ env=env,
+ cwd=tempdir,
+ creationflags = 0x00000008, # detached process
+ close_fds=True)
+ else:
+ port_server = subprocess.Popen(
+ args,
+ env=env,
+ preexec_fn=os.setsid,
+ close_fds=True)
+ time.sleep(1)
+ # ensure port server is up
+ waits = 0
+ while True:
+ if waits > 10:
+ print('killing port server due to excessive start up waits')
+ port_server.kill()
+ if port_server.poll() is not None:
+ print('port_server failed to start')
+ # try one final time: maybe another build managed to start one
+ time.sleep(1)
+ try:
+ urllib.request.urlopen('http://localhost:%d/get' % port_server_port,
+ timeout=1).read()
+ print('last ditch attempt to contact port server succeeded')
+ break
+ except:
+ traceback.print_exc()
+ port_log = open(logfile, 'r').read()
+ print(port_log)
+ sys.exit(1)
+ try:
+ urllib.request.urlopen('http://localhost:%d/get' % port_server_port,
+ timeout=1).read()
+ print('port server is up and ready')
+ break
+ except socket.timeout:
+ print('waiting for port_server: timeout')
+ traceback.print_exc();
+ time.sleep(1)
+ waits += 1
+ except urllib.error.URLError:
+ print('waiting for port_server: urlerror')
+ traceback.print_exc();
+ time.sleep(1)
+ waits += 1
+ except:
+ traceback.print_exc()
+ port_server.kill()
+ raise
+
diff --git a/tools/profiling/microbenchmark/bm.py b/tools/run_tests/run_microbenchmark.py
similarity index 78%
rename from tools/profiling/microbenchmark/bm.py
rename to tools/run_tests/run_microbenchmark.py
index b4f0de841fd..42a31a622f7 100755
--- a/tools/profiling/microbenchmark/bm.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -33,8 +33,18 @@ import os
import subprocess
import sys
+import python_utils.jobset as jobset
+import python_utils.start_port_server as start_port_server
+
flamegraph_dir = os.path.join(os.path.expanduser('~'), 'FlameGraph')
+os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
+if not os.path.exists('reports'):
+ os.makedirs('reports')
+
+port_server_port = 32766
+start_port_server.start_port_server(port_server_port)
+
def fnize(s):
out = ''
for c in s:
@@ -45,10 +55,6 @@ def fnize(s):
out += c
return out
-os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
-if not os.path.exists('reports'):
- os.makedirs('reports')
-
# index html
index_html = """
@@ -66,6 +72,9 @@ def link(txt, tgt):
global index_html
index_html += "%s
\n" % (tgt, txt)
+benchmarks = []
+profile_analysis = []
+
for bm_name in sys.argv[1:]:
# generate latency profiles
heading('Latency Profiles: %s' % bm_name)
@@ -75,13 +84,18 @@ for bm_name in sys.argv[1:]:
for line in subprocess.check_output(['bins/basicprof/%s' % bm_name,
'--benchmark_list_tests']).splitlines():
link(line, '%s.txt' % fnize(line))
- with open('reports/%s.txt' % fnize(line), 'w') as f:
- f.write(subprocess.check_output(['bins/basicprof/%s' % bm_name,
- '--benchmark_filter=^%s$' % line]))
- f.write('\n***********************************************************\n')
- f.write(subprocess.check_output([
- sys.executable, 'tools/profiling/latency_profile/profile_analyzer.py',
- '--source', 'latency_trace.txt', '--fmt', 'simple']))
+ benchmarks.append(
+ jobset.JobSpec(['bins/basicprof/%s' % bm_name, '--benchmark_filter=^%s$' % line],
+ environ={'LATENCY_TRACE': '%s.trace' % fnize(line)}))
+ profile_analysis.append(
+ jobset.JobSpec([sys.executable,
+ 'tools/profiling/latency_profile/profile_analyzer.py',
+ '--source', '%s.trace' % fnize(line), '--fmt', 'simple',
+ '--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=None))
+
+ jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
+ add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
# generate flamegraphs
heading('Flamegraphs: %s' % bm_name)
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 9d767258102..999ebf87eb7 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -57,6 +57,7 @@ import uuid
import python_utils.jobset as jobset
import python_utils.report_utils as report_utils
import python_utils.watch_dirs as watch_dirs
+import python_utils.start_port_server as start_port_server
_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
@@ -1322,97 +1323,6 @@ def _shut_down_legacy_server(legacy_server_port):
'http://localhost:%d/quitquitquit' % legacy_server_port).read()
-def _start_port_server(port_server_port):
- # check if a compatible port server is running
- # if incompatible (version mismatch) ==> start a new one
- # if not running ==> start a new one
- # otherwise, leave it up
- try:
- version = int(urllib.request.urlopen(
- 'http://localhost:%d/version_number' % port_server_port,
- timeout=10).read())
- print('detected port server running version %d' % version)
- running = True
- except Exception as e:
- print('failed to detect port server: %s' % sys.exc_info()[0])
- print(e.strerror)
- running = False
- if running:
- current_version = int(subprocess.check_output(
- [sys.executable, os.path.abspath('tools/run_tests/python_utils/port_server.py'),
- 'dump_version']))
- print('my port server is version %d' % current_version)
- running = (version >= current_version)
- if not running:
- print('port_server version mismatch: killing the old one')
- urllib.request.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read()
- time.sleep(1)
- if not running:
- fd, logfile = tempfile.mkstemp()
- os.close(fd)
- print('starting port_server, with log file %s' % logfile)
- args = [sys.executable, os.path.abspath('tools/run_tests/python_utils/port_server.py'),
- '-p', '%d' % port_server_port, '-l', logfile]
- env = dict(os.environ)
- env['BUILD_ID'] = 'pleaseDontKillMeJenkins'
- if platform_string() == 'windows':
- # Working directory of port server needs to be outside of Jenkins
- # workspace to prevent file lock issues.
- tempdir = tempfile.mkdtemp()
- port_server = subprocess.Popen(
- args,
- env=env,
- cwd=tempdir,
- creationflags = 0x00000008, # detached process
- close_fds=True)
- else:
- port_server = subprocess.Popen(
- args,
- env=env,
- preexec_fn=os.setsid,
- close_fds=True)
- time.sleep(1)
- # ensure port server is up
- waits = 0
- while True:
- if waits > 10:
- print('killing port server due to excessive start up waits')
- port_server.kill()
- if port_server.poll() is not None:
- print('port_server failed to start')
- # try one final time: maybe another build managed to start one
- time.sleep(1)
- try:
- urllib.request.urlopen('http://localhost:%d/get' % port_server_port,
- timeout=1).read()
- print('last ditch attempt to contact port server succeeded')
- break
- except:
- traceback.print_exc()
- port_log = open(logfile, 'r').read()
- print(port_log)
- sys.exit(1)
- try:
- urllib.request.urlopen('http://localhost:%d/get' % port_server_port,
- timeout=1).read()
- print('port server is up and ready')
- break
- except socket.timeout:
- print('waiting for port_server: timeout')
- traceback.print_exc();
- time.sleep(1)
- waits += 1
- except urllib.error.URLError:
- print('waiting for port_server: urlerror')
- traceback.print_exc();
- time.sleep(1)
- waits += 1
- except:
- traceback.print_exc()
- port_server.kill()
- raise
-
-
def _calculate_num_runs_failures(list_of_results):
"""Caculate number of runs and failures for a particular test.
@@ -1460,7 +1370,7 @@ def _build_and_run(
antagonists = [subprocess.Popen(['tools/run_tests/python_utils/antagonist.py'])
for _ in range(0, args.antagonists)]
port_server_port = 32766
- _start_port_server(port_server_port)
+ start_port_server.start_port_server(port_server_port)
resultset = None
num_test_failures = 0
try:
From b0fd02ed069c67df3d045fdf1131e6f429941263 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Fri, 3 Feb 2017 15:58:24 -0800
Subject: [PATCH 035/167] Add examples from fuzzer server
---
.../039c25bc070936901fc95f63ce9cc3058158fb6d | Bin 0 -> 89 bytes
.../0f01df12331467c4eed400465254eda05eaeb110 | Bin 0 -> 276 bytes
.../174ea33060bccea880dfdcfa12c5349e8eb4cb2a | Bin 0 -> 144 bytes
.../25c05b84c4b4f1a93f0f72d368c3c3644b564881 | Bin 0 -> 296 bytes
.../2d743ec0a0826177cfa7ffb335c0034f482e70e5 | Bin 0 -> 85 bytes
.../30738789e20323323196dd3e6435fa278e73279e | Bin 0 -> 85 bytes
.../33e01fe9738c887b159ca5add342b22c13e526cf | Bin 0 -> 230 bytes
.../3a3346314bb9ddaf14877b653cfd506b6ad34fab | Bin 0 -> 358 bytes
.../42231300ca5cf30d18f55b66020926882c64248c | Bin 0 -> 81 bytes
.../428cce92c42645f4cc4060a8cb9cef3a803c0341 | Bin 0 -> 230 bytes
.../43cdc82b082bbdc4d7d23437a7f761f1ca32ca73 | Bin 0 -> 253 bytes
.../448fc1dc939aa7f398f1577e418630abecc0a1d7 | Bin 0 -> 227 bytes
.../46171f477d11338f4cc948915350772d54319200 | Bin 0 -> 116 bytes
.../51ea84d5a790d3d2495be453f5341c41b6153644 | Bin 0 -> 90 bytes
.../5547a3544fc5c634024d546366704547dd72cc2b | Bin 0 -> 85 bytes
.../64656ddf81738f914ead8003c19d0148c54f34d6 | Bin 0 -> 87 bytes
.../681b758cad3bbce4bde2d1a78a2ec4600c59b05c | Bin 0 -> 127 bytes
.../72031f24261c32d2e3bb2c7909a9315227172730 | Bin 0 -> 85 bytes
.../783484ad9e15085e9039c7504aac71af1ad549a2 | Bin 0 -> 144 bytes
.../78e43d163fc8226d72b979c0fe6e1593ef3cb542 | Bin 0 -> 132 bytes
.../7fb64b5785ebe699ca50327c88c1d8b99432fa23 | Bin 0 -> 89 bytes
.../82731abc38788755495b1bac7b58bc0f12e4bdd1 | Bin 0 -> 111 bytes
.../83776278a4997b0d178602c8419f3e6481dec01d | Bin 0 -> 226 bytes
.../92c816d98f9f8669f43b46b22d5da21464d9ef41 | Bin 0 -> 516 bytes
.../9ca8f5c67662fa6726db2680978e443d80785a9f | Bin 0 -> 109 bytes
.../9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660 | Bin 0 -> 114 bytes
.../a270e4304cc0dcd2c67b78c0495dedb10419f0af | Bin 0 -> 275 bytes
.../bc42e00a7d67fb68df3cb5893908c04884b6ad5e | Bin 0 -> 252 bytes
.../c1e5524945b3e3eabedfbb675be9e9ea99a36b94 | Bin 0 -> 85 bytes
.../c9f81864507c264369dd22c72aeb16f1cb1742b0 | Bin 0 -> 228 bytes
...h-177af631195e806f4056847cea4d09b5eb28cf8a | Bin 0 -> 345 bytes
...h-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d | Bin 0 -> 332 bytes
...h-b5ae6881c767a7769bb957ac379f22aafe4ef05e | Bin 0 -> 230 bytes
.../d0d622fa3916e800e959a3fc2c90e213d518e5f4 | Bin 0 -> 365 bytes
.../dd229da166c3bec675e882d17092238cf7d245f3 | Bin 0 -> 229 bytes
.../de45c55043f63ec680e990b1edf1f0cc60ebbf4e | Bin 0 -> 109 bytes
.../e709e8861c09e29cdae73e337587a63fb0ccf76d | Bin 0 -> 86 bytes
.../e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1 | Bin 0 -> 200 bytes
.../e9932127668f9de0743fc639dca31acedbfc68fd | Bin 0 -> 112 bytes
.../eacf4905e489566a3e5fcaaeac9fe91cbf916e06 | Bin 0 -> 85 bytes
.../ec55cbebe6db506acf7af9e5d26386630319623d | Bin 0 -> 87 bytes
.../f09c5cabe569b5c22a16d7d584074d54d9343edc | Bin 0 -> 365 bytes
.../f9048c4c18e729b6f49e929876ec30866deb16a9 | Bin 0 -> 84 bytes
.../f92897ee60bd24634aa1582f162c1c8f4b249148 | Bin 0 -> 127 bytes
.../fd05ad1a9d183c2a25d820aca9940caacbaa0660 | Bin 0 -> 129 bytes
tools/run_tests/generated/tests.json | 1090 ++++++++++++++++-
46 files changed, 1040 insertions(+), 50 deletions(-)
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/25c05b84c4b4f1a93f0f72d368c3c3644b564881
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/30738789e20323323196dd3e6435fa278e73279e
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/3a3346314bb9ddaf14877b653cfd506b6ad34fab
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/72031f24261c32d2e3bb2c7909a9315227172730
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/783484ad9e15085e9039c7504aac71af1ad549a2
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/78e43d163fc8226d72b979c0fe6e1593ef3cb542
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/7fb64b5785ebe699ca50327c88c1d8b99432fa23
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/a270e4304cc0dcd2c67b78c0495dedb10419f0af
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/bc42e00a7d67fb68df3cb5893908c04884b6ad5e
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b5ae6881c767a7769bb957ac379f22aafe4ef05e
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/d0d622fa3916e800e959a3fc2c90e213d518e5f4
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/dd229da166c3bec675e882d17092238cf7d245f3
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/de45c55043f63ec680e990b1edf1f0cc60ebbf4e
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/e709e8861c09e29cdae73e337587a63fb0ccf76d
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/e9932127668f9de0743fc639dca31acedbfc68fd
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/eacf4905e489566a3e5fcaaeac9fe91cbf916e06
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/ec55cbebe6db506acf7af9e5d26386630319623d
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/f09c5cabe569b5c22a16d7d584074d54d9343edc
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/f9048c4c18e729b6f49e929876ec30866deb16a9
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/f92897ee60bd24634aa1582f162c1c8f4b249148
create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/fd05ad1a9d183c2a25d820aca9940caacbaa0660
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d b/test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d
new file mode 100644
index 0000000000000000000000000000000000000000..fd96a329756d715cb856d11ea4034df9495cb971
GIT binary patch
literal 89
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
k^#A|=zh0P|hlzoKff0oN{|7M`e|0i2aPu&-GcafZ03>x9!vFvP
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110
new file mode 100644
index 0000000000000000000000000000000000000000..09bf4db5853b1dd44e72c0e6c1e4d189403ad84e
GIT binary patch
literal 276
zcmZvXKMny=5Ql&BR-Uy)Bod8AM-&{vQ8pXKpM+gzS*1oIG!msdsNBF&Brc(Op0x#u
zsb(@W-#4RTmV^b!!9#Z#MQKeVnfE(!JoT3g8S&B&gBkmg9h?jpM`JeCVu^qX83WK>
zgHZI^wStQ4|9J8SenEp@XiCj|@7C$#TUp;V6K2N#I0!?Y0t(Rd+ym(yPF`u)@YdXu
sM3o!RFznhCB+w7VB1sE$zo1F7-NCq^!wtA^?b5|wZ=Y!a4)X39FO$np+W-In
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a b/test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a
new file mode 100644
index 0000000000000000000000000000000000000000..da32e950137574065ac207a8cf453f654e9066d8
GIT binary patch
literal 144
zcmWek%*kP3Do!mbOD$qxU}4~5&`-mNOA?FHQ%mCW64&OY#^(c7
z7GfP=Tl^IErPF0U{Z%nKh<_!V-ceJ$Inu2002+E|F%l
zSe8OYQ_S!8W|UJm(r++wO7h^U8zxCifF_Zty8rsM`wYGlo*61~Y^Hq{%oB|5a^m790GlI6#
z@D}ZOCZ+22u_}rjJ_HH$w_>Gty_`cSXAUCe5Olv{Fp=sA7lOVH0ad;dR`+uay84G6
LJ_G`^!wY@^>2g-K
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5
new file mode 100644
index 0000000000000000000000000000000000000000..5449b346c0100433e517cddd5fc469deb9a12623
GIT binary patch
literal 85
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X+S9<4Y2Y(o;*~^AgwQrpD(3)fHu?h@~?0
j|Nmbv%+15dz`(%x|38orXJGu*$-p4O!^oV&z^(}Ztj5{uGPOXBkq*XE|i=L1z1WvZky
i^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8k0Tpa}rK+!}xY
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf b/test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf
new file mode 100644
index 0000000000000000000000000000000000000000..9b3060c5175d2ae06f17f53f7191affb91848e3f
GIT binary patch
literal 230
zcmW-au}%U(6h-e01W}2NpJ0JfKy0y4J9}gOGA=Lcgx%TAo7puq8WRfr7`}mupRlCy
z4>U0(<6v=bag%e8_AD(6l**;f#1>nOeJjPP$_VkjnQjyj<
z7xM%SFQ-L~9Hmm(3gO#Y`+jwH?)eAX6KOLhwE02Ch#q){BhTH51GdUg=k0)wC<^4#
zsRm*Pgs;??Y7WD~Sgdoy#oDA&WhTyL`=H|6d+Txt-R`a3`7jzmzyd-^h`-mb;RD0P
zO_YkIOY8wC`lQ~U;RIZZ>rlBAtP
OTl$$0l%imL2dIDg6LoX|
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c b/test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c
new file mode 100644
index 0000000000000000000000000000000000000000..0119532390b97d956b7848e72509c14494a10466
GIT binary patch
literal 81
zcmZQ7PAw`+En;9`Vc=rWPs;~$8PkgjlJ$yM~PO8T$YK
guNUU#VPs$sVEq4|fq}7;je(JYn~Rx&fq|JF04XyULI3~&
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341 b/test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341
new file mode 100644
index 0000000000000000000000000000000000000000..39faa0d693f5dbc35cedcce5d8c46193e1b7b22f
GIT binary patch
literal 230
zcmZvWO$x#=5QSe_f53LCjKDck>f_xsI-25;p0F|J6fFX5su=+@D<6O6H4<9)X+T4PSCAyvtJ@5zA!B8FLp
MJeeYehz-;E3m>;lhyVZp
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73 b/test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73
new file mode 100644
index 0000000000000000000000000000000000000000..c8250c8ccf5d930986a6d389428781844a04059e
GIT binary patch
literal 253
zcmZvUK?=e!5Je}kinZN{&?|_WdH@d-VmqyYwkgxJP&a}*S9$|aAl^@q80ta=XYpbF
ze>~nGbw~gn%wU~qJ^X%7N!&DrFp_dKqLQ}~1^>soa{nc`zXil{s*~vY<0w}h3R0LN
zoUOHoMKEOm{&B({Cm3!ni=}opQXeLC3@~e5zyJmz8x8t6#Y}n;pSbC1EqC0et|?AP
dm6DLgJ?Zw6incI9wq~bE8PeMxR0RTn=Py?9Q7r%f
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7
new file mode 100644
index 0000000000000000000000000000000000000000..d5f631429e598b6f49f9d2a44da1cff0216d573b
GIT binary patch
literal 227
zcmW-aF-`+95JkV85CTLr9DxQ>5b8|-9-Fet#cvnJXVh|;+qy*e_Bm6pXD6fH0n~24a4UiO{TRvJ
z^wB%i1JdW$)0>CMJL|#oDGmAMV!W3pwm#N@lZoUSE>pHdtGJWT)z21Pm#LM)c8#MU
H*0{$XZB9vh
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200 b/test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200
new file mode 100644
index 0000000000000000000000000000000000000000..df032667c6d82427e91bae4f3590a3c22d1f13ef
GIT binary patch
literal 116
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
z^#A|=zh0P|hmnDSf${%;Ai==+tCN9&n}>-Rq!%d60MwtFoS&DHSX3Eb3N$r7F+DY}
I1Sp{i0I@S9?EnA(
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644 b/test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644
new file mode 100644
index 0000000000000000000000000000000000000000..df8ee081bfb74c566acfe0a36041e663543f8c33
GIT binary patch
literal 90
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOPm-P7~=C1*XE|i=L1z2
mWu~MuX!QU8|G!?Cn+GVz!1(_^kYHf^)ycpB6k%sz&;$S<6&ox7
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b b/test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b
new file mode 100644
index 0000000000000000000000000000000000000000..9e6f5b687d42fa7b59a11a1284b99f860bbdedd3
GIT binary patch
literal 85
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
i^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8kObzy$!vK^md}
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6
new file mode 100644
index 0000000000000000000000000000000000000000..daf5bc14b1c80f229a90efa7cb46770e8a64f830
GIT binary patch
literal 87
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
l^#A|=zh0P|hmnDSf${%;Ai==+tCN9&mw}syiJ5^x69E0Z8p{9x
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c b/test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c
new file mode 100644
index 0000000000000000000000000000000000000000..d54a2af33deaa60e9f3c116697e91fea4b9bfce0
GIT binary patch
literal 127
zcmZQ7PAw`+En;9`Vc=p&OV0;!({l35lS^_K%GEhiIW&sOG_;cSii>l;$1}0=IM!rVMSRsjR!
Zk4^>##j5{uGPOXBkq*XE|i=L1z1Wu~Mu
j^#A|=zh0P|hmnDSf${%;Ai==+tCN9&n}>;+fk6`h$W>SiqLaz{JQ<&X>A}gQF--<3CWi<&oR}wJZ#*?3_#-44hI-#i>Q*
zeBZ#*TK^fC6jRleBNQ1JlQRix}Qnw>mNOA?FHQ%mCW64&OY#^(c-7O7jM
nq%!pX|Np;Un45=@fq{YX|9>FC!1$|^fq|Qqhmo0qfn5^-9}^nr
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1
new file mode 100644
index 0000000000000000000000000000000000000000..20c7c70f83590364a0c65a49a4482cdc87d1ae0d
GIT binary patch
literal 111
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
z^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8dZV%fOJVmy(*6SejE3pIBOwkzbTqQVCS6
F2>=HZBgFs!
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d b/test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d
new file mode 100644
index 0000000000000000000000000000000000000000..2570ea8bc6cc06db8153843d2d5513c75a091aa2
GIT binary patch
literal 226
zcmW-aF;W6S5JmqC2#A!4M<5XcFhLj<`_)Hp
zs0XB{H;dcH`8(^u`kY4mdUJ;fs={k8ZJ||L94iv&+YFXU6-k?!hVO-5q5aM
EAHKs#bpQYW
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41 b/test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41
new file mode 100644
index 0000000000000000000000000000000000000000..c000647a860f717a4d0d16ac558586b553700ccd
GIT binary patch
literal 516
zcmZvYF;4jlhOev^3ae&5R|>`I
z@}$77ivrhJJfU%8Tzk4?Ys#w>wsEwf^S;(wk+LPQg{#FX5^fJ0xc|U!FV8oWP?r4w
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f b/test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f
new file mode 100644
index 0000000000000000000000000000000000000000..4954b7255c19957e4f6350ae31ad1da055c28943
GIT binary patch
literal 109
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
z^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8dZUo06KASejE3pIBOwkzbTqQVCSa1OU$=
BBc1>N
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660 b/test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660
new file mode 100644
index 0000000000000000000000000000000000000000..86f991ed002eea2ba938fea2f153f80d98f69509
GIT binary patch
literal 114
zcmZQ7PAw`+En;9`Vc=rWPs`7T@EOyK3X=7Ti*w>j5{uGPORVDa5_41I^MOhgi!xKJ
m82bPJ|6ec6&BM%qt`wmXs4$fQ2$v3Cb6H*ge*OW3qFnFO_}
zO4a+`D`ix(mX+-D>3st@mn8UHggXm0nj+IZnD_sb23(>O_Z4k$p=>j-2q3MHlCE8Oxx
sQdMh1!*SqSkU&2bi=m~WBM8VNEZfn
zq_PB8#e+|>{rt{Yu{11z#^h3_Hx;MBXCw<-YsXT~J^}(j0>>~Og`iahre8XJbs(H2
z$vIk2bGAX3r7z??J6lCcU+r^UxJ(T+w|>Hn6d9ETwC&8S&dxcGk37ZLxzax&;3
zm_(iXFuxxI&7TQ$j%B1w`Kk;Ot=>>e5f`JzNUQAn
UXRE$Re{Ep9fqoA*@SrUG0b*27#Q*>R
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94
new file mode 100644
index 0000000000000000000000000000000000000000..12bb8f2d6492baea865a6c1117c6db1d5d5ad611
GIT binary patch
literal 85
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
i^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8j_Rpa}rTOd7lZ
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0
new file mode 100644
index 0000000000000000000000000000000000000000..0331bad1a67ff859eeb3944004bd137cd0bf95a6
GIT binary patch
literal 228
zcmW-aJx&8L6okjlj{-zA9DxEtL8wCkbo7YYdTgE+i(T*P*=v*rniO!DoPmmqq@krE
z5<)Ugikafm{AkY-S)f!YZE@a;tw|Q9%h*uKEFZu%yA_h+)W@@RhUSV&9
H6>jkl{VYng
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a
new file mode 100644
index 0000000000000000000000000000000000000000..344825c5718c64f75fdb61fd8a2508ab7c268ac9
GIT binary patch
literal 345
zcmXw#y-veG5QOK>0Rc(JBT%3;33Vudjvi5;4tp^czO%Ld5vgd>AR+N2eg-ODBn>SU
zNC@dz+t6$=+S&PbbVb|}L#dR@cu{iZEU!%?vau=o8XCX^2Us2#g{b`V6+%lF@3KE1
zJXMt&%PG~Su-;JXh~qo!J>{mVZG3NTnk-Kw!#d+v)N+>CGDCR1R*#3%S)`#p`jB(r
z8BpI(GnsD_L_63eeROhqcD2Nib)W(UQ{F;$$wK@V>|3i
MTYKnmiCR|Xzm>*u?EnA(
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d
new file mode 100644
index 0000000000000000000000000000000000000000..ce2ffbb6d521decab532d53df1e95ece851feae6
GIT binary patch
literal 332
zcmYL^u}T9$6h+_6h8WEvgrGklqNXs`vCwq(Vm*wTmvwQnyS$m*kj69-w2D8HZ?N(w
zEYk>nfP$#wTZ34yw21b`ZBKzA?8Sf$T*
z?@R2zu;Jj>WUWz}Vst9iBUBmZMOQja(J1Ts(Y3lP5;NcuJyK~8OG*YhPryH3h-teS
z1`@<=RdUJ);^RK#|5SruP1aHF937vWckf8n$D2rvo6dfx3U{Pan`cg0j0#HJ1WG}k
zjlz4d@@=(h#XV&1-D>5~WaG#gU|y%=2f}|~X6ntBGXcv5tUn{X`njJrLs@Zw_~PVN
XLmLBIe;LpQ@y+r!v~&OqI5YAGsa$N-
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b5ae6881c767a7769bb957ac379f22aafe4ef05e b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b5ae6881c767a7769bb957ac379f22aafe4ef05e
new file mode 100644
index 0000000000000000000000000000000000000000..3518dffafcdae38f7f74427001738c54e37a1602
GIT binary patch
literal 230
zcmY+8I}XAy5JblbABm*n5I_?oPC&yEs4bIhJ|e`CZ6QSz)TuZL7o;(3s?cn)J3H@1
zmdu?DFvAM_QtQocAu7}7nYFES%2X#OJN3Si)EqTUL3nxZpX($Q0EG8EAU-3Iq){Ax
z`Rw_ha@`fm4F7c$>ZWa$6-0Gr;)96|6Sp)?*uZ1lF7S@RqYQSnbNwM}wZ5vFR3R^e
SBa7fNE)t~C95F-?jF(^0CrxDl
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d0d622fa3916e800e959a3fc2c90e213d518e5f4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d0d622fa3916e800e959a3fc2c90e213d518e5f4
new file mode 100644
index 0000000000000000000000000000000000000000..0de93e6a0d2f68b2b13d7615b284bdd36a57b444
GIT binary patch
literal 365
zcmZutK}th05PdT(Y5Fa0yg+vq7xf4pq6heVG!{YqWq$d8Sr-AR8~5TBa;boq&_$f2
z2rZb9VJ7qDy~l9pq;~?0QQ?|RHMkq;dB$dNR+DoxBu&_^mTWTCx}(;8+m?A+%jS03
zb&vJ7k+s{_&rNu8b*s$saOd!zQrcad%?JRcqyhB32lQtGR9T_t6DNiFQ|B{ve$6TU
zF?;uKtLXk5bVn*Y)~kojpE59Vi3E(ueaXn<1(w9l5j~QclsOCz_Owta$cF+!G+%jh
fm!LQeSX`0#S0t;Yj{$GGPIy98<$#HW{Q!OeWdCU#
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/dd229da166c3bec675e882d17092238cf7d245f3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/dd229da166c3bec675e882d17092238cf7d245f3
new file mode 100644
index 0000000000000000000000000000000000000000..2a994d9ddaced7c7f44ef0e93d50634477a5f987
GIT binary patch
literal 229
zcmZvWO$x#=5QSe_f53La
zWG`fa2^QEKj2U-P+pa8}Yo%AVCNH&moJpFHw8x5YXXe{7%LM?z90tU50J1zuV>g^R
z^rj5{uGPOXBkq*XE|i=L1z1Wu~Mu
z^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8dZUo06KASejE3pIBOwkzbTqQVCS42>{PX
BBgFs!
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e709e8861c09e29cdae73e337587a63fb0ccf76d b/test/core/end2end/fuzzers/api_fuzzer_corpus/e709e8861c09e29cdae73e337587a63fb0ccf76d
new file mode 100644
index 0000000000000000000000000000000000000000..a4815427911a633677da9cf7d6c9d71eeff54e57
GIT binary patch
literal 86
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
j^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8kObz@-HM;|&_j
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1
new file mode 100644
index 0000000000000000000000000000000000000000..af332baf9a0591c2ecd8d61d4fa1be6cff691264
GIT binary patch
literal 200
zcmYMuOAZ1d3mv}yZQCW;q|
zzyu3yb|HLf;o_-Zr*tscMn~Cr`#h2fJQ?=`;ZaJtFO?PmL@AsgUL&Bi?CLJJ!TZz)
vKiGIRXIam380*OA=JCvzj5{uGPOXBkq*XE|i=L1z1Wu~Mu
z^#A|=zh0P|hmnDSf${%;Ai==+tCN9&n}>-Rsy8(`KQAS*s4~73XkvU~dTL$?P_ZTe
DLANCB
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/eacf4905e489566a3e5fcaaeac9fe91cbf916e06 b/test/core/end2end/fuzzers/api_fuzzer_corpus/eacf4905e489566a3e5fcaaeac9fe91cbf916e06
new file mode 100644
index 0000000000000000000000000000000000000000..44f3e00f9863c3b1a14fc6bbbb7824be2ce07d7d
GIT binary patch
literal 85
zcmZQ7PAw`+En;9`Vc=rWPs`5-^BL2N3X=7Ti*w>j5{uGPOXBkq*XE|i=L1z1Wu~Mu
i^#A|=zh0P|hmnDSf${%;Ai==+tCN8ND8kObpa}rTU>d;y
literal 0
HcmV?d00001
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ec55cbebe6db506acf7af9e5d26386630319623d b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec55cbebe6db506acf7af9e5d26386630319623d
new file mode 100644
index 0000000000000000000000000000000000000000..14ebab0cf35e33b520b8517b798b5c20b7f8f9dd
GIT binary patch
literal 87
zcmZQ7PAw`+En;9`Vc=rWPs`6Q267qGiwctUs*7{tOA?FHQ}YsYQ{(f2s){mGiW&O<
l|F0M3=3!)DaA5rZpMim~lZ_k5;pJgsWngAt1Tq@;QQIUXn@-Bie$fp8+LJzTL
z7R3b<5~|bHRYf?6cA~%(6;9Yyy_{*sb9TLW1ADG72H2mUvKzQw{fIBeosVN_5|BL&%g
h1j}~_$~y@MN2Kuy#akJ3!lQjBA|ab|!py_J0^hRVX
Date: Mon, 6 Feb 2017 19:30:09 +0100
Subject: [PATCH 036/167] Fix issue #9597
Generate consistently named PDBs for libraries across generators
and install those PDBs if present.
---
templates/CMakeLists.txt.template | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 444fb6a2dc3..52a060a8808 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -442,7 +442,19 @@
% endif
% endfor
)
-
+
+ if(WIN32 AND MSVC)
+ set_target_properties(${lib.name} PROPERTIES COMPILE_PDB_NAME "${lib.name}"
+ COMPILE_PDB_OUTPUT_DIRECTORY <%text>"${CMAKE_BINARY_DIR}%text>"
+ )
+ if (gRPC_INSTALL)
+ install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/%text>${lib.name}.pdb
+ DESTINATION <%text>${CMAKE_INSTALL_LIBDIR}%text> OPTIONAL
+ )
+ endif()
+ endif()
+
+
% for src in lib.src:
% if proto_re.match(src):
protobuf_generate_grpc_cpp(
From d5923578c0c43a5716dd78c6467ccdd5199feff2 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Mon, 6 Feb 2017 11:25:59 -0800
Subject: [PATCH 037/167] nit fixes
---
gRPC-Core.podspec | 1 +
.../tests/CronetUnitTests/CronetUnitTests.m | 10 +++++-----
templates/gRPC-Core.podspec.template | 1 +
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 840d8132c66..0ef61442a4b 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -883,6 +883,7 @@ Pod::Spec.new do |s|
'test/core/end2end/end2end_test_utils.c',
'test/core/end2end/tests/*.{c,h}',
'test/core/end2end/data/*.{c,h}',
+ 'test/core/util/debugger_macros.c',
'test/core/util/test_config.{c,h}',
'test/core/util/port.h',
'test/core/util/port_posix.c',
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index 9589926d8b5..408952a091b 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -273,7 +273,7 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
-- (void)PacketCoalescing:(bool)use_coalescing {
+- (void)packetCoalescing:(BOOL)use_coalescing {
grpc_arg arg;
arg.key = GRPC_ARG_USE_CRONET_PACKET_COALESCING;
arg.type = GRPC_ARG_INTEGER;
@@ -390,7 +390,7 @@ unsigned int parse_h2_length(const char *field) {
char buf[4096];
long len;
- bool coalesced = false;
+ BOOL coalesced = NO;
while ((len = SSL_read(ssl, buf, sizeof(buf))) > 0) {
gpr_log(GPR_DEBUG, "Read len: %ld", len);
@@ -408,7 +408,7 @@ unsigned int parse_h2_length(const char *field) {
(buf[p + 4] & 1) != 0 && // EOS bit is set
0 == memcmp("hello world", &buf[p + 14],
11)) { // Message is correct
- coalesced = true;
+ coalesced = YES;
break;
}
p += (parse_h2_length(&buf[p]) + 9);
@@ -448,8 +448,8 @@ unsigned int parse_h2_length(const char *field) {
}
- (void)testPacketCoalescing {
- [self PacketCoalescing:true];
- [self PacketCoalescing:false];
+ [self packetCoalescing:YES];
+ [self packetCoalescing:NO];
}
@end
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index 0738b7221b5..0c1ff64a002 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -179,6 +179,7 @@
'test/core/end2end/end2end_test_utils.c',
'test/core/end2end/tests/*.{c,h}',
'test/core/end2end/data/*.{c,h}',
+ 'test/core/util/debugger_macros.c',
'test/core/util/test_config.{c,h}',
'test/core/util/port.h',
'test/core/util/port_posix.c',
From 93727aaaa767db37f1f30c1eec444b44091c4959 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Mon, 6 Feb 2017 13:05:39 -0800
Subject: [PATCH 038/167] Fix memory leak when re-attempting send_status after
it failed
---
src/core/lib/surface/call.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 70bab4c0796..a8152964fc4 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -1483,6 +1483,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
}
bctl->send_final_op = 1;
call->sent_final_op = 1;
+ GPR_ASSERT(call->send_extra_metadata_count == 0);
call->send_extra_metadata_count = 1;
call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem(
exec_ctx, call->channel, op->data.send_status_from_server.status);
@@ -1511,6 +1512,10 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
(int)op->data.send_status_from_server.trailing_metadata_count,
op->data.send_status_from_server.trailing_metadata, 1, 1, NULL,
0)) {
+ for (int n = 0; n < call->send_extra_metadata_count; n++) {
+ GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md);
+ }
+ call->send_extra_metadata_count = 0;
error = GRPC_CALL_ERROR_INVALID_METADATA;
goto done_with_error;
}
From e1cf1b691d3e82742214c8772a71e79e3209c2ce Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Mon, 6 Feb 2017 13:31:05 -0800
Subject: [PATCH 039/167] nit fix 2
---
src/objective-c/tests/CronetUnitTests/CronetUnitTests.m | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index 408952a091b..b6237c950bf 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -273,11 +273,11 @@ unsigned int parse_h2_length(const char *field) {
grpc_completion_queue_destroy(cq);
}
-- (void)packetCoalescing:(BOOL)use_coalescing {
+- (void)packetCoalescing:(BOOL)useCoalescing {
grpc_arg arg;
arg.key = GRPC_ARG_USE_CRONET_PACKET_COALESCING;
arg.type = GRPC_ARG_INTEGER;
- arg.value.integer = use_coalescing ? 1 : 0;
+ arg.value.integer = useCoalescing ? 1 : 0;
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
grpc_call *c;
grpc_slice request_payload_slice =
@@ -418,7 +418,7 @@ unsigned int parse_h2_length(const char *field) {
}
}
- XCTAssert(coalesced == use_coalescing);
+ XCTAssert(coalesced == useCoalescing);
SSL_free(ssl);
SSL_CTX_free(ctx);
close(s);
From 5ff4bfb651ebb061d76e6b14af1d6b02050ffc97 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Fri, 27 Jan 2017 17:20:20 -0800
Subject: [PATCH 040/167] Advance protoc version to 3.1.0
---
src/objective-c/!ProtoCompiler.podspec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec
index b55f6c93c62..dc4d8e964e6 100644
--- a/src/objective-c/!ProtoCompiler.podspec
+++ b/src/objective-c/!ProtoCompiler.podspec
@@ -36,7 +36,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them.
s.name = '!ProtoCompiler'
- v = '3.0.2'
+ v = '3.1.0'
s.version = v
s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files'
s.description = <<-DESC
From d81c6b6d0127ea4c649aa7e97a9d38a86ff0ade0 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Sat, 28 Jan 2017 20:34:05 -0800
Subject: [PATCH 041/167] Advance protoc dependency version as well
---
src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
index bcc2bb61265..0c96784e685 100644
--- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
+++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
@@ -98,7 +98,7 @@ Pod::Spec.new do |s|
s.preserve_paths = plugin
# Restrict the protoc version to the one supported by this plugin.
- s.dependency '!ProtoCompiler', '3.0.2'
+ s.dependency '!ProtoCompiler', '3.1.0'
# For the Protobuf dependency not to complain:
s.ios.deployment_target = '7.1'
s.osx.deployment_target = '10.9'
From 50bd995a9839ae26217dc6f8635b8aba9f379a83 Mon Sep 17 00:00:00 2001
From: Muxi Yan
Date: Mon, 6 Feb 2017 14:05:01 -0800
Subject: [PATCH 042/167] Advance BoringSSL version
---
gRPC-Core.podspec | 2 +-
src/objective-c/BoringSSL.podspec | 382 +++++++++++++--------------
templates/gRPC-Core.podspec.template | 2 +-
3 files changed, 190 insertions(+), 196 deletions(-)
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 02336eec814..f4b32dea897 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -191,7 +191,7 @@ Pod::Spec.new do |s|
ss.header_mappings_dir = '.'
ss.libraries = 'z'
ss.dependency "#{s.name}/Interface", version
- ss.dependency 'BoringSSL', '~> 7.0'
+ ss.dependency 'BoringSSL', '~> 8.0'
# To save you from scrolling, this is the last part of the podspec.
ss.source_files = 'src/core/lib/profiling/timers.h',
diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec
index 47b5b1a2e7b..908bb0b5e5e 100644
--- a/src/objective-c/BoringSSL.podspec
+++ b/src/objective-c/BoringSSL.podspec
@@ -31,7 +31,7 @@
Pod::Spec.new do |s|
s.name = 'BoringSSL'
- version = '7.0'
+ version = '8.0'
s.version = version
s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google’s needs.'
# Adapted from the homepage:
@@ -388,42 +388,42 @@ Pod::Spec.new do |s|
0x28340c19,
0x283480ac,
0x283500ea,
- 0x2c322910,
- 0x2c32a91e,
- 0x2c332930,
- 0x2c33a942,
- 0x2c342956,
- 0x2c34a968,
- 0x2c352983,
- 0x2c35a995,
- 0x2c3629a8,
+ 0x2c3228ca,
+ 0x2c32a8d8,
+ 0x2c3328ea,
+ 0x2c33a8fc,
+ 0x2c342910,
+ 0x2c34a922,
+ 0x2c35293d,
+ 0x2c35a94f,
+ 0x2c362962,
0x2c36832d,
- 0x2c3729b5,
- 0x2c37a9c7,
- 0x2c3829da,
- 0x2c38a9f1,
- 0x2c3929ff,
- 0x2c39aa0f,
- 0x2c3a2a21,
- 0x2c3aaa35,
- 0x2c3b2a46,
- 0x2c3baa65,
- 0x2c3c2a79,
- 0x2c3caa8f,
- 0x2c3d2aa8,
- 0x2c3daac5,
- 0x2c3e2ad6,
- 0x2c3eaae4,
- 0x2c3f2afc,
- 0x2c3fab14,
- 0x2c402b21,
+ 0x2c37296f,
+ 0x2c37a981,
+ 0x2c382994,
+ 0x2c38a9ab,
+ 0x2c3929b9,
+ 0x2c39a9c9,
+ 0x2c3a29db,
+ 0x2c3aa9ef,
+ 0x2c3b2a00,
+ 0x2c3baa1f,
+ 0x2c3c2a33,
+ 0x2c3caa49,
+ 0x2c3d2a62,
+ 0x2c3daa7f,
+ 0x2c3e2a90,
+ 0x2c3eaa9e,
+ 0x2c3f2ab6,
+ 0x2c3faace,
+ 0x2c402adb,
0x2c4090e7,
- 0x2c412b32,
- 0x2c41ab45,
+ 0x2c412aec,
+ 0x2c41aaff,
0x2c4210c0,
- 0x2c42ab56,
+ 0x2c42ab10,
0x2c430720,
- 0x2c43aa57,
+ 0x2c43aa11,
0x30320000,
0x30328015,
0x3033001f,
@@ -639,74 +639,74 @@ Pod::Spec.new do |s|
0x405b1e9e,
0x405b9eaf,
0x405c1ec2,
- 0x405c9ee3,
- 0x405d1ef0,
- 0x405d9f07,
- 0x405e1f27,
+ 0x405c9ed3,
+ 0x405d1ee0,
+ 0x405d9ef7,
+ 0x405e1f17,
0x405e8a95,
- 0x405f1f48,
- 0x405f9f55,
- 0x40601f63,
- 0x40609f85,
- 0x40611fad,
- 0x40619fc2,
- 0x40621fd9,
- 0x40629fea,
- 0x40631ffb,
- 0x4063a010,
- 0x40642027,
- 0x4064a053,
- 0x4065206e,
- 0x4065a085,
- 0x4066209d,
- 0x4066a0c7,
- 0x406720f2,
- 0x4067a113,
- 0x40682126,
- 0x4068a147,
- 0x40692179,
- 0x4069a1a7,
- 0x406a21c8,
- 0x406aa1e8,
- 0x406b2370,
- 0x406ba393,
- 0x406c23a9,
- 0x406ca60b,
- 0x406d263a,
- 0x406da662,
- 0x406e2690,
- 0x406ea6a8,
- 0x406f26c7,
- 0x406fa6dc,
- 0x407026ef,
- 0x4070a70c,
+ 0x405f1f38,
+ 0x405f9f45,
+ 0x40601f53,
+ 0x40609f75,
+ 0x40611f9d,
+ 0x40619fb2,
+ 0x40621fc9,
+ 0x40629fda,
+ 0x40631feb,
+ 0x4063a000,
+ 0x40642017,
+ 0x4064a043,
+ 0x4065205e,
+ 0x4065a075,
+ 0x4066208d,
+ 0x4066a0b7,
+ 0x406720e2,
+ 0x4067a103,
+ 0x40682116,
+ 0x4068a137,
+ 0x40692169,
+ 0x4069a197,
+ 0x406a21b8,
+ 0x406aa1d8,
+ 0x406b2360,
+ 0x406ba383,
+ 0x406c2399,
+ 0x406ca5c5,
+ 0x406d25f4,
+ 0x406da61c,
+ 0x406e264a,
+ 0x406ea662,
+ 0x406f2681,
+ 0x406fa696,
+ 0x407026a9,
+ 0x4070a6c6,
0x40710800,
- 0x4071a71e,
- 0x40722731,
- 0x4072a74a,
- 0x40732762,
+ 0x4071a6d8,
+ 0x407226eb,
+ 0x4072a704,
+ 0x4073271c,
0x4073936d,
- 0x40742776,
- 0x4074a790,
- 0x407527a1,
- 0x4075a7b5,
- 0x407627c3,
+ 0x40742730,
+ 0x4074a74a,
+ 0x4075275b,
+ 0x4075a76f,
+ 0x4076277d,
0x407691aa,
- 0x407727e8,
- 0x4077a80a,
- 0x40782825,
- 0x4078a85e,
- 0x40792875,
- 0x4079a88b,
- 0x407a2897,
- 0x407aa8aa,
- 0x407b28bf,
- 0x407ba8d1,
- 0x407c28e6,
- 0x407ca8ef,
- 0x407d2162,
+ 0x407727a2,
+ 0x4077a7c4,
+ 0x407827df,
+ 0x4078a818,
+ 0x4079282f,
+ 0x4079a845,
+ 0x407a2851,
+ 0x407aa864,
+ 0x407b2879,
+ 0x407ba88b,
+ 0x407c28a0,
+ 0x407ca8a9,
+ 0x407d2152,
0x407d9c57,
- 0x407e283a,
+ 0x407e27f4,
0x407e9e16,
0x407f1a67,
0x407f9887,
@@ -714,45 +714,42 @@ Pod::Spec.new do |s|
0x40809a8f,
0x40811cd9,
0x40819c08,
- 0x4082267b,
+ 0x40822635,
0x4082986d,
0x40831df1,
- 0x4083a038,
+ 0x4083a028,
0x40841aa3,
0x40849e4e,
- 0x40851ed3,
- 0x41f4229b,
- 0x41f9232d,
- 0x41fe2220,
- 0x41fea3fc,
- 0x41ff24ed,
- 0x420322b4,
- 0x420822d6,
- 0x4208a312,
- 0x42092204,
- 0x4209a34c,
- 0x420a225b,
- 0x420aa23b,
- 0x420b227b,
- 0x420ba2f4,
- 0x420c2509,
- 0x420ca3c9,
- 0x420d23e3,
- 0x420da41a,
- 0x42122434,
- 0x421724d0,
- 0x4217a476,
- 0x421c2498,
- 0x421f2453,
- 0x42212520,
- 0x422624b3,
- 0x422b25ef,
- 0x422ba59d,
- 0x422c25d7,
- 0x422ca55c,
- 0x422d253b,
- 0x422da5bc,
- 0x422e2582,
+ 0x41f4228b,
+ 0x41f9231d,
+ 0x41fe2210,
+ 0x41fea3ec,
+ 0x41ff24dd,
+ 0x420322a4,
+ 0x420822c6,
+ 0x4208a302,
+ 0x420921f4,
+ 0x4209a33c,
+ 0x420a224b,
+ 0x420aa22b,
+ 0x420b226b,
+ 0x420ba2e4,
+ 0x420c24f9,
+ 0x420ca3b9,
+ 0x420d23d3,
+ 0x420da40a,
+ 0x42122424,
+ 0x421724c0,
+ 0x4217a466,
+ 0x421c2488,
+ 0x421f2443,
+ 0x42212510,
+ 0x422624a3,
+ 0x422b25a9,
+ 0x422ba572,
+ 0x422c2591,
+ 0x422ca54c,
+ 0x422d252b,
0x4432072b,
0x4432873a,
0x44330746,
@@ -795,69 +792,69 @@ Pod::Spec.new do |s|
0x4c3d136d,
0x4c3d937c,
0x4c3e1389,
- 0x50322b68,
- 0x5032ab77,
- 0x50332b82,
- 0x5033ab92,
- 0x50342bab,
- 0x5034abc5,
- 0x50352bd3,
- 0x5035abe9,
- 0x50362bfb,
- 0x5036ac11,
- 0x50372c2a,
- 0x5037ac3d,
- 0x50382c55,
- 0x5038ac66,
- 0x50392c7b,
- 0x5039ac8f,
- 0x503a2caf,
- 0x503aacc5,
- 0x503b2cdd,
- 0x503bacef,
- 0x503c2d0b,
- 0x503cad22,
- 0x503d2d3b,
- 0x503dad51,
- 0x503e2d5e,
- 0x503ead74,
- 0x503f2d86,
+ 0x50322b22,
+ 0x5032ab31,
+ 0x50332b3c,
+ 0x5033ab4c,
+ 0x50342b65,
+ 0x5034ab7f,
+ 0x50352b8d,
+ 0x5035aba3,
+ 0x50362bb5,
+ 0x5036abcb,
+ 0x50372be4,
+ 0x5037abf7,
+ 0x50382c0f,
+ 0x5038ac20,
+ 0x50392c35,
+ 0x5039ac49,
+ 0x503a2c69,
+ 0x503aac7f,
+ 0x503b2c97,
+ 0x503baca9,
+ 0x503c2cc5,
+ 0x503cacdc,
+ 0x503d2cf5,
+ 0x503dad0b,
+ 0x503e2d18,
+ 0x503ead2e,
+ 0x503f2d40,
0x503f8382,
- 0x50402d99,
- 0x5040ada9,
- 0x50412dc3,
- 0x5041add2,
- 0x50422dec,
- 0x5042ae09,
- 0x50432e19,
- 0x5043ae29,
- 0x50442e38,
+ 0x50402d53,
+ 0x5040ad63,
+ 0x50412d7d,
+ 0x5041ad8c,
+ 0x50422da6,
+ 0x5042adc3,
+ 0x50432dd3,
+ 0x5043ade3,
+ 0x50442df2,
0x5044843f,
- 0x50452e4c,
- 0x5045ae6a,
- 0x50462e7d,
- 0x5046ae93,
- 0x50472ea5,
- 0x5047aeba,
- 0x50482ee0,
- 0x5048aeee,
- 0x50492f01,
- 0x5049af16,
- 0x504a2f2c,
- 0x504aaf3c,
- 0x504b2f5c,
- 0x504baf6f,
- 0x504c2f92,
- 0x504cafc0,
- 0x504d2fd2,
- 0x504dafef,
- 0x504e300a,
- 0x504eb026,
- 0x504f3038,
- 0x504fb04f,
- 0x5050305e,
+ 0x50452e06,
+ 0x5045ae24,
+ 0x50462e37,
+ 0x5046ae4d,
+ 0x50472e5f,
+ 0x5047ae74,
+ 0x50482e9a,
+ 0x5048aea8,
+ 0x50492ebb,
+ 0x5049aed0,
+ 0x504a2ee6,
+ 0x504aaef6,
+ 0x504b2f16,
+ 0x504baf29,
+ 0x504c2f4c,
+ 0x504caf7a,
+ 0x504d2f8c,
+ 0x504dafa9,
+ 0x504e2fc4,
+ 0x504eafe0,
+ 0x504f2ff2,
+ 0x504fb009,
+ 0x50503018,
0x505086ef,
- 0x50513071,
+ 0x5051302b,
0x58320ec9,
0x68320e8b,
0x68328c25,
@@ -1292,7 +1289,6 @@ Pod::Spec.new do |s|
"NO_RENEGOTIATION\\0"
"NO_REQUIRED_DIGEST\\0"
"NO_SHARED_CIPHER\\0"
- "NO_SHARED_GROUP\\0"
"NULL_SSL_CTX\\0"
"NULL_SSL_METHOD_PASSED\\0"
"OLD_SESSION_CIPHER_NOT_RETURNED\\0"
@@ -1353,9 +1349,7 @@ Pod::Spec.new do |s|
"TLSV1_ALERT_USER_CANCELLED\\0"
"TLSV1_BAD_CERTIFICATE_HASH_VALUE\\0"
"TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE\\0"
- "TLSV1_CERTIFICATE_REQUIRED\\0"
"TLSV1_CERTIFICATE_UNOBTAINABLE\\0"
- "TLSV1_UNKNOWN_PSK_IDENTITY\\0"
"TLSV1_UNRECOGNIZED_NAME\\0"
"TLSV1_UNSUPPORTED_EXTENSION\\0"
"TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST\\0"
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index d43bcb93ef2..84720d2cd96 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -151,7 +151,7 @@
ss.header_mappings_dir = '.'
ss.libraries = 'z'
ss.dependency "#{s.name}/Interface", version
- ss.dependency 'BoringSSL', '~> 7.0'
+ ss.dependency 'BoringSSL', '~> 8.0'
# To save you from scrolling, this is the last part of the podspec.
ss.source_files = ${ruby_multiline_list(grpc_private_files(libs), 22)}
From cc08a4f24f26f649b6af10b45ae5a0d141fd118c Mon Sep 17 00:00:00 2001
From: Piotr Pietraszkiewicz
Date: Tue, 7 Feb 2017 11:02:58 +0100
Subject: [PATCH 043/167] Fix issue #9602
This is achieved by putting `grpc++_codegegen_proto` on the
`filegroup` of `grpc++`.
---
build.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/build.yaml b/build.yaml
index 456db28cef4..a453e6b4373 100644
--- a/build.yaml
+++ b/build.yaml
@@ -1063,6 +1063,7 @@ libs:
filegroups:
- grpc++_base
- grpc++_codegen_base
+ - grpc++_codegen_proto
- grpc++_codegen_base_src
secure: check
vs_project_guid: '{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}'
From 78e6451dae37a91d9a77941bf836776a1807cad0 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 7 Feb 2017 07:03:26 -0800
Subject: [PATCH 044/167] Add a hook to disable BDP probing
---
include/grpc/impl/codegen/grpc_types.h | 2 +
.../chttp2/transport/chttp2_transport.c | 58 +++++++++++--------
.../ext/transport/chttp2/transport/internal.h | 3 +
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index 7fbaf56e75b..bc0b2bd7f86 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -179,6 +179,8 @@ typedef struct {
Larger values give lower CPU usage for large messages, but more head of line
blocking for small messages. */
#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size"
+/** Should BDP probing be performed? */
+#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe"
/** Minimum time (in milliseconds) between successive ping frames being sent */
#define GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS \
"grpc.http2.min_time_between_pings_ms"
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
index fa18f5a725a..8a9eaa8b6a2 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
@@ -292,6 +292,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
t->sent_local_settings = 0;
t->write_buffer_size = DEFAULT_WINDOW;
+ t->enable_bdp_probe = true;
if (is_client) {
grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string(
@@ -358,6 +359,10 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
&channel_args->args[i],
(grpc_integer_options){0, 0, MAX_WRITE_BUFFER_SIZE});
+ } else if (0 ==
+ strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) {
+ t->enable_bdp_probe = grpc_channel_arg_get_integer(
+ &channel_args->args[i], (grpc_integer_options){1, 0, 1});
} else {
static const struct {
const char *channel_arg_name;
@@ -1908,33 +1913,36 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
&t->read_action_locked);
- if (need_bdp_ping) {
- GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
- grpc_bdp_estimator_schedule_ping(&t->bdp_estimator);
- send_ping_locked(exec_ctx, t,
- GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE,
- &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked);
- }
-
- int64_t estimate = -1;
- if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) {
- double target = 1 + log2((double)estimate);
- double memory_pressure = grpc_resource_quota_get_memory_pressure(
- grpc_resource_user_quota(grpc_endpoint_get_resource_user(t->ep)));
- if (memory_pressure > 0.8) {
- target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1);
+ if (t->enable_bdp_probe) {
+ if (need_bdp_ping) {
+ GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
+ grpc_bdp_estimator_schedule_ping(&t->bdp_estimator);
+ send_ping_locked(exec_ctx, t,
+ GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE,
+ &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked);
}
- double bdp_error = target - grpc_pid_controller_last(&t->pid_controller);
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update);
- double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9;
- if (dt > 0.1) {
- dt = 0.1;
+
+ int64_t estimate = -1;
+ if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) {
+ double target = 1 + log2((double)estimate);
+ double memory_pressure = grpc_resource_quota_get_memory_pressure(
+ grpc_resource_user_quota(grpc_endpoint_get_resource_user(t->ep)));
+ if (memory_pressure > 0.8) {
+ target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1);
+ }
+ double bdp_error =
+ target - grpc_pid_controller_last(&t->pid_controller);
+ gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
+ gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update);
+ double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9;
+ if (dt > 0.1) {
+ dt = 0.1;
+ }
+ double log2_bdp_guess =
+ grpc_pid_controller_update(&t->pid_controller, bdp_error, dt);
+ update_bdp(exec_ctx, t, pow(2, log2_bdp_guess));
+ t->last_pid_update = now;
}
- double log2_bdp_guess =
- grpc_pid_controller_update(&t->pid_controller, bdp_error, dt);
- update_bdp(exec_ctx, t, pow(2, log2_bdp_guess));
- t->last_pid_update = now;
}
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
} else {
diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h
index 1dabf9edba2..075d421dd46 100644
--- a/src/core/ext/transport/chttp2/transport/internal.h
+++ b/src/core/ext/transport/chttp2/transport/internal.h
@@ -227,6 +227,9 @@ struct grpc_chttp2_transport {
/** is there a read request to the endpoint outstanding? */
uint8_t endpoint_reading;
+ /** should we probe bdp? */
+ bool enable_bdp_probe;
+
/** various lists of streams */
grpc_chttp2_stream_list lists[STREAM_LIST_COUNT];
From 49124e7ae16bd7423a1fa238181743a797d72437 Mon Sep 17 00:00:00 2001
From: Robbie Shade
Date: Tue, 7 Feb 2017 10:42:22 -0500
Subject: [PATCH 045/167] Adds an exec_ctx argument to orphan_cb in udp_server
---
src/core/lib/iomgr/udp_server.c | 4 ++--
src/core/lib/iomgr/udp_server.h | 3 ++-
test/core/iomgr/udp_server_test.c | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c
index 02a194c9825..2a1c8d39fae 100644
--- a/src/core/lib/iomgr/udp_server.c
+++ b/src/core/lib/iomgr/udp_server.c
@@ -178,7 +178,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
/* Call the orphan_cb to signal that the FD is about to be closed and
* should no longer be used. */
GPR_ASSERT(sp->orphan_cb);
- sp->orphan_cb(sp->emfd);
+ sp->orphan_cb(exec_ctx, sp->emfd);
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
"udp_listener_shutdown");
@@ -204,7 +204,7 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
if (s->active_ports) {
for (sp = s->head; sp; sp = sp->next) {
GPR_ASSERT(sp->orphan_cb);
- sp->orphan_cb(sp->emfd);
+ sp->orphan_cb(exec_ctx, sp->emfd);
grpc_fd_shutdown(exec_ctx, sp->emfd,
GRPC_ERROR_CREATE("Server destroyed"));
}
diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h
index ce068cbf04c..ed63fa7d817 100644
--- a/src/core/lib/iomgr/udp_server.h
+++ b/src/core/lib/iomgr/udp_server.h
@@ -54,7 +54,8 @@ typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx,
grpc_fd *emfd);
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */
-typedef void (*grpc_udp_server_orphan_cb)(grpc_fd *emfd);
+typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx *exec_ctx,
+ grpc_fd *emfd);
/* Create a server, initially not bound to any ports */
grpc_udp_server *grpc_udp_server_create(void);
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index ba7a52ea21c..ba572017a22 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -88,7 +88,7 @@ static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd) {
gpr_mu_unlock(g_mu);
}
-static void on_fd_orphaned(grpc_fd *emfd) {
+static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd) {
gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d",
grpc_fd_wrapped_fd(emfd));
g_number_of_orphan_calls++;
From 5f3a1430682976f94bccc58719a08a45ca493ff6 Mon Sep 17 00:00:00 2001
From: Carl Mastrangelo
Date: Tue, 7 Feb 2017 08:14:29 -0800
Subject: [PATCH 046/167] remove extra space in Csharp code
---
src/csharp/ext/grpc_csharp_ext.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index e1f4d7cdf31..6a241190b27 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -761,7 +761,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
ops[nops].data.send_message.send_message = ctx->send_message;
ops[nops].flags = write_flags;
ops[nops].reserved = NULL;
- nops ++;
+ nops++;
}
if (send_empty_initial_metadata) {
ops[nops].op = GRPC_OP_SEND_INITIAL_METADATA;
From b038beb7245877b71e30e782ddd6c86d82d11d17 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 7 Feb 2017 08:28:51 -0800
Subject: [PATCH 047/167] Add counters for mutex acquisitions, expose in
bm_fullstack
---
Makefile | 8 +++++
build.yaml | 3 ++
src/core/lib/support/sync_posix.c | 7 ++++
test/cpp/microbenchmarks/bm_fullstack.cc | 46 +++++++++++++++++++-----
tools/run_tests/generated/configs.json | 3 ++
tools/run_tests/generated/tests.json | 34 ++++++++++++++++++
6 files changed, 92 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index 0413cc0e009..3d8f7e6a432 100644
--- a/Makefile
+++ b/Makefile
@@ -212,6 +212,14 @@ CPPFLAGS_mutrace = -O3 -fno-omit-frame-pointer
LDFLAGS_mutrace = -rdynamic
DEFINES_mutrace = NDEBUG
+VALID_CONFIG_counters = 1
+CC_counters = $(DEFAULT_CC)
+CXX_counters = $(DEFAULT_CXX)
+LD_counters = $(DEFAULT_CC)
+LDXX_counters = $(DEFAULT_CXX)
+CPPFLAGS_counters = -O2 -DGPR_MU_COUNTERS
+DEFINES_counters = NDEBUG
+
# General settings.
diff --git a/build.yaml b/build.yaml
index 456db28cef4..a13ba05b990 100644
--- a/build.yaml
+++ b/build.yaml
@@ -3825,6 +3825,9 @@ configs:
basicprof:
CPPFLAGS: -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
DEFINES: NDEBUG
+ counters:
+ CPPFLAGS: -O2 -DGPR_MU_COUNTERS
+ DEFINES: NDEBUG
dbg:
CPPFLAGS: -O0
DEFINES: _DEBUG DEBUG
diff --git a/src/core/lib/support/sync_posix.c b/src/core/lib/support/sync_posix.c
index dcb0969a4ea..de0f0484b57 100644
--- a/src/core/lib/support/sync_posix.c
+++ b/src/core/lib/support/sync_posix.c
@@ -42,11 +42,18 @@
#include
#include "src/core/lib/profiling/timers.h"
+#ifdef GPR_MU_COUNTERS
+gpr_atm grpc_mu_locks = 0;
+#endif
+
void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); }
void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); }
void gpr_mu_lock(gpr_mu* mu) {
+#ifdef GPR_MU_COUNTERS
+ gpr_atm_no_barrier_fetch_add(&grpc_mu_locks, 1);
+#endif
GPR_TIMER_BEGIN("gpr_mu_lock", 0);
GPR_ASSERT(pthread_mutex_lock(mu) == 0);
GPR_TIMER_END("gpr_mu_lock", 0);
diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc
index c3e96c572c8..c5ace53ff9b 100644
--- a/test/cpp/microbenchmarks/bm_fullstack.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack.cc
@@ -94,7 +94,37 @@ static void ApplyCommonChannelArguments(ChannelArguments* c) {
c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX);
}
-class FullstackFixture {
+#ifdef GPR_MU_COUNTERS
+extern "C" gpr_atm grpc_mu_locks;
+#endif
+
+class BaseFixture {
+ public:
+ void Finish(benchmark::State& s) {
+ std::ostringstream out;
+ this->AddToLabel(out, s);
+#ifdef GPR_MU_COUNTERS
+ out << " locks/iteration:"
+ << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) -
+ mu_locks_at_start_) /
+ (double)s.iterations());
+#endif
+ auto label = out.str();
+ if (label.length() && label[0] == ' ') {
+ label = label.substr(1);
+ }
+ s.SetLabel(label);
+ }
+
+ virtual void AddToLabel(std::ostream& out, benchmark::State& s) = 0;
+
+ private:
+#ifdef GPR_MU_COUNTERS
+ const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&grpc_mu_locks);
+#endif
+};
+
+class FullstackFixture : public BaseFixture {
public:
FullstackFixture(Service* service, const grpc::string& address) {
ServerBuilder b;
@@ -130,7 +160,7 @@ class TCP : public FullstackFixture {
public:
TCP(Service* service) : FullstackFixture(service, MakeAddress()) {}
- void Finish(benchmark::State& state) {}
+ void AddToLabel(std::ostream& out, benchmark::State& state) {}
private:
static grpc::string MakeAddress() {
@@ -145,7 +175,7 @@ class UDS : public FullstackFixture {
public:
UDS(Service* service) : FullstackFixture(service, MakeAddress()) {}
- void Finish(benchmark::State& state) {}
+ void AddToLabel(std::ostream& out, benchmark::State& state) override {}
private:
static grpc::string MakeAddress() {
@@ -157,7 +187,7 @@ class UDS : public FullstackFixture {
}
};
-class EndpointPairFixture {
+class EndpointPairFixture : public BaseFixture {
public:
EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints) {
ServerBuilder b;
@@ -233,7 +263,7 @@ class SockPair : public EndpointPairFixture {
"test", initialize_stuff.rq(), 8192)) {
}
- void Finish(benchmark::State& state) {}
+ void AddToLabel(std::ostream& out, benchmark::State& state) {}
};
class InProcessCHTTP2 : public EndpointPairFixture {
@@ -241,11 +271,9 @@ class InProcessCHTTP2 : public EndpointPairFixture {
InProcessCHTTP2(Service* service)
: EndpointPairFixture(service, MakeEndpoints()) {}
- void Finish(benchmark::State& state) {
- std::ostringstream out;
- out << "writes/iteration:"
+ void AddToLabel(std::ostream& out, benchmark::State& state) {
+ out << " writes/iteration:"
<< ((double)stats_.num_writes / (double)state.iterations());
- state.SetLabel(out.str());
}
private:
diff --git a/tools/run_tests/generated/configs.json b/tools/run_tests/generated/configs.json
index 091f5d98239..9173bd7c19c 100644
--- a/tools/run_tests/generated/configs.json
+++ b/tools/run_tests/generated/configs.json
@@ -66,5 +66,8 @@
},
{
"config": "mutrace"
+ },
+ {
+ "config": "counters"
}
]
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 4cc543962e4..34f777de166 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -39242,6 +39242,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39277,6 +39278,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39312,6 +39314,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39347,6 +39350,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39384,6 +39388,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39421,6 +39426,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39456,6 +39462,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39491,6 +39498,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39526,6 +39534,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39561,6 +39570,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39596,6 +39606,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39631,6 +39642,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39666,6 +39678,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39701,6 +39714,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39736,6 +39750,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39771,6 +39786,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39806,6 +39822,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39841,6 +39858,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39876,6 +39894,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39911,6 +39930,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39946,6 +39966,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -39983,6 +40004,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40020,6 +40042,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40055,6 +40078,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40090,6 +40114,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40125,6 +40150,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40160,6 +40186,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40195,6 +40222,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40230,6 +40258,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40265,6 +40294,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40300,6 +40330,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40335,6 +40366,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40370,6 +40402,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
@@ -40405,6 +40438,7 @@
"asan-noleaks",
"asan-trace-cmp",
"basicprof",
+ "counters",
"dbg",
"gcov",
"helgrind",
From 01d7d9b2e52e5945616610025527908c4101df03 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 7 Feb 2017 08:39:05 -0800
Subject: [PATCH 048/167] Add allocations/iteration counters to bm_fullstack
---
test/cpp/microbenchmarks/bm_fullstack.cc | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc
index c5ace53ff9b..32fd5351659 100644
--- a/test/cpp/microbenchmarks/bm_fullstack.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack.cc
@@ -54,6 +54,7 @@ extern "C" {
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
+#include "test/core/util/memory_counters.h"
#include "test/core/util/passthru_endpoint.h"
#include "test/core/util/port.h"
}
@@ -67,6 +68,7 @@ namespace testing {
static class InitializeStuff {
public:
InitializeStuff() {
+ grpc_memory_counters_init();
init_lib_.init();
rq_ = grpc_resource_quota_create("bm");
}
@@ -104,11 +106,15 @@ class BaseFixture {
std::ostringstream out;
this->AddToLabel(out, s);
#ifdef GPR_MU_COUNTERS
- out << " locks/iteration:"
- << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) -
- mu_locks_at_start_) /
- (double)s.iterations());
+ out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) -
+ mu_locks_at_start_) /
+ (double)s.iterations());
#endif
+ grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
+ out << " allocs/iter:"
+ << ((double)(counters_at_end.total_allocs_absolute -
+ counters_at_start_.total_allocs_absolute) /
+ (double)s.iterations());
auto label = out.str();
if (label.length() && label[0] == ' ') {
label = label.substr(1);
@@ -122,6 +128,7 @@ class BaseFixture {
#ifdef GPR_MU_COUNTERS
const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&grpc_mu_locks);
#endif
+ grpc_memory_counters counters_at_start_ = grpc_memory_counters_snapshot();
};
class FullstackFixture : public BaseFixture {
@@ -272,7 +279,7 @@ class InProcessCHTTP2 : public EndpointPairFixture {
: EndpointPairFixture(service, MakeEndpoints()) {}
void AddToLabel(std::ostream& out, benchmark::State& state) {
- out << " writes/iteration:"
+ out << " writes/iter:"
<< ((double)stats_.num_writes / (double)state.iterations());
}
From 6911d08388a7958e159d96481770caf8e7bb8a9e Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 7 Feb 2017 10:30:44 -0800
Subject: [PATCH 049/167] Fix platform_string() usage, cut temporary space
usage
---
.../python_utils/start_port_server.py | 3 ++-
tools/run_tests/run_microbenchmark.py | 19 +++++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/tools/run_tests/python_utils/start_port_server.py b/tools/run_tests/python_utils/start_port_server.py
index 4103eb0534b..d521aa6a9d9 100644
--- a/tools/run_tests/python_utils/start_port_server.py
+++ b/tools/run_tests/python_utils/start_port_server.py
@@ -35,6 +35,7 @@ import subprocess
import tempfile
import sys
import time
+import jobset
def start_port_server(port_server_port):
# check if a compatible port server is running
@@ -69,7 +70,7 @@ def start_port_server(port_server_port):
'-p', '%d' % port_server_port, '-l', logfile]
env = dict(os.environ)
env['BUILD_ID'] = 'pleaseDontKillMeJenkins'
- if platform_string() == 'windows':
+ if jobset.platform_string() == 'windows':
# Working directory of port server needs to be outside of Jenkins
# workspace to prevent file lock issues.
tempdir = tempfile.mkdtemp()
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index 42a31a622f7..d51388bbf05 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -74,6 +74,7 @@ def link(txt, tgt):
benchmarks = []
profile_analysis = []
+cleanup = []
for bm_name in sys.argv[1:]:
# generate latency profiles
@@ -92,10 +93,20 @@ for bm_name in sys.argv[1:]:
'tools/profiling/latency_profile/profile_analyzer.py',
'--source', '%s.trace' % fnize(line), '--fmt', 'simple',
'--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=None))
-
- jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
- add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
- jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ cleanup.append('rm', '%s.trace' % fnize(line))
+ if len(benchmarks) >= 2 * multiprocessing.cpu_count():
+ jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
+ add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+ benchmarks = []
+ profile_analysis = []
+ cleanup = []
+ if len(benchmarks):
+ jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
+ add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
# generate flamegraphs
heading('Flamegraphs: %s' % bm_name)
From 715e43bc81227d86f6a8a102aab488d47db801f4 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 7 Feb 2017 11:13:16 -0800
Subject: [PATCH 050/167] Make a jobspec
---
tools/run_tests/run_microbenchmark.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index d51388bbf05..852b83967a9 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -93,7 +93,7 @@ for bm_name in sys.argv[1:]:
'tools/profiling/latency_profile/profile_analyzer.py',
'--source', '%s.trace' % fnize(line), '--fmt', 'simple',
'--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=None))
- cleanup.append('rm', '%s.trace' % fnize(line))
+ cleanup.append(jobset.JobSpec(['rm', '%s.trace' % fnize(line)]))
if len(benchmarks) >= 2 * multiprocessing.cpu_count():
jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
From 0a8e32ab7f9666c45fb5651cec10f61dc538a79d Mon Sep 17 00:00:00 2001
From: ncteisen
Date: Tue, 7 Feb 2017 12:25:19 -0800
Subject: [PATCH 051/167] Add more verbose status msg to rst_stream case
---
.../ext/transport/chttp2/transport/frame_rst_stream.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
index 7d5beed09dd..2e93ae2b857 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
@@ -109,8 +109,14 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
(((uint32_t)p->reason_bytes[3]));
grpc_error *error = GRPC_ERROR_NONE;
if (reason != GRPC_HTTP2_NO_ERROR || s->header_frames_received < 2) {
- error = grpc_error_set_int(GRPC_ERROR_CREATE("RST_STREAM"),
- GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
+ char *message;
+ gpr_asprintf(&message, "Received RST_STREAM with error code %d",
+ reason);
+ error = grpc_error_set_int(
+ grpc_error_set_str(GRPC_ERROR_CREATE("RST_STREAM"),
+ GRPC_ERROR_STR_GRPC_MESSAGE, message),
+ GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
+ gpr_free(message);
}
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, error);
}
From dc9bee7ce4dd64392acd62b447e06b1cd0f4cd6b Mon Sep 17 00:00:00 2001
From: "Mark D. Roth"
Date: Tue, 7 Feb 2017 12:29:14 -0800
Subject: [PATCH 052/167] Add proxy mapper method for overriding the name to
resolve.
---
src/core/ext/client_channel/client_channel.c | 44 +++++-----------
.../client_channel/client_channel_plugin.c | 2 +
src/core/ext/client_channel/http_proxy.c | 51 +++++++++++++++++-
src/core/ext/client_channel/http_proxy.h | 4 +-
src/core/ext/client_channel/proxy_mapper.c | 25 ++++++---
src/core/ext/client_channel/proxy_mapper.h | 36 +++++++++----
.../client_channel/proxy_mapper_registry.c | 52 +++++++++++++------
.../client_channel/proxy_mapper_registry.h | 16 ++++--
src/core/ext/client_channel/subchannel.c | 4 +-
9 files changed, 159 insertions(+), 75 deletions(-)
diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c
index 4ab467329a6..06038bb5ba9 100644
--- a/src/core/ext/client_channel/client_channel.c
+++ b/src/core/ext/client_channel/client_channel.c
@@ -44,8 +44,8 @@
#include
#include "src/core/ext/client_channel/http_connect_handshaker.h"
-#include "src/core/ext/client_channel/http_proxy.h"
#include "src/core/ext/client_channel/lb_policy_registry.h"
+#include "src/core/ext/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/client_channel/resolver_registry.h"
#include "src/core/ext/client_channel/subchannel.h"
#include "src/core/lib/channel/channel_args.h"
@@ -153,10 +153,6 @@ static void *method_parameters_create_from_json(const grpc_json *json) {
*/
typedef struct client_channel_channel_data {
- /** server name */
- char *server_name;
- /** HTTP CONNECT proxy to use, if any */
- char *proxy_name;
/** resolver for this channel */
grpc_resolver *resolver;
/** have we started resolving this channel */
@@ -317,17 +313,6 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg,
// Use pick_first if nothing was specified and we didn't select grpclb
// above.
if (lb_policy_name == NULL) lb_policy_name = "pick_first";
- // If using a proxy, add channel arg for server in HTTP CONNECT request.
- if (chand->proxy_name != NULL) {
- grpc_arg new_arg;
- new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER;
- new_arg.type = GRPC_ARG_STRING;
- new_arg.value.string = chand->server_name;
- grpc_channel_args *tmp_args = chand->resolver_result;
- chand->resolver_result =
- grpc_channel_args_copy_and_add(chand->resolver_result, &new_arg, 1);
- grpc_channel_args_destroy(exec_ctx, tmp_args);
- }
// Instantiate LB policy.
grpc_lb_policy_args lb_policy_args;
lb_policy_args.args = chand->resolver_result;
@@ -542,24 +527,21 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
grpc_client_channel_factory_ref(arg->value.pointer.p);
chand->client_channel_factory = arg->value.pointer.p;
- // Instantiate resolver.
+ // Get server name to resolve, using proxy mapper if needed.
arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
GPR_ASSERT(arg != NULL);
GPR_ASSERT(arg->type == GRPC_ARG_STRING);
- grpc_uri *uri = grpc_uri_parse(arg->value.string, true);
- if (uri == NULL) return GRPC_ERROR_CREATE("cannot parse server URI");
- if (uri->path[0] == '\0') {
- grpc_uri_destroy(uri);
- return GRPC_ERROR_CREATE("server URI is missing path");
- }
- chand->server_name =
- gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
- grpc_uri_destroy(uri);
- chand->proxy_name = grpc_get_http_proxy_server();
- char *name_to_resolve =
- chand->proxy_name == NULL ? arg->value.string : chand->proxy_name;
+ char *proxy_name = NULL;
+ grpc_channel_args *new_args = NULL;
+ grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
+ &proxy_name, &new_args);
+ // Instantiate resolver.
chand->resolver = grpc_resolver_create(
- exec_ctx, name_to_resolve, args->channel_args, chand->interested_parties);
+ exec_ctx, proxy_name != NULL ? proxy_name : arg->value.string,
+ new_args != NULL ? new_args : args->channel_args,
+ chand->interested_parties);
+ if (proxy_name != NULL) gpr_free(proxy_name);
+ if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
if (chand->resolver == NULL) {
return GRPC_ERROR_CREATE("resolver creation failed");
}
@@ -570,8 +552,6 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {
channel_data *chand = elem->channel_data;
- gpr_free(chand->server_name);
- gpr_free(chand->proxy_name);
if (chand->resolver != NULL) {
grpc_resolver_shutdown(exec_ctx, chand->resolver);
GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
diff --git a/src/core/ext/client_channel/client_channel_plugin.c b/src/core/ext/client_channel/client_channel_plugin.c
index 7f75233727e..6f9df3e386e 100644
--- a/src/core/ext/client_channel/client_channel_plugin.c
+++ b/src/core/ext/client_channel/client_channel_plugin.c
@@ -39,6 +39,7 @@
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/http_connect_handshaker.h"
+#include "src/core/ext/client_channel/http_proxy.h"
#include "src/core/ext/client_channel/lb_policy_registry.h"
#include "src/core/ext/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/client_channel/resolver_registry.h"
@@ -82,6 +83,7 @@ void grpc_client_channel_init(void) {
grpc_lb_policy_registry_init();
grpc_resolver_registry_init();
grpc_proxy_mapper_registry_init();
+ grpc_register_http_proxy_mapper();
grpc_subchannel_index_init();
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN,
set_default_host_if_unset, NULL);
diff --git a/src/core/ext/client_channel/http_proxy.c b/src/core/ext/client_channel/http_proxy.c
index 9a6c818c4ee..7daa0714951 100644
--- a/src/core/ext/client_channel/http_proxy.c
+++ b/src/core/ext/client_channel/http_proxy.c
@@ -40,10 +40,13 @@
#include
#include
+#include "src/core/ext/client_channel/http_connect_handshaker.h"
+#include "src/core/ext/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/client_channel/uri_parser.h"
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/support/env.h"
-char* grpc_get_http_proxy_server() {
+static char* grpc_get_http_proxy_server() {
char* uri_str = gpr_getenv("http_proxy");
if (uri_str == NULL) return NULL;
grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
@@ -66,3 +69,49 @@ done:
grpc_uri_destroy(uri);
return proxy_name;
}
+
+static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper* mapper,
+ const char* server_uri,
+ const grpc_channel_args* args,
+ char** name_to_resolve,
+ grpc_channel_args** new_args) {
+ *name_to_resolve = grpc_get_http_proxy_server();
+ if (*name_to_resolve == NULL) return false;
+ grpc_uri* uri = grpc_uri_parse(server_uri, false /* suppress_errors */);
+ if (uri == NULL || uri->path[0] == '\0') {
+ gpr_log(GPR_ERROR,
+ "'http_proxy' environment variable set, but cannot "
+ "parse server URI '%s' -- not using proxy",
+ server_uri);
+ if (uri != NULL) grpc_uri_destroy(uri);
+ return false;
+ }
+ grpc_arg new_arg;
+ new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER;
+ new_arg.type = GRPC_ARG_STRING;
+ new_arg.value.string = uri->path[0] == '/' ? uri->path + 1 : uri->path;
+ *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
+ grpc_uri_destroy(uri);
+ return true;
+}
+
+static bool proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper* mapper,
+ const grpc_resolved_address* address,
+ const grpc_channel_args* args,
+ grpc_resolved_address** new_address,
+ grpc_channel_args** new_args) {
+ return false;
+}
+
+static void proxy_mapper_destroy(grpc_proxy_mapper* mapper) {}
+
+static const grpc_proxy_mapper_vtable proxy_mapper_vtable = {
+ proxy_mapper_map_name, proxy_mapper_map_address, proxy_mapper_destroy};
+
+static grpc_proxy_mapper proxy_mapper = {&proxy_mapper_vtable};
+
+void grpc_register_http_proxy_mapper() {
+ grpc_proxy_mapper_register(true /* at_start */, &proxy_mapper);
+}
diff --git a/src/core/ext/client_channel/http_proxy.h b/src/core/ext/client_channel/http_proxy.h
index 0d77ae253b0..c8882b1ef18 100644
--- a/src/core/ext/client_channel/http_proxy.h
+++ b/src/core/ext/client_channel/http_proxy.h
@@ -34,8 +34,6 @@
#ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H
#define GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H
-/// Returns the name of the proxy to use, or NULL if no proxy is configured.
-/// Caller takes ownership of result.
-char* grpc_get_http_proxy_server();
+void grpc_register_http_proxy_mapper();
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H */
diff --git a/src/core/ext/client_channel/proxy_mapper.c b/src/core/ext/client_channel/proxy_mapper.c
index 6b6f328d3ce..f92afe847bf 100644
--- a/src/core/ext/client_channel/proxy_mapper.c
+++ b/src/core/ext/client_channel/proxy_mapper.c
@@ -38,13 +38,24 @@ void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
mapper->vtable = vtable;
}
-bool grpc_proxy_mapper_map(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
- const grpc_resolved_address* address,
- const grpc_channel_args* args,
- grpc_resolved_address** new_address,
- grpc_channel_args** new_args) {
- return mapper->vtable->map(exec_ctx, mapper, address, args, new_address,
- new_args);
+bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper* mapper,
+ const char* server_uri,
+ const grpc_channel_args* args,
+ char** name_to_resolve,
+ grpc_channel_args** new_args) {
+ return mapper->vtable->map_name(exec_ctx, mapper, server_uri, args,
+ name_to_resolve, new_args);
+}
+
+bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper* mapper,
+ const grpc_resolved_address* address,
+ const grpc_channel_args* args,
+ grpc_resolved_address** new_address,
+ grpc_channel_args** new_args) {
+ return mapper->vtable->map_address(exec_ctx, mapper, address, args,
+ new_address, new_args);
}
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper) {
diff --git a/src/core/ext/client_channel/proxy_mapper.h b/src/core/ext/client_channel/proxy_mapper.h
index fa930379e70..6e4607fe4d9 100644
--- a/src/core/ext/client_channel/proxy_mapper.h
+++ b/src/core/ext/client_channel/proxy_mapper.h
@@ -43,15 +43,22 @@
typedef struct grpc_proxy_mapper grpc_proxy_mapper;
typedef struct {
+ /// Determines the proxy name to resolve for \a server_uri.
+ /// If no proxy is needed, returns false.
+ /// Otherwise, sets \a name_to_resolve, optionally sets \a new_args,
+ /// and returns true.
+ bool (*map_name)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
+ const char* server_uri, const grpc_channel_args* args,
+ char** name_to_resolve, grpc_channel_args** new_args);
/// Determines the proxy address to use to contact \a address.
/// If no proxy is needed, returns false.
/// Otherwise, sets \a new_address, optionally sets \a new_args, and
/// returns true.
- bool (*map)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
- const grpc_resolved_address* address,
- const grpc_channel_args* args,
- grpc_resolved_address** new_address,
- grpc_channel_args** new_args);
+ bool (*map_address)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
+ const grpc_resolved_address* address,
+ const grpc_channel_args* args,
+ grpc_resolved_address** new_address,
+ grpc_channel_args** new_args);
/// Destroys \a mapper.
void (*destroy)(grpc_proxy_mapper* mapper);
} grpc_proxy_mapper_vtable;
@@ -63,11 +70,20 @@ struct grpc_proxy_mapper {
void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
grpc_proxy_mapper* mapper);
-bool grpc_proxy_mapper_map(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
- const grpc_resolved_address* address,
- const grpc_channel_args* args,
- grpc_resolved_address** new_address,
- grpc_channel_args** new_args);
+bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper* mapper,
+ const char* server_uri,
+ const grpc_channel_args* args,
+ char** name_to_resolve,
+ grpc_channel_args** new_args);
+
+bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper* mapper,
+ const grpc_resolved_address* address,
+ const grpc_channel_args* args,
+ grpc_resolved_address** new_address,
+ grpc_channel_args** new_args);
+
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper);
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_H */
diff --git a/src/core/ext/client_channel/proxy_mapper_registry.c b/src/core/ext/client_channel/proxy_mapper_registry.c
index 0a156c8b1c1..2c44b9d4903 100644
--- a/src/core/ext/client_channel/proxy_mapper_registry.c
+++ b/src/core/ext/client_channel/proxy_mapper_registry.c
@@ -61,15 +61,28 @@ static void grpc_proxy_mapper_list_register(grpc_proxy_mapper_list* list,
++list->num_mappers;
}
-static bool grpc_proxy_mapper_list_map(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper_list* list,
- const grpc_resolved_address* address,
- const grpc_channel_args* args,
- grpc_resolved_address** new_address,
- grpc_channel_args** new_args) {
+static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
+ grpc_proxy_mapper_list* list,
+ const char* server_uri,
+ const grpc_channel_args* args,
+ char** name_to_resolve,
+ grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) {
- if (grpc_proxy_mapper_map(exec_ctx, list->list[i], address, args,
- new_address, new_args)) {
+ if (grpc_proxy_mapper_map_name(exec_ctx, list->list[i], server_uri, args,
+ name_to_resolve, new_args)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool grpc_proxy_mapper_list_map_address(
+ grpc_exec_ctx* exec_ctx, grpc_proxy_mapper_list* list,
+ const grpc_resolved_address* address, const grpc_channel_args* args,
+ grpc_resolved_address** new_address, grpc_channel_args** new_args) {
+ for (size_t i = 0; i < list->num_mappers; ++i) {
+ if (grpc_proxy_mapper_map_address(exec_ctx, list->list[i], address, args,
+ new_address, new_args)) {
return true;
}
}
@@ -101,11 +114,20 @@ void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper) {
grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper);
}
-bool grpc_proxy_mappers_map(grpc_exec_ctx* exec_ctx,
- const grpc_resolved_address* address,
- const grpc_channel_args* args,
- grpc_resolved_address** new_address,
- grpc_channel_args** new_args) {
- return grpc_proxy_mapper_list_map(exec_ctx, &g_proxy_mapper_list, address,
- args, new_address, new_args);
+bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
+ const char* server_uri,
+ const grpc_channel_args* args,
+ char** name_to_resolve,
+ grpc_channel_args** new_args) {
+ return grpc_proxy_mapper_list_map_name(exec_ctx, &g_proxy_mapper_list,
+ server_uri, args, name_to_resolve,
+ new_args);
+}
+bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
+ const grpc_resolved_address* address,
+ const grpc_channel_args* args,
+ grpc_resolved_address** new_address,
+ grpc_channel_args** new_args) {
+ return grpc_proxy_mapper_list_map_address(
+ exec_ctx, &g_proxy_mapper_list, address, args, new_address, new_args);
}
diff --git a/src/core/ext/client_channel/proxy_mapper_registry.h b/src/core/ext/client_channel/proxy_mapper_registry.h
index b76af8d4564..742b57a2d49 100644
--- a/src/core/ext/client_channel/proxy_mapper_registry.h
+++ b/src/core/ext/client_channel/proxy_mapper_registry.h
@@ -44,10 +44,16 @@ void grpc_proxy_mapper_registry_shutdown();
/// the list. Otherwise, it will be added to the end.
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper);
-bool grpc_proxy_mappers_map(grpc_exec_ctx* exec_ctx,
- const grpc_resolved_address* address,
- const grpc_channel_args* args,
- grpc_resolved_address** new_address,
- grpc_channel_args** new_args);
+bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
+ const char* server_uri,
+ const grpc_channel_args* args,
+ char** name_to_resolve,
+ grpc_channel_args** new_args);
+
+bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
+ const grpc_resolved_address* address,
+ const grpc_channel_args* args,
+ grpc_resolved_address** new_address,
+ grpc_channel_args** new_args);
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */
diff --git a/src/core/ext/client_channel/subchannel.c b/src/core/ext/client_channel/subchannel.c
index f1e4e079e21..9396937783a 100644
--- a/src/core/ext/client_channel/subchannel.c
+++ b/src/core/ext/client_channel/subchannel.c
@@ -336,8 +336,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
grpc_set_initial_connect_string(&addr, &c->initial_connect_string);
grpc_resolved_address *new_address = NULL;
grpc_channel_args *new_args = NULL;
- if (grpc_proxy_mappers_map(exec_ctx, addr, args->args, &new_address,
- &new_args)) {
+ if (grpc_proxy_mappers_map_address(exec_ctx, addr, args->args, &new_address,
+ &new_args)) {
GPR_ASSERT(new_address != NULL);
gpr_free(addr);
addr = new_address;
From 5f3cfe960f708a397c4465a3064072dd3b2d7bb7 Mon Sep 17 00:00:00 2001
From: Harvey Tuch
Date: Fri, 20 Jan 2017 11:02:11 -0500
Subject: [PATCH 053/167] Fix read from uninitialized memory bug in
GrpcBufferWriter.
This commit fixes an issue in which the following sequence of operations
leads to use of uninitialized memory:
1. Caller invokes GrpcBufferWriter::Next(), and then makes use of 8191
bytes in the returned buffer (which is 8192 bytes in size).
2. Caller then returns the unused single byte via
GrpcBufferWriter::BackUp(). This method invokes
g_core_codegen_interface->grpc_slice_split_tail(), which causes
backup_slice_ to be a grpc_slice with one byte.
3. At the next invocation of GrpcBufferWriter::Next(), a reference to
the single byte grpc_slice is returned to the caller.
The problem here is that the returned reference is to the inlined buffer
in the grpc_slice, which is resident in slice_, not the location of the
buffer inside slice_buffer_ after
g_core_codegen_interface->grpc_slice_buffer_add() in
GrpcBufferWriter::Next(). As a result, any data the caller writes to the
returned void* data is lost.
The solution is to avoid inlined backup slices.
---
CMakeLists.txt | 32 +++
Makefile | 48 ++++
build.yaml | 12 +
include/grpc++/impl/codegen/proto_utils.h | 9 +-
test/cpp/codegen/codegen_test_full.cc | 2 +-
test/cpp/codegen/proto_utils_test.cc | 93 +++++++
.../generated/sources_and_headers.json | 17 ++
tools/run_tests/generated/tests.json | 22 ++
.../proto_utils_test/proto_utils_test.vcxproj | 248 ++++++++++++++++++
.../proto_utils_test.vcxproj.filters | 200 ++++++++++++++
10 files changed, 681 insertions(+), 2 deletions(-)
create mode 100644 test/cpp/codegen/proto_utils_test.cc
create mode 100644 vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj
create mode 100644 vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj.filters
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d52e199842c..c6a57e5f826 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -611,6 +611,7 @@ add_dependencies(buildtests_cxx metrics_client)
add_dependencies(buildtests_cxx mock_test)
add_dependencies(buildtests_cxx noop-benchmark)
add_dependencies(buildtests_cxx proto_server_reflection_test)
+add_dependencies(buildtests_cxx proto_utils_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx qps_interarrival_test)
endif()
@@ -8484,6 +8485,37 @@ target_link_libraries(proto_server_reflection_test
${_gRPC_GFLAGS_LIBRARIES}
)
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
+add_executable(proto_utils_test
+ test/cpp/codegen/proto_utils_test.cc
+ third_party/googletest/src/gtest-all.cc
+)
+
+
+target_include_directories(proto_utils_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE third_party/googletest/include
+ PRIVATE third_party/googletest
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(proto_utils_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc++
+ grpc
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
diff --git a/Makefile b/Makefile
index 0413cc0e009..d6b7a659be3 100644
--- a/Makefile
+++ b/Makefile
@@ -1072,6 +1072,7 @@ metrics_client: $(BINDIR)/$(CONFIG)/metrics_client
mock_test: $(BINDIR)/$(CONFIG)/mock_test
noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark
proto_server_reflection_test: $(BINDIR)/$(CONFIG)/proto_server_reflection_test
+proto_utils_test: $(BINDIR)/$(CONFIG)/proto_utils_test
qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test
qps_json_driver: $(BINDIR)/$(CONFIG)/qps_json_driver
qps_openloop_test: $(BINDIR)/$(CONFIG)/qps_openloop_test
@@ -1469,6 +1470,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \
+ $(BINDIR)/$(CONFIG)/proto_utils_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
@@ -1572,6 +1574,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \
+ $(BINDIR)/$(CONFIG)/proto_utils_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
@@ -1901,6 +1904,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/noop-benchmark || ( echo test noop-benchmark failed ; exit 1 )
$(E) "[RUN] Testing proto_server_reflection_test"
$(Q) $(BINDIR)/$(CONFIG)/proto_server_reflection_test || ( echo test proto_server_reflection_test failed ; exit 1 )
+ $(E) "[RUN] Testing proto_utils_test"
+ $(Q) $(BINDIR)/$(CONFIG)/proto_utils_test || ( echo test proto_utils_test failed ; exit 1 )
$(E) "[RUN] Testing qps_openloop_test"
$(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 )
$(E) "[RUN] Testing round_robin_end2end_test"
@@ -13907,6 +13912,49 @@ endif
endif
+PROTO_UTILS_TEST_SRC = \
+ test/cpp/codegen/proto_utils_test.cc \
+
+PROTO_UTILS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PROTO_UTILS_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/proto_utils_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/proto_utils_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/proto_utils_test: $(PROTOBUF_DEP) $(PROTO_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(PROTO_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/proto_utils_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/cpp/codegen/proto_utils_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a
+
+deps_proto_utils_test: $(PROTO_UTILS_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(PROTO_UTILS_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
QPS_INTERARRIVAL_TEST_SRC = \
test/cpp/qps/qps_interarrival_test.cc \
diff --git a/build.yaml b/build.yaml
index 456db28cef4..cacb5c4790f 100644
--- a/build.yaml
+++ b/build.yaml
@@ -3442,6 +3442,18 @@ targets:
- grpc
- gpr_test_util
- gpr
+- name: proto_utils_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/cpp/codegen/proto_utils_test.cc
+ deps:
+ - grpc++
+ - grpc
+ filegroups:
+ - grpc++_codegen_base
+ - grpc++_codegen_proto
- name: qps_interarrival_test
build: test
run: false
diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h
index 2123b62ed9e..6df9de4fd22 100644
--- a/include/grpc++/impl/codegen/proto_utils.h
+++ b/include/grpc++/impl/codegen/proto_utils.h
@@ -50,6 +50,8 @@ extern CoreCodegenInterface* g_core_codegen_interface;
namespace internal {
+class GrpcBufferWriterPeer;
+
const int kGrpcBufferWriterMaxBufferLength = 8192;
class GrpcBufferWriter final
@@ -91,13 +93,18 @@ class GrpcBufferWriter final
&slice_, GRPC_SLICE_LENGTH(slice_) - count);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
}
- have_backup_ = true;
+ // It's dangerous to keep an inlined grpc_slice as the backup slice, since
+ // on a following Next() call, a reference will be returned to this slice
+ // via GRPC_SLICE_START_PTR, which will not be an adddress held by
+ // slice_buffer_.
+ have_backup_ = backup_slice_.refcount != NULL;
byte_count_ -= count;
}
grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
private:
+ friend class GrpcBufferWriterPeer;
const int block_size_;
int64_t byte_count_;
grpc_slice_buffer* slice_buffer_;
diff --git a/test/cpp/codegen/codegen_test_full.cc b/test/cpp/codegen/codegen_test_full.cc
index d6e2416b550..bc19fc9669d 100644
--- a/test/cpp/codegen/codegen_test_full.cc
+++ b/test/cpp/codegen/codegen_test_full.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2016, Google Inc.
+ * Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc
new file mode 100644
index 00000000000..1daa142b50f
--- /dev/null
+++ b/test/cpp/codegen/proto_utils_test.cc
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2017, 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
+#include
+
+namespace grpc {
+namespace internal {
+
+static GrpcLibraryInitializer g_gli_initializer;
+
+// Provide access to GrpcBufferWriter internals.
+class GrpcBufferWriterPeer {
+ public:
+ explicit GrpcBufferWriterPeer(internal::GrpcBufferWriter* writer)
+ : writer_(writer) {}
+ bool have_backup() const { return writer_->have_backup_; }
+ const grpc_slice& backup_slice() const { return writer_->backup_slice_; }
+ const grpc_slice& slice() const { return writer_->slice_; }
+
+ private:
+ GrpcBufferWriter* writer_;
+};
+
+class ProtoUtilsTest : public ::testing::Test {};
+
+// Regression test for a memory corruption bug where a series of
+// GrpcBufferWriter Next()/Backup() invocations could result in a dangling
+// pointer returned by Next() due to the interaction between grpc_slice inlining
+// and GRPC_SLICE_START_PTR.
+TEST_F(ProtoUtilsTest, BackupNext) {
+ // Ensure the GrpcBufferWriter internals are initialized.
+ g_gli_initializer.summon();
+
+ grpc_byte_buffer* bp;
+ GrpcBufferWriter writer(&bp, 8192);
+ GrpcBufferWriterPeer peer(&writer);
+
+ void* data;
+ int size;
+ // Allocate a slice.
+ ASSERT_TRUE(writer.Next(&data, &size));
+ EXPECT_EQ(8192, size);
+ // Return a single byte. Before the fix that this test acts as a regression
+ // for, this would have resulted in an inlined backup slice.
+ writer.BackUp(1);
+ EXPECT_TRUE(!peer.have_backup());
+ // On the next allocation, the slice is non-inlined.
+ ASSERT_TRUE(writer.Next(&data, &size));
+ EXPECT_TRUE(peer.slice().refcount != NULL);
+
+ // Cleanup.
+ g_core_codegen_interface->grpc_byte_buffer_destroy(bp);
+}
+
+} // namespace internal
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 52d8ae183b4..def360afc85 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -3048,6 +3048,23 @@
"third_party": false,
"type": "target"
},
+ {
+ "deps": [
+ "grpc",
+ "grpc++",
+ "grpc++_codegen_base",
+ "grpc++_codegen_proto"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "proto_utils_test",
+ "src": [
+ "test/cpp/codegen/proto_utils_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
{
"deps": [
"gpr",
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 4cc543962e4..1b636686cd0 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -2975,6 +2975,28 @@
"windows"
]
},
+ {
+ "args": [],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "proto_utils_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ]
+ },
{
"args": [],
"ci_platforms": [
diff --git a/vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj b/vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj
new file mode 100644
index 00000000000..fc2355624f8
--- /dev/null
+++ b/vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj
@@ -0,0 +1,248 @@
+
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {D55F5F6B-BAB1-C421-7138-CDC08C686DCF}
+ true
+ $(SolutionDir)IntDir\$(MSBuildProjectName)\
+
+
+
+ v100
+
+
+ v110
+
+
+ v120
+
+
+ v140
+
+
+ Application
+ true
+ Unicode
+
+
+ Application
+ false
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ proto_utils_test
+ static
+ Debug
+ static
+ Debug
+
+
+ proto_utils_test
+ static
+ Release
+ static
+ Release
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDebug
+ true
+ None
+ false
+
+
+ Console
+ true
+ false
+
+
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDebug
+ true
+ None
+ false
+
+
+ Console
+ true
+ false
+
+
+
+
+
+ NotUsing
+ Level3
+ MaxSpeed
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ true
+ true
+ MultiThreaded
+ true
+ None
+ false
+
+
+ Console
+ true
+ false
+ true
+ true
+
+
+
+
+
+ NotUsing
+ Level3
+ MaxSpeed
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ true
+ true
+ MultiThreaded
+ true
+ None
+ false
+
+
+ Console
+ true
+ false
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {C187A093-A0FE-489D-A40A-6E33DE0F9FEB}
+
+
+ {29D16885-7228-4C31-81ED-5F9187C7F2A9}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
+
+
diff --git a/vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj.filters b/vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj.filters
new file mode 100644
index 00000000000..e6b4a924589
--- /dev/null
+++ b/vsprojects/vcxproj/test/proto_utils_test/proto_utils_test.vcxproj.filters
@@ -0,0 +1,200 @@
+
+
+
+
+ test\cpp\codegen
+
+
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen\security
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+ include\grpc++\impl\codegen
+
+
+
+
+
+ {cc3989e4-cb32-e89b-2d05-41ad6dd1dfdf}
+
+
+ {59dc67c7-fb18-960b-db77-99ea8e6c0a5f}
+
+
+ {6c2c28e0-a57f-8eb7-4897-41ec191373f9}
+
+
+ {6740e44a-b709-0cb2-faa4-c1a792d909c5}
+
+
+ {cbb79e1d-95bc-e475-8e86-af33a7603af1}
+
+
+ {c4a45c0f-ccce-7e26-d0bb-9e54ad676140}
+
+
+ {4aff0d7b-5c9d-080c-faa6-e8126853f149}
+
+
+ {35a120bf-8b2f-77e1-cab7-24259b5ed1db}
+
+
+ {9d60ac43-ff38-4dfc-8c33-9167fb47fa90}
+
+
+ {7845357d-2b4b-6f25-c68b-79be9ab587fb}
+
+
+ {22e8c70f-796c-f2c0-d87d-e4ef419609a1}
+
+
+
+
From f2fe4f7dbd00a285f265167bb8fec5c48fd7345b Mon Sep 17 00:00:00 2001
From: yang-g
Date: Tue, 7 Feb 2017 12:47:22 -0800
Subject: [PATCH 054/167] Add a PreServerStart in global server callbacks
---
include/grpc++/server.h | 2 ++
src/cpp/server/server_cc.cc | 1 +
2 files changed, 3 insertions(+)
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index fba9952e6e7..002f252a8f5 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -88,6 +88,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
virtual void PreSynchronousRequest(ServerContext* context) = 0;
/// Called after application callback for each synchronous server request
virtual void PostSynchronousRequest(ServerContext* context) = 0;
+ /// Called before server is started.
+ virtual void PreServerStart(Server* server) {}
};
/// Set the global callback object. Can only be called once. Does not take
/// ownership of callbacks, and expects the pointed to object to be alive
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index f6a7f1d755b..29898a4209e 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -478,6 +478,7 @@ int Server::AddListeningPort(const grpc::string& addr,
bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
GPR_ASSERT(!started_);
+ global_callbacks_->PreServerStart(this);
started_ = true;
grpc_server_start(server_);
From 8c58a489a2cf8f81299d97a082995cb77eb0bc52 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Tue, 7 Feb 2017 14:52:59 -0800
Subject: [PATCH 055/167] Save allocating a grpc_error if there is no error
---
src/core/lib/surface/call.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 70bab4c0796..7f1410a0856 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -897,7 +897,7 @@ static void recv_common_filter(grpc_exec_ctx *exec_ctx, grpc_call *call,
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, msg);
gpr_free(msg);
grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message);
- } else {
+ } else if (error != GRPC_ERROR_NONE) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "");
}
From e128e837f0f55c93334a97517e99a03cc2699da2 Mon Sep 17 00:00:00 2001
From: ncteisen
Date: Tue, 7 Feb 2017 16:22:14 -0800
Subject: [PATCH 056/167] clang fmt
---
src/core/ext/transport/chttp2/transport/frame_rst_stream.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
index 2e93ae2b857..cb017e75f04 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
@@ -110,11 +110,10 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
grpc_error *error = GRPC_ERROR_NONE;
if (reason != GRPC_HTTP2_NO_ERROR || s->header_frames_received < 2) {
char *message;
- gpr_asprintf(&message, "Received RST_STREAM with error code %d",
- reason);
+ gpr_asprintf(&message, "Received RST_STREAM with error code %d", reason);
error = grpc_error_set_int(
- grpc_error_set_str(GRPC_ERROR_CREATE("RST_STREAM"),
- GRPC_ERROR_STR_GRPC_MESSAGE, message),
+ grpc_error_set_str(GRPC_ERROR_CREATE("RST_STREAM"),
+ GRPC_ERROR_STR_GRPC_MESSAGE, message),
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
gpr_free(message);
}
From 3a5bba0a2034a2dffbfeb7a30281f8ac43d5ce59 Mon Sep 17 00:00:00 2001
From: Paul Marks
Date: Tue, 7 Feb 2017 16:28:09 -0800
Subject: [PATCH 057/167] Connect to "localhost" from interop clients.
This is for compatibility with IPv6-only environments; see the Google
bug b/32531998.
Note that InteropClient.cs and http2_client.cc don't appear to be tested
by our internal branch, but I've included them for consistency.
---
src/csharp/Grpc.IntegrationTesting/InteropClient.cs | 2 +-
src/python/grpcio_tests/tests/interop/client.py | 2 +-
test/cpp/interop/client.cc | 2 +-
test/cpp/interop/http2_client.cc | 2 +-
test/cpp/interop/reconnect_interop_client.cc | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
index 5ba83b143ed..68a8f4879b4 100644
--- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
+++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
@@ -56,7 +56,7 @@ namespace Grpc.IntegrationTesting
{
private class ClientOptions
{
- [Option("server_host", Default = "127.0.0.1")]
+ [Option("server_host", Default = "localhost")]
public string ServerHost { get; set; }
[Option("server_host_override", Default = TestCredentials.DefaultHostOverride)]
diff --git a/src/python/grpcio_tests/tests/interop/client.py b/src/python/grpcio_tests/tests/interop/client.py
index 833818e6625..97f6843d3cb 100644
--- a/src/python/grpcio_tests/tests/interop/client.py
+++ b/src/python/grpcio_tests/tests/interop/client.py
@@ -45,7 +45,7 @@ def _args():
'--server_host',
help='the host to which to connect',
type=str,
- default="127.0.0.1")
+ default="localhost")
parser.add_argument(
'--server_port', help='the port to which to connect', type=int)
parser.add_argument(
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 8a00b61cef1..5688ab79716 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -51,7 +51,7 @@ DEFINE_bool(use_tls, false, "Whether to use tls.");
DEFINE_string(custom_credentials_type, "", "User provided credentials type.");
DEFINE_bool(use_test_ca, false, "False to use SSL roots for google");
DEFINE_int32(server_port, 0, "Server port.");
-DEFINE_string(server_host, "127.0.0.1", "Server host to connect to");
+DEFINE_string(server_host, "localhost", "Server host to connect to");
DEFINE_string(server_host_override, "foo.test.google.fr",
"Override the server host which is sent in HTTP header");
DEFINE_string(
diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc
index 38aee43b26a..b96e9fac36e 100644
--- a/test/cpp/interop/http2_client.cc
+++ b/test/cpp/interop/http2_client.cc
@@ -223,7 +223,7 @@ bool Http2Client::DoMaxStreams() {
} // namespace grpc
DEFINE_int32(server_port, 0, "Server port.");
-DEFINE_string(server_host, "127.0.0.1", "Server host to connect to");
+DEFINE_string(server_host, "localhost", "Server host to connect to");
DEFINE_string(test_case, "rst_after_header",
"Configure different test cases. Valid options are:\n\n"
"goaway\n"
diff --git a/test/cpp/interop/reconnect_interop_client.cc b/test/cpp/interop/reconnect_interop_client.cc
index 797e52c744f..1c2f6066377 100644
--- a/test/cpp/interop/reconnect_interop_client.cc
+++ b/test/cpp/interop/reconnect_interop_client.cc
@@ -48,7 +48,7 @@
DEFINE_int32(server_control_port, 0, "Server port for control rpcs.");
DEFINE_int32(server_retry_port, 0, "Server port for testing reconnection.");
-DEFINE_string(server_host, "127.0.0.1", "Server host to connect to");
+DEFINE_string(server_host, "localhost", "Server host to connect to");
DEFINE_int32(max_reconnect_backoff_ms, 0,
"Maximum backoff time, or 0 for default.");
From 012915045fca08c365add95a8e29eb40021ecd64 Mon Sep 17 00:00:00 2001
From: David Garcia Quintas
Date: Tue, 7 Feb 2017 13:26:41 -0800
Subject: [PATCH 058/167] Secure naming support for gRPCLB
---
BUILD | 62 +++++--
CMakeLists.txt | 4 +
Makefile | 6 +
binding.gyp | 2 +
build.yaml | 22 ++-
config.m4 | 2 +
gRPC-Core.podspec | 6 +
grpc.gemspec | 4 +
package.xml | 4 +
src/core/ext/client_channel/subchannel.c | 16 +-
src/core/ext/client_channel/subchannel.h | 3 +
src/core/ext/lb_policy/grpclb/grpclb.c | 171 +++++++++++-------
.../ext/lb_policy/grpclb/grpclb_channel.c | 77 ++++++++
.../ext/lb_policy/grpclb/grpclb_channel.h | 56 ++++++
.../lb_policy/grpclb/grpclb_channel_secure.c | 107 +++++++++++
.../ext/lb_policy/round_robin/round_robin.c | 7 +
.../client/secure/secure_channel_create.c | 171 +++++++++++++-----
src/core/lib/iomgr/sockaddr_utils.c | 38 ++--
src/core/lib/iomgr/sockaddr_utils.h | 4 +
.../lib/security/credentials/credentials.c | 47 +++++
.../lib/security/credentials/credentials.h | 13 ++
.../credentials/fake/fake_credentials.c | 8 +-
.../credentials/fake/fake_credentials.h | 15 ++
.../security/transport/client_auth_filter.c | 2 +-
.../lib/security/transport/lb_targets_info.c | 70 +++++++
.../lib/security/transport/lb_targets_info.h | 47 +++++
.../security/transport/security_connector.c | 141 +++++++++++++--
.../security/transport/security_connector.h | 7 +-
.../security/transport/security_handshaker.c | 4 +-
src/core/lib/surface/init_secure.c | 2 +-
src/python/grpcio/grpc_core_dependencies.py | 2 +
test/core/end2end/fake_resolver.c | 29 ++-
.../core/surface/secure_channel_create_test.c | 2 +-
test/cpp/grpclb/grpclb_test.cc | 89 ++++++---
tools/doxygen/Doxyfile.core.internal | 4 +
.../generated/sources_and_headers.json | 37 +++-
vsprojects/vcxproj/grpc/grpc.vcxproj | 6 +
vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 12 ++
.../grpc_unsecure/grpc_unsecure.vcxproj | 3 +
.../grpc_unsecure.vcxproj.filters | 6 +
40 files changed, 1098 insertions(+), 210 deletions(-)
create mode 100644 src/core/ext/lb_policy/grpclb/grpclb_channel.c
create mode 100644 src/core/ext/lb_policy/grpclb/grpclb_channel.h
create mode 100644 src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
create mode 100644 src/core/lib/security/transport/lb_targets_info.c
create mode 100644 src/core/lib/security/transport/lb_targets_info.h
diff --git a/BUILD b/BUILD
index 58971ff8e35..c56d9c9746f 100644
--- a/BUILD
+++ b/BUILD
@@ -63,7 +63,7 @@ grpc_cc_library(
deps = [
"census",
"grpc_base",
- "grpc_lb_policy_grpclb",
+ "grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_pick_first",
"grpc_lb_policy_round_robin",
"grpc_load_reporting",
@@ -624,9 +624,9 @@ grpc_cc_library(
"src/core/lib/surface/completion_queue.h",
"src/core/lib/surface/event_string.h",
"src/core/lib/surface/init.h",
- "src/core/lib/surface/validate_metadata.h",
"src/core/lib/surface/lame_client.h",
"src/core/lib/surface/server.h",
+ "src/core/lib/surface/validate_metadata.h",
"src/core/lib/transport/byte_stream.h",
"src/core/lib/transport/connectivity_state.h",
"src/core/lib/transport/error_utils.h",
@@ -665,7 +665,6 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_client_channel",
- language = "c",
srcs = [
"src/core/ext/client_channel/channel_connectivity.c",
"src/core/ext/client_channel/client_channel.c",
@@ -709,6 +708,7 @@ grpc_cc_library(
"src/core/ext/client_channel/subchannel_index.h",
"src/core/ext/client_channel/uri_parser.h",
],
+ language = "c",
deps = [
"grpc_base",
],
@@ -735,11 +735,37 @@ grpc_cc_library(
name = "grpc_lb_policy_grpclb",
srcs = [
"src/core/ext/lb_policy/grpclb/grpclb.c",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.c",
+ "src/core/ext/lb_policy/grpclb/load_balancer_api.c",
+ "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
+ ],
+ hdrs = [
+ "src/core/ext/lb_policy/grpclb/grpclb.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.h",
+ "src/core/ext/lb_policy/grpclb/load_balancer_api.h",
+ "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
+ ],
+ external_deps = [
+ "nanopb",
+ ],
+ language = "c",
+ deps = [
+ "grpc_base",
+ "grpc_client_channel",
+ ],
+)
+
+grpc_cc_library(
+ name = "grpc_lb_policy_grpclb_secure",
+ srcs = [
+ "src/core/ext/lb_policy/grpclb/grpclb.c",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
],
hdrs = [
"src/core/ext/lb_policy/grpclb/grpclb.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
],
@@ -750,6 +776,7 @@ grpc_cc_library(
deps = [
"grpc_base",
"grpc_client_channel",
+ "grpc_secure",
],
)
@@ -837,6 +864,7 @@ grpc_cc_library(
"src/core/lib/security/credentials/ssl/ssl_credentials.c",
"src/core/lib/security/transport/client_auth_filter.c",
"src/core/lib/security/transport/secure_endpoint.c",
+ "src/core/lib/security/transport/lb_targets_info.c",
"src/core/lib/security/transport/security_connector.c",
"src/core/lib/security/transport/security_handshaker.c",
"src/core/lib/security/transport/server_auth_filter.c",
@@ -860,6 +888,7 @@ grpc_cc_library(
"src/core/lib/security/credentials/ssl/ssl_credentials.h",
"src/core/lib/security/transport/auth_filters.h",
"src/core/lib/security/transport/secure_endpoint.h",
+ "src/core/lib/security/transport/lb_targets_info.h",
"src/core/lib/security/transport/security_connector.h",
"src/core/lib/security/transport/security_handshaker.h",
"src/core/lib/security/transport/tsi_error.h",
@@ -943,22 +972,21 @@ grpc_cc_library(
)
grpc_cc_library(
- name = "grpc_transport_chttp2_client_connector",
- hdrs = [
- "src/core/ext/transport/chttp2/client/chttp2_connector.h",
- ],
- srcs = [
- "src/core/ext/transport/chttp2/client/chttp2_connector.c",
- ],
- language = "c",
- deps = [
- "grpc_transport_chttp2",
- "grpc_base",
- "grpc_client_channel",
- ],
+ name = "grpc_transport_chttp2_client_connector",
+ srcs = [
+ "src/core/ext/transport/chttp2/client/chttp2_connector.c",
+ ],
+ hdrs = [
+ "src/core/ext/transport/chttp2/client/chttp2_connector.h",
+ ],
+ language = "c",
+ deps = [
+ "grpc_base",
+ "grpc_client_channel",
+ "grpc_transport_chttp2",
+ ],
)
-
grpc_cc_library(
name = "grpc_transport_chttp2_client_insecure",
srcs = [
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c6a57e5f826..cf9908b0606 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -953,6 +953,7 @@ add_library(grpc
src/core/lib/security/credentials/plugin/plugin_credentials.c
src/core/lib/security/credentials/ssl/ssl_credentials.c
src/core/lib/security/transport/client_auth_filter.c
+ src/core/lib/security/transport/lb_targets_info.c
src/core/lib/security/transport/secure_endpoint.c
src/core/lib/security/transport/security_connector.c
src/core/lib/security/transport/security_handshaker.c
@@ -993,6 +994,7 @@ add_library(grpc
src/core/ext/transport/chttp2/client/insecure/channel_create.c
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
src/core/ext/lb_policy/grpclb/grpclb.c
+ src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
src/core/ext/lb_policy/grpclb/load_balancer_api.c
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
third_party/nanopb/pb_common.c
@@ -1272,6 +1274,7 @@ add_library(grpc_cronet
src/core/lib/security/credentials/plugin/plugin_credentials.c
src/core/lib/security/credentials/ssl/ssl_credentials.c
src/core/lib/security/transport/client_auth_filter.c
+ src/core/lib/security/transport/lb_targets_info.c
src/core/lib/security/transport/secure_endpoint.c
src/core/lib/security/transport/security_connector.c
src/core/lib/security/transport/security_handshaker.c
@@ -1773,6 +1776,7 @@ add_library(grpc_unsecure
src/core/ext/load_reporting/load_reporting.c
src/core/ext/load_reporting/load_reporting_filter.c
src/core/ext/lb_policy/grpclb/grpclb.c
+ src/core/ext/lb_policy/grpclb/grpclb_channel.c
src/core/ext/lb_policy/grpclb/load_balancer_api.c
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
third_party/nanopb/pb_common.c
diff --git a/Makefile b/Makefile
index d6b7a659be3..d0602def847 100644
--- a/Makefile
+++ b/Makefile
@@ -2794,6 +2794,7 @@ LIBGRPC_SRC = \
src/core/lib/security/credentials/plugin/plugin_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/transport/client_auth_filter.c \
+ src/core/lib/security/transport/lb_targets_info.c \
src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/security_connector.c \
src/core/lib/security/transport/security_handshaker.c \
@@ -2834,6 +2835,7 @@ LIBGRPC_SRC = \
src/core/ext/transport/chttp2/client/insecure/channel_create.c \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
src/core/ext/lb_policy/grpclb/grpclb.c \
+ src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
@@ -3127,6 +3129,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/security/credentials/plugin/plugin_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/transport/client_auth_filter.c \
+ src/core/lib/security/transport/lb_targets_info.c \
src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/security_connector.c \
src/core/lib/security/transport/security_handshaker.c \
@@ -3644,6 +3647,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/load_reporting/load_reporting.c \
src/core/ext/load_reporting/load_reporting_filter.c \
src/core/ext/lb_policy/grpclb/grpclb.c \
+ src/core/ext/lb_policy/grpclb/grpclb_channel.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
@@ -17705,6 +17709,7 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first.
+src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c: $(OPENSSL_DEP)
src/core/ext/transport/chttp2/client/secure/secure_channel_create.c: $(OPENSSL_DEP)
src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c: $(OPENSSL_DEP)
src/core/ext/transport/cronet/client/secure/cronet_channel_create.c: $(OPENSSL_DEP)
@@ -17726,6 +17731,7 @@ src/core/lib/security/credentials/oauth2/oauth2_credentials.c: $(OPENSSL_DEP)
src/core/lib/security/credentials/plugin/plugin_credentials.c: $(OPENSSL_DEP)
src/core/lib/security/credentials/ssl/ssl_credentials.c: $(OPENSSL_DEP)
src/core/lib/security/transport/client_auth_filter.c: $(OPENSSL_DEP)
+src/core/lib/security/transport/lb_targets_info.c: $(OPENSSL_DEP)
src/core/lib/security/transport/secure_endpoint.c: $(OPENSSL_DEP)
src/core/lib/security/transport/security_connector.c: $(OPENSSL_DEP)
src/core/lib/security/transport/security_handshaker.c: $(OPENSSL_DEP)
diff --git a/binding.gyp b/binding.gyp
index 1815a5a4760..8ff3d8c1a34 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -758,6 +758,7 @@
'src/core/lib/security/credentials/plugin/plugin_credentials.c',
'src/core/lib/security/credentials/ssl/ssl_credentials.c',
'src/core/lib/security/transport/client_auth_filter.c',
+ 'src/core/lib/security/transport/lb_targets_info.c',
'src/core/lib/security/transport/secure_endpoint.c',
'src/core/lib/security/transport/security_connector.c',
'src/core/lib/security/transport/security_handshaker.c',
@@ -798,6 +799,7 @@
'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/lb_policy/grpclb/grpclb.c',
+ 'src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
diff --git a/build.yaml b/build.yaml
index cacb5c4790f..7fec296ad3d 100644
--- a/build.yaml
+++ b/build.yaml
@@ -452,10 +452,28 @@ filegroups:
- name: grpc_lb_policy_grpclb
headers:
- src/core/ext/lb_policy/grpclb/grpclb.h
+ - src/core/ext/lb_policy/grpclb/grpclb_channel.h
- src/core/ext/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src:
- src/core/ext/lb_policy/grpclb/grpclb.c
+ - src/core/ext/lb_policy/grpclb/grpclb_channel.c
+ - src/core/ext/lb_policy/grpclb/load_balancer_api.c
+ - src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
+ plugin: grpc_lb_policy_grpclb
+ uses:
+ - grpc_base
+ - grpc_client_channel
+ - nanopb
+- name: grpc_lb_policy_grpclb_secure
+ headers:
+ - src/core/ext/lb_policy/grpclb/grpclb.h
+ - src/core/ext/lb_policy/grpclb/grpclb_channel.h
+ - src/core/ext/lb_policy/grpclb/load_balancer_api.h
+ - src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
+ src:
+ - src/core/ext/lb_policy/grpclb/grpclb.c
+ - src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
- src/core/ext/lb_policy/grpclb/load_balancer_api.c
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb
@@ -518,6 +536,7 @@ filegroups:
- src/core/lib/security/credentials/plugin/plugin_credentials.h
- src/core/lib/security/credentials/ssl/ssl_credentials.h
- src/core/lib/security/transport/auth_filters.h
+ - src/core/lib/security/transport/lb_targets_info.h
- src/core/lib/security/transport/secure_endpoint.h
- src/core/lib/security/transport/security_connector.h
- src/core/lib/security/transport/security_handshaker.h
@@ -541,6 +560,7 @@ filegroups:
- src/core/lib/security/credentials/plugin/plugin_credentials.c
- src/core/lib/security/credentials/ssl/ssl_credentials.c
- src/core/lib/security/transport/client_auth_filter.c
+ - src/core/lib/security/transport/lb_targets_info.c
- src/core/lib/security/transport/secure_endpoint.c
- src/core/lib/security/transport/security_connector.c
- src/core/lib/security/transport/security_handshaker.c
@@ -909,7 +929,7 @@ libs:
- grpc_transport_chttp2_client_secure
- grpc_transport_chttp2_server_insecure
- grpc_transport_chttp2_client_insecure
- - grpc_lb_policy_grpclb
+ - grpc_lb_policy_grpclb_secure
- grpc_lb_policy_pick_first
- grpc_lb_policy_round_robin
- grpc_resolver_dns_native
diff --git a/config.m4 b/config.m4
index 2c6c89f3eeb..90536e503ed 100644
--- a/config.m4
+++ b/config.m4
@@ -237,6 +237,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/security/credentials/plugin/plugin_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/transport/client_auth_filter.c \
+ src/core/lib/security/transport/lb_targets_info.c \
src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/security_connector.c \
src/core/lib/security/transport/security_handshaker.c \
@@ -277,6 +278,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/transport/chttp2/client/insecure/channel_create.c \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
src/core/ext/lb_policy/grpclb/grpclb.c \
+ src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 7632174f31c..77743f69bdc 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -388,6 +388,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/credentials/plugin/plugin_credentials.h',
'src/core/lib/security/credentials/ssl/ssl_credentials.h',
'src/core/lib/security/transport/auth_filters.h',
+ 'src/core/lib/security/transport/lb_targets_info.h',
'src/core/lib/security/transport/secure_endpoint.h',
'src/core/lib/security/transport/security_connector.h',
'src/core/lib/security/transport/security_handshaker.h',
@@ -420,6 +421,7 @@ Pod::Spec.new do |s|
'src/core/ext/client_channel/uri_parser.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/lb_policy/grpclb/grpclb.h',
+ 'src/core/ext/lb_policy/grpclb/grpclb_channel.h',
'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'third_party/nanopb/pb.h',
@@ -596,6 +598,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/credentials/plugin/plugin_credentials.c',
'src/core/lib/security/credentials/ssl/ssl_credentials.c',
'src/core/lib/security/transport/client_auth_filter.c',
+ 'src/core/lib/security/transport/lb_targets_info.c',
'src/core/lib/security/transport/secure_endpoint.c',
'src/core/lib/security/transport/security_connector.c',
'src/core/lib/security/transport/security_handshaker.c',
@@ -636,6 +639,7 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/lb_policy/grpclb/grpclb.c',
+ 'src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
@@ -813,6 +817,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/credentials/plugin/plugin_credentials.h',
'src/core/lib/security/credentials/ssl/ssl_credentials.h',
'src/core/lib/security/transport/auth_filters.h',
+ 'src/core/lib/security/transport/lb_targets_info.h',
'src/core/lib/security/transport/secure_endpoint.h',
'src/core/lib/security/transport/security_connector.h',
'src/core/lib/security/transport/security_handshaker.h',
@@ -845,6 +850,7 @@ Pod::Spec.new do |s|
'src/core/ext/client_channel/uri_parser.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/lb_policy/grpclb/grpclb.h',
+ 'src/core/ext/lb_policy/grpclb/grpclb_channel.h',
'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'third_party/nanopb/pb.h',
diff --git a/grpc.gemspec b/grpc.gemspec
index 7b132686c8f..6e7e1174da4 100755
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -305,6 +305,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.h )
s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.h )
s.files += %w( src/core/lib/security/transport/auth_filters.h )
+ s.files += %w( src/core/lib/security/transport/lb_targets_info.h )
s.files += %w( src/core/lib/security/transport/secure_endpoint.h )
s.files += %w( src/core/lib/security/transport/security_connector.h )
s.files += %w( src/core/lib/security/transport/security_handshaker.h )
@@ -337,6 +338,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/client_channel/uri_parser.h )
s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h )
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.h )
+ s.files += %w( src/core/ext/lb_policy/grpclb/grpclb_channel.h )
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.h )
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h )
s.files += %w( third_party/nanopb/pb.h )
@@ -513,6 +515,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.c )
s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.c )
s.files += %w( src/core/lib/security/transport/client_auth_filter.c )
+ s.files += %w( src/core/lib/security/transport/lb_targets_info.c )
s.files += %w( src/core/lib/security/transport/secure_endpoint.c )
s.files += %w( src/core/lib/security/transport/security_connector.c )
s.files += %w( src/core/lib/security/transport/security_handshaker.c )
@@ -553,6 +556,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c )
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c )
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.c )
+ s.files += %w( src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c )
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.c )
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c )
s.files += %w( third_party/nanopb/pb_common.c )
diff --git a/package.xml b/package.xml
index e4c0e83cc71..7aa894a1781 100644
--- a/package.xml
+++ b/package.xml
@@ -314,6 +314,7 @@
+
@@ -346,6 +347,7 @@
+
@@ -522,6 +524,7 @@
+
@@ -562,6 +565,7 @@
+
diff --git a/src/core/ext/client_channel/subchannel.c b/src/core/ext/client_channel/subchannel.c
index f1e4e079e21..abbbfdfd644 100644
--- a/src/core/ext/client_channel/subchannel.c
+++ b/src/core/ext/client_channel/subchannel.c
@@ -788,7 +788,8 @@ grpc_call_stack *grpc_subchannel_call_get_call_stack(
return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call);
}
-static void grpc_uri_to_sockaddr(char *uri_str, grpc_resolved_address *addr) {
+static void grpc_uri_to_sockaddr(const char *uri_str,
+ grpc_resolved_address *addr) {
grpc_uri *uri = grpc_uri_parse(uri_str, 0 /* suppress_errors */);
GPR_ASSERT(uri != NULL);
if (strcmp(uri->scheme, "ipv4") == 0) {
@@ -803,14 +804,19 @@ static void grpc_uri_to_sockaddr(char *uri_str, grpc_resolved_address *addr) {
void grpc_get_subchannel_address_arg(const grpc_channel_args *args,
grpc_resolved_address *addr) {
+ const char *addr_uri_str = grpc_get_subchannel_address_uri_arg(args);
+ memset(addr, 0, sizeof(*addr));
+ if (*addr_uri_str != '\0') {
+ grpc_uri_to_sockaddr(addr_uri_str, addr);
+ }
+}
+
+const char *grpc_get_subchannel_address_uri_arg(const grpc_channel_args *args) {
const grpc_arg *addr_arg =
grpc_channel_args_find(args, GRPC_ARG_SUBCHANNEL_ADDRESS);
GPR_ASSERT(addr_arg != NULL); // Should have been set by LB policy.
GPR_ASSERT(addr_arg->type == GRPC_ARG_STRING);
- memset(addr, 0, sizeof(*addr));
- if (*addr_arg->value.string != '\0') {
- grpc_uri_to_sockaddr(addr_arg->value.string, addr);
- }
+ return addr_arg->value.string;
}
grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr) {
diff --git a/src/core/ext/client_channel/subchannel.h b/src/core/ext/client_channel/subchannel.h
index 9bd35a77049..26ce9544871 100644
--- a/src/core/ext/client_channel/subchannel.h
+++ b/src/core/ext/client_channel/subchannel.h
@@ -178,6 +178,9 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
void grpc_get_subchannel_address_arg(const grpc_channel_args *args,
grpc_resolved_address *addr);
+/// Returns the URI string for the address to connect to.
+const char *grpc_get_subchannel_address_uri_arg(const grpc_channel_args *args);
+
/// Returns a new channel arg encoding the subchannel address as a string.
/// Caller is responsible for freeing the string.
grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr);
diff --git a/src/core/ext/lb_policy/grpclb/grpclb.c b/src/core/ext/lb_policy/grpclb/grpclb.c
index 308facb7e7a..ab62e5ed6a1 100644
--- a/src/core/ext/lb_policy/grpclb/grpclb.c
+++ b/src/core/ext/lb_policy/grpclb/grpclb.c
@@ -112,11 +112,13 @@
#include "src/core/ext/client_channel/lb_policy_registry.h"
#include "src/core/ext/client_channel/parse_address.h"
#include "src/core/ext/lb_policy/grpclb/grpclb.h"
+#include "src/core/ext/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/ext/lb_policy/grpclb/load_balancer_api.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/slice/slice_hash_table.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/backoff.h"
@@ -751,6 +753,96 @@ static void glb_rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_ERROR_UNREF(error);
}
+static void destroy_balancer_name(grpc_exec_ctx *exec_ctx,
+ void *balancer_name) {
+ gpr_free(balancer_name);
+}
+
+static void *copy_balancer_name(void *balancer_name) {
+ return gpr_strdup(balancer_name);
+}
+
+static grpc_slice_hash_table_entry targets_info_entry_create(
+ const char *address, const char *balancer_name) {
+ static const grpc_slice_hash_table_vtable vtable = {destroy_balancer_name,
+ copy_balancer_name};
+ grpc_slice_hash_table_entry entry;
+ entry.key = grpc_slice_from_copied_string(address);
+ entry.value = (void *)balancer_name;
+ entry.vtable = &vtable;
+ return entry;
+}
+
+/* Returns the target URI for the LB service whose addresses are in \a
+ * addresses. Using this URI, a bidirectional streaming channel will be created
+ * for the reception of load balancing updates.
+ *
+ * The output argument \a targets_info will be updated to contain a mapping of
+ * "LB server address" to "balancer name", as reported by the naming system.
+ * This mapping will be propagated via the channel arguments of the
+ * aforementioned LB streaming channel, to be used by the security connector for
+ * secure naming checks. The user is responsible for freeing \a targets_info. */
+static char *get_lb_uri_target_addresses(grpc_exec_ctx *exec_ctx,
+ const grpc_lb_addresses *addresses,
+ grpc_slice_hash_table **targets_info) {
+ size_t num_grpclb_addrs = 0;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
+ }
+ /* All input addresses come from a resolver that claims they are LB services.
+ * It's the resolver's responsibility to make sure this policy is only
+ * instantiated and used in that case. Otherwise, something has gone wrong. */
+ GPR_ASSERT(num_grpclb_addrs > 0);
+
+ grpc_slice_hash_table_entry *targets_info_entries =
+ gpr_malloc(sizeof(*targets_info_entries) * num_grpclb_addrs);
+
+ /* construct a target ipvX://ip1:port1,ip2:port2,... from the addresses in \a
+ * addresses */
+ /* TODO(dgq): support mixed ip version */
+ char **addr_strs = gpr_malloc(sizeof(char *) * num_grpclb_addrs);
+ size_t addr_index = 0;
+
+ for (size_t i = 0; i < addresses->num_addresses; i++) {
+ if (addresses->addresses[i].user_data != NULL) {
+ gpr_log(GPR_ERROR,
+ "This LB policy doesn't support user data. It will be ignored");
+ }
+ if (addresses->addresses[i].is_balancer) {
+ char *addr_str;
+ GPR_ASSERT(grpc_sockaddr_to_string(
+ &addr_str, &addresses->addresses[i].address, true) > 0);
+ targets_info_entries[addr_index] = targets_info_entry_create(
+ addr_str, addresses->addresses[i].balancer_name);
+ addr_strs[addr_index++] = addr_str;
+ }
+ }
+ GPR_ASSERT(addr_index == num_grpclb_addrs);
+
+ size_t uri_path_len;
+ char *uri_path = gpr_strjoin_sep((const char **)addr_strs, num_grpclb_addrs,
+ ",", &uri_path_len);
+ for (size_t i = 0; i < num_grpclb_addrs; i++) gpr_free(addr_strs[i]);
+ gpr_free(addr_strs);
+
+ char *target_uri_str = NULL;
+ /* TODO(dgq): Don't assume all addresses will share the scheme of the first
+ * one */
+ gpr_asprintf(&target_uri_str, "%s:%s",
+ grpc_sockaddr_get_uri_scheme(&addresses->addresses[0].address),
+ uri_path);
+ gpr_free(uri_path);
+
+ *targets_info =
+ grpc_slice_hash_table_create(num_grpclb_addrs, targets_info_entries);
+ for (size_t i = 0; i < num_grpclb_addrs; i++) {
+ grpc_slice_unref_internal(exec_ctx, targets_info_entries[i].key);
+ }
+ gpr_free(targets_info_entries);
+
+ return target_uri_str;
+}
+
static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
grpc_lb_policy_factory *factory,
grpc_lb_policy_args *args) {
@@ -788,85 +880,30 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
}
grpc_uri_destroy(uri);
- /* All input addresses in addresses come from a resolver that claims
- * they are LB services. It's the resolver's responsibility to make sure
- * this policy is only instantiated and used in that case.
- *
- * Create a client channel over them to communicate with a LB service */
glb_policy->cc_factory = args->client_channel_factory;
glb_policy->args = grpc_channel_args_copy(args->args);
GPR_ASSERT(glb_policy->cc_factory != NULL);
- /* construct a target from the addresses in args, given in the form
- * ipvX://ip1:port1,ip2:port2,...
- * TODO(dgq): support mixed ip version */
- char **addr_strs = gpr_malloc(sizeof(char *) * num_grpclb_addrs);
- size_t addr_index = 0;
- for (size_t i = 0; i < addresses->num_addresses; i++) {
- if (addresses->addresses[i].user_data != NULL) {
- gpr_log(GPR_ERROR,
- "This LB policy doesn't support user data. It will be ignored");
- }
- if (addresses->addresses[i].is_balancer) {
- if (addr_index == 0) {
- addr_strs[addr_index++] =
- grpc_sockaddr_to_uri(&addresses->addresses[i].address);
- } else {
- GPR_ASSERT(grpc_sockaddr_to_string(&addr_strs[addr_index++],
- &addresses->addresses[i].address,
- true) > 0);
- }
- }
- }
- size_t uri_path_len;
- char *target_uri_str = gpr_strjoin_sep((const char **)addr_strs,
- num_grpclb_addrs, ",", &uri_path_len);
-
- /* Create a channel to talk to the LBs.
- *
- * We strip out the channel arg for the LB policy name, since we want
- * to use the default (pick_first) in this case.
- *
- * We also strip out the channel arg for the resolved addresses, since
- * that will be generated by the name resolver used in the LB channel.
- * Note that the LB channel will use the sockaddr resolver, so this
- * won't actually generate a query to DNS (or some other name service).
- * However, the addresses returned by the sockaddr resolver will have
- * is_balancer=false, whereas our own addresses have is_balancer=true.
- * We need the LB channel to return addresses with is_balancer=false
- * so that it does not wind up recursively using the grpclb LB policy,
- * as per the special case logic in client_channel.c.
- *
- * Finally, we also strip out the channel arg for the server URI,
- * since that will be different for the LB channel than for the parent
- * channel. (The client channel factory will re-add this arg with
- * the right value.)
- */
- static const char *keys_to_remove[] = {
- GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI};
- grpc_channel_args *new_args = grpc_channel_args_copy_and_remove(
- args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove));
- glb_policy->lb_channel = grpc_client_channel_factory_create_channel(
- exec_ctx, glb_policy->cc_factory, target_uri_str,
- GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
- grpc_channel_args_destroy(exec_ctx, new_args);
-
- gpr_free(target_uri_str);
- for (size_t i = 0; i < num_grpclb_addrs; i++) {
- gpr_free(addr_strs[i]);
- }
- gpr_free(addr_strs);
-
+ grpc_slice_hash_table *targets_info = NULL;
+ /* Create a client channel over them to communicate with a LB service */
+ char *lb_service_target_addresses =
+ get_lb_uri_target_addresses(exec_ctx, addresses, &targets_info);
+ grpc_channel_args *lb_channel_args =
+ get_lb_channel_args(exec_ctx, targets_info, args->args);
+ glb_policy->lb_channel = grpc_lb_policy_grpclb_create_lb_channel(
+ exec_ctx, lb_service_target_addresses, args->client_channel_factory,
+ lb_channel_args);
+ grpc_slice_hash_table_unref(exec_ctx, targets_info);
+ grpc_channel_args_destroy(exec_ctx, lb_channel_args);
+ gpr_free(lb_service_target_addresses);
if (glb_policy->lb_channel == NULL) {
gpr_free(glb_policy);
return NULL;
}
-
grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable);
gpr_mu_init(&glb_policy->mu);
grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE,
"grpclb");
-
return &glb_policy->base;
}
diff --git a/src/core/ext/lb_policy/grpclb/grpclb_channel.c b/src/core/ext/lb_policy/grpclb/grpclb_channel.c
new file mode 100644
index 00000000000..1b8bbab1b69
--- /dev/null
+++ b/src/core/ext/lb_policy/grpclb/grpclb_channel.c
@@ -0,0 +1,77 @@
+/*
+ *
+ * Copyright 2017, 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
+
+#include "src/core/ext/client_channel/client_channel.h"
+#include "src/core/ext/lb_policy/grpclb/grpclb_channel.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/support/string.h"
+
+grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
+ grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
+ grpc_client_channel_factory *client_channel_factory,
+ grpc_channel_args *args) {
+ grpc_channel *lb_channel = grpc_client_channel_factory_create_channel(
+ exec_ctx, client_channel_factory, lb_service_target_addresses,
+ GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, args);
+ return lb_channel;
+}
+
+grpc_channel_args *get_lb_channel_args(grpc_exec_ctx *exec_ctx,
+ grpc_slice_hash_table *targets_info,
+ const grpc_channel_args *args) {
+ /* We strip out the channel arg for the LB policy name, since we want
+ * to use the default (pick_first) in this case.
+ *
+ * We also strip out the channel arg for the resolved addresses, since
+ * that will be generated by the name resolver used in the LB channel.
+ * Note that the LB channel will use the sockaddr resolver, so this
+ * won't actually generate a query to DNS (or some other name service).
+ * However, the addresses returned by the sockaddr resolver will have
+ * is_balancer=false, whereas our own addresses have is_balancer=true.
+ * We need the LB channel to return addresses with is_balancer=false
+ * so that it does not wind up recursively using the grpclb LB policy,
+ * as per the special case logic in client_channel.c.
+ *
+ * Lastly, we also strip out the channel arg for the server URI,
+ * since that will be different for the LB channel than for the parent
+ * channel (the client channel factory will re-add this arg with
+ * the right value). */
+ static const char *keys_to_remove[] = {
+ GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI};
+ return grpc_channel_args_copy_and_remove(args, keys_to_remove,
+ GPR_ARRAY_SIZE(keys_to_remove));
+}
diff --git a/src/core/ext/lb_policy/grpclb/grpclb_channel.h b/src/core/ext/lb_policy/grpclb/grpclb_channel.h
new file mode 100644
index 00000000000..f66082d78ee
--- /dev/null
+++ b/src/core/ext/lb_policy/grpclb/grpclb_channel.h
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright 2017, 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_GRPCLB_GRPCLB_CHANNEL_H
+#define GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H
+
+#include "src/core/ext/client_channel/lb_policy_factory.h"
+#include "src/core/lib/slice/slice_hash_table.h"
+
+/** Create the channel used for communicating with an LB service.
+ * Note that an LB *service* may be comprised of several LB *servers*.
+ *
+ * \a lb_service_target_addresses is the target URI containing the addresses
+ * from resolving the LB service's name (eg, ipv4:10.0.0.1:1234,10.2.3.4:9876).
+ * \a client_channel_factory will be used for the creation of the LB channel,
+ * alongside the channel args passed in \a args. */
+grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
+ grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
+ grpc_client_channel_factory *client_channel_factory,
+ grpc_channel_args *args);
+
+grpc_channel_args *get_lb_channel_args(grpc_exec_ctx *exec_ctx,
+ grpc_slice_hash_table *targets_info,
+ const grpc_channel_args *args);
+
+#endif /* GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H */
diff --git a/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c b/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
new file mode 100644
index 00000000000..2fee5f1b8ea
--- /dev/null
+++ b/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
@@ -0,0 +1,107 @@
+/*
+ *
+ * Copyright 2017, 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
+
+#include "src/core/ext/client_channel/client_channel.h"
+#include "src/core/ext/lb_policy/grpclb/grpclb_channel.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/transport/lb_targets_info.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/support/string.h"
+
+grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
+ grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
+ grpc_client_channel_factory *client_channel_factory,
+ grpc_channel_args *args) {
+ grpc_channel_args *new_args = args;
+ grpc_channel_credentials *channel_credentials =
+ grpc_channel_credentials_find_in_args(args);
+ if (channel_credentials != NULL) {
+ /* Substitute the channel credentials with a version without call
+ * credentials: the load balancer is not necessarily trusted to handle
+ * bearer token credentials */
+ static const char *keys_to_remove[] = {GRPC_ARG_CHANNEL_CREDENTIALS};
+ grpc_channel_credentials *creds_sans_call_creds =
+ grpc_channel_credentials_duplicate_without_call_credentials(
+ channel_credentials);
+ GPR_ASSERT(creds_sans_call_creds != NULL);
+ grpc_arg args_to_add[] = {
+ grpc_channel_credentials_to_arg(creds_sans_call_creds)};
+ /* Create the new set of channel args */
+ new_args = grpc_channel_args_copy_and_add_and_remove(
+ args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add,
+ GPR_ARRAY_SIZE(args_to_add));
+ grpc_channel_credentials_unref(exec_ctx, creds_sans_call_creds);
+ }
+ grpc_channel *lb_channel = grpc_client_channel_factory_create_channel(
+ exec_ctx, client_channel_factory, lb_service_target_addresses,
+ GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
+ if (channel_credentials != NULL) {
+ grpc_channel_args_destroy(exec_ctx, new_args);
+ }
+ return lb_channel;
+}
+
+grpc_channel_args *get_lb_channel_args(grpc_exec_ctx *exec_ctx,
+ grpc_slice_hash_table *targets_info,
+ const grpc_channel_args *args) {
+ const grpc_arg targets_info_arg =
+ grpc_lb_targets_info_create_channel_arg(targets_info);
+ /* We strip out the channel arg for the LB policy name, since we want
+ * to use the default (pick_first) in this case.
+ *
+ * We also strip out the channel arg for the resolved addresses, since
+ * that will be generated by the name resolver used in the LB channel.
+ * Note that the LB channel will use the sockaddr resolver, so this
+ * won't actually generate a query to DNS (or some other name service).
+ * However, the addresses returned by the sockaddr resolver will have
+ * is_balancer=false, whereas our own addresses have is_balancer=true.
+ * We need the LB channel to return addresses with is_balancer=false
+ * so that it does not wind up recursively using the grpclb LB policy,
+ * as per the special case logic in client_channel.c.
+ *
+ * Lastly, we also strip out the channel arg for the server URI,
+ * since that will be different for the LB channel than for the parent
+ * channel (the client channel factory will re-add this arg with
+ * the right value). */
+ static const char *keys_to_remove[] = {
+ GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI};
+ /* Add the targets info table to be used for secure naming */
+ return grpc_channel_args_copy_and_add_and_remove(
+ args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &targets_info_arg,
+ 1);
+}
diff --git a/src/core/ext/lb_policy/round_robin/round_robin.c b/src/core/ext/lb_policy/round_robin/round_robin.c
index d17d8fa057a..3e060d189ab 100644
--- a/src/core/ext/lb_policy/round_robin/round_robin.c
+++ b/src/core/ext/lb_policy/round_robin/round_robin.c
@@ -739,6 +739,13 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
sc_args.args = new_args;
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
exec_ctx, args->client_channel_factory, &sc_args);
+ if (grpc_lb_round_robin_trace) {
+ char *address_uri =
+ grpc_sockaddr_to_uri(&addresses->addresses[i].address);
+ gpr_log(GPR_DEBUG, "Created subchannel %p for address uri %s",
+ (void *)subchannel, address_uri);
+ gpr_free(address_uri);
+ }
grpc_channel_args_destroy(exec_ctx, new_args);
if (subchannel != NULL) {
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 d3e53984f2d..d8c18eb1223 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
@@ -40,10 +40,15 @@
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/resolver_registry.h"
+#include "src/core/ext/client_channel/uri_parser.h"
#include "src/core/ext/transport/chttp2/client/chttp2_connector.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/transport/lb_targets_info.h"
#include "src/core/lib/security/transport/security_connector.h"
+#include "src/core/lib/slice/slice_hash_table.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
@@ -53,12 +58,114 @@ static void client_channel_factory_ref(
static void client_channel_factory_unref(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {}
+static grpc_subchannel_args *get_secure_naming_subchannel_args(
+ grpc_exec_ctx *exec_ctx, const grpc_subchannel_args *args) {
+ grpc_channel_credentials *channel_credentials =
+ grpc_channel_credentials_find_in_args(args->args);
+ if (channel_credentials == NULL) {
+ gpr_log(GPR_ERROR,
+ "Can't create subchannel: channel credentials missing for secure "
+ "channel.");
+ return NULL;
+ }
+ // Make sure security connector does not already exist in args.
+ if (grpc_security_connector_find_in_args(args->args) != NULL) {
+ gpr_log(GPR_ERROR,
+ "Can't create subchannel: security connector already present in "
+ "channel args.");
+ return NULL;
+ }
+ // 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);
+ GPR_ASSERT(server_uri_arg != NULL);
+ GPR_ASSERT(server_uri_arg->type == GRPC_ARG_STRING);
+ const char *server_uri_str = server_uri_arg->value.string;
+ GPR_ASSERT(server_uri_str != NULL);
+ grpc_uri *server_uri =
+ grpc_uri_parse(server_uri_str, true /* supress errors */);
+ GPR_ASSERT(server_uri != NULL);
+ const char *server_uri_path;
+ server_uri_path =
+ server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path;
+ const grpc_slice_hash_table *targets_info =
+ grpc_lb_targets_info_find_in_args(args->args);
+ char *target_name_to_check = NULL;
+ if (targets_info != NULL) { // LB channel
+ // Find the balancer name for the target.
+ const char *target_uri_str =
+ grpc_get_subchannel_address_uri_arg(args->args);
+ grpc_uri *target_uri =
+ grpc_uri_parse(target_uri_str, false /* suppress errors */);
+ GPR_ASSERT(target_uri != NULL);
+ if (target_uri->path[0] != '\0') { // "path" may be empty
+ const grpc_slice key = grpc_slice_from_static_string(
+ target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
+ const char *value = grpc_slice_hash_table_get(targets_info, key);
+ if (value != NULL) target_name_to_check = gpr_strdup(value);
+ grpc_slice_unref_internal(exec_ctx, key);
+ }
+ if (target_name_to_check == NULL) {
+ // If the target name to check hasn't already been set, fall back to using
+ // SERVER_URI
+ target_name_to_check = gpr_strdup(server_uri_path);
+ }
+ grpc_uri_destroy(target_uri);
+ } else { // regular channel: the secure name is the original server URI.
+ target_name_to_check = gpr_strdup(server_uri_path);
+ }
+ grpc_uri_destroy(server_uri);
+ GPR_ASSERT(target_name_to_check != NULL);
+ grpc_channel_security_connector *subchannel_security_connector = NULL;
+ // Create the security connector using the credentials and target name.
+ grpc_channel_args *new_args_from_connector = NULL;
+ const grpc_security_status security_status =
+ grpc_channel_credentials_create_security_connector(
+ exec_ctx, channel_credentials, target_name_to_check, args->args,
+ &subchannel_security_connector, &new_args_from_connector);
+ if (security_status != GRPC_SECURITY_OK) {
+ gpr_log(GPR_ERROR,
+ "Failed to create secure subchannel for secure name '%s'",
+ target_name_to_check);
+ gpr_free(target_name_to_check);
+ return NULL;
+ }
+ gpr_free(target_name_to_check);
+ grpc_arg new_security_connector_arg =
+ grpc_security_connector_to_arg(&subchannel_security_connector->base);
+
+ grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
+ new_args_from_connector != NULL ? new_args_from_connector : args->args,
+ &new_security_connector_arg, 1);
+ GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base,
+ "lb_channel_create");
+ if (new_args_from_connector != NULL) {
+ grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
+ }
+ grpc_subchannel_args *final_sc_args = gpr_malloc(sizeof(*final_sc_args));
+ memcpy(final_sc_args, args, sizeof(*args));
+ final_sc_args->args = new_args;
+ return final_sc_args;
+}
+
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_subchannel_args *subchannel_args =
+ get_secure_naming_subchannel_args(exec_ctx, args);
+ if (subchannel_args == NULL) {
+ gpr_log(
+ GPR_ERROR,
+ "Failed to create subchannel arguments during subchannel creation.");
+ return NULL;
+ }
grpc_connector *connector = grpc_chttp2_connector_create();
- grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
+ grpc_subchannel *s =
+ grpc_subchannel_create(exec_ctx, connector, subchannel_args);
grpc_connector_unref(exec_ctx, connector);
+ grpc_channel_args_destroy(exec_ctx,
+ (grpc_channel_args *)subchannel_args->args);
+ gpr_free(subchannel_args);
return s;
}
@@ -91,10 +198,10 @@ static const grpc_client_channel_factory_vtable client_channel_factory_vtable =
static grpc_client_channel_factory client_channel_factory = {
&client_channel_factory_vtable};
-/* Create a secure client channel:
- Asynchronously: - resolve target
- - connect to it (trying alternatives as presented)
- - perform handshakes */
+// Create a secure client channel:
+// Asynchronously: - resolve target
+// - connect to it (trying alternatives as presented)
+// - perform handshakes
grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
const char *target,
const grpc_channel_args *args,
@@ -103,47 +210,25 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
GRPC_API_TRACE(
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
"reserved=%p)",
- 4, (creds, target, args, reserved));
+ 4, ((void *)creds, target, (void *)args, (void *)reserved));
GPR_ASSERT(reserved == NULL);
- // Make sure security connector does not already exist in args.
- if (grpc_find_security_connector_in_args(args) != NULL) {
- gpr_log(GPR_ERROR, "Cannot set security context in channel args.");
+ grpc_channel *channel = NULL;
+ if (creds != NULL) {
+ // Add channel args containing the client channel factory and channel
+ // credentials.
+ grpc_arg args_to_add[] = {
+ grpc_client_channel_factory_create_channel_arg(&client_channel_factory),
+ grpc_channel_credentials_to_arg(creds)};
+ grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
+ args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
+ // Create channel.
+ channel = client_channel_factory_create_channel(
+ &exec_ctx, &client_channel_factory, target,
+ GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
+ // Clean up.
+ grpc_channel_args_destroy(&exec_ctx, new_args);
grpc_exec_ctx_finish(&exec_ctx);
- return grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Security connector exists in channel args.");
- }
- // Create security connector and construct new channel args.
- grpc_channel_security_connector *security_connector;
- grpc_channel_args *new_args_from_connector;
- if (grpc_channel_credentials_create_security_connector(
- &exec_ctx, creds, target, args, &security_connector,
- &new_args_from_connector) != GRPC_SECURITY_OK) {
- grpc_exec_ctx_finish(&exec_ctx);
- return grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL, "Failed to create security connector.");
- }
- // Add channel args containing the client channel factory and security
- // connector.
- grpc_arg args_to_add[2];
- args_to_add[0] =
- grpc_client_channel_factory_create_channel_arg(&client_channel_factory);
- args_to_add[1] = grpc_security_connector_to_arg(&security_connector->base);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
- new_args_from_connector != NULL ? new_args_from_connector : args,
- args_to_add, GPR_ARRAY_SIZE(args_to_add));
- if (new_args_from_connector != NULL) {
- grpc_channel_args_destroy(&exec_ctx, new_args_from_connector);
}
- // Create channel.
- grpc_channel *channel = client_channel_factory_create_channel(
- &exec_ctx, &client_channel_factory, target,
- GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
- // Clean up.
- GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &security_connector->base,
- "secure_client_channel_factory_create_channel");
- grpc_channel_args_destroy(&exec_ctx, new_args);
- grpc_exec_ctx_finish(&exec_ctx);
return channel != NULL ? channel
: grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL,
diff --git a/src/core/lib/iomgr/sockaddr_utils.c b/src/core/lib/iomgr/sockaddr_utils.c
index 44bc2f968be..ffa62cb53c0 100644
--- a/src/core/lib/iomgr/sockaddr_utils.c
+++ b/src/core/lib/iomgr/sockaddr_utils.c
@@ -190,31 +190,37 @@ int grpc_sockaddr_to_string(char **out,
}
char *grpc_sockaddr_to_uri(const grpc_resolved_address *resolved_addr) {
- char *temp;
- char *result;
grpc_resolved_address addr_normalized;
- const struct sockaddr *addr;
-
if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
resolved_addr = &addr_normalized;
}
+ const char *scheme = grpc_sockaddr_get_uri_scheme(resolved_addr);
+ if (scheme == NULL || strcmp("unix", scheme) == 0) {
+ return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr);
+ }
+ char *path = NULL;
+ char *uri_str = NULL;
+ if (grpc_sockaddr_to_string(&path, resolved_addr,
+ false /* suppress errors */) &&
+ scheme != NULL) {
+ gpr_asprintf(&uri_str, "%s:%s", scheme, path);
+ }
+ gpr_free(path);
+ return uri_str != NULL ? uri_str : NULL;
+}
- addr = (const struct sockaddr *)resolved_addr->addr;
-
+const char *grpc_sockaddr_get_uri_scheme(
+ const grpc_resolved_address *resolved_addr) {
+ const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
switch (addr->sa_family) {
case AF_INET:
- grpc_sockaddr_to_string(&temp, resolved_addr, 0);
- gpr_asprintf(&result, "ipv4:%s", temp);
- gpr_free(temp);
- return result;
+ return "ipv4";
case AF_INET6:
- grpc_sockaddr_to_string(&temp, resolved_addr, 0);
- gpr_asprintf(&result, "ipv6:%s", temp);
- gpr_free(temp);
- return result;
- default:
- return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr);
+ return "ipv6";
+ case AF_UNIX:
+ return "unix";
}
+ return NULL;
}
int grpc_sockaddr_get_port(const grpc_resolved_address *resolved_addr) {
diff --git a/src/core/lib/iomgr/sockaddr_utils.h b/src/core/lib/iomgr/sockaddr_utils.h
index 5371e360c59..2b22f11b49d 100644
--- a/src/core/lib/iomgr/sockaddr_utils.h
+++ b/src/core/lib/iomgr/sockaddr_utils.h
@@ -84,6 +84,10 @@ int grpc_sockaddr_set_port(const grpc_resolved_address *addr, int port);
int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr,
int normalize);
+/* Returns the URI string corresponding to \a addr */
char *grpc_sockaddr_to_uri(const grpc_resolved_address *addr);
+/* Returns the URI scheme corresponding to \a addr */
+const char *grpc_sockaddr_get_uri_scheme(const grpc_resolved_address *addr);
+
#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */
diff --git a/src/core/lib/security/credentials/credentials.c b/src/core/lib/security/credentials/credentials.c
index 9781a22a86d..b24697ce54b 100644
--- a/src/core/lib/security/credentials/credentials.c
+++ b/src/core/lib/security/credentials/credentials.c
@@ -160,6 +160,53 @@ grpc_channel_credentials_duplicate_without_call_credentials(
}
}
+static void credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
+ grpc_channel_credentials_unref(exec_ctx, p);
+}
+
+static void *credentials_pointer_arg_copy(void *p) {
+ return grpc_channel_credentials_ref(p);
+}
+
+static int credentials_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
+
+static const grpc_arg_pointer_vtable credentials_pointer_vtable = {
+ credentials_pointer_arg_copy, credentials_pointer_arg_destroy,
+ credentials_pointer_cmp};
+
+grpc_arg grpc_channel_credentials_to_arg(
+ grpc_channel_credentials *credentials) {
+ grpc_arg result;
+ result.type = GRPC_ARG_POINTER;
+ result.key = GRPC_ARG_CHANNEL_CREDENTIALS;
+ result.value.pointer.vtable = &credentials_pointer_vtable;
+ result.value.pointer.p = credentials;
+ return result;
+}
+
+grpc_channel_credentials *grpc_channel_credentials_from_arg(
+ const grpc_arg *arg) {
+ if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return NULL;
+ if (arg->type != GRPC_ARG_POINTER) {
+ gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
+ GRPC_ARG_CHANNEL_CREDENTIALS);
+ return NULL;
+ }
+ return arg->value.pointer.p;
+}
+
+grpc_channel_credentials *grpc_channel_credentials_find_in_args(
+ const grpc_channel_args *args) {
+ size_t i;
+ if (args == NULL) return NULL;
+ for (i = 0; i < args->num_args; i++) {
+ grpc_channel_credentials *credentials =
+ grpc_channel_credentials_from_arg(&args->args[i]);
+ if (credentials != NULL) return credentials;
+ }
+ return NULL;
+}
+
grpc_server_credentials *grpc_server_credentials_ref(
grpc_server_credentials *creds) {
if (creds == NULL) return NULL;
diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h
index 3011df6b8a2..510b79552a3 100644
--- a/src/core/lib/security/credentials/credentials.h
+++ b/src/core/lib/security/credentials/credentials.h
@@ -100,6 +100,8 @@ void grpc_override_well_known_credentials_path_getter(
/* --- grpc_channel_credentials. --- */
+#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
+
typedef struct {
void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c);
@@ -140,6 +142,17 @@ grpc_channel_credentials *
grpc_channel_credentials_duplicate_without_call_credentials(
grpc_channel_credentials *creds);
+/* Util to encapsulate the channel credentials in a channel arg. */
+grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials *credentials);
+
+/* Util to get the channel credentials from a channel arg. */
+grpc_channel_credentials *grpc_channel_credentials_from_arg(
+ const grpc_arg *arg);
+
+/* Util to find the channel credentials from channel args. */
+grpc_channel_credentials *grpc_channel_credentials_find_in_args(
+ const grpc_channel_args *args);
+
/* --- grpc_credentials_md. --- */
typedef struct {
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.c b/src/core/lib/security/credentials/fake/fake_credentials.c
index a8679d097d0..a0629f76ce1 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.c
+++ b/src/core/lib/security/credentials/fake/fake_credentials.c
@@ -35,13 +35,13 @@
#include
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/iomgr/executor.h"
-
#include
#include
#include
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/support/string.h"
+
/* -- Fake transport security credentials. -- */
static grpc_security_status fake_transport_security_create_security_connector(
@@ -49,7 +49,7 @@ static grpc_security_status fake_transport_security_create_security_connector(
grpc_call_credentials *call_creds, const char *target,
const grpc_channel_args *args, grpc_channel_security_connector **sc,
grpc_channel_args **new_args) {
- *sc = grpc_fake_channel_security_connector_create(call_creds);
+ *sc = grpc_fake_channel_security_connector_create(call_creds, target, args);
return GRPC_SECURITY_OK;
}
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h
index 9cf38084a3d..0fe98417c6c 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.h
+++ b/src/core/lib/security/credentials/fake/fake_credentials.h
@@ -38,6 +38,21 @@
/* -- Fake transport security credentials. -- */
+/* Used to verify the target names given to the fake transport security
+ * connector.
+ *
+ * Its syntax by example:
+ * For LB channels:
+ * "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
+ * For regular channels:
+ * "backend_taget_1,backend_target_2,..."
+ *
+ * That is to say, LB channels have a heading list of LB targets separated from
+ * the list of backend targets by a semicolon. For non-LB channels, only the
+ * latter is present. */
+#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
+ "grpc.test_only.fake_security.expected_target"
+
/* Creates a fake transport security credentials object for testing. */
grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void);
diff --git a/src/core/lib/security/transport/client_auth_filter.c b/src/core/lib/security/transport/client_auth_filter.c
index cf056e80080..b9bbe1b3043 100644
--- a/src/core/lib/security/transport/client_auth_filter.c
+++ b/src/core/lib/security/transport/client_auth_filter.c
@@ -335,7 +335,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_channel_element_args *args) {
grpc_security_connector *sc =
- grpc_find_security_connector_in_args(args->channel_args);
+ grpc_security_connector_find_in_args(args->channel_args);
grpc_auth_context *auth_context =
grpc_find_auth_context_in_args(args->channel_args);
diff --git a/src/core/lib/security/transport/lb_targets_info.c b/src/core/lib/security/transport/lb_targets_info.c
new file mode 100644
index 00000000000..e73483c0399
--- /dev/null
+++ b/src/core/lib/security/transport/lb_targets_info.c
@@ -0,0 +1,70 @@
+/*
+ *
+ * Copyright 2017, 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 "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/security/transport/lb_targets_info.h"
+
+/* Channel arg key for the mapping of LB server addresses to their names for
+ * secure naming purposes. */
+#define GRPC_ARG_LB_SECURE_NAMING_MAP "grpc.lb_secure_naming_map"
+
+static void *targets_info_copy(void *p) { return grpc_slice_hash_table_ref(p); }
+static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) {
+ grpc_slice_hash_table_unref(exec_ctx, p);
+}
+static int targets_info_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
+static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = {
+ targets_info_copy, targets_info_destroy, targets_info_cmp};
+
+grpc_arg grpc_lb_targets_info_create_channel_arg(
+ grpc_slice_hash_table *targets_info) {
+ grpc_arg arg;
+ arg.type = GRPC_ARG_POINTER;
+ arg.key = GRPC_ARG_LB_SECURE_NAMING_MAP;
+ arg.value.pointer.p = targets_info;
+ arg.value.pointer.vtable = &server_to_balancer_names_vtable;
+ return arg;
+}
+
+grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
+ const grpc_channel_args *args) {
+ const grpc_arg *targets_info_arg =
+ grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP);
+ if (targets_info_arg != NULL) {
+ GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER);
+ return targets_info_arg->value.pointer.p;
+ }
+ return NULL;
+}
diff --git a/src/core/lib/security/transport/lb_targets_info.h b/src/core/lib/security/transport/lb_targets_info.h
new file mode 100644
index 00000000000..5e6cacc1979
--- /dev/null
+++ b/src/core/lib/security/transport/lb_targets_info.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2017, 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_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H
+#define GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H
+
+#include "src/core/lib/slice/slice_hash_table.h"
+
+/** Return a channel argument containing \a targets_info. */
+grpc_arg grpc_lb_targets_info_create_channel_arg(
+ grpc_slice_hash_table *targets_info);
+
+/** Return the instance of targets info in \a args or NULL */
+grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
+ const grpc_channel_args *args);
+
+#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */
diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c
index b09127811b0..aeb04e33a31 100644
--- a/src/core/lib/security/transport/security_connector.c
+++ b/src/core/lib/security/transport/security_connector.c
@@ -43,10 +43,13 @@
#include
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/credentials/fake/fake_credentials.h"
+#include "src/core/lib/security/transport/lb_targets_info.h"
#include "src/core/lib/security/transport/secure_endpoint.h"
#include "src/core/lib/security/transport/security_handshaker.h"
#include "src/core/lib/support/env.h"
@@ -205,23 +208,23 @@ static const grpc_arg_pointer_vtable connector_pointer_vtable = {
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) {
grpc_arg result;
result.type = GRPC_ARG_POINTER;
- result.key = GRPC_SECURITY_CONNECTOR_ARG;
+ result.key = GRPC_ARG_SECURITY_CONNECTOR;
result.value.pointer.vtable = &connector_pointer_vtable;
result.value.pointer.p = sc;
return result;
}
grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) {
- if (strcmp(arg->key, GRPC_SECURITY_CONNECTOR_ARG)) return NULL;
+ if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return NULL;
if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
- GRPC_SECURITY_CONNECTOR_ARG);
+ GRPC_ARG_SECURITY_CONNECTOR);
return NULL;
}
return arg->value.pointer.p;
}
-grpc_security_connector *grpc_find_security_connector_in_args(
+grpc_security_connector *grpc_security_connector_find_in_args(
const grpc_channel_args *args) {
size_t i;
if (args == NULL) return NULL;
@@ -235,11 +238,21 @@ grpc_security_connector *grpc_find_security_connector_in_args(
/* -- Fake implementation. -- */
+typedef struct {
+ grpc_channel_security_connector base;
+ char *target;
+ char *expected_targets;
+ bool is_lb_channel;
+} grpc_fake_channel_security_connector;
+
static void fake_channel_destroy(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc) {
- grpc_channel_security_connector *c = (grpc_channel_security_connector *)sc;
- grpc_call_credentials_unref(exec_ctx, c->request_metadata_creds);
- gpr_free(sc);
+ grpc_fake_channel_security_connector *c =
+ (grpc_fake_channel_security_connector *)sc;
+ grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
+ gpr_free(c->target);
+ gpr_free(c->expected_targets);
+ gpr_free(c);
}
static void fake_server_destroy(grpc_exec_ctx *exec_ctx,
@@ -247,6 +260,68 @@ static void fake_server_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(sc);
}
+static bool fake_check_target(const char *target_type, const char *target,
+ const char *set_str) {
+ GPR_ASSERT(target_type != NULL);
+ GPR_ASSERT(target != NULL);
+ char **set = NULL;
+ size_t set_size = 0;
+ gpr_string_split(set_str, ",", &set, &set_size);
+ bool found = false;
+ for (size_t i = 0; i < set_size; ++i) {
+ if (set[i] != NULL && strcmp(target, set[i]) == 0) found = true;
+ }
+ for (size_t i = 0; i < set_size; ++i) {
+ gpr_free(set[i]);
+ }
+ gpr_free(set);
+ return found;
+}
+
+static void fake_secure_name_check(const char *target,
+ const char *expected_targets,
+ bool is_lb_channel) {
+ if (expected_targets == NULL) return;
+ char **lbs_and_backends = NULL;
+ size_t lbs_and_backends_size = 0;
+ bool success = false;
+ gpr_string_split(expected_targets, ";", &lbs_and_backends,
+ &lbs_and_backends_size);
+ if (lbs_and_backends_size > 2 || lbs_and_backends_size == 0) {
+ gpr_log(GPR_ERROR, "Invalid expected targets arg value: '%s'",
+ expected_targets);
+ goto done;
+ }
+ if (is_lb_channel) {
+ if (lbs_and_backends_size != 2) {
+ gpr_log(GPR_ERROR,
+ "Invalid expected targets arg value: '%s'. Expectations for LB "
+ "channels must be of the form 'be1,be2,be3,...;lb1,lb2,...",
+ expected_targets);
+ goto done;
+ }
+ if (!fake_check_target("LB", target, lbs_and_backends[1])) {
+ gpr_log(GPR_ERROR, "LB target '%s' not found in expected set '%s'",
+ target, lbs_and_backends[1]);
+ goto done;
+ }
+ success = true;
+ } else {
+ if (!fake_check_target("Backend", target, lbs_and_backends[0])) {
+ gpr_log(GPR_ERROR, "Backend target '%s' not found in expected set '%s'",
+ target, lbs_and_backends[0]);
+ goto done;
+ }
+ success = true;
+ }
+done:
+ for (size_t i = 0; i < lbs_and_backends_size; ++i) {
+ gpr_free(lbs_and_backends[i]);
+ }
+ gpr_free(lbs_and_backends);
+ if (!success) abort();
+}
+
static void fake_check_peer(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, tsi_peer peer,
grpc_auth_context **auth_context,
@@ -277,12 +352,28 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx,
grpc_auth_context_add_cstring_property(
*auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
-
end:
grpc_closure_sched(exec_ctx, on_peer_checked, error);
tsi_peer_destruct(&peer);
}
+static void fake_channel_check_peer(grpc_exec_ctx *exec_ctx,
+ grpc_security_connector *sc, tsi_peer peer,
+ grpc_auth_context **auth_context,
+ grpc_closure *on_peer_checked) {
+ fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ grpc_fake_channel_security_connector *c =
+ (grpc_fake_channel_security_connector *)sc;
+ fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel);
+}
+
+static void fake_server_check_peer(grpc_exec_ctx *exec_ctx,
+ grpc_security_connector *sc, tsi_peer peer,
+ grpc_auth_context **auth_context,
+ grpc_closure *on_peer_checked) {
+ fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+}
+
static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx,
grpc_channel_security_connector *sc,
const char *host,
@@ -313,22 +404,32 @@ static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx,
}
static grpc_security_connector_vtable fake_channel_vtable = {
- fake_channel_destroy, fake_check_peer};
+ fake_channel_destroy, fake_channel_check_peer};
-static grpc_security_connector_vtable fake_server_vtable = {fake_server_destroy,
- fake_check_peer};
+static grpc_security_connector_vtable fake_server_vtable = {
+ fake_server_destroy, fake_server_check_peer};
grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
- grpc_call_credentials *request_metadata_creds) {
- grpc_channel_security_connector *c = gpr_malloc(sizeof(*c));
+ grpc_call_credentials *request_metadata_creds, const char *target,
+ const grpc_channel_args *args) {
+ grpc_fake_channel_security_connector *c = gpr_malloc(sizeof(*c));
memset(c, 0, sizeof(*c));
- gpr_ref_init(&c->base.refcount, 1);
- c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
- c->base.vtable = &fake_channel_vtable;
- c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds);
- c->check_call_host = fake_channel_check_call_host;
- c->add_handshakers = fake_channel_add_handshakers;
- return c;
+ gpr_ref_init(&c->base.base.refcount, 1);
+ c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
+ c->base.base.vtable = &fake_channel_vtable;
+ c->base.request_metadata_creds =
+ grpc_call_credentials_ref(request_metadata_creds);
+ c->base.check_call_host = fake_channel_check_call_host;
+ c->base.add_handshakers = fake_channel_add_handshakers;
+ c->target = gpr_strdup(target);
+ const grpc_arg *expected_target_arg =
+ grpc_channel_args_find(args, GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS);
+ if (expected_target_arg != NULL) {
+ GPR_ASSERT(expected_target_arg->type == GRPC_ARG_STRING);
+ c->expected_targets = gpr_strdup(expected_target_arg->value.string);
+ }
+ c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != NULL);
+ return &c->base;
}
grpc_server_security_connector *grpc_fake_server_security_connector_create(
diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h
index eba4e6d1d7b..3df2fecd393 100644
--- a/src/core/lib/security/transport/security_connector.h
+++ b/src/core/lib/security/transport/security_connector.h
@@ -57,7 +57,7 @@ typedef enum { GRPC_SECURITY_OK = 0, GRPC_SECURITY_ERROR } grpc_security_status;
typedef struct grpc_security_connector grpc_security_connector;
-#define GRPC_SECURITY_CONNECTOR_ARG "grpc.security_connector"
+#define GRPC_ARG_SECURITY_CONNECTOR "grpc.security_connector"
typedef struct {
void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc);
@@ -115,7 +115,7 @@ grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc);
grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg);
/* Util to find the connector from channel args. */
-grpc_security_connector *grpc_find_security_connector_in_args(
+grpc_security_connector *grpc_security_connector_find_in_args(
const grpc_channel_args *args);
/* --- channel_security_connector object. ---
@@ -175,7 +175,8 @@ void grpc_server_security_connector_add_handshakers(
/* For TESTING ONLY!
Creates a fake connector that emulates real channel security. */
grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
- grpc_call_credentials *request_metadata_creds);
+ grpc_call_credentials *request_metadata_creds, const char *target,
+ const grpc_channel_args *args);
/* For TESTING ONLY!
Creates a fake connector that emulates real server security. */
diff --git a/src/core/lib/security/transport/security_handshaker.c b/src/core/lib/security/transport/security_handshaker.c
index bb8a3bf6cdf..5d57543ac58 100644
--- a/src/core/lib/security/transport/security_handshaker.c
+++ b/src/core/lib/security/transport/security_handshaker.c
@@ -451,7 +451,7 @@ static void client_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory,
const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
grpc_channel_security_connector *security_connector =
- (grpc_channel_security_connector *)grpc_find_security_connector_in_args(
+ (grpc_channel_security_connector *)grpc_security_connector_find_in_args(
args);
grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector,
handshake_mgr);
@@ -461,7 +461,7 @@ static void server_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *hf,
const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
grpc_server_security_connector *security_connector =
- (grpc_server_security_connector *)grpc_find_security_connector_in_args(
+ (grpc_server_security_connector *)grpc_security_connector_find_in_args(
args);
grpc_server_security_connector_add_handshakers(exec_ctx, security_connector,
handshake_mgr);
diff --git a/src/core/lib/surface/init_secure.c b/src/core/lib/surface/init_secure.c
index a44407d3bb4..46b9a8f922c 100644
--- a/src/core/lib/surface/init_secure.c
+++ b/src/core/lib/surface/init_secure.c
@@ -56,7 +56,7 @@ static bool maybe_prepend_client_auth_filter(
grpc_channel_stack_builder_get_channel_arguments(builder);
if (args) {
for (size_t i = 0; i < args->num_args; i++) {
- if (0 == strcmp(GRPC_SECURITY_CONNECTOR_ARG, args->args[i].key)) {
+ if (0 == strcmp(GRPC_ARG_SECURITY_CONNECTOR, args->args[i].key)) {
return grpc_channel_stack_builder_prepend_filter(
builder, &grpc_client_auth_filter, NULL, NULL);
}
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 6bca3ed1a58..a9f20e6d2a8 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -231,6 +231,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/security/credentials/plugin/plugin_credentials.c',
'src/core/lib/security/credentials/ssl/ssl_credentials.c',
'src/core/lib/security/transport/client_auth_filter.c',
+ 'src/core/lib/security/transport/lb_targets_info.c',
'src/core/lib/security/transport/secure_endpoint.c',
'src/core/lib/security/transport/security_connector.c',
'src/core/lib/security/transport/security_handshaker.c',
@@ -271,6 +272,7 @@ CORE_SOURCE_FILES = [
'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/lb_policy/grpclb/grpclb.c',
+ 'src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c
index 8e711c6b419..4f05f69f01f 100644
--- a/test/core/end2end/fake_resolver.c
+++ b/test/core/end2end/fake_resolver.c
@@ -154,12 +154,34 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
grpc_uri_get_query_arg(args->uri, "lb_enabled");
const bool lb_enabled =
lb_enabled_qpart != NULL && strcmp("0", lb_enabled_qpart) != 0;
+
+ // Get the balancer's names.
+ const char* balancer_names =
+ grpc_uri_get_query_arg(args->uri, "balancer_names");
+ grpc_slice_buffer balancer_names_parts;
+ grpc_slice_buffer_init(&balancer_names_parts);
+ if (balancer_names != NULL) {
+ const grpc_slice balancer_names_slice =
+ grpc_slice_from_copied_string(balancer_names);
+ grpc_slice_split(balancer_names_slice, ",", &balancer_names_parts);
+ grpc_slice_unref(balancer_names_slice);
+ }
+
// Construct addresses.
grpc_slice path_slice =
grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing);
grpc_slice_buffer path_parts;
grpc_slice_buffer_init(&path_parts);
grpc_slice_split(path_slice, ",", &path_parts);
+ if (balancer_names_parts.count > 0 &&
+ path_parts.count != balancer_names_parts.count) {
+ gpr_log(GPR_ERROR,
+ "Balancer names present but mismatched with number of addresses: "
+ "%lu balancer names != %lu addresses",
+ (unsigned long)balancer_names_parts.count,
+ (unsigned long)path_parts.count);
+ return NULL;
+ }
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */);
bool errors_found = false;
@@ -171,10 +193,15 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
errors_found = true;
}
gpr_free(part_str);
- addresses->addresses[i].is_balancer = lb_enabled;
if (errors_found) break;
+ addresses->addresses[i].is_balancer = lb_enabled;
+ addresses->addresses[i].balancer_name =
+ balancer_names_parts.count > 0
+ ? grpc_dump_slice(balancer_names_parts.slices[i], GPR_DUMP_ASCII)
+ : NULL;
}
grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &balancer_names_parts);
grpc_slice_unref(path_slice);
if (errors_found) {
grpc_lb_addresses_destroy(exec_ctx, addresses);
diff --git a/test/core/surface/secure_channel_create_test.c b/test/core/surface/secure_channel_create_test.c
index 280806707e2..567f8ae16e0 100644
--- a/test/core/surface/secure_channel_create_test.c
+++ b/test/core/surface/secure_channel_create_test.c
@@ -62,7 +62,7 @@ void test_security_connector_already_in_arg(void) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
arg.value.pointer.p = NULL;
- arg.key = GRPC_SECURITY_CONNECTOR_ARG;
+ arg.key = GRPC_ARG_SECURITY_CONNECTOR;
grpc_channel_args args;
args.num_args = 1;
args.args = &arg;
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index 4b8a434c789..89ed9249adc 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -52,8 +52,10 @@
#include
extern "C" {
#include "src/core/ext/client_channel/client_channel.h"
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/security/credentials/fake/fake_credentials.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/support/tmpfile.h"
#include "src/core/lib/surface/channel.h"
@@ -110,6 +112,7 @@ typedef struct server_fixture {
grpc_call *server_call;
grpc_completion_queue *cq;
char *servers_hostport;
+ const char *balancer_name;
int port;
const char *lb_token_prefix;
gpr_thd_id tid;
@@ -201,10 +204,12 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
&request_metadata_recv, sf->cq, sf->cq,
tag(200));
GPR_ASSERT(GRPC_CALL_OK == error);
- gpr_log(GPR_INFO, "LB Server[%s] up", sf->servers_hostport);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) up", sf->servers_hostport,
+ sf->balancer_name);
CQ_EXPECT_COMPLETION(cqv, tag(200), 1);
cq_verify(cqv);
- gpr_log(GPR_INFO, "LB Server[%s] after tag 200", sf->servers_hostport);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 200", sf->servers_hostport,
+ sf->balancer_name);
// make sure we've received the initial metadata from the grpclb request.
GPR_ASSERT(request_metadata_recv.count > 0);
@@ -221,7 +226,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(202), 1);
cq_verify(cqv);
- gpr_log(GPR_INFO, "LB Server[%s] after RECV_MSG", sf->servers_hostport);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) after RECV_MSG", sf->servers_hostport,
+ sf->balancer_name);
// validate initial request.
grpc_byte_buffer_reader bbr;
@@ -250,7 +256,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
op++;
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
- gpr_log(GPR_INFO, "LB Server[%s] after tag 201", sf->servers_hostport);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 201", sf->servers_hostport,
+ sf->balancer_name);
for (int i = 0; i < 2; i++) {
if (i == 0) {
@@ -276,13 +283,14 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(203), 1);
cq_verify(cqv);
- gpr_log(GPR_INFO, "LB Server[%s] after SEND_MESSAGE, iter %d",
- sf->servers_hostport, i);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) after SEND_MESSAGE, iter %d",
+ sf->servers_hostport, sf->balancer_name, i);
grpc_byte_buffer_destroy(response_payload);
grpc_slice_unref(response_payload_slice);
}
- gpr_log(GPR_INFO, "LB Server[%s] shutting down", sf->servers_hostport);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) shutting down", sf->servers_hostport,
+ sf->balancer_name);
op = ops;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
@@ -299,8 +307,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
CQ_EXPECT_COMPLETION(cqv, tag(201), 1);
CQ_EXPECT_COMPLETION(cqv, tag(204), 1);
cq_verify(cqv);
- gpr_log(GPR_INFO, "LB Server[%s] after tag 204. All done. LB server out",
- sf->servers_hostport);
+ gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 204. All done. LB server out",
+ sf->servers_hostport, sf->balancer_name);
grpc_call_destroy(s);
@@ -561,10 +569,38 @@ static void perform_request(client_fixture *cf) {
gpr_free(peer);
}
-static void setup_client(const char *server_hostport, client_fixture *cf) {
+#define BALANCERS_NAME "lb.name"
+static void setup_client(const server_fixture *lb_server,
+ const server_fixture *backends, client_fixture *cf) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ char *lb_uri;
+ // The grpclb LB policy will be automatically selected by virtue of
+ // the fact that the returned addresses are balancer addresses.
+ gpr_asprintf(&lb_uri, "test:///%s?lb_enabled=1&balancer_names=%s",
+ lb_server->servers_hostport, lb_server->balancer_name);
+
+ grpc_arg expected_target_arg;
+ expected_target_arg.type = GRPC_ARG_STRING;
+ expected_target_arg.key =
+ const_cast(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS);
+
+ char *expected_target_names = NULL;
+ const char *backends_name = lb_server->servers_hostport;
+ gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME);
+
+ expected_target_arg.value.string = const_cast(expected_target_names);
+ grpc_channel_args *args =
+ grpc_channel_args_copy_and_add(NULL, &expected_target_arg, 1);
+ gpr_free(expected_target_names);
+
cf->cq = grpc_completion_queue_create(NULL);
- cf->server_uri = gpr_strdup(server_hostport);
- cf->client = grpc_insecure_channel_create(cf->server_uri, NULL, NULL);
+ cf->server_uri = lb_uri;
+ grpc_channel_credentials *fake_creds =
+ grpc_fake_transport_security_credentials_create();
+ cf->client =
+ grpc_secure_channel_create(fake_creds, cf->server_uri, args, NULL);
+ grpc_channel_credentials_unref(&exec_ctx, fake_creds);
+ grpc_channel_args_destroy(&exec_ctx, args);
}
static void teardown_client(client_fixture *cf) {
@@ -591,10 +627,14 @@ static void setup_server(const char *host, server_fixture *sf) {
gpr_join_host_port(&sf->servers_hostport, host, sf->port);
}
+ grpc_server_credentials *server_creds =
+ grpc_fake_transport_security_server_credentials_create();
+
sf->server = grpc_server_create(NULL, NULL);
grpc_server_register_completion_queue(sf->server, sf->cq, NULL);
- GPR_ASSERT((assigned_port = grpc_server_add_insecure_http2_port(
- sf->server, sf->servers_hostport)) > 0);
+ GPR_ASSERT((assigned_port = grpc_server_add_secure_http2_port(
+ sf->server, sf->servers_hostport, server_creds)) > 0);
+ grpc_server_credentials_release(server_creds);
GPR_ASSERT(sf->port == assigned_port);
grpc_server_start(sf->server);
}
@@ -656,17 +696,10 @@ static test_fixture setup_test_fixture(int lb_server_update_delay_ms) {
}
tf.lb_server.lb_token_prefix = LB_TOKEN_PREFIX;
+ tf.lb_server.balancer_name = BALANCERS_NAME;
setup_server("127.0.0.1", &tf.lb_server);
gpr_thd_new(&tf.lb_server.tid, fork_lb_server, &tf.lb_server, &options);
-
- char *server_uri;
- // The grpclb LB policy will be automatically selected by virtue of
- // the fact that the returned addresses are balancer addresses.
- gpr_asprintf(&server_uri, "test:///%s?lb_enabled=1",
- tf.lb_server.servers_hostport);
- setup_client(server_uri, &tf.client);
- gpr_free(server_uri);
-
+ setup_client(&tf.lb_server, tf.lb_backends, &tf.client);
return tf;
}
@@ -711,8 +744,9 @@ TEST(GrpclbTest, Updates) {
// batch 1. All subsequent picks will come from the second half of the
// backends, those coming in the LB update.
tf_result = grpc::test_update(800);
- GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced == 1);
- GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 0);
+ GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced +
+ tf_result.lb_backends[1].num_calls_serviced ==
+ 1);
GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced +
tf_result.lb_backends[3].num_calls_serviced >
0);
@@ -728,8 +762,9 @@ TEST(GrpclbTest, Updates) {
// update. In any case, the total number of serviced calls must again be equal
// to four across all the backends.
tf_result = grpc::test_update(2500);
- GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced >= 1);
- GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 1);
+ GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced +
+ tf_result.lb_backends[1].num_calls_serviced >=
+ 2);
GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced +
tf_result.lb_backends[3].num_calls_serviced >
0);
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 285b7dd3215..499390eb5b9 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -927,6 +927,8 @@ src/core/ext/client_channel/uri_parser.c \
src/core/ext/client_channel/uri_parser.h \
src/core/ext/lb_policy/grpclb/grpclb.c \
src/core/ext/lb_policy/grpclb/grpclb.h \
+src/core/ext/lb_policy/grpclb/grpclb_channel.h \
+src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.h \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
@@ -1191,6 +1193,8 @@ src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.h \
src/core/lib/security/transport/auth_filters.h \
src/core/lib/security/transport/client_auth_filter.c \
+src/core/lib/security/transport/lb_targets_info.c \
+src/core/lib/security/transport/lb_targets_info.h \
src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/secure_endpoint.h \
src/core/lib/security/transport/security_connector.c \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index def360afc85..6a8c29169bd 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -5197,7 +5197,7 @@
"census",
"gpr",
"grpc_base",
- "grpc_lb_policy_grpclb",
+ "grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_pick_first",
"grpc_lb_policy_round_robin",
"grpc_load_reporting",
@@ -7514,6 +7514,7 @@
],
"headers": [
"src/core/ext/lb_policy/grpclb/grpclb.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
],
@@ -7523,6 +7524,37 @@
"src": [
"src/core/ext/lb_policy/grpclb/grpclb.c",
"src/core/ext/lb_policy/grpclb/grpclb.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.c",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.h",
+ "src/core/ext/lb_policy/grpclb/load_balancer_api.c",
+ "src/core/ext/lb_policy/grpclb/load_balancer_api.h",
+ "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
+ "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
+ ],
+ "third_party": false,
+ "type": "filegroup"
+ },
+ {
+ "deps": [
+ "gpr",
+ "grpc_base",
+ "grpc_client_channel",
+ "nanopb"
+ ],
+ "headers": [
+ "src/core/ext/lb_policy/grpclb/grpclb.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.h",
+ "src/core/ext/lb_policy/grpclb/load_balancer_api.h",
+ "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
+ ],
+ "is_filegroup": true,
+ "language": "c",
+ "name": "grpc_lb_policy_grpclb_secure",
+ "src": [
+ "src/core/ext/lb_policy/grpclb/grpclb.c",
+ "src/core/ext/lb_policy/grpclb/grpclb.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel.h",
+ "src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
@@ -7638,6 +7670,7 @@
"src/core/lib/security/credentials/plugin/plugin_credentials.h",
"src/core/lib/security/credentials/ssl/ssl_credentials.h",
"src/core/lib/security/transport/auth_filters.h",
+ "src/core/lib/security/transport/lb_targets_info.h",
"src/core/lib/security/transport/secure_endpoint.h",
"src/core/lib/security/transport/security_connector.h",
"src/core/lib/security/transport/security_handshaker.h",
@@ -7679,6 +7712,8 @@
"src/core/lib/security/credentials/ssl/ssl_credentials.h",
"src/core/lib/security/transport/auth_filters.h",
"src/core/lib/security/transport/client_auth_filter.c",
+ "src/core/lib/security/transport/lb_targets_info.c",
+ "src/core/lib/security/transport/lb_targets_info.h",
"src/core/lib/security/transport/secure_endpoint.c",
"src/core/lib/security/transport/secure_endpoint.h",
"src/core/lib/security/transport/security_connector.c",
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj
index c7aa771e5ff..4d010ac6072 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj
@@ -437,6 +437,7 @@
+
@@ -469,6 +470,7 @@
+
@@ -804,6 +806,8 @@
+
+
@@ -884,6 +888,8 @@
+
+
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
index 00aa8b27818..191fc18f868 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
@@ -472,6 +472,9 @@
src\core\lib\security\transport
+
+ src\core\lib\security\transport
+
src\core\lib\security\transport
@@ -592,6 +595,9 @@
src\core\ext\lb_policy\grpclb
+
+ src\core\ext\lb_policy\grpclb
+
src\core\ext\lb_policy\grpclb
@@ -1178,6 +1184,9 @@
src\core\lib\security\transport
+
+ src\core\lib\security\transport
+
src\core\lib\security\transport
@@ -1274,6 +1283,9 @@
src\core\ext\lb_policy\grpclb
+
+ src\core\ext\lb_policy\grpclb
+
src\core\ext\lb_policy\grpclb
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
index f2c9d1ae03f..6d120cc0fa1 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
@@ -437,6 +437,7 @@
+
@@ -802,6 +803,8 @@
+
+
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
index d3117bd272d..c06af3fd86e 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
@@ -520,6 +520,9 @@
src\core\ext\lb_policy\grpclb
+
+ src\core\ext\lb_policy\grpclb
+
src\core\ext\lb_policy\grpclb
@@ -1121,6 +1124,9 @@
src\core\ext\lb_policy\grpclb
+
+ src\core\ext\lb_policy\grpclb
+
src\core\ext\lb_policy\grpclb
From 2b43481ff3d99339f2fdb8e1e681c0717bed2259 Mon Sep 17 00:00:00 2001
From: thinkerou
Date: Wed, 8 Feb 2017 13:02:48 +0800
Subject: [PATCH 059/167] fix undefined name
---
src/python/grpcio_tests/commands.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py
index af0ffe34750..40f9b834546 100644
--- a/src/python/grpcio_tests/commands.py
+++ b/src/python/grpcio_tests/commands.py
@@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Provides distutils command classes for the gRPC Python setup process."""
-import distutils
+from distutils import errors as _errors
import glob
import os
import os.path
@@ -186,7 +186,7 @@ class RunInterop(test.test):
def finalize_options(self):
if self.client and self.server:
- raise DistutilsOptionError(
+ raise _errors.DistutilsOptionError(
'you may only specify one of client or server')
def run(self):
From c18f3ed03873a90a0f986f12a84e742c89fc84b0 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 8 Feb 2017 09:28:55 -0800
Subject: [PATCH 060/167] Reduce concurrency
---
tools/run_tests/run_microbenchmark.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index 852b83967a9..851c506a2e8 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -94,7 +94,7 @@ for bm_name in sys.argv[1:]:
'--source', '%s.trace' % fnize(line), '--fmt', 'simple',
'--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=None))
cleanup.append(jobset.JobSpec(['rm', '%s.trace' % fnize(line)]))
- if len(benchmarks) >= 2 * multiprocessing.cpu_count():
+ if len(benchmarks) >= multiprocessing.cpu_count():
jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
From 265775fc20496ea18d49c42d39fe727b65f78bc4 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 8 Feb 2017 11:40:14 -0800
Subject: [PATCH 061/167] Handle zero-length filenames
---
src/core/lib/profiling/basic_timers.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/core/lib/profiling/basic_timers.c b/src/core/lib/profiling/basic_timers.c
index c4f27728227..1fbc9d7023d 100644
--- a/src/core/lib/profiling/basic_timers.c
+++ b/src/core/lib/profiling/basic_timers.c
@@ -90,7 +90,8 @@ static int g_writing_enabled = 1;
static const char *output_filename() {
if (output_filename_or_null == NULL) {
output_filename_or_null = gpr_getenv("LATENCY_TRACE");
- if (output_filename_or_null == NULL) {
+ if (output_filename_or_null == NULL ||
+ strlen(output_filename_or_null) == 0) {
output_filename_or_null = "latency_trace.txt";
}
}
From f74d1727917747a0cef75fa9b849aa77cfa091c4 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 8 Feb 2017 11:38:09 -0800
Subject: [PATCH 062/167] Further limit concurrency
---
tools/run_tests/run_microbenchmark.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index 851c506a2e8..7856affd8c4 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -94,7 +94,7 @@ for bm_name in sys.argv[1:]:
'--source', '%s.trace' % fnize(line), '--fmt', 'simple',
'--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=None))
cleanup.append(jobset.JobSpec(['rm', '%s.trace' % fnize(line)]))
- if len(benchmarks) >= multiprocessing.cpu_count():
+ if len(benchmarks) >= min(4, multiprocessing.cpu_count()):
jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
From 360c0d50654716966e2ca6e96110ffd15aabfee0 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 8 Feb 2017 13:36:44 -0800
Subject: [PATCH 063/167] Add comments, fix bug
---
tools/profiling/latency_profile/run_latency_profile.sh | 2 +-
tools/run_tests/run_microbenchmark.py | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/profiling/latency_profile/run_latency_profile.sh b/tools/profiling/latency_profile/run_latency_profile.sh
index 7ebe308e0a0..715f525d2ff 100755
--- a/tools/profiling/latency_profile/run_latency_profile.sh
+++ b/tools/profiling/latency_profile/run_latency_profile.sh
@@ -44,4 +44,4 @@ else
PYTHON=python2.7
fi
-$PYTHON tools/profiling/microbenchmark/bm.py bm_fullstack
+$PYTHON tools/run_tests/run_microbenchmark.py bm_fullstack
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index 7856affd8c4..a5794dc9eee 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -94,7 +94,13 @@ for bm_name in sys.argv[1:]:
'--source', '%s.trace' % fnize(line), '--fmt', 'simple',
'--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=None))
cleanup.append(jobset.JobSpec(['rm', '%s.trace' % fnize(line)]))
+ # periodically flush out the list of jobs: profile_analysis jobs at least
+ # consume upwards of five gigabytes of ram in some cases, and so analysing
+ # hundreds of them at once is impractical -- but we want at least some
+ # concurrency or the work takes too long
if len(benchmarks) >= min(4, multiprocessing.cpu_count()):
+ # run up to half the cpu count: each benchmark can use up to two cores
+ # (one for the microbenchmark, one for the data flush)
jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
@@ -102,6 +108,7 @@ for bm_name in sys.argv[1:]:
benchmarks = []
profile_analysis = []
cleanup = []
+ # run the remaining benchmarks that weren't flushed
if len(benchmarks):
jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
@@ -131,4 +138,4 @@ for bm_name in sys.argv[1:]:
index_html += "\n\n"
with open('reports/index.html', 'w') as f:
- w.write(index_html)
+ f.write(index_html)
From 2ef0d54ffcddbd1dadd6cc546ce9df6c5c0bfb0f Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 8 Feb 2017 13:53:18 -0800
Subject: [PATCH 064/167] Handle one core
---
src/core/lib/profiling/basic_timers.c | 1 +
tools/run_tests/run_microbenchmark.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/core/lib/profiling/basic_timers.c b/src/core/lib/profiling/basic_timers.c
index 1fbc9d7023d..1f1987fb8e7 100644
--- a/src/core/lib/profiling/basic_timers.c
+++ b/src/core/lib/profiling/basic_timers.c
@@ -43,6 +43,7 @@
#include
#include
#include
+#include
#include "src/core/lib/support/env.h"
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index a5794dc9eee..096d7d78ab2 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -101,7 +101,7 @@ for bm_name in sys.argv[1:]:
if len(benchmarks) >= min(4, multiprocessing.cpu_count()):
# run up to half the cpu count: each benchmark can use up to two cores
# (one for the microbenchmark, one for the data flush)
- jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
+ jobset.run(benchmarks, maxjobs=max(1, multiprocessing.cpu_count()/2),
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
@@ -110,7 +110,7 @@ for bm_name in sys.argv[1:]:
cleanup = []
# run the remaining benchmarks that weren't flushed
if len(benchmarks):
- jobset.run(benchmarks, maxjobs=multiprocessing.cpu_count()/2,
+ jobset.run(benchmarks, maxjobs=max(1, multiprocessing.cpu_count()/2),
add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port})
jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
From aa64ddf10962b811e0767b71775d8983ec89cab5 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 8 Feb 2017 14:20:08 -0800
Subject: [PATCH 065/167] Allow uploading results to BigQuery
---
.../latency_profile/run_latency_profile.sh | 2 +-
tools/profiling/microbenchmarks/bm2bq.py | 162 ++++++++++++++++++
tools/run_tests/run_microbenchmark.py | 59 ++++++-
3 files changed, 216 insertions(+), 7 deletions(-)
create mode 100755 tools/profiling/microbenchmarks/bm2bq.py
diff --git a/tools/profiling/latency_profile/run_latency_profile.sh b/tools/profiling/latency_profile/run_latency_profile.sh
index 715f525d2ff..e9baee09574 100755
--- a/tools/profiling/latency_profile/run_latency_profile.sh
+++ b/tools/profiling/latency_profile/run_latency_profile.sh
@@ -44,4 +44,4 @@ else
PYTHON=python2.7
fi
-$PYTHON tools/run_tests/run_microbenchmark.py bm_fullstack
+$PYTHON tools/run_tests/run_microbenchmark.py --collect summary perf latency --bigquery_upload
diff --git a/tools/profiling/microbenchmarks/bm2bq.py b/tools/profiling/microbenchmarks/bm2bq.py
new file mode 100755
index 00000000000..124dbdfec52
--- /dev/null
+++ b/tools/profiling/microbenchmarks/bm2bq.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python2.7
+#
+# Convert google-benchmark json output to something that can be uploaded to
+# BigQuery
+#
+#
+# Copyright 2017, 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.
+
+import sys
+import json
+import csv
+import os
+
+columns = [
+ ('jenkins_build', 'integer'),
+ ('jenkins_job', 'string'),
+ ('date', 'timestamp'),
+ ('cpu_scaling_enabled', 'boolean'),
+ ('num_cpus', 'integer'),
+ ('mhz_per_cpu', 'integer'),
+ ('library_build_type', 'string'),
+ ('name', 'string'),
+ ('fixture', 'string'),
+ ('client_mutator', 'string'),
+ ('server_mutator', 'string'),
+ ('request_size', 'integer'),
+ ('response_size', 'integer'),
+ ('request_count', 'integer'),
+ ('iterations', 'integer'),
+ ('time_unit', 'string'),
+ ('real_time', 'integer'),
+ ('cpu_time', 'integer'),
+ ('bytes_per_second', 'float'),
+ ('allocs_per_iteration', 'float'),
+ ('locks_per_iteration', 'float'),
+ ('writes_per_iteration', 'float'),
+]
+
+if sys.argv[1] == '--schema':
+ print ',\n'.join('%s:%s' % (k, t.upper()) for k, t in columns)
+ sys.exit(0)
+
+with open(sys.argv[1]) as f:
+ js = json.loads(f.read())
+
+writer = csv.DictWriter(sys.stdout, [c for c,t in columns])
+
+bm_specs = {
+ 'BM_UnaryPingPong': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size', 'response_size'],
+ },
+ 'BM_PumpStreamClientToServer': {
+ 'tpl': ['fixture'],
+ 'dyn': ['request_size'],
+ },
+ 'BM_PumpStreamServerToClient': {
+ 'tpl': ['fixture'],
+ 'dyn': ['request_size'],
+ },
+ 'BM_StreamingPingPong': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size', 'request_count'],
+ },
+ 'BM_StreamingPingPongMsgs': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size'],
+ }
+}
+
+def numericalize(s):
+ if not s: return ''
+ if s[-1] == 'k':
+ return int(s[:-1]) * 1024
+ if s[-1] == 'M':
+ return int(s[:-1]) * 1024 * 1024
+ if 0 <= (ord(s[-1]) - ord('0')) <= 9:
+ return int(s)
+ assert 'not a number: %s' % s
+
+def parse_name(name):
+ rest = name
+ out = {}
+ tpl_args = []
+ dyn_args = []
+ if '<' in rest:
+ tpl_bit = rest[rest.find('<') + 1 : rest.rfind('>')]
+ arg = ''
+ nesting = 0
+ for c in tpl_bit:
+ if c == '<':
+ nesting += 1
+ arg += c
+ elif c == '>':
+ nesting -= 1
+ arg += c
+ elif c == ',':
+ if nesting == 0:
+ tpl_args.append(arg.strip())
+ arg = ''
+ else:
+ arg += c
+ else:
+ arg += c
+ tpl_args.append(arg.strip())
+ rest = rest[:rest.find('<')] + rest[rest.rfind('>') + 1:]
+ if '/' in rest:
+ s = rest.split('/')
+ rest = s[0]
+ dyn_args = s[1:]
+ name = rest
+ assert name in bm_specs
+ assert len(dyn_args) == len(bm_specs[name]['dyn'])
+ assert len(tpl_args) == len(bm_specs[name]['tpl'])
+ out['name'] = name
+ out.update(dict((k, numericalize(v)) for k, v in zip(bm_specs[name]['dyn'], dyn_args)))
+ out.update(dict(zip(bm_specs[name]['tpl'], tpl_args)))
+ return out
+
+for bm in js['benchmarks']:
+ context = js['context']
+ labels_list = [s.split(':') for s in bm.get('label', '').split(' ')]
+ for el in labels_list:
+ el[0] = el[0].replace('/iter', '_per_iteration')
+ labels = dict(labels_list)
+ row = {
+ 'jenkins_build': os.environ.get('BUILD_NUMBER', ''),
+ 'jenkins_job': os.environ.get('JOB_NAME', ''),
+ }
+ row.update(context)
+ row.update(bm)
+ row.update(parse_name(row['name']))
+ row.update(labels)
+ del row['label']
+ writer.writerow(row)
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index 096d7d78ab2..2084599e352 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -32,6 +32,7 @@ import multiprocessing
import os
import subprocess
import sys
+import argparse
import python_utils.jobset as jobset
import python_utils.start_port_server as start_port_server
@@ -72,12 +73,16 @@ def link(txt, tgt):
global index_html
index_html += "%s
\n" % (tgt, txt)
-benchmarks = []
-profile_analysis = []
-cleanup = []
+def text(txt):
+ global index_html
+ index_html += "
%s " % txt
+
+def collect_latency(bm_name, args):
+ """generate latency profiles"""
+ benchmarks = []
+ profile_analysis = []
+ cleanup = []
-for bm_name in sys.argv[1:]:
- # generate latency profiles
heading('Latency Profiles: %s' % bm_name)
subprocess.check_call(
['make', bm_name,
@@ -115,7 +120,8 @@ for bm_name in sys.argv[1:]:
jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
- # generate flamegraphs
+def collect_perf(bm_name, args):
+ """generate flamegraphs"""
heading('Flamegraphs: %s' % bm_name)
subprocess.check_call(
['make', bm_name,
@@ -136,6 +142,47 @@ for bm_name in sys.argv[1:]:
f.write(subprocess.check_output([
'%s/flamegraph.pl' % flamegraph_dir, '/tmp/bm.folded']))
+def collect_summary(bm_name, args):
+ heading('Summary: %s' % bm_name)
+ subprocess.check_call(
+ ['make', bm_name,
+ 'CONFIG=counters', '-j', '%d' % multiprocessing.cpu_count()])
+ text(subprocess.check_output(['bins/counters/%s' % bm_name,
+ '--benchmark_out=out.json',
+ '--benchmark_out_format=json']))
+ if args.bigquery_upload:
+ with open('/tmp/out.csv', 'w') as f:
+ f.write(subprocess.check_output(['tools/profiling/microbenchmarks/bm2bq.py out.json']))
+ subprocess.check_call(['bq', 'load', 'microbenchmarks.microbenchmarks', 'out.csv'])
+
+collectors = {
+ 'latency': collect_latency,
+ 'perf': collect_perf,
+ 'summary': collect_summary,
+}
+
+argp = argparse.ArgumentParser(description='Collect data from microbenchmarks')
+argp.add_argument('-c', '--collect',
+ choices=sorted(collectors.keys()),
+ nargs='+',
+ default=sorted(collectors.keys()),
+ help='Which collectors should be run against each benchmark')
+argp.add_argument('-b', '--benchmarks',
+ default=['bm_fullstack'],
+ nargs='+',
+ type=str,
+ help='Which microbenchmarks should be run')
+argp.add_argument('--bigquery_upload',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Upload results from summary collection to bigquery')
+args = argp.parse_args()
+
+for bm_name in args.benchmarks:
+ for collect in args.collect:
+ collectors[collect](bm_name, args)
+
index_html += "\n