From 17ed6b17c7ebc4d70da020b6f785db22c835c722 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 18 Aug 2016 09:33:33 -0700 Subject: Percent encoding routines --- src/core/lib/support/percent_encoding.c | 124 ++++++++++++++++++++++++++++ src/core/lib/support/percent_encoding.h | 44 ++++++++++ src/python/grpcio/grpc_core_dependencies.py | 1 + 3 files changed, 169 insertions(+) create mode 100644 src/core/lib/support/percent_encoding.c create mode 100644 src/core/lib/support/percent_encoding.h (limited to 'src') diff --git a/src/core/lib/support/percent_encoding.c b/src/core/lib/support/percent_encoding.c new file mode 100644 index 0000000000..5da763c9a5 --- /dev/null +++ b/src/core/lib/support/percent_encoding.c @@ -0,0 +1,124 @@ +/* + * + * 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/support/percent_encoding.h" + +#include + +static bool is_unreserved_character(uint8_t c) { + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || + (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~'; +} + +gpr_slice gpr_percent_encode_slice(gpr_slice slice) { + static const uint8_t hex[] = "0123456789ABCDEF"; + + // first pass: count the number of bytes needed to output this string + size_t output_length = 0; + const uint8_t *slice_start = GPR_SLICE_START_PTR(slice); + const uint8_t *slice_end = GPR_SLICE_END_PTR(slice); + const uint8_t *p; + bool any_reserved_bytes = false; + for (p = slice_start; p < slice_end; p++) { + bool unres = is_unreserved_character(*p); + output_length += unres ? 1 : 3; + any_reserved_bytes |= !unres; + } + // no unreserved bytes: return the string unmodified + if (!any_reserved_bytes) { + return gpr_slice_ref(slice); + } + // second pass: actually encode + gpr_slice out = gpr_slice_malloc(output_length); + uint8_t *q = GPR_SLICE_START_PTR(out); + for (p = slice_start; p < slice_end; p++) { + if (is_unreserved_character(*p)) { + *q++ = *p; + } else { + *q++ = '%'; + *q++ = hex[*p >> 4]; + *q++ = hex[*p & 15]; + } + } + GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); + return out; +} + +static bool valid_hex(const uint8_t *p, const uint8_t *end) { + if (p == end) return false; + return (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || + (*p >= 'A' && *p <= 'F'); +} + +static uint8_t dehex(uint8_t c) { + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + if (c >= 'a' && c <= 'f') return c - 'a' + 10; + GPR_UNREACHABLE_CODE(return 255); +} + +bool gpr_percent_decode_slice(gpr_slice slice_in, gpr_slice *slice_out) { + const uint8_t *p = GPR_SLICE_START_PTR(slice_in); + const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); + size_t out_length = 0; + bool any_percent_encoded_stuff = false; + while (p != in_end) { + if (*p == '%') { + if (!valid_hex(++p, in_end)) return false; + if (!valid_hex(++p, in_end)) return false; + p++; + any_percent_encoded_stuff = true; + out_length++; + } else { + p++; + out_length++; + } + } + if (!any_percent_encoded_stuff) { + *slice_out = gpr_slice_ref(slice_in); + return true; + } + p = GPR_SLICE_START_PTR(slice_in); + *slice_out = gpr_slice_malloc(out_length); + uint8_t *q = GPR_SLICE_START_PTR(*slice_out); + while (p != in_end) { + if (*p == '%') { + *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); + p += 3; + } else { + *q++ = *p++; + } + } + GPR_ASSERT(q == GPR_SLICE_END_PTR(*slice_out)); + return true; +} diff --git a/src/core/lib/support/percent_encoding.h b/src/core/lib/support/percent_encoding.h new file mode 100644 index 0000000000..df59cbd606 --- /dev/null +++ b/src/core/lib/support/percent_encoding.h @@ -0,0 +1,44 @@ +/* + * + * 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 PRECENT_H +#define PRECENT_H + +#include + +#include + +gpr_slice gpr_percent_encode_slice(gpr_slice slice); +bool gpr_percent_decode_slice(gpr_slice slice_in, gpr_slice *slice_out); + +#endif /* PRECENT_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 7ae76f52c1..c81a64acf4 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -51,6 +51,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/log_posix.c', 'src/core/lib/support/log_windows.c', 'src/core/lib/support/murmur_hash.c', + 'src/core/lib/support/percent_encoding.c', 'src/core/lib/support/slice.c', 'src/core/lib/support/slice_buffer.c', 'src/core/lib/support/stack_lockfree.c', -- cgit v1.2.3 From c5c2c72d0fcbae0e3c05681ba3418f01a8511b54 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 18 Aug 2016 09:46:32 -0700 Subject: Appease the casting gods --- src/core/lib/support/percent_encoding.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/lib/support/percent_encoding.c b/src/core/lib/support/percent_encoding.c index 5da763c9a5..88953f2542 100644 --- a/src/core/lib/support/percent_encoding.c +++ b/src/core/lib/support/percent_encoding.c @@ -81,9 +81,9 @@ static bool valid_hex(const uint8_t *p, const uint8_t *end) { } static uint8_t dehex(uint8_t c) { - if (c >= '0' && c <= '9') return c - '0'; - if (c >= 'A' && c <= 'F') return c - 'A' + 10; - if (c >= 'a' && c <= 'f') return c - 'a' + 10; + if (c >= '0' && c <= '9') return (uint8_t)(c - '0'); + if (c >= 'A' && c <= 'F') return (uint8_t)(c - 'A' + 10); + if (c >= 'a' && c <= 'f') return (uint8_t)(c - 'a' + 10); GPR_UNREACHABLE_CODE(return 255); } -- cgit v1.2.3 From 1c7a84202f954e9d4fe328a5fd4eaf8439d894ef Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 18 Aug 2016 11:13:11 -0700 Subject: Add a strict and a permissive decoder, allow different reserved alphabets --- CMakeLists.txt | 22 + Makefile | 35 +- build.yaml | 6 + src/core/lib/support/percent_encoding.c | 76 ++- src/core/lib/support/percent_encoding.h | 11 +- test/core/support/percent_decode_fuzzer.c | 5 +- test/core/support/percent_encode_fuzzer.c | 11 +- test/core/support/percent_encoding_test.c | 95 +++- tools/codegen/core/gen_percent_encoding_tables.c | 84 +++ tools/run_tests/sources_and_headers.json | 11 + tools/run_tests/tests.json | 570 +++++++++++++++++++++ vsprojects/buildtests_c.sln | 21 + vsprojects/grpc.sln | 21 + .../gen_percent_encoding_tables.vcxproj | 162 ++++++ .../gen_percent_encoding_tables.vcxproj.filters | 21 + 15 files changed, 1119 insertions(+), 32 deletions(-) create mode 100644 tools/codegen/core/gen_percent_encoding_tables.c create mode 100644 vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj create mode 100644 vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj.filters (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index c6a0bedfc8..5064149c6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1526,6 +1526,28 @@ install(TARGETS gen_legal_metadata_characters EXPORT gRPCTargets ) +add_executable(gen_percent_encoding_tables + tools/codegen/core/gen_percent_encoding_tables.c +) + +target_include_directories(gen_percent_encoding_tables + 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 +) + + + +install(TARGETS gen_percent_encoding_tables EXPORT gRPCTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + + add_executable(grpc_create_jwt test/core/security/create_jwt.c ) diff --git a/Makefile b/Makefile index 1e267cb462..49b545c652 100644 --- a/Makefile +++ b/Makefile @@ -937,6 +937,7 @@ fling_stream_test: $(BINDIR)/$(CONFIG)/fling_stream_test fling_test: $(BINDIR)/$(CONFIG)/fling_test gen_hpack_tables: $(BINDIR)/$(CONFIG)/gen_hpack_tables gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters +gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test gpr_backoff_test: $(BINDIR)/$(CONFIG)/gpr_backoff_test @@ -1842,7 +1843,7 @@ test_python: static_c tools: tools_c tools_cxx -tools_c: privatelibs_c $(BINDIR)/$(CONFIG)/gen_hpack_tables $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters $(BINDIR)/$(CONFIG)/grpc_create_jwt $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token $(BINDIR)/$(CONFIG)/grpc_verify_jwt +tools_c: privatelibs_c $(BINDIR)/$(CONFIG)/gen_hpack_tables $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables $(BINDIR)/$(CONFIG)/grpc_create_jwt $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token $(BINDIR)/$(CONFIG)/grpc_verify_jwt tools_cxx: privatelibs_cxx @@ -7730,6 +7731,38 @@ endif endif +GEN_PERCENT_ENCODING_TABLES_SRC = \ + tools/codegen/core/gen_percent_encoding_tables.c \ + +GEN_PERCENT_ENCODING_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_PERCENT_ENCODING_TABLES_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS) + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(GEN_PERCENT_ENCODING_TABLES_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables + +endif + +$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_percent_encoding_tables.o: + +deps_gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep) +endif +endif + + GOAWAY_SERVER_TEST_SRC = \ test/core/end2end/goaway_server_test.c \ diff --git a/build.yaml b/build.yaml index fca0486400..9697ebd85f 100644 --- a/build.yaml +++ b/build.yaml @@ -1573,6 +1573,12 @@ targets: src: - tools/codegen/core/gen_legal_metadata_characters.c deps: [] +- name: gen_percent_encoding_tables + build: tool + language: c + src: + - tools/codegen/core/gen_percent_encoding_tables.c + deps: [] - name: goaway_server_test cpu_cost: 0.1 build: test diff --git a/src/core/lib/support/percent_encoding.c b/src/core/lib/support/percent_encoding.c index 88953f2542..3c19f264f9 100644 --- a/src/core/lib/support/percent_encoding.c +++ b/src/core/lib/support/percent_encoding.c @@ -35,12 +35,22 @@ #include -static bool is_unreserved_character(uint8_t c) { - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || - (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~'; +const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0xfe, 0xff, 0xff, + 0x87, 0xfe, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8] = { + 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +static bool is_unreserved_character(uint8_t c, + const uint8_t *unreserved_bytes) { + return ((unreserved_bytes[c / 8] >> (c % 8)) & 1) != 0; } -gpr_slice gpr_percent_encode_slice(gpr_slice slice) { +gpr_slice gpr_percent_encode_slice(gpr_slice slice, + const uint8_t *unreserved_bytes) { static const uint8_t hex[] = "0123456789ABCDEF"; // first pass: count the number of bytes needed to output this string @@ -50,7 +60,7 @@ gpr_slice gpr_percent_encode_slice(gpr_slice slice) { const uint8_t *p; bool any_reserved_bytes = false; for (p = slice_start; p < slice_end; p++) { - bool unres = is_unreserved_character(*p); + bool unres = is_unreserved_character(*p, unreserved_bytes); output_length += unres ? 1 : 3; any_reserved_bytes |= !unres; } @@ -62,7 +72,7 @@ gpr_slice gpr_percent_encode_slice(gpr_slice slice) { gpr_slice out = gpr_slice_malloc(output_length); uint8_t *q = GPR_SLICE_START_PTR(out); for (p = slice_start; p < slice_end; p++) { - if (is_unreserved_character(*p)) { + if (is_unreserved_character(*p, unreserved_bytes)) { *q++ = *p; } else { *q++ = '%'; @@ -75,7 +85,7 @@ gpr_slice gpr_percent_encode_slice(gpr_slice slice) { } static bool valid_hex(const uint8_t *p, const uint8_t *end) { - if (p == end) return false; + if (p >= end) return false; return (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'); } @@ -87,7 +97,9 @@ static uint8_t dehex(uint8_t c) { GPR_UNREACHABLE_CODE(return 255); } -bool gpr_percent_decode_slice(gpr_slice slice_in, gpr_slice *slice_out) { +bool gpr_strict_percent_decode_slice(gpr_slice slice_in, + const uint8_t *unreserved_bytes, + gpr_slice *slice_out) { const uint8_t *p = GPR_SLICE_START_PTR(slice_in); const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); size_t out_length = 0; @@ -97,11 +109,13 @@ bool gpr_percent_decode_slice(gpr_slice slice_in, gpr_slice *slice_out) { if (!valid_hex(++p, in_end)) return false; if (!valid_hex(++p, in_end)) return false; p++; - any_percent_encoded_stuff = true; out_length++; - } else { + any_percent_encoded_stuff = true; + } else if (is_unreserved_character(*p, unreserved_bytes)) { p++; out_length++; + } else { + return false; } } if (!any_percent_encoded_stuff) { @@ -122,3 +136,45 @@ bool gpr_percent_decode_slice(gpr_slice slice_in, gpr_slice *slice_out) { GPR_ASSERT(q == GPR_SLICE_END_PTR(*slice_out)); return true; } + +gpr_slice gpr_permissive_percent_decode_slice(gpr_slice slice_in) { + const uint8_t *p = GPR_SLICE_START_PTR(slice_in); + const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); + size_t out_length = 0; + bool any_percent_encoded_stuff = false; + while (p != in_end) { + if (*p == '%') { + if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { + p++; + out_length++; + } else { + p += 3; + out_length++; + any_percent_encoded_stuff = true; + } + } else { + p++; + out_length++; + } + } + if (!any_percent_encoded_stuff) { + return gpr_slice_ref(slice_in); + } + p = GPR_SLICE_START_PTR(slice_in); + gpr_slice out = gpr_slice_malloc(out_length); + uint8_t *q = GPR_SLICE_START_PTR(out); + while (p != in_end) { + if (*p == '%') { + if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { + *q++ = *p++; + } else { + *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); + p += 3; + } + } else { + *q++ = *p++; + } + } + GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); + return out; +} diff --git a/src/core/lib/support/percent_encoding.h b/src/core/lib/support/percent_encoding.h index df59cbd606..41f28d01f8 100644 --- a/src/core/lib/support/percent_encoding.h +++ b/src/core/lib/support/percent_encoding.h @@ -38,7 +38,14 @@ #include -gpr_slice gpr_percent_encode_slice(gpr_slice slice); -bool gpr_percent_decode_slice(gpr_slice slice_in, gpr_slice *slice_out); +extern const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8]; +extern const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8]; + +gpr_slice gpr_percent_encode_slice(gpr_slice slice, + const uint8_t *unreserved_bytes); +bool gpr_strict_percent_decode_slice(gpr_slice slice_in, + const uint8_t *unreserved_bytes, + gpr_slice *slice_out); +gpr_slice gpr_permissive_percent_decode_slice(gpr_slice slice_in); #endif /* PRECENT_H */ diff --git a/test/core/support/percent_decode_fuzzer.c b/test/core/support/percent_decode_fuzzer.c index 730a2b85ba..d8d56b831d 100644 --- a/test/core/support/percent_decode_fuzzer.c +++ b/test/core/support/percent_decode_fuzzer.c @@ -49,7 +49,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_memory_counters_init(); gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size); gpr_slice output; - if (gpr_percent_decode_slice(input, &output)) { + if (gpr_percent_decode_slice(input, false, &output)) { + gpr_slice_unref(output); + } + if (gpr_percent_decode_slice(input, true, &output)) { gpr_slice_unref(output); } gpr_slice_unref(input); diff --git a/test/core/support/percent_encode_fuzzer.c b/test/core/support/percent_encode_fuzzer.c index bc04633303..1c65e72cbb 100644 --- a/test/core/support/percent_encode_fuzzer.c +++ b/test/core/support/percent_encode_fuzzer.c @@ -44,14 +44,14 @@ bool squelch = true; bool leak_check = true; -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +static void test(const uint8_t *data, size_t size, const uint8_t *dict) { struct grpc_memory_counters counters; grpc_memory_counters_init(); gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size); - gpr_slice output = gpr_percent_encode_slice(input); + gpr_slice output = gpr_percent_encode_slice(input, dict); gpr_slice decoded_output; // encoder must always produce decodable output - GPR_ASSERT(gpr_percent_decode_slice(output, &decoded_output)); + GPR_ASSERT(gpr_percent_decode_slice(output, false, &decoded_output)); // and decoded output must always match the input GPR_ASSERT(gpr_slice_cmp(input, decoded_output) == 0); gpr_slice_unref(input); @@ -60,5 +60,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { counters = grpc_memory_counters_snapshot(); grpc_memory_counters_destroy(); GPR_ASSERT(counters.total_size_relative == 0); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + test(data, size, gpr_url_percent_encoding_unreserved_bytes); + test(data, size, gpr_compatible_percent_encoding_unreserved_bytes); return 0; } diff --git a/test/core/support/percent_encoding_test.c b/test/core/support/percent_encoding_test.c index 812ce0d35e..ab5f3f2d14 100644 --- a/test/core/support/percent_encoding_test.c +++ b/test/core/support/percent_encoding_test.c @@ -39,11 +39,16 @@ #include "src/core/lib/support/string.h" #include "test/core/util/test_config.h" -#define TEST_VECTOR(raw, encoded) \ - test_vector(raw, sizeof(raw) - 1, encoded, sizeof(encoded) - 1) +#define TEST_VECTOR(raw, encoded, dict) \ + test_vector(raw, sizeof(raw) - 1, encoded, sizeof(encoded) - 1, dict) + +#define TEST_NONCONFORMANT_VECTOR(encoded, permissive_unencoded, dict) \ + test_nonconformant_vector(encoded, sizeof(encoded) - 1, \ + permissive_unencoded, \ + sizeof(permissive_unencoded) - 1, dict) static void test_vector(const char *raw, size_t raw_length, const char *encoded, - size_t encoded_length) { + size_t encoded_length, const uint8_t *dict) { char *raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *encoded_msg = gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -54,39 +59,99 @@ static void test_vector(const char *raw, size_t raw_length, const char *encoded, gpr_slice raw_slice = gpr_slice_from_copied_buffer(raw, raw_length); gpr_slice encoded_slice = gpr_slice_from_copied_buffer(encoded, encoded_length); - gpr_slice raw2encoded_slice = gpr_percent_encode_slice(raw_slice); + gpr_slice raw2encoded_slice = gpr_percent_encode_slice(raw_slice, dict); gpr_slice encoded2raw_slice; - GPR_ASSERT(gpr_percent_decode_slice(encoded_slice, &encoded2raw_slice)); + GPR_ASSERT( + gpr_strict_percent_decode_slice(encoded_slice, dict, &encoded2raw_slice)); + gpr_slice encoded2raw_permissive_slice = + gpr_permissive_percent_decode_slice(encoded_slice); char *raw2encoded_msg = gpr_dump_slice(raw2encoded_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *encoded2raw_msg = gpr_dump_slice(encoded2raw_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "Result:\nraw2encoded = %s\nencoded2raw = %s", - raw2encoded_msg, encoded2raw_msg); + char *encoded2raw_permissive_msg = gpr_dump_slice( + encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, + "Result:\nraw2encoded = %s\nencoded2raw = %s\nencoded2raw_permissive " + "= %s", + raw2encoded_msg, encoded2raw_msg, encoded2raw_permissive_msg); gpr_free(raw2encoded_msg); gpr_free(encoded2raw_msg); + gpr_free(encoded2raw_permissive_msg); GPR_ASSERT(0 == gpr_slice_cmp(raw_slice, encoded2raw_slice)); + GPR_ASSERT(0 == gpr_slice_cmp(raw_slice, encoded2raw_permissive_slice)); GPR_ASSERT(0 == gpr_slice_cmp(encoded_slice, raw2encoded_slice)); gpr_slice_unref(encoded2raw_slice); + gpr_slice_unref(encoded2raw_permissive_slice); gpr_slice_unref(raw2encoded_slice); gpr_slice_unref(raw_slice); gpr_slice_unref(encoded_slice); } +static void test_nonconformant_vector(const char *encoded, + size_t encoded_length, + const char *permissive_unencoded, + size_t permissive_unencoded_length, + const uint8_t *dict) { + char *permissive_unencoded_msg = + gpr_dump(permissive_unencoded, permissive_unencoded_length, + GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *encoded_msg = + gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg, + encoded_msg); + gpr_free(permissive_unencoded_msg); + gpr_free(encoded_msg); + + gpr_slice permissive_unencoded_slice = gpr_slice_from_copied_buffer( + permissive_unencoded, permissive_unencoded_length); + gpr_slice encoded_slice = + gpr_slice_from_copied_buffer(encoded, encoded_length); + gpr_slice encoded2raw_slice; + GPR_ASSERT(!gpr_strict_percent_decode_slice(encoded_slice, dict, + &encoded2raw_slice)); + gpr_slice encoded2raw_permissive_slice = + gpr_permissive_percent_decode_slice(encoded_slice); + + char *encoded2raw_permissive_msg = gpr_dump_slice( + encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s", + encoded2raw_permissive_msg); + gpr_free(encoded2raw_permissive_msg); + + GPR_ASSERT(0 == gpr_slice_cmp(permissive_unencoded_slice, + encoded2raw_permissive_slice)); + + gpr_slice_unref(permissive_unencoded_slice); + gpr_slice_unref(encoded2raw_permissive_slice); + gpr_slice_unref(encoded_slice); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); TEST_VECTOR( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"); - TEST_VECTOR("\x00", "%00"); - TEST_VECTOR("\x01", "%01"); - TEST_VECTOR("a b", "a%20b"); - TEST_VECTOR(" b", "%20b"); - TEST_VECTOR("\x0f", "%0F"); - TEST_VECTOR("\xff", "%FF"); - TEST_VECTOR("\xee", "%EE"); + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", + gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\x00", "%00", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\x01", "%01", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("a b", "a%20b", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR(" b", "%20b", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("a b", "a b", gpr_compatible_percent_encoding_unreserved_bytes); + TEST_VECTOR(" b", " b", gpr_compatible_percent_encoding_unreserved_bytes); + TEST_VECTOR("\x0f", "%0F", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\xff", "%FF", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\xee", "%EE", gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("%", "%", + gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("%A", "%A", + gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("%AG", "%AG", + gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("\0", "\0", + gpr_url_percent_encoding_unreserved_bytes); return 0; } diff --git a/tools/codegen/core/gen_percent_encoding_tables.c b/tools/codegen/core/gen_percent_encoding_tables.c new file mode 100644 index 0000000000..93f30deeb3 --- /dev/null +++ b/tools/codegen/core/gen_percent_encoding_tables.c @@ -0,0 +1,84 @@ +/* + * + * 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. + * + */ + +/* generates constant table for metadata.c */ + +#include +#include + +static unsigned char legal_bits[256 / 8]; + +static void legal(int x) { + int byte = x / 8; + int bit = x % 8; + /* NB: the following integer arithmetic operation needs to be in its + * expanded form due to the "integral promotion" performed (see section + * 3.2.1.1 of the C89 draft standard). A cast to the smaller container type + * is then required to avoid the compiler warning */ + legal_bits[byte] = + (unsigned char)((legal_bits[byte] | (unsigned char)(1 << bit))); +} + +static void dump(const char *name) { + int i; + + printf("const uint8_t %s[256/8] = ", name); + for (i = 0; i < 256 / 8; i++) + printf("%c 0x%02x", i ? ',' : '{', legal_bits[i]); + printf(" };\n"); +} + +static void clear(void) { memset(legal_bits, 0, sizeof(legal_bits)); } + +int main(void) { + int i; + + clear(); + for (i = 'a'; i <= 'z'; i++) legal(i); + for (i = 'A'; i <= 'Z'; i++) legal(i); + for (i = '0'; i <= '9'; i++) legal(i); + legal('-'); + legal('_'); + legal('.'); + legal('~'); + dump("gpr_url_percent_encoding_unreserved_bytes"); + + clear(); + for (i = 32; i <= 126; i++) { + if (i == '%') continue; + legal(i); + } + dump("gpr_compatible_percent_encoding_unreserved_bytes"); + + return 0; +} diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 96bd054b25..beda2cee7b 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -485,6 +485,17 @@ "third_party": false, "type": "target" }, + { + "deps": [], + "headers": [], + "language": "c", + "name": "gen_percent_encoding_tables", + "src": [ + "tools/codegen/core/gen_percent_encoding_tables.c" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 0777b5216a..0ffcbe3df8 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -83303,6 +83303,576 @@ ], "uses_polling": false }, + { + "args": [ + "test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_decode_corpus/xyz" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_decode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/support/percent_encode_corpus/xyz" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "percent_encode_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, { "args": [ "test/core/end2end/fuzzers/server_fuzzer_corpus/01c008fa.bin" diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index 029219e1af..8f3546f7be 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -300,6 +300,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_legal_metadata_characte lib = "False" EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_percent_encoding_tables", "vcxproj\.\gen_percent_encoding_tables\gen_percent_encoding_tables.vcxproj", "{95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr", "vcxproj\.\gpr\gpr.vcxproj", "{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}" ProjectSection(myProperties) = preProject lib = "True" @@ -1907,6 +1912,22 @@ Global {A635DE99-B131-CA00-2D3B-8691D60B76C2}.Release-DLL|Win32.Build.0 = Release|Win32 {A635DE99-B131-CA00-2D3B-8691D60B76C2}.Release-DLL|x64.ActiveCfg = Release|x64 {A635DE99-B131-CA00-2D3B-8691D60B76C2}.Release-DLL|x64.Build.0 = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|Win32.ActiveCfg = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|x64.ActiveCfg = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|Win32.ActiveCfg = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|x64.ActiveCfg = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|Win32.Build.0 = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|x64.Build.0 = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|Win32.Build.0 = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|x64.Build.0 = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|x64.Build.0 = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|Win32.Build.0 = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|x64.ActiveCfg = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|x64.Build.0 = Release|x64 {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Debug|Win32.ActiveCfg = Debug|Win32 {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Debug|x64.ActiveCfg = Debug|x64 {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/vsprojects/grpc.sln b/vsprojects/grpc.sln index 84720914b0..e299f8e802 100644 --- a/vsprojects/grpc.sln +++ b/vsprojects/grpc.sln @@ -22,6 +22,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_legal_metadata_characte lib = "False" EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_percent_encoding_tables", "vcxproj\.\gen_percent_encoding_tables\gen_percent_encoding_tables.vcxproj", "{95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr", "vcxproj\.\gpr\gpr.vcxproj", "{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}" ProjectSection(myProperties) = preProject lib = "True" @@ -222,6 +227,22 @@ Global {A635DE99-B131-CA00-2D3B-8691D60B76C2}.Release-DLL|Win32.Build.0 = Release|Win32 {A635DE99-B131-CA00-2D3B-8691D60B76C2}.Release-DLL|x64.ActiveCfg = Release|x64 {A635DE99-B131-CA00-2D3B-8691D60B76C2}.Release-DLL|x64.Build.0 = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|Win32.ActiveCfg = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|x64.ActiveCfg = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|Win32.ActiveCfg = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|x64.ActiveCfg = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|Win32.Build.0 = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug|x64.Build.0 = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|Win32.Build.0 = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release|x64.Build.0 = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Debug-DLL|x64.Build.0 = Debug|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|Win32.Build.0 = Release|Win32 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|x64.ActiveCfg = Release|x64 + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5}.Release-DLL|x64.Build.0 = Release|x64 {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Debug|Win32.ActiveCfg = Debug|Win32 {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Debug|x64.ActiveCfg = Debug|x64 {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj b/vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj new file mode 100644 index 0000000000..446b4129d2 --- /dev/null +++ b/vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj @@ -0,0 +1,162 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {95D6E277-5ED9-EBDB-3DB8-19C610D2C6F5} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + gen_percent_encoding_tables + + + gen_percent_encoding_tables + + + + 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 + + + + + + + + + + + + + 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/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj.filters b/vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj.filters new file mode 100644 index 0000000000..a787887c88 --- /dev/null +++ b/vsprojects/vcxproj/gen_percent_encoding_tables/gen_percent_encoding_tables.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + tools\codegen\core + + + + + + {e587d5b5-125f-1c73-e004-3c5659aa666b} + + + {0e90891e-2dd7-433f-2e97-b8495275cc10} + + + {194d6b8d-bf65-b581-90a4-13447dbfa951} + + + + -- cgit v1.2.3 From f0efb491d8bc1df3e5d54533b3e641ee61268de6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 18 Aug 2016 11:25:38 -0700 Subject: Fix comments --- src/core/lib/support/percent_encoding.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/core/lib/support/percent_encoding.h b/src/core/lib/support/percent_encoding.h index 41f28d01f8..8259740678 100644 --- a/src/core/lib/support/percent_encoding.h +++ b/src/core/lib/support/percent_encoding.h @@ -41,11 +41,23 @@ extern const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8]; extern const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8]; +/* Percent-encode a slice, returning the new slice (this cannot fail): + unreserved_bytes is a bitfield indicating which bytes are considered + unreserved and thus do not need percent encoding */ gpr_slice gpr_percent_encode_slice(gpr_slice slice, const uint8_t *unreserved_bytes); +/* Percent-decode a slice, strictly. + If the input is legal (contains no unreserved bytes, and legal % encodings), + returns true and sets *slice_out to the decoded slice. + If the input is not legal, returns false and leaves *slice_out untouched. + unreserved_bytes is a bitfield indicating which bytes are considered + unreserved and thus do not need percent encoding */ bool gpr_strict_percent_decode_slice(gpr_slice slice_in, const uint8_t *unreserved_bytes, gpr_slice *slice_out); +/* Percent-decode a slice, permissively. + If a % triplet can not be decoded, pass it through verbatim. + This cannot fail. */ gpr_slice gpr_permissive_percent_decode_slice(gpr_slice slice_in); #endif /* PRECENT_H */ -- cgit v1.2.3 From 87879d2bbeb8113fcba1d1e2af980aa4ae68a525 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 18 Aug 2016 11:28:44 -0700 Subject: Fix comments --- src/core/lib/support/percent_encoding.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/core/lib/support/percent_encoding.h b/src/core/lib/support/percent_encoding.h index 8259740678..61d7b6d361 100644 --- a/src/core/lib/support/percent_encoding.h +++ b/src/core/lib/support/percent_encoding.h @@ -38,7 +38,15 @@ #include +/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in + gpr_percent_encode_slice, gpr_strict_percent_decode_slice). + Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines + */ extern const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8]; +/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in + gpr_percent_encode_slice, gpr_strict_percent_decode_slice). + Flags ascii7 non-control characters excluding '%' as unreserved bytes for the + percent encoding routines */ extern const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8]; /* Percent-encode a slice, returning the new slice (this cannot fail): -- cgit v1.2.3 From 47127507bee18ed701a4c6be7748f4f72d35117d Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 19 Aug 2016 22:32:24 +0200 Subject: Fixing loading precompiled Ruby extension on 2.x.10+ --- src/ruby/lib/grpc/grpc.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index b60a828d66..720e821619 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -28,7 +28,8 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. begin - require_relative "#{RUBY_VERSION.sub(/\.\d$/, '')}/grpc_c" + RUBY_VERSION =~ /(\d+\.\d+)/ + require "#{$1}/grpc_c" rescue LoadError require_relative 'grpc_c' end -- cgit v1.2.3 From 398dde49fc6358c3dc7461ea3a6d7a7fbf883d9e Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 19 Aug 2016 22:53:15 +0200 Subject: Restoring require_relative. --- src/ruby/lib/grpc/grpc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index 720e821619..eff84a47a6 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -29,7 +29,7 @@ begin RUBY_VERSION =~ /(\d+\.\d+)/ - require "#{$1}/grpc_c" + require_relative "#{$1}/grpc_c" rescue LoadError require_relative 'grpc_c' end -- cgit v1.2.3 From 8067d729473d2916ffad7d6dde939ca484a3d01b Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Fri, 19 Aug 2016 16:07:02 -0700 Subject: dont catch load error when loading grpc lib in grpc gem --- src/ruby/lib/grpc/grpc.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index eff84a47a6..71be174835 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -28,8 +28,12 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. begin - RUBY_VERSION =~ /(\d+\.\d+)/ - require_relative "#{$1}/grpc_c" -rescue LoadError - require_relative 'grpc_c' + ruby_version_dirname = /(\d+\.\d+)/.match(RUBY_VERSION) + distrib_lib_dir = File.expand_path("#{ruby_version_dirname}/grpc_c", + File.dirname(__FILE__)) + if File.directory?(distrib_lib_dir) + require_relative "#{distrib_lib_dir}/grpc_c" + else + require_relative 'grpc_c' + end end -- cgit v1.2.3 From 8dd21260be260ebbef6d6d1edc346789d877bd15 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Fri, 19 Aug 2016 18:35:35 -0700 Subject: fix directory check --- src/ruby/lib/grpc/grpc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index 71be174835..5f0c42ca2c 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -29,7 +29,7 @@ begin ruby_version_dirname = /(\d+\.\d+)/.match(RUBY_VERSION) - distrib_lib_dir = File.expand_path("#{ruby_version_dirname}/grpc_c", + distrib_lib_dir = File.expand_path(ruby_version_dirname, File.dirname(__FILE__)) if File.directory?(distrib_lib_dir) require_relative "#{distrib_lib_dir}/grpc_c" -- cgit v1.2.3 From 7a6e30e61c29eeab8c9cae6577d92ff59c1f64f6 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Sat, 20 Aug 2016 15:34:13 +0000 Subject: Python grpc.secure_channel doc string correction --- src/python/grpcio/grpc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 513839df7d..1cbe93cddd 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1193,7 +1193,7 @@ def insecure_channel(target, options=None): def secure_channel(target, credentials, options=None): - """Creates an insecure Channel to a server. + """Creates a secure Channel to a server. Args: target: The target to which to connect. -- cgit v1.2.3 From e61aab26511db51975649bddb6a63d871a5cbeb3 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Sat, 20 Aug 2016 09:40:03 -0700 Subject: convert match data to string --- src/ruby/lib/grpc/grpc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index 5f0c42ca2c..f46710dc74 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -28,7 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. begin - ruby_version_dirname = /(\d+\.\d+)/.match(RUBY_VERSION) + ruby_version_dirname = /(\d+\.\d+)/.match(RUBY_VERSION).to_s distrib_lib_dir = File.expand_path(ruby_version_dirname, File.dirname(__FILE__)) if File.directory?(distrib_lib_dir) -- cgit v1.2.3 From f57158be12adaba211d4371f5311a403b0c01d43 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 22 Aug 2016 08:41:24 -0700 Subject: Add explanations --- src/core/lib/support/percent_encoding.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/lib/support/percent_encoding.h b/src/core/lib/support/percent_encoding.h index 61d7b6d361..000bf14ede 100644 --- a/src/core/lib/support/percent_encoding.h +++ b/src/core/lib/support/percent_encoding.h @@ -31,8 +31,15 @@ * */ -#ifndef PRECENT_H -#define PRECENT_H +#ifndef GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H +#define GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H + +/* Percent encoding and decoding of slices. + Transforms arbitrary strings into safe-for-transmission strings by using + variants of percent encoding (RFC 3986). + Two major variants are supplied: one that strictly matches URL encoding, + and another which applies percent encoding only to non-http2 header + bytes (the 'compatible' variant) */ #include @@ -68,4 +75,4 @@ bool gpr_strict_percent_decode_slice(gpr_slice slice_in, This cannot fail. */ gpr_slice gpr_permissive_percent_decode_slice(gpr_slice slice_in); -#endif /* PRECENT_H */ +#endif /* GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H */ -- cgit v1.2.3 From 8749c96595f4f6a9a000f3e30a54ada0d1a9b1ae Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Mon, 22 Aug 2016 08:45:12 -0700 Subject: php: bump version --- examples/php/composer.json | 3 +-- package.xml | 38 ++++++++++++++++++++++++++++---- src/php/composer.json | 2 +- templates/package.xml.template | 34 ++++++++++++++++++++++++++-- templates/src/php/composer.json.template | 23 +++++++++++++++++++ tools/buildgen/plugins/expand_version.py | 17 +++++++++++--- 6 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 templates/src/php/composer.json.template (limited to 'src') diff --git a/examples/php/composer.json b/examples/php/composer.json index d40b5db059..97e9608fe0 100644 --- a/examples/php/composer.json +++ b/examples/php/composer.json @@ -1,8 +1,7 @@ { "name": "grpc/grpc-demo", "description": "gRPC example for PHP", - "minimum-stability": "dev", "require": { - "grpc/grpc": "v0.15.2" + "grpc/grpc": "v1.0.0", } } diff --git a/package.xml b/package.xml index 81aa5b2823..6e3aab7a76 100644 --- a/package.xml +++ b/package.xml @@ -10,11 +10,11 @@ grpc-packages@google.com yes - 2016-08-09 + 2016-08-22 - 1.0.1 - 1.0.1 + 1.0.1RC1 + 1.0.1RC1 stable @@ -22,7 +22,7 @@ BSD -- Fixed Ubuntu compile error #7571, #7642 +- TBD @@ -1146,5 +1146,35 @@ Update to wrap gRPC C Core version 0.10.0 - Fixed Ubuntu compile error #7571, #7642 + + + 1.0.0 + 1.0.0 + + + stable + stable + + 2016-08-18 + BSD + +- gRPC 1.0.0 release + + + + + 1.0.1RC1 + 1.0.1RC1 + + + stable + stable + + 2016-08-22 + BSD + +- TBD + + diff --git a/src/php/composer.json b/src/php/composer.json index 1eacc643a2..db56d2ce6e 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -5,7 +5,7 @@ "keywords": ["rpc"], "homepage": "http://grpc.io", "license": "BSD-3-Clause", - "version": "1.0.0", + "version": "1.0.1", "require": { "php": ">=5.5.0", "stanley-cheung/protobuf-php": "v0.6" diff --git a/templates/package.xml.template b/templates/package.xml.template index 43d3aa2a58..65fef1892f 100644 --- a/templates/package.xml.template +++ b/templates/package.xml.template @@ -12,7 +12,7 @@ grpc-packages@google.com yes - 2016-08-09 + 2016-08-22 ${settings.php_version.php()} @@ -24,7 +24,7 @@ BSD - - Fixed Ubuntu compile error #7571, #7642 + - TBD @@ -264,5 +264,35 @@ - Fixed Ubuntu compile error #7571, #7642 + + + 1.0.0 + 1.0.0 + + + stable + stable + + 2016-08-18 + BSD + + - gRPC 1.0.0 release + + + + + ${settings.php_version.php()} + ${settings.php_version.php()} + + + stable + stable + + 2016-08-22 + BSD + + - TBD + + diff --git a/templates/src/php/composer.json.template b/templates/src/php/composer.json.template new file mode 100644 index 0000000000..bf876f345e --- /dev/null +++ b/templates/src/php/composer.json.template @@ -0,0 +1,23 @@ +%YAML 1.2 +--- | + { + "name": "grpc/grpc", + "type": "library", + "description": "gRPC library for PHP", + "keywords": ["rpc"], + "homepage": "http://grpc.io", + "license": "BSD-3-Clause", + "version": "${settings.php_version.php_composer()}", + "require": { + "php": ">=5.5.0", + "stanley-cheung/protobuf-php": "v0.6" + }, + "require-dev": { + "google/auth": "v0.9" + }, + "autoload": { + "psr-4": { + "Grpc\\": "lib/Grpc/" + } + } + } diff --git a/tools/buildgen/plugins/expand_version.py b/tools/buildgen/plugins/expand_version.py index c6cc5621c9..6098cca59c 100755 --- a/tools/buildgen/plugins/expand_version.py +++ b/tools/buildgen/plugins/expand_version.py @@ -85,10 +85,21 @@ class Version: return '%d.%d.%d' % (self.major, self.minor, self.patch) def php(self): - """Version string in PHP style""" - """PECL does not allow tag in version string""" - return '%d.%d.%d' % (self.major, self.minor, self.patch) + """Version string for PHP PECL package""" + s = '%d.%d.%d' % (self.major, self.minor, self.patch) + if self.tag: + if self.tag == 'dev': + s += 'dev' + elif len(self.tag) >= 3 and self.tag[0:3] == 'pre': + s += 'RC%d' % int(self.tag[3:]) + else: + raise Exception('Don\'t know how to translate version tag "%s" to PECL version' % self.tag) + return s + def php_composer(self): + """Version string for PHP Composer package""" + return '%d.%d.%d' % (self.major, self.minor, self.patch) + def mako_plugin(dictionary): """Expand version numbers: - for each language, ensure there's a language_version tag in -- cgit v1.2.3 From f24a405551085c45d8c4fdbf12b0acdc650fa7c2 Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Mon, 22 Aug 2016 09:24:22 -0700 Subject: Remove unused imports in grpcio-tests --- src/python/grpcio_tests/setup.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/python/grpcio_tests/setup.py b/src/python/grpcio_tests/setup.py index 3524355cbf..7384206602 100644 --- a/src/python/grpcio_tests/setup.py +++ b/src/python/grpcio_tests/setup.py @@ -31,13 +31,9 @@ import os import os.path -import shutil import sys -from distutils import core as _core -from distutils import extension as _extension import setuptools -from setuptools.command import egg_info import grpc.tools.command -- cgit v1.2.3 From 102fa966b67c2aca6dbfb9ff4833505615adab0a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 22 Aug 2016 13:56:36 -0700 Subject: Rename some files to avoid conflicting .obj files on Windows --- BUILD | 28 +- CMakeLists.txt | 28 +- Makefile | 32 +- build.yaml | 16 +- src/cpp/client/channel.cc | 144 ----- src/cpp/client/channel_cc.cc | 144 +++++ src/cpp/client/credentials.cc | 48 -- src/cpp/client/credentials_cc.cc | 48 ++ src/cpp/common/completion_queue.cc | 74 --- src/cpp/common/completion_queue_cc.cc | 74 +++ src/cpp/server/server.cc | 633 --------------------- src/cpp/server/server_cc.cc | 633 +++++++++++++++++++++ src/cpp/util/byte_buffer.cc | 98 ---- src/cpp/util/byte_buffer_cc.cc | 98 ++++ src/cpp/util/slice.cc | 48 -- src/cpp/util/slice_cc.cc | 48 ++ src/cpp/util/time.cc | 95 ---- src/cpp/util/time_cc.cc | 95 ++++ test/cpp/util/test_config.cc | 52 -- test/cpp/util/test_config_cc.cc | 52 ++ tools/doxygen/Doxyfile.c++.internal | 14 +- .../run_tests/sanity/check_sources_and_headers.py | 5 +- tools/run_tests/sources_and_headers.json | 18 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 16 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 16 +- .../grpc++_test_config/grpc++_test_config.vcxproj | 2 +- .../grpc++_test_config.vcxproj.filters | 2 +- .../grpc++_unsecure/grpc++_unsecure.vcxproj | 16 +- .../grpc++_unsecure.vcxproj.filters | 16 +- 29 files changed, 1297 insertions(+), 1296 deletions(-) delete mode 100644 src/cpp/client/channel.cc create mode 100644 src/cpp/client/channel_cc.cc delete mode 100644 src/cpp/client/credentials.cc create mode 100644 src/cpp/client/credentials_cc.cc delete mode 100644 src/cpp/common/completion_queue.cc create mode 100644 src/cpp/common/completion_queue_cc.cc delete mode 100644 src/cpp/server/server.cc create mode 100644 src/cpp/server/server_cc.cc delete mode 100644 src/cpp/util/byte_buffer.cc create mode 100644 src/cpp/util/byte_buffer_cc.cc delete mode 100644 src/cpp/util/slice.cc create mode 100644 src/cpp/util/slice_cc.cc delete mode 100644 src/cpp/util/time.cc create mode 100644 src/cpp/util/time_cc.cc delete mode 100644 test/cpp/util/test_config.cc create mode 100644 test/cpp/util/test_config_cc.cc (limited to 'src') diff --git a/BUILD b/BUILD index 6e1289d8c0..385afc48d9 100644 --- a/BUILD +++ b/BUILD @@ -1320,32 +1320,32 @@ cc_library( "src/cpp/common/secure_channel_arguments.cc", "src/cpp/common/secure_create_auth_context.cc", "src/cpp/server/secure_server_credentials.cc", - "src/cpp/client/channel.cc", + "src/cpp/client/channel_cc.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", "src/cpp/client/create_channel_posix.cc", - "src/cpp/client/credentials.cc", + "src/cpp/client/credentials_cc.cc", "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/common/channel_arguments.cc", - "src/cpp/common/completion_queue.cc", + "src/cpp/common/completion_queue_cc.cc", "src/cpp/common/core_codegen.cc", "src/cpp/common/rpc_method.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.cc", "src/cpp/server/insecure_server_credentials.cc", - "src/cpp/server/server.cc", "src/cpp/server/server_builder.cc", + "src/cpp/server/server_cc.cc", "src/cpp/server/server_context.cc", "src/cpp/server/server_credentials.cc", "src/cpp/server/server_posix.cc", - "src/cpp/util/byte_buffer.cc", - "src/cpp/util/slice.cc", + "src/cpp/util/byte_buffer_cc.cc", + "src/cpp/util/slice_cc.cc", "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", - "src/cpp/util/time.cc", + "src/cpp/util/time_cc.cc", "src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_stack.c", "src/core/lib/channel/channel_stack_builder.c", @@ -1719,32 +1719,32 @@ cc_library( "src/core/lib/transport/transport.h", "src/core/lib/transport/transport_impl.h", "src/cpp/common/insecure_create_auth_context.cc", - "src/cpp/client/channel.cc", + "src/cpp/client/channel_cc.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", "src/cpp/client/create_channel_posix.cc", - "src/cpp/client/credentials.cc", + "src/cpp/client/credentials_cc.cc", "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/common/channel_arguments.cc", - "src/cpp/common/completion_queue.cc", + "src/cpp/common/completion_queue_cc.cc", "src/cpp/common/core_codegen.cc", "src/cpp/common/rpc_method.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.cc", "src/cpp/server/insecure_server_credentials.cc", - "src/cpp/server/server.cc", "src/cpp/server/server_builder.cc", + "src/cpp/server/server_cc.cc", "src/cpp/server/server_context.cc", "src/cpp/server/server_credentials.cc", "src/cpp/server/server_posix.cc", - "src/cpp/util/byte_buffer.cc", - "src/cpp/util/slice.cc", + "src/cpp/util/byte_buffer_cc.cc", + "src/cpp/util/slice_cc.cc", "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", - "src/cpp/util/time.cc", + "src/cpp/util/time_cc.cc", "src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_stack.c", "src/core/lib/channel/channel_stack_builder.c", diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e90720a5..0dbf3f67fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -699,32 +699,32 @@ add_library(grpc++ src/cpp/common/secure_channel_arguments.cc src/cpp/common/secure_create_auth_context.cc src/cpp/server/secure_server_credentials.cc - src/cpp/client/channel.cc + src/cpp/client/channel_cc.cc src/cpp/client/client_context.cc src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc - src/cpp/client/credentials.cc + src/cpp/client/credentials_cc.cc src/cpp/client/generic_stub.cc src/cpp/client/insecure_credentials.cc src/cpp/common/channel_arguments.cc - src/cpp/common/completion_queue.cc + src/cpp/common/completion_queue_cc.cc src/cpp/common/core_codegen.cc src/cpp/common/rpc_method.cc src/cpp/server/async_generic_service.cc src/cpp/server/create_default_thread_pool.cc src/cpp/server/dynamic_thread_pool.cc src/cpp/server/insecure_server_credentials.cc - src/cpp/server/server.cc src/cpp/server/server_builder.cc + src/cpp/server/server_cc.cc src/cpp/server/server_context.cc src/cpp/server/server_credentials.cc src/cpp/server/server_posix.cc - src/cpp/util/byte_buffer.cc - src/cpp/util/slice.cc + src/cpp/util/byte_buffer_cc.cc + src/cpp/util/slice_cc.cc src/cpp/util/status.cc src/cpp/util/string_ref.cc - src/cpp/util/time.cc + src/cpp/util/time_cc.cc src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -855,32 +855,32 @@ target_link_libraries(grpc++_reflection add_library(grpc++_unsecure src/cpp/common/insecure_create_auth_context.cc - src/cpp/client/channel.cc + src/cpp/client/channel_cc.cc src/cpp/client/client_context.cc src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc - src/cpp/client/credentials.cc + src/cpp/client/credentials_cc.cc src/cpp/client/generic_stub.cc src/cpp/client/insecure_credentials.cc src/cpp/common/channel_arguments.cc - src/cpp/common/completion_queue.cc + src/cpp/common/completion_queue_cc.cc src/cpp/common/core_codegen.cc src/cpp/common/rpc_method.cc src/cpp/server/async_generic_service.cc src/cpp/server/create_default_thread_pool.cc src/cpp/server/dynamic_thread_pool.cc src/cpp/server/insecure_server_credentials.cc - src/cpp/server/server.cc src/cpp/server/server_builder.cc + src/cpp/server/server_cc.cc src/cpp/server/server_context.cc src/cpp/server/server_credentials.cc src/cpp/server/server_posix.cc - src/cpp/util/byte_buffer.cc - src/cpp/util/slice.cc + src/cpp/util/byte_buffer_cc.cc + src/cpp/util/slice_cc.cc src/cpp/util/status.cc src/cpp/util/string_ref.cc - src/cpp/util/time.cc + src/cpp/util/time_cc.cc src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c diff --git a/Makefile b/Makefile index da53211281..e6c35328a9 100644 --- a/Makefile +++ b/Makefile @@ -3363,32 +3363,32 @@ LIBGRPC++_SRC = \ src/cpp/common/secure_channel_arguments.cc \ src/cpp/common/secure_create_auth_context.cc \ src/cpp/server/secure_server_credentials.cc \ - src/cpp/client/channel.cc \ + src/cpp/client/channel_cc.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_posix.cc \ - src/cpp/client/credentials.cc \ + src/cpp/client/credentials_cc.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/common/channel_arguments.cc \ - src/cpp/common/completion_queue.cc \ + src/cpp/common/completion_queue_cc.cc \ src/cpp/common/core_codegen.cc \ src/cpp/common/rpc_method.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ src/cpp/server/insecure_server_credentials.cc \ - src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ + src/cpp/server/server_cc.cc \ src/cpp/server/server_context.cc \ src/cpp/server/server_credentials.cc \ src/cpp/server/server_posix.cc \ - src/cpp/util/byte_buffer.cc \ - src/cpp/util/slice.cc \ + src/cpp/util/byte_buffer_cc.cc \ + src/cpp/util/slice_cc.cc \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ - src/cpp/util/time.cc \ + src/cpp/util/time_cc.cc \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3776,7 +3776,7 @@ endif LIBGRPC++_TEST_CONFIG_SRC = \ - test/cpp/util/test_config.cc \ + test/cpp/util/test_config_cc.cc \ PUBLIC_HEADERS_CXX += \ @@ -3944,32 +3944,32 @@ $(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/tes LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/insecure_create_auth_context.cc \ - src/cpp/client/channel.cc \ + src/cpp/client/channel_cc.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_posix.cc \ - src/cpp/client/credentials.cc \ + src/cpp/client/credentials_cc.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/common/channel_arguments.cc \ - src/cpp/common/completion_queue.cc \ + src/cpp/common/completion_queue_cc.cc \ src/cpp/common/core_codegen.cc \ src/cpp/common/rpc_method.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ src/cpp/server/insecure_server_credentials.cc \ - src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ + src/cpp/server/server_cc.cc \ src/cpp/server/server_context.cc \ src/cpp/server/server_credentials.cc \ src/cpp/server/server_posix.cc \ - src/cpp/util/byte_buffer.cc \ - src/cpp/util/slice.cc \ + src/cpp/util/byte_buffer_cc.cc \ + src/cpp/util/slice_cc.cc \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ - src/cpp/util/time.cc \ + src/cpp/util/time_cc.cc \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -15050,7 +15050,7 @@ test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) test/cpp/util/proto_file_parser.cc: $(OPENSSL_DEP) test/cpp/util/string_ref_helper.cc: $(OPENSSL_DEP) test/cpp/util/subprocess.cc: $(OPENSSL_DEP) -test/cpp/util/test_config.cc: $(OPENSSL_DEP) +test/cpp/util/test_config_cc.cc: $(OPENSSL_DEP) test/cpp/util/test_credentials_provider.cc: $(OPENSSL_DEP) endif diff --git a/build.yaml b/build.yaml index 8377c65545..63933c67d9 100644 --- a/build.yaml +++ b/build.yaml @@ -686,32 +686,32 @@ filegroups: - src/cpp/server/dynamic_thread_pool.h - src/cpp/server/thread_pool_interface.h src: - - src/cpp/client/channel.cc + - src/cpp/client/channel_cc.cc - src/cpp/client/client_context.cc - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc - - src/cpp/client/credentials.cc + - src/cpp/client/credentials_cc.cc - src/cpp/client/generic_stub.cc - src/cpp/client/insecure_credentials.cc - src/cpp/common/channel_arguments.cc - - src/cpp/common/completion_queue.cc + - src/cpp/common/completion_queue_cc.cc - src/cpp/common/core_codegen.cc - src/cpp/common/rpc_method.cc - src/cpp/server/async_generic_service.cc - src/cpp/server/create_default_thread_pool.cc - src/cpp/server/dynamic_thread_pool.cc - src/cpp/server/insecure_server_credentials.cc - - src/cpp/server/server.cc - src/cpp/server/server_builder.cc + - src/cpp/server/server_cc.cc - src/cpp/server/server_context.cc - src/cpp/server/server_credentials.cc - src/cpp/server/server_posix.cc - - src/cpp/util/byte_buffer.cc - - src/cpp/util/slice.cc + - src/cpp/util/byte_buffer_cc.cc + - src/cpp/util/slice_cc.cc - src/cpp/util/status.cc - src/cpp/util/string_ref.cc - - src/cpp/util/time.cc + - src/cpp/util/time_cc.cc uses: - grpc_base - grpc++_codegen_base @@ -978,7 +978,7 @@ libs: headers: - test/cpp/util/test_config.h src: - - test/cpp/util/test_config.cc + - test/cpp/util/test_config_cc.cc - name: grpc++_test_util build: private language: c++ diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc deleted file mode 100644 index 43b3875cb3..0000000000 --- a/src/cpp/client/channel.cc +++ /dev/null @@ -1,144 +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 - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/core/lib/profiling/timers.h" - -namespace grpc { - -static internal::GrpcLibraryInitializer g_gli_initializer; -Channel::Channel(const grpc::string& host, grpc_channel* channel) - : host_(host), c_channel_(channel) { - g_gli_initializer.summon(); -} - -Channel::~Channel() { grpc_channel_destroy(c_channel_); } - -Call Channel::CreateCall(const RpcMethod& method, ClientContext* context, - CompletionQueue* cq) { - const bool kRegistered = method.channel_tag() && context->authority().empty(); - grpc_call* c_call = NULL; - if (kRegistered) { - c_call = grpc_channel_create_registered_call( - c_channel_, context->propagate_from_call_, - context->propagation_options_.c_bitmask(), cq->cq(), - method.channel_tag(), context->raw_deadline(), nullptr); - } else { - const char* host_str = NULL; - if (!context->authority().empty()) { - host_str = context->authority_.c_str(); - } else if (!host_.empty()) { - host_str = host_.c_str(); - } - c_call = grpc_channel_create_call(c_channel_, context->propagate_from_call_, - context->propagation_options_.c_bitmask(), - cq->cq(), method.name(), host_str, - context->raw_deadline(), nullptr); - } - grpc_census_call_set_context(c_call, context->census_context()); - context->set_call(c_call, shared_from_this()); - return Call(c_call, this, cq); -} - -void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) { - static const size_t MAX_OPS = 8; - size_t nops = 0; - grpc_op cops[MAX_OPS]; - ops->FillOps(cops, &nops); - GPR_ASSERT(GRPC_CALL_OK == - grpc_call_start_batch(call->call(), cops, nops, ops, nullptr)); -} - -void* Channel::RegisterMethod(const char* method) { - return grpc_channel_register_call( - c_channel_, method, host_.empty() ? NULL : host_.c_str(), nullptr); -} - -grpc_connectivity_state Channel::GetState(bool try_to_connect) { - return grpc_channel_check_connectivity_state(c_channel_, try_to_connect); -} - -namespace { -class TagSaver GRPC_FINAL : public CompletionQueueTag { - public: - explicit TagSaver(void* tag) : tag_(tag) {} - ~TagSaver() GRPC_OVERRIDE {} - bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { - *tag = tag_; - delete this; - return true; - } - - private: - void* tag_; -}; - -} // namespace - -void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, - CompletionQueue* cq, void* tag) { - TagSaver* tag_saver = new TagSaver(tag); - grpc_channel_watch_connectivity_state(c_channel_, last_observed, deadline, - cq->cq(), tag_saver); -} - -bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline) { - CompletionQueue cq; - bool ok = false; - void* tag = NULL; - NotifyOnStateChangeImpl(last_observed, deadline, &cq, NULL); - cq.Next(&tag, &ok); - GPR_ASSERT(tag == NULL); - return ok; -} - -} // namespace grpc diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc new file mode 100644 index 0000000000..43b3875cb3 --- /dev/null +++ b/src/cpp/client/channel_cc.cc @@ -0,0 +1,144 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/core/lib/profiling/timers.h" + +namespace grpc { + +static internal::GrpcLibraryInitializer g_gli_initializer; +Channel::Channel(const grpc::string& host, grpc_channel* channel) + : host_(host), c_channel_(channel) { + g_gli_initializer.summon(); +} + +Channel::~Channel() { grpc_channel_destroy(c_channel_); } + +Call Channel::CreateCall(const RpcMethod& method, ClientContext* context, + CompletionQueue* cq) { + const bool kRegistered = method.channel_tag() && context->authority().empty(); + grpc_call* c_call = NULL; + if (kRegistered) { + c_call = grpc_channel_create_registered_call( + c_channel_, context->propagate_from_call_, + context->propagation_options_.c_bitmask(), cq->cq(), + method.channel_tag(), context->raw_deadline(), nullptr); + } else { + const char* host_str = NULL; + if (!context->authority().empty()) { + host_str = context->authority_.c_str(); + } else if (!host_.empty()) { + host_str = host_.c_str(); + } + c_call = grpc_channel_create_call(c_channel_, context->propagate_from_call_, + context->propagation_options_.c_bitmask(), + cq->cq(), method.name(), host_str, + context->raw_deadline(), nullptr); + } + grpc_census_call_set_context(c_call, context->census_context()); + context->set_call(c_call, shared_from_this()); + return Call(c_call, this, cq); +} + +void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) { + static const size_t MAX_OPS = 8; + size_t nops = 0; + grpc_op cops[MAX_OPS]; + ops->FillOps(cops, &nops); + GPR_ASSERT(GRPC_CALL_OK == + grpc_call_start_batch(call->call(), cops, nops, ops, nullptr)); +} + +void* Channel::RegisterMethod(const char* method) { + return grpc_channel_register_call( + c_channel_, method, host_.empty() ? NULL : host_.c_str(), nullptr); +} + +grpc_connectivity_state Channel::GetState(bool try_to_connect) { + return grpc_channel_check_connectivity_state(c_channel_, try_to_connect); +} + +namespace { +class TagSaver GRPC_FINAL : public CompletionQueueTag { + public: + explicit TagSaver(void* tag) : tag_(tag) {} + ~TagSaver() GRPC_OVERRIDE {} + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { + *tag = tag_; + delete this; + return true; + } + + private: + void* tag_; +}; + +} // namespace + +void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + CompletionQueue* cq, void* tag) { + TagSaver* tag_saver = new TagSaver(tag); + grpc_channel_watch_connectivity_state(c_channel_, last_observed, deadline, + cq->cq(), tag_saver); +} + +bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) { + CompletionQueue cq; + bool ok = false; + void* tag = NULL; + NotifyOnStateChangeImpl(last_observed, deadline, &cq, NULL); + cq.Next(&tag, &ok); + GPR_ASSERT(tag == NULL); + return ok; +} + +} // namespace grpc diff --git a/src/cpp/client/credentials.cc b/src/cpp/client/credentials.cc deleted file mode 100644 index e6a4f81b0d..0000000000 --- a/src/cpp/client/credentials.cc +++ /dev/null @@ -1,48 +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 -#include - -namespace grpc { - -static internal::GrpcLibraryInitializer g_gli_initializer; -ChannelCredentials::ChannelCredentials() { g_gli_initializer.summon(); } - -ChannelCredentials::~ChannelCredentials() {} - -CallCredentials::CallCredentials() { g_gli_initializer.summon(); } - -CallCredentials::~CallCredentials() {} - -} // namespace grpc diff --git a/src/cpp/client/credentials_cc.cc b/src/cpp/client/credentials_cc.cc new file mode 100644 index 0000000000..e6a4f81b0d --- /dev/null +++ b/src/cpp/client/credentials_cc.cc @@ -0,0 +1,48 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +namespace grpc { + +static internal::GrpcLibraryInitializer g_gli_initializer; +ChannelCredentials::ChannelCredentials() { g_gli_initializer.summon(); } + +ChannelCredentials::~ChannelCredentials() {} + +CallCredentials::CallCredentials() { g_gli_initializer.summon(); } + +CallCredentials::~CallCredentials() {} + +} // namespace grpc diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc deleted file mode 100644 index 00cc102f92..0000000000 --- a/src/cpp/common/completion_queue.cc +++ /dev/null @@ -1,74 +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 - -#include - -#include -#include -#include -#include - -namespace grpc { - -static internal::GrpcLibraryInitializer g_gli_initializer; - -CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) {} - -void CompletionQueue::Shutdown() { - g_gli_initializer.summon(); - grpc_completion_queue_shutdown(cq_); -} - -CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( - void** tag, bool* ok, gpr_timespec deadline) { - for (;;) { - auto ev = grpc_completion_queue_next(cq_, deadline, nullptr); - switch (ev.type) { - case GRPC_QUEUE_TIMEOUT: - return TIMEOUT; - case GRPC_QUEUE_SHUTDOWN: - return SHUTDOWN; - case GRPC_OP_COMPLETE: - auto cq_tag = static_cast(ev.tag); - *ok = ev.success != 0; - *tag = cq_tag; - if (cq_tag->FinalizeResult(tag, ok)) { - return GOT_EVENT; - } - break; - } - } -} - -} // namespace grpc diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc new file mode 100644 index 0000000000..00cc102f92 --- /dev/null +++ b/src/cpp/common/completion_queue_cc.cc @@ -0,0 +1,74 @@ +/* + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +#include +#include +#include +#include + +namespace grpc { + +static internal::GrpcLibraryInitializer g_gli_initializer; + +CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) {} + +void CompletionQueue::Shutdown() { + g_gli_initializer.summon(); + grpc_completion_queue_shutdown(cq_); +} + +CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( + void** tag, bool* ok, gpr_timespec deadline) { + for (;;) { + auto ev = grpc_completion_queue_next(cq_, deadline, nullptr); + switch (ev.type) { + case GRPC_QUEUE_TIMEOUT: + return TIMEOUT; + case GRPC_QUEUE_SHUTDOWN: + return SHUTDOWN; + case GRPC_OP_COMPLETE: + auto cq_tag = static_cast(ev.tag); + *ok = ev.success != 0; + *tag = cq_tag; + if (cq_tag->FinalizeResult(tag, ok)) { + return GOT_EVENT; + } + break; + } + } +} + +} // namespace grpc diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc deleted file mode 100644 index af04fd4ca6..0000000000 --- a/src/cpp/server/server.cc +++ /dev/null @@ -1,633 +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 - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "src/core/lib/profiling/timers.h" -#include "src/cpp/server/thread_pool_interface.h" - -namespace grpc { - -class DefaultGlobalCallbacks GRPC_FINAL : public Server::GlobalCallbacks { - public: - ~DefaultGlobalCallbacks() GRPC_OVERRIDE {} - void PreSynchronousRequest(ServerContext* context) GRPC_OVERRIDE {} - void PostSynchronousRequest(ServerContext* context) GRPC_OVERRIDE {} -}; - -static std::shared_ptr g_callbacks = nullptr; -static gpr_once g_once_init_callbacks = GPR_ONCE_INIT; - -static void InitGlobalCallbacks() { - if (!g_callbacks) { - g_callbacks.reset(new DefaultGlobalCallbacks()); - } -} - -class Server::UnimplementedAsyncRequestContext { - protected: - UnimplementedAsyncRequestContext() : generic_stream_(&server_context_) {} - - GenericServerContext server_context_; - GenericServerAsyncReaderWriter generic_stream_; -}; - -class Server::UnimplementedAsyncRequest GRPC_FINAL - : public UnimplementedAsyncRequestContext, - public GenericAsyncRequest { - public: - UnimplementedAsyncRequest(Server* server, ServerCompletionQueue* cq) - : GenericAsyncRequest(server, &server_context_, &generic_stream_, cq, cq, - NULL, false), - server_(server), - cq_(cq) {} - - bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; - - ServerContext* context() { return &server_context_; } - GenericServerAsyncReaderWriter* stream() { return &generic_stream_; } - - private: - Server* const server_; - ServerCompletionQueue* const cq_; -}; - -typedef SneakyCallOpSet - UnimplementedAsyncResponseOp; -class Server::UnimplementedAsyncResponse GRPC_FINAL - : public UnimplementedAsyncResponseOp { - public: - UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); - ~UnimplementedAsyncResponse() { delete request_; } - - bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { - bool r = UnimplementedAsyncResponseOp::FinalizeResult(tag, status); - delete this; - return r; - } - - private: - UnimplementedAsyncRequest* const request_; -}; - -class Server::ShutdownRequest GRPC_FINAL : public CompletionQueueTag { - public: - bool FinalizeResult(void** tag, bool* status) { - delete this; - return false; - } -}; - -class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { - public: - SyncRequest(RpcServiceMethod* method, void* tag) - : method_(method), - tag_(tag), - in_flight_(false), - has_request_payload_(method->method_type() == RpcMethod::NORMAL_RPC || - method->method_type() == - RpcMethod::SERVER_STREAMING), - call_details_(nullptr), - cq_(nullptr) { - grpc_metadata_array_init(&request_metadata_); - } - - ~SyncRequest() { - if (call_details_) { - delete call_details_; - } - grpc_metadata_array_destroy(&request_metadata_); - } - - static SyncRequest* Wait(CompletionQueue* cq, bool* ok) { - void* tag = nullptr; - *ok = false; - if (!cq->Next(&tag, ok)) { - return nullptr; - } - auto* mrd = static_cast(tag); - GPR_ASSERT(mrd->in_flight_); - return mrd; - } - - static bool AsyncWait(CompletionQueue* cq, SyncRequest** req, bool* ok, - gpr_timespec deadline) { - void* tag = nullptr; - *ok = false; - switch (cq->AsyncNext(&tag, ok, deadline)) { - case CompletionQueue::TIMEOUT: - *req = nullptr; - return true; - case CompletionQueue::SHUTDOWN: - *req = nullptr; - return false; - case CompletionQueue::GOT_EVENT: - *req = static_cast(tag); - GPR_ASSERT((*req)->in_flight_); - return true; - } - GPR_UNREACHABLE_CODE(return false); - } - - void SetupRequest() { cq_ = grpc_completion_queue_create(nullptr); } - - void TeardownRequest() { - grpc_completion_queue_destroy(cq_); - cq_ = nullptr; - } - - void Request(grpc_server* server, grpc_completion_queue* notify_cq) { - GPR_ASSERT(cq_ && !in_flight_); - in_flight_ = true; - if (tag_) { - GPR_ASSERT(GRPC_CALL_OK == - grpc_server_request_registered_call( - server, tag_, &call_, &deadline_, &request_metadata_, - has_request_payload_ ? &request_payload_ : nullptr, cq_, - notify_cq, this)); - } else { - if (!call_details_) { - call_details_ = new grpc_call_details; - grpc_call_details_init(call_details_); - } - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( - server, &call_, call_details_, - &request_metadata_, cq_, notify_cq, this)); - } - } - - bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { - if (!*status) { - grpc_completion_queue_destroy(cq_); - } - if (call_details_) { - deadline_ = call_details_->deadline; - grpc_call_details_destroy(call_details_); - grpc_call_details_init(call_details_); - } - return true; - } - - class CallData GRPC_FINAL { - public: - explicit CallData(Server* server, SyncRequest* mrd) - : cq_(mrd->cq_), - call_(mrd->call_, server, &cq_, server->max_message_size_), - ctx_(mrd->deadline_, mrd->request_metadata_.metadata, - mrd->request_metadata_.count), - has_request_payload_(mrd->has_request_payload_), - request_payload_(mrd->request_payload_), - method_(mrd->method_) { - ctx_.set_call(mrd->call_); - ctx_.cq_ = &cq_; - GPR_ASSERT(mrd->in_flight_); - mrd->in_flight_ = false; - mrd->request_metadata_.count = 0; - } - - ~CallData() { - if (has_request_payload_ && request_payload_) { - grpc_byte_buffer_destroy(request_payload_); - } - } - - void Run(std::shared_ptr global_callbacks) { - ctx_.BeginCompletionOp(&call_); - global_callbacks->PreSynchronousRequest(&ctx_); - method_->handler()->RunHandler(MethodHandler::HandlerParameter( - &call_, &ctx_, request_payload_, call_.max_message_size())); - global_callbacks->PostSynchronousRequest(&ctx_); - request_payload_ = nullptr; - void* ignored_tag; - bool ignored_ok; - cq_.Shutdown(); - GPR_ASSERT(cq_.Next(&ignored_tag, &ignored_ok) == false); - } - - private: - CompletionQueue cq_; - Call call_; - ServerContext ctx_; - const bool has_request_payload_; - grpc_byte_buffer* request_payload_; - RpcServiceMethod* const method_; - }; - - private: - RpcServiceMethod* const method_; - void* const tag_; - bool in_flight_; - const bool has_request_payload_; - uint32_t incoming_flags_; - grpc_call* call_; - grpc_call_details* call_details_; - gpr_timespec deadline_; - grpc_metadata_array request_metadata_; - grpc_byte_buffer* request_payload_; - grpc_completion_queue* cq_; -}; - -static internal::GrpcLibraryInitializer g_gli_initializer; -Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, - int max_message_size, ChannelArguments* args) - : max_message_size_(max_message_size), - started_(false), - shutdown_(false), - shutdown_notified_(false), - num_running_cb_(0), - sync_methods_(new std::list), - has_generic_service_(false), - server_(nullptr), - thread_pool_(thread_pool), - thread_pool_owned_(thread_pool_owned), - server_initializer_(new ServerInitializer(this)) { - g_gli_initializer.summon(); - gpr_once_init(&g_once_init_callbacks, InitGlobalCallbacks); - global_callbacks_ = g_callbacks; - global_callbacks_->UpdateArguments(args); - grpc_channel_args channel_args; - args->SetChannelArgs(&channel_args); - server_ = grpc_server_create(&channel_args, nullptr); - if (thread_pool_ == nullptr) { - grpc_server_register_non_listening_completion_queue(server_, cq_.cq(), - nullptr); - } else { - grpc_server_register_completion_queue(server_, cq_.cq(), nullptr); - } -} - -Server::~Server() { - { - grpc::unique_lock lock(mu_); - if (started_ && !shutdown_) { - lock.unlock(); - Shutdown(); - } else if (!started_) { - cq_.Shutdown(); - } - } - void* got_tag; - bool ok; - GPR_ASSERT(!cq_.Next(&got_tag, &ok)); - grpc_server_destroy(server_); - if (thread_pool_owned_) { - delete thread_pool_; - } - delete sync_methods_; -} - -void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) { - GPR_ASSERT(!g_callbacks); - GPR_ASSERT(callbacks); - g_callbacks.reset(callbacks); -} - -grpc_server* Server::c_server() { return server_; } - -CompletionQueue* Server::completion_queue() { return &cq_; } - -static grpc_server_register_method_payload_handling PayloadHandlingForMethod( - RpcServiceMethod* method) { - switch (method->method_type()) { - case RpcMethod::NORMAL_RPC: - case RpcMethod::SERVER_STREAMING: - return GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER; - case RpcMethod::CLIENT_STREAMING: - case RpcMethod::BIDI_STREAMING: - return GRPC_SRM_PAYLOAD_NONE; - } - GPR_UNREACHABLE_CODE(return GRPC_SRM_PAYLOAD_NONE;); -} - -bool Server::RegisterService(const grpc::string* host, Service* service) { - bool has_async_methods = service->has_async_methods(); - if (has_async_methods) { - GPR_ASSERT(service->server_ == nullptr && - "Can only register an asynchronous service against one server."); - service->server_ = this; - } - const char* method_name = nullptr; - for (auto it = service->methods_.begin(); it != service->methods_.end(); - ++it) { - if (it->get() == nullptr) { // Handled by generic service if any. - continue; - } - RpcServiceMethod* method = it->get(); - void* tag = grpc_server_register_method( - server_, method->name(), host ? host->c_str() : nullptr, - PayloadHandlingForMethod(method), 0); - if (tag == nullptr) { - gpr_log(GPR_DEBUG, "Attempt to register %s multiple times", - method->name()); - return false; - } - if (method->handler() == nullptr) { - method->set_server_tag(tag); - } else { - sync_methods_->emplace_back(method, tag); - } - method_name = method->name(); - } - - // Parse service name. - if (method_name != nullptr) { - std::stringstream ss(method_name); - grpc::string service_name; - if (std::getline(ss, service_name, '/') && - std::getline(ss, service_name, '/')) { - services_.push_back(service_name); - } - } - return true; -} - -void Server::RegisterAsyncGenericService(AsyncGenericService* service) { - GPR_ASSERT(service->server_ == nullptr && - "Can only register an async generic service against one server."); - service->server_ = this; - has_generic_service_ = true; -} - -int Server::AddListeningPort(const grpc::string& addr, - ServerCredentials* creds) { - GPR_ASSERT(!started_); - return creds->AddPortToServer(addr, server_); -} - -bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { - GPR_ASSERT(!started_); - started_ = true; - grpc_server_start(server_); - - if (!has_generic_service_) { - if (!sync_methods_->empty()) { - unknown_method_.reset(new RpcServiceMethod( - "unknown", RpcMethod::BIDI_STREAMING, new UnknownMethodHandler)); - // Use of emplace_back with just constructor arguments is not accepted - // here by gcc-4.4 because it can't match the anonymous nullptr with a - // proper constructor implicitly. Construct the object and use push_back. - sync_methods_->push_back(SyncRequest(unknown_method_.get(), nullptr)); - } - for (size_t i = 0; i < num_cqs; i++) { - if (cqs[i]->IsFrequentlyPolled()) { - new UnimplementedAsyncRequest(this, cqs[i]); - } - } - } - // Start processing rpcs. - if (!sync_methods_->empty()) { - for (auto m = sync_methods_->begin(); m != sync_methods_->end(); m++) { - m->SetupRequest(); - m->Request(server_, cq_.cq()); - } - - ScheduleCallback(); - } - - return true; -} - -void Server::ShutdownInternal(gpr_timespec deadline) { - grpc::unique_lock lock(mu_); - if (started_ && !shutdown_) { - shutdown_ = true; - grpc_server_shutdown_and_notify(server_, cq_.cq(), new ShutdownRequest()); - cq_.Shutdown(); - lock.unlock(); - // Spin, eating requests until the completion queue is completely shutdown. - // If the deadline expires then cancel anything that's pending and keep - // spinning forever until the work is actually drained. - // Since nothing else needs to touch state guarded by mu_, holding it - // through this loop is fine. - SyncRequest* request; - bool ok; - while (SyncRequest::AsyncWait(&cq_, &request, &ok, deadline)) { - if (request == NULL) { // deadline expired - grpc_server_cancel_all_calls(server_); - deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - } else if (ok) { - SyncRequest::CallData call_data(this, request); - } - } - lock.lock(); - - // Wait for running callbacks to finish. - while (num_running_cb_ != 0) { - callback_cv_.wait(lock); - } - - shutdown_notified_ = true; - shutdown_cv_.notify_all(); - } -} - -void Server::Wait() { - grpc::unique_lock lock(mu_); - while (started_ && !shutdown_notified_) { - shutdown_cv_.wait(lock); - } -} - -void Server::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) { - static const size_t MAX_OPS = 8; - size_t nops = 0; - grpc_op cops[MAX_OPS]; - ops->FillOps(cops, &nops); - auto result = grpc_call_start_batch(call->call(), cops, nops, ops, nullptr); - GPR_ASSERT(GRPC_CALL_OK == result); -} - -ServerInterface::BaseAsyncRequest::BaseAsyncRequest( - ServerInterface* server, ServerContext* context, - ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag, - bool delete_on_finalize) - : server_(server), - context_(context), - stream_(stream), - call_cq_(call_cq), - tag_(tag), - delete_on_finalize_(delete_on_finalize), - call_(nullptr) { - memset(&initial_metadata_array_, 0, sizeof(initial_metadata_array_)); -} - -bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag, - bool* status) { - if (*status) { - for (size_t i = 0; i < initial_metadata_array_.count; i++) { - context_->client_metadata_.insert( - std::pair( - initial_metadata_array_.metadata[i].key, - grpc::string_ref( - initial_metadata_array_.metadata[i].value, - initial_metadata_array_.metadata[i].value_length))); - } - } - grpc_metadata_array_destroy(&initial_metadata_array_); - context_->set_call(call_); - context_->cq_ = call_cq_; - Call call(call_, server_, call_cq_, server_->max_message_size()); - if (*status && call_) { - context_->BeginCompletionOp(&call); - } - // just the pointers inside call are copied here - stream_->BindCall(&call); - *tag = tag_; - if (delete_on_finalize_) { - delete this; - } - return true; -} - -ServerInterface::RegisteredAsyncRequest::RegisteredAsyncRequest( - ServerInterface* server, ServerContext* context, - ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag) - : BaseAsyncRequest(server, context, stream, call_cq, tag, true) {} - -void ServerInterface::RegisteredAsyncRequest::IssueRequest( - void* registered_method, grpc_byte_buffer** payload, - ServerCompletionQueue* notification_cq) { - grpc_server_request_registered_call( - server_->server(), registered_method, &call_, &context_->deadline_, - &initial_metadata_array_, payload, call_cq_->cq(), notification_cq->cq(), - this); -} - -ServerInterface::GenericAsyncRequest::GenericAsyncRequest( - ServerInterface* server, GenericServerContext* context, - ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag, bool delete_on_finalize) - : BaseAsyncRequest(server, context, stream, call_cq, tag, - delete_on_finalize) { - grpc_call_details_init(&call_details_); - GPR_ASSERT(notification_cq); - GPR_ASSERT(call_cq); - grpc_server_request_call(server->server(), &call_, &call_details_, - &initial_metadata_array_, call_cq->cq(), - notification_cq->cq(), this); -} - -bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, - bool* status) { - // TODO(yangg) remove the copy here. - if (*status) { - static_cast(context_)->method_ = - call_details_.method; - static_cast(context_)->host_ = call_details_.host; - } - gpr_free(call_details_.method); - gpr_free(call_details_.host); - return BaseAsyncRequest::FinalizeResult(tag, status); -} - -bool Server::UnimplementedAsyncRequest::FinalizeResult(void** tag, - bool* status) { - if (GenericAsyncRequest::FinalizeResult(tag, status) && *status) { - new UnimplementedAsyncRequest(server_, cq_); - new UnimplementedAsyncResponse(this); - } else { - delete this; - } - return false; -} - -Server::UnimplementedAsyncResponse::UnimplementedAsyncResponse( - UnimplementedAsyncRequest* request) - : request_(request) { - Status status(StatusCode::UNIMPLEMENTED, ""); - UnknownMethodHandler::FillOps(request_->context(), this); - request_->stream()->call_.PerformOps(this); -} - -void Server::ScheduleCallback() { - { - grpc::unique_lock lock(mu_); - num_running_cb_++; - } - thread_pool_->Add(std::bind(&Server::RunRpc, this)); -} - -void Server::RunRpc() { - // Wait for one more incoming rpc. - bool ok; - GPR_TIMER_SCOPE("Server::RunRpc", 0); - auto* mrd = SyncRequest::Wait(&cq_, &ok); - if (mrd) { - ScheduleCallback(); - if (ok) { - SyncRequest::CallData cd(this, mrd); - { - mrd->SetupRequest(); - grpc::unique_lock lock(mu_); - if (!shutdown_) { - mrd->Request(server_, cq_.cq()); - } else { - // destroy the structure that was created - mrd->TeardownRequest(); - } - } - GPR_TIMER_SCOPE("cd.Run()", 0); - cd.Run(global_callbacks_); - } - } - - { - grpc::unique_lock lock(mu_); - num_running_cb_--; - if (shutdown_) { - callback_cv_.notify_all(); - } - } -} - -ServerInitializer* Server::initializer() { return server_initializer_.get(); } - -} // namespace grpc diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc new file mode 100644 index 0000000000..af04fd4ca6 --- /dev/null +++ b/src/cpp/server/server_cc.cc @@ -0,0 +1,633 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/core/lib/profiling/timers.h" +#include "src/cpp/server/thread_pool_interface.h" + +namespace grpc { + +class DefaultGlobalCallbacks GRPC_FINAL : public Server::GlobalCallbacks { + public: + ~DefaultGlobalCallbacks() GRPC_OVERRIDE {} + void PreSynchronousRequest(ServerContext* context) GRPC_OVERRIDE {} + void PostSynchronousRequest(ServerContext* context) GRPC_OVERRIDE {} +}; + +static std::shared_ptr g_callbacks = nullptr; +static gpr_once g_once_init_callbacks = GPR_ONCE_INIT; + +static void InitGlobalCallbacks() { + if (!g_callbacks) { + g_callbacks.reset(new DefaultGlobalCallbacks()); + } +} + +class Server::UnimplementedAsyncRequestContext { + protected: + UnimplementedAsyncRequestContext() : generic_stream_(&server_context_) {} + + GenericServerContext server_context_; + GenericServerAsyncReaderWriter generic_stream_; +}; + +class Server::UnimplementedAsyncRequest GRPC_FINAL + : public UnimplementedAsyncRequestContext, + public GenericAsyncRequest { + public: + UnimplementedAsyncRequest(Server* server, ServerCompletionQueue* cq) + : GenericAsyncRequest(server, &server_context_, &generic_stream_, cq, cq, + NULL, false), + server_(server), + cq_(cq) {} + + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; + + ServerContext* context() { return &server_context_; } + GenericServerAsyncReaderWriter* stream() { return &generic_stream_; } + + private: + Server* const server_; + ServerCompletionQueue* const cq_; +}; + +typedef SneakyCallOpSet + UnimplementedAsyncResponseOp; +class Server::UnimplementedAsyncResponse GRPC_FINAL + : public UnimplementedAsyncResponseOp { + public: + UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); + ~UnimplementedAsyncResponse() { delete request_; } + + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { + bool r = UnimplementedAsyncResponseOp::FinalizeResult(tag, status); + delete this; + return r; + } + + private: + UnimplementedAsyncRequest* const request_; +}; + +class Server::ShutdownRequest GRPC_FINAL : public CompletionQueueTag { + public: + bool FinalizeResult(void** tag, bool* status) { + delete this; + return false; + } +}; + +class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { + public: + SyncRequest(RpcServiceMethod* method, void* tag) + : method_(method), + tag_(tag), + in_flight_(false), + has_request_payload_(method->method_type() == RpcMethod::NORMAL_RPC || + method->method_type() == + RpcMethod::SERVER_STREAMING), + call_details_(nullptr), + cq_(nullptr) { + grpc_metadata_array_init(&request_metadata_); + } + + ~SyncRequest() { + if (call_details_) { + delete call_details_; + } + grpc_metadata_array_destroy(&request_metadata_); + } + + static SyncRequest* Wait(CompletionQueue* cq, bool* ok) { + void* tag = nullptr; + *ok = false; + if (!cq->Next(&tag, ok)) { + return nullptr; + } + auto* mrd = static_cast(tag); + GPR_ASSERT(mrd->in_flight_); + return mrd; + } + + static bool AsyncWait(CompletionQueue* cq, SyncRequest** req, bool* ok, + gpr_timespec deadline) { + void* tag = nullptr; + *ok = false; + switch (cq->AsyncNext(&tag, ok, deadline)) { + case CompletionQueue::TIMEOUT: + *req = nullptr; + return true; + case CompletionQueue::SHUTDOWN: + *req = nullptr; + return false; + case CompletionQueue::GOT_EVENT: + *req = static_cast(tag); + GPR_ASSERT((*req)->in_flight_); + return true; + } + GPR_UNREACHABLE_CODE(return false); + } + + void SetupRequest() { cq_ = grpc_completion_queue_create(nullptr); } + + void TeardownRequest() { + grpc_completion_queue_destroy(cq_); + cq_ = nullptr; + } + + void Request(grpc_server* server, grpc_completion_queue* notify_cq) { + GPR_ASSERT(cq_ && !in_flight_); + in_flight_ = true; + if (tag_) { + GPR_ASSERT(GRPC_CALL_OK == + grpc_server_request_registered_call( + server, tag_, &call_, &deadline_, &request_metadata_, + has_request_payload_ ? &request_payload_ : nullptr, cq_, + notify_cq, this)); + } else { + if (!call_details_) { + call_details_ = new grpc_call_details; + grpc_call_details_init(call_details_); + } + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + server, &call_, call_details_, + &request_metadata_, cq_, notify_cq, this)); + } + } + + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { + if (!*status) { + grpc_completion_queue_destroy(cq_); + } + if (call_details_) { + deadline_ = call_details_->deadline; + grpc_call_details_destroy(call_details_); + grpc_call_details_init(call_details_); + } + return true; + } + + class CallData GRPC_FINAL { + public: + explicit CallData(Server* server, SyncRequest* mrd) + : cq_(mrd->cq_), + call_(mrd->call_, server, &cq_, server->max_message_size_), + ctx_(mrd->deadline_, mrd->request_metadata_.metadata, + mrd->request_metadata_.count), + has_request_payload_(mrd->has_request_payload_), + request_payload_(mrd->request_payload_), + method_(mrd->method_) { + ctx_.set_call(mrd->call_); + ctx_.cq_ = &cq_; + GPR_ASSERT(mrd->in_flight_); + mrd->in_flight_ = false; + mrd->request_metadata_.count = 0; + } + + ~CallData() { + if (has_request_payload_ && request_payload_) { + grpc_byte_buffer_destroy(request_payload_); + } + } + + void Run(std::shared_ptr global_callbacks) { + ctx_.BeginCompletionOp(&call_); + global_callbacks->PreSynchronousRequest(&ctx_); + method_->handler()->RunHandler(MethodHandler::HandlerParameter( + &call_, &ctx_, request_payload_, call_.max_message_size())); + global_callbacks->PostSynchronousRequest(&ctx_); + request_payload_ = nullptr; + void* ignored_tag; + bool ignored_ok; + cq_.Shutdown(); + GPR_ASSERT(cq_.Next(&ignored_tag, &ignored_ok) == false); + } + + private: + CompletionQueue cq_; + Call call_; + ServerContext ctx_; + const bool has_request_payload_; + grpc_byte_buffer* request_payload_; + RpcServiceMethod* const method_; + }; + + private: + RpcServiceMethod* const method_; + void* const tag_; + bool in_flight_; + const bool has_request_payload_; + uint32_t incoming_flags_; + grpc_call* call_; + grpc_call_details* call_details_; + gpr_timespec deadline_; + grpc_metadata_array request_metadata_; + grpc_byte_buffer* request_payload_; + grpc_completion_queue* cq_; +}; + +static internal::GrpcLibraryInitializer g_gli_initializer; +Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, + int max_message_size, ChannelArguments* args) + : max_message_size_(max_message_size), + started_(false), + shutdown_(false), + shutdown_notified_(false), + num_running_cb_(0), + sync_methods_(new std::list), + has_generic_service_(false), + server_(nullptr), + thread_pool_(thread_pool), + thread_pool_owned_(thread_pool_owned), + server_initializer_(new ServerInitializer(this)) { + g_gli_initializer.summon(); + gpr_once_init(&g_once_init_callbacks, InitGlobalCallbacks); + global_callbacks_ = g_callbacks; + global_callbacks_->UpdateArguments(args); + grpc_channel_args channel_args; + args->SetChannelArgs(&channel_args); + server_ = grpc_server_create(&channel_args, nullptr); + if (thread_pool_ == nullptr) { + grpc_server_register_non_listening_completion_queue(server_, cq_.cq(), + nullptr); + } else { + grpc_server_register_completion_queue(server_, cq_.cq(), nullptr); + } +} + +Server::~Server() { + { + grpc::unique_lock lock(mu_); + if (started_ && !shutdown_) { + lock.unlock(); + Shutdown(); + } else if (!started_) { + cq_.Shutdown(); + } + } + void* got_tag; + bool ok; + GPR_ASSERT(!cq_.Next(&got_tag, &ok)); + grpc_server_destroy(server_); + if (thread_pool_owned_) { + delete thread_pool_; + } + delete sync_methods_; +} + +void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) { + GPR_ASSERT(!g_callbacks); + GPR_ASSERT(callbacks); + g_callbacks.reset(callbacks); +} + +grpc_server* Server::c_server() { return server_; } + +CompletionQueue* Server::completion_queue() { return &cq_; } + +static grpc_server_register_method_payload_handling PayloadHandlingForMethod( + RpcServiceMethod* method) { + switch (method->method_type()) { + case RpcMethod::NORMAL_RPC: + case RpcMethod::SERVER_STREAMING: + return GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER; + case RpcMethod::CLIENT_STREAMING: + case RpcMethod::BIDI_STREAMING: + return GRPC_SRM_PAYLOAD_NONE; + } + GPR_UNREACHABLE_CODE(return GRPC_SRM_PAYLOAD_NONE;); +} + +bool Server::RegisterService(const grpc::string* host, Service* service) { + bool has_async_methods = service->has_async_methods(); + if (has_async_methods) { + GPR_ASSERT(service->server_ == nullptr && + "Can only register an asynchronous service against one server."); + service->server_ = this; + } + const char* method_name = nullptr; + for (auto it = service->methods_.begin(); it != service->methods_.end(); + ++it) { + if (it->get() == nullptr) { // Handled by generic service if any. + continue; + } + RpcServiceMethod* method = it->get(); + void* tag = grpc_server_register_method( + server_, method->name(), host ? host->c_str() : nullptr, + PayloadHandlingForMethod(method), 0); + if (tag == nullptr) { + gpr_log(GPR_DEBUG, "Attempt to register %s multiple times", + method->name()); + return false; + } + if (method->handler() == nullptr) { + method->set_server_tag(tag); + } else { + sync_methods_->emplace_back(method, tag); + } + method_name = method->name(); + } + + // Parse service name. + if (method_name != nullptr) { + std::stringstream ss(method_name); + grpc::string service_name; + if (std::getline(ss, service_name, '/') && + std::getline(ss, service_name, '/')) { + services_.push_back(service_name); + } + } + return true; +} + +void Server::RegisterAsyncGenericService(AsyncGenericService* service) { + GPR_ASSERT(service->server_ == nullptr && + "Can only register an async generic service against one server."); + service->server_ = this; + has_generic_service_ = true; +} + +int Server::AddListeningPort(const grpc::string& addr, + ServerCredentials* creds) { + GPR_ASSERT(!started_); + return creds->AddPortToServer(addr, server_); +} + +bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { + GPR_ASSERT(!started_); + started_ = true; + grpc_server_start(server_); + + if (!has_generic_service_) { + if (!sync_methods_->empty()) { + unknown_method_.reset(new RpcServiceMethod( + "unknown", RpcMethod::BIDI_STREAMING, new UnknownMethodHandler)); + // Use of emplace_back with just constructor arguments is not accepted + // here by gcc-4.4 because it can't match the anonymous nullptr with a + // proper constructor implicitly. Construct the object and use push_back. + sync_methods_->push_back(SyncRequest(unknown_method_.get(), nullptr)); + } + for (size_t i = 0; i < num_cqs; i++) { + if (cqs[i]->IsFrequentlyPolled()) { + new UnimplementedAsyncRequest(this, cqs[i]); + } + } + } + // Start processing rpcs. + if (!sync_methods_->empty()) { + for (auto m = sync_methods_->begin(); m != sync_methods_->end(); m++) { + m->SetupRequest(); + m->Request(server_, cq_.cq()); + } + + ScheduleCallback(); + } + + return true; +} + +void Server::ShutdownInternal(gpr_timespec deadline) { + grpc::unique_lock lock(mu_); + if (started_ && !shutdown_) { + shutdown_ = true; + grpc_server_shutdown_and_notify(server_, cq_.cq(), new ShutdownRequest()); + cq_.Shutdown(); + lock.unlock(); + // Spin, eating requests until the completion queue is completely shutdown. + // If the deadline expires then cancel anything that's pending and keep + // spinning forever until the work is actually drained. + // Since nothing else needs to touch state guarded by mu_, holding it + // through this loop is fine. + SyncRequest* request; + bool ok; + while (SyncRequest::AsyncWait(&cq_, &request, &ok, deadline)) { + if (request == NULL) { // deadline expired + grpc_server_cancel_all_calls(server_); + deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + } else if (ok) { + SyncRequest::CallData call_data(this, request); + } + } + lock.lock(); + + // Wait for running callbacks to finish. + while (num_running_cb_ != 0) { + callback_cv_.wait(lock); + } + + shutdown_notified_ = true; + shutdown_cv_.notify_all(); + } +} + +void Server::Wait() { + grpc::unique_lock lock(mu_); + while (started_ && !shutdown_notified_) { + shutdown_cv_.wait(lock); + } +} + +void Server::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) { + static const size_t MAX_OPS = 8; + size_t nops = 0; + grpc_op cops[MAX_OPS]; + ops->FillOps(cops, &nops); + auto result = grpc_call_start_batch(call->call(), cops, nops, ops, nullptr); + GPR_ASSERT(GRPC_CALL_OK == result); +} + +ServerInterface::BaseAsyncRequest::BaseAsyncRequest( + ServerInterface* server, ServerContext* context, + ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag, + bool delete_on_finalize) + : server_(server), + context_(context), + stream_(stream), + call_cq_(call_cq), + tag_(tag), + delete_on_finalize_(delete_on_finalize), + call_(nullptr) { + memset(&initial_metadata_array_, 0, sizeof(initial_metadata_array_)); +} + +bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag, + bool* status) { + if (*status) { + for (size_t i = 0; i < initial_metadata_array_.count; i++) { + context_->client_metadata_.insert( + std::pair( + initial_metadata_array_.metadata[i].key, + grpc::string_ref( + initial_metadata_array_.metadata[i].value, + initial_metadata_array_.metadata[i].value_length))); + } + } + grpc_metadata_array_destroy(&initial_metadata_array_); + context_->set_call(call_); + context_->cq_ = call_cq_; + Call call(call_, server_, call_cq_, server_->max_message_size()); + if (*status && call_) { + context_->BeginCompletionOp(&call); + } + // just the pointers inside call are copied here + stream_->BindCall(&call); + *tag = tag_; + if (delete_on_finalize_) { + delete this; + } + return true; +} + +ServerInterface::RegisteredAsyncRequest::RegisteredAsyncRequest( + ServerInterface* server, ServerContext* context, + ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag) + : BaseAsyncRequest(server, context, stream, call_cq, tag, true) {} + +void ServerInterface::RegisteredAsyncRequest::IssueRequest( + void* registered_method, grpc_byte_buffer** payload, + ServerCompletionQueue* notification_cq) { + grpc_server_request_registered_call( + server_->server(), registered_method, &call_, &context_->deadline_, + &initial_metadata_array_, payload, call_cq_->cq(), notification_cq->cq(), + this); +} + +ServerInterface::GenericAsyncRequest::GenericAsyncRequest( + ServerInterface* server, GenericServerContext* context, + ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag, bool delete_on_finalize) + : BaseAsyncRequest(server, context, stream, call_cq, tag, + delete_on_finalize) { + grpc_call_details_init(&call_details_); + GPR_ASSERT(notification_cq); + GPR_ASSERT(call_cq); + grpc_server_request_call(server->server(), &call_, &call_details_, + &initial_metadata_array_, call_cq->cq(), + notification_cq->cq(), this); +} + +bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, + bool* status) { + // TODO(yangg) remove the copy here. + if (*status) { + static_cast(context_)->method_ = + call_details_.method; + static_cast(context_)->host_ = call_details_.host; + } + gpr_free(call_details_.method); + gpr_free(call_details_.host); + return BaseAsyncRequest::FinalizeResult(tag, status); +} + +bool Server::UnimplementedAsyncRequest::FinalizeResult(void** tag, + bool* status) { + if (GenericAsyncRequest::FinalizeResult(tag, status) && *status) { + new UnimplementedAsyncRequest(server_, cq_); + new UnimplementedAsyncResponse(this); + } else { + delete this; + } + return false; +} + +Server::UnimplementedAsyncResponse::UnimplementedAsyncResponse( + UnimplementedAsyncRequest* request) + : request_(request) { + Status status(StatusCode::UNIMPLEMENTED, ""); + UnknownMethodHandler::FillOps(request_->context(), this); + request_->stream()->call_.PerformOps(this); +} + +void Server::ScheduleCallback() { + { + grpc::unique_lock lock(mu_); + num_running_cb_++; + } + thread_pool_->Add(std::bind(&Server::RunRpc, this)); +} + +void Server::RunRpc() { + // Wait for one more incoming rpc. + bool ok; + GPR_TIMER_SCOPE("Server::RunRpc", 0); + auto* mrd = SyncRequest::Wait(&cq_, &ok); + if (mrd) { + ScheduleCallback(); + if (ok) { + SyncRequest::CallData cd(this, mrd); + { + mrd->SetupRequest(); + grpc::unique_lock lock(mu_); + if (!shutdown_) { + mrd->Request(server_, cq_.cq()); + } else { + // destroy the structure that was created + mrd->TeardownRequest(); + } + } + GPR_TIMER_SCOPE("cd.Run()", 0); + cd.Run(global_callbacks_); + } + } + + { + grpc::unique_lock lock(mu_); + num_running_cb_--; + if (shutdown_) { + callback_cv_.notify_all(); + } + } +} + +ServerInitializer* Server::initializer() { return server_initializer_.get(); } + +} // namespace grpc diff --git a/src/cpp/util/byte_buffer.cc b/src/cpp/util/byte_buffer.cc deleted file mode 100644 index c2cd20ee07..0000000000 --- a/src/cpp/util/byte_buffer.cc +++ /dev/null @@ -1,98 +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 -#include - -namespace grpc { - -ByteBuffer::ByteBuffer(const Slice* slices, size_t nslices) { - // TODO(yangg) maybe expose some core API to simplify this - std::vector c_slices(nslices); - for (size_t i = 0; i < nslices; i++) { - c_slices[i] = slices[i].slice_; - } - buffer_ = grpc_raw_byte_buffer_create(c_slices.data(), nslices); -} - -ByteBuffer::~ByteBuffer() { - if (buffer_) { - grpc_byte_buffer_destroy(buffer_); - } -} - -void ByteBuffer::Clear() { - if (buffer_) { - grpc_byte_buffer_destroy(buffer_); - buffer_ = nullptr; - } -} - -Status ByteBuffer::Dump(std::vector* slices) const { - slices->clear(); - if (!buffer_) { - return Status(StatusCode::FAILED_PRECONDITION, "Buffer not initialized"); - } - grpc_byte_buffer_reader reader; - if (!grpc_byte_buffer_reader_init(&reader, buffer_)) { - return Status(StatusCode::INTERNAL, - "Couldn't initialize byte buffer reader"); - } - gpr_slice s; - while (grpc_byte_buffer_reader_next(&reader, &s)) { - slices->push_back(Slice(s, Slice::STEAL_REF)); - } - grpc_byte_buffer_reader_destroy(&reader); - return Status::OK; -} - -size_t ByteBuffer::Length() const { - if (buffer_) { - return grpc_byte_buffer_length(buffer_); - } else { - return 0; - } -} - -ByteBuffer::ByteBuffer(const ByteBuffer& buf) - : buffer_(grpc_byte_buffer_copy(buf.buffer_)) {} - -ByteBuffer& ByteBuffer::operator=(const ByteBuffer& buf) { - Clear(); // first remove existing data - if (buf.buffer_) { - buffer_ = grpc_byte_buffer_copy(buf.buffer_); // then copy - } - return *this; -} - -} // namespace grpc diff --git a/src/cpp/util/byte_buffer_cc.cc b/src/cpp/util/byte_buffer_cc.cc new file mode 100644 index 0000000000..c2cd20ee07 --- /dev/null +++ b/src/cpp/util/byte_buffer_cc.cc @@ -0,0 +1,98 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +namespace grpc { + +ByteBuffer::ByteBuffer(const Slice* slices, size_t nslices) { + // TODO(yangg) maybe expose some core API to simplify this + std::vector c_slices(nslices); + for (size_t i = 0; i < nslices; i++) { + c_slices[i] = slices[i].slice_; + } + buffer_ = grpc_raw_byte_buffer_create(c_slices.data(), nslices); +} + +ByteBuffer::~ByteBuffer() { + if (buffer_) { + grpc_byte_buffer_destroy(buffer_); + } +} + +void ByteBuffer::Clear() { + if (buffer_) { + grpc_byte_buffer_destroy(buffer_); + buffer_ = nullptr; + } +} + +Status ByteBuffer::Dump(std::vector* slices) const { + slices->clear(); + if (!buffer_) { + return Status(StatusCode::FAILED_PRECONDITION, "Buffer not initialized"); + } + grpc_byte_buffer_reader reader; + if (!grpc_byte_buffer_reader_init(&reader, buffer_)) { + return Status(StatusCode::INTERNAL, + "Couldn't initialize byte buffer reader"); + } + gpr_slice s; + while (grpc_byte_buffer_reader_next(&reader, &s)) { + slices->push_back(Slice(s, Slice::STEAL_REF)); + } + grpc_byte_buffer_reader_destroy(&reader); + return Status::OK; +} + +size_t ByteBuffer::Length() const { + if (buffer_) { + return grpc_byte_buffer_length(buffer_); + } else { + return 0; + } +} + +ByteBuffer::ByteBuffer(const ByteBuffer& buf) + : buffer_(grpc_byte_buffer_copy(buf.buffer_)) {} + +ByteBuffer& ByteBuffer::operator=(const ByteBuffer& buf) { + Clear(); // first remove existing data + if (buf.buffer_) { + buffer_ = grpc_byte_buffer_copy(buf.buffer_); // then copy + } + return *this; +} + +} // namespace grpc diff --git a/src/cpp/util/slice.cc b/src/cpp/util/slice.cc deleted file mode 100644 index 7e88423b6c..0000000000 --- a/src/cpp/util/slice.cc +++ /dev/null @@ -1,48 +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 - -namespace grpc { - -Slice::Slice() : slice_(gpr_empty_slice()) {} - -Slice::~Slice() { gpr_slice_unref(slice_); } - -Slice::Slice(gpr_slice slice, AddRef) : slice_(gpr_slice_ref(slice)) {} - -Slice::Slice(gpr_slice slice, StealRef) : slice_(slice) {} - -Slice::Slice(const Slice& other) : slice_(gpr_slice_ref(other.slice_)) {} - -} // namespace grpc diff --git a/src/cpp/util/slice_cc.cc b/src/cpp/util/slice_cc.cc new file mode 100644 index 0000000000..7e88423b6c --- /dev/null +++ b/src/cpp/util/slice_cc.cc @@ -0,0 +1,48 @@ +/* + * + * 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 + +namespace grpc { + +Slice::Slice() : slice_(gpr_empty_slice()) {} + +Slice::~Slice() { gpr_slice_unref(slice_); } + +Slice::Slice(gpr_slice slice, AddRef) : slice_(gpr_slice_ref(slice)) {} + +Slice::Slice(gpr_slice slice, StealRef) : slice_(slice) {} + +Slice::Slice(const Slice& other) : slice_(gpr_slice_ref(other.slice_)) {} + +} // namespace grpc diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc deleted file mode 100644 index c43d848cc6..0000000000 --- a/src/cpp/util/time.cc +++ /dev/null @@ -1,95 +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 - -#ifndef GRPC_CXX0X_NO_CHRONO - -#include -#include - -using std::chrono::duration_cast; -using std::chrono::nanoseconds; -using std::chrono::seconds; -using std::chrono::system_clock; -using std::chrono::high_resolution_clock; - -namespace grpc { - -void Timepoint2Timespec(const system_clock::time_point& from, - gpr_timespec* to) { - system_clock::duration deadline = from.time_since_epoch(); - seconds secs = duration_cast(deadline); - if (from == system_clock::time_point::max() || - secs.count() >= gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec || - secs.count() < 0) { - *to = gpr_inf_future(GPR_CLOCK_REALTIME); - return; - } - nanoseconds nsecs = duration_cast(deadline - secs); - to->tv_sec = (int64_t)secs.count(); - to->tv_nsec = (int32_t)nsecs.count(); - to->clock_type = GPR_CLOCK_REALTIME; -} - -void TimepointHR2Timespec(const high_resolution_clock::time_point& from, - gpr_timespec* to) { - high_resolution_clock::duration deadline = from.time_since_epoch(); - seconds secs = duration_cast(deadline); - if (from == high_resolution_clock::time_point::max() || - secs.count() >= gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec || - secs.count() < 0) { - *to = gpr_inf_future(GPR_CLOCK_REALTIME); - return; - } - nanoseconds nsecs = duration_cast(deadline - secs); - to->tv_sec = (int64_t)secs.count(); - to->tv_nsec = (int32_t)nsecs.count(); - to->clock_type = GPR_CLOCK_REALTIME; -} - -system_clock::time_point Timespec2Timepoint(gpr_timespec t) { - if (gpr_time_cmp(t, gpr_inf_future(t.clock_type)) == 0) { - return system_clock::time_point::max(); - } - t = gpr_convert_clock_type(t, GPR_CLOCK_REALTIME); - system_clock::time_point tp; - tp += duration_cast(seconds(t.tv_sec)); - tp += - duration_cast(nanoseconds(t.tv_nsec)); - return tp; -} - -} // namespace grpc - -#endif // !GRPC_CXX0X_NO_CHRONO diff --git a/src/cpp/util/time_cc.cc b/src/cpp/util/time_cc.cc new file mode 100644 index 0000000000..c43d848cc6 --- /dev/null +++ b/src/cpp/util/time_cc.cc @@ -0,0 +1,95 @@ +/* + * + * 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 + +#ifndef GRPC_CXX0X_NO_CHRONO + +#include +#include + +using std::chrono::duration_cast; +using std::chrono::nanoseconds; +using std::chrono::seconds; +using std::chrono::system_clock; +using std::chrono::high_resolution_clock; + +namespace grpc { + +void Timepoint2Timespec(const system_clock::time_point& from, + gpr_timespec* to) { + system_clock::duration deadline = from.time_since_epoch(); + seconds secs = duration_cast(deadline); + if (from == system_clock::time_point::max() || + secs.count() >= gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec || + secs.count() < 0) { + *to = gpr_inf_future(GPR_CLOCK_REALTIME); + return; + } + nanoseconds nsecs = duration_cast(deadline - secs); + to->tv_sec = (int64_t)secs.count(); + to->tv_nsec = (int32_t)nsecs.count(); + to->clock_type = GPR_CLOCK_REALTIME; +} + +void TimepointHR2Timespec(const high_resolution_clock::time_point& from, + gpr_timespec* to) { + high_resolution_clock::duration deadline = from.time_since_epoch(); + seconds secs = duration_cast(deadline); + if (from == high_resolution_clock::time_point::max() || + secs.count() >= gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec || + secs.count() < 0) { + *to = gpr_inf_future(GPR_CLOCK_REALTIME); + return; + } + nanoseconds nsecs = duration_cast(deadline - secs); + to->tv_sec = (int64_t)secs.count(); + to->tv_nsec = (int32_t)nsecs.count(); + to->clock_type = GPR_CLOCK_REALTIME; +} + +system_clock::time_point Timespec2Timepoint(gpr_timespec t) { + if (gpr_time_cmp(t, gpr_inf_future(t.clock_type)) == 0) { + return system_clock::time_point::max(); + } + t = gpr_convert_clock_type(t, GPR_CLOCK_REALTIME); + system_clock::time_point tp; + tp += duration_cast(seconds(t.tv_sec)); + tp += + duration_cast(nanoseconds(t.tv_nsec)); + return tp; +} + +} // namespace grpc + +#endif // !GRPC_CXX0X_NO_CHRONO diff --git a/test/cpp/util/test_config.cc b/test/cpp/util/test_config.cc deleted file mode 100644 index 8711746129..0000000000 --- a/test/cpp/util/test_config.cc +++ /dev/null @@ -1,52 +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/cpp/util/test_config.h" -#include - -// In some distros, gflags is in the namespace google, and in some others, -// in gflags. This hack is enabling us to find both. -namespace google {} -namespace gflags {} -using namespace google; -using namespace gflags; - -namespace grpc { -namespace testing { - -void InitTest(int* argc, char*** argv, bool remove_flags) { - ParseCommandLineFlags(argc, argv, remove_flags); -} - -} // namespace testing -} // namespace grpc diff --git a/test/cpp/util/test_config_cc.cc b/test/cpp/util/test_config_cc.cc new file mode 100644 index 0000000000..8711746129 --- /dev/null +++ b/test/cpp/util/test_config_cc.cc @@ -0,0 +1,52 @@ +/* + * + * 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/cpp/util/test_config.h" +#include + +// In some distros, gflags is in the namespace google, and in some others, +// in gflags. This hack is enabling us to find both. +namespace google {} +namespace gflags {} +using namespace google; +using namespace gflags; + +namespace grpc { +namespace testing { + +void InitTest(int* argc, char*** argv, bool remove_flags) { + ParseCommandLineFlags(argc, argv, remove_flags); +} + +} // namespace testing +} // namespace grpc diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 8d38d9a36f..67312d7ad4 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -956,32 +956,32 @@ src/cpp/common/secure_auth_context.cc \ src/cpp/common/secure_channel_arguments.cc \ src/cpp/common/secure_create_auth_context.cc \ src/cpp/server/secure_server_credentials.cc \ -src/cpp/client/channel.cc \ +src/cpp/client/channel_cc.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_posix.cc \ -src/cpp/client/credentials.cc \ +src/cpp/client/credentials_cc.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/common/channel_arguments.cc \ -src/cpp/common/completion_queue.cc \ +src/cpp/common/completion_queue_cc.cc \ src/cpp/common/core_codegen.cc \ src/cpp/common/rpc_method.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ src/cpp/server/insecure_server_credentials.cc \ -src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ +src/cpp/server/server_cc.cc \ src/cpp/server/server_context.cc \ src/cpp/server/server_credentials.cc \ src/cpp/server/server_posix.cc \ -src/cpp/util/byte_buffer.cc \ -src/cpp/util/slice.cc \ +src/cpp/util/byte_buffer_cc.cc \ +src/cpp/util/slice_cc.cc \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ -src/cpp/util/time.cc \ +src/cpp/util/time_cc.cc \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ diff --git a/tools/run_tests/sanity/check_sources_and_headers.py b/tools/run_tests/sanity/check_sources_and_headers.py index c028499ca6..524640942e 100755 --- a/tools/run_tests/sanity/check_sources_and_headers.py +++ b/tools/run_tests/sanity/check_sources_and_headers.py @@ -62,7 +62,8 @@ def target_has_header(target, name): def produces_object(name): return os.path.splitext(name)[1] in ['.c', '.cc'] -obj_producer_to_source = {'c': {}, 'c++': {}, 'csharp': {}} +c_ish = {} +obj_producer_to_source = {'c': c_ish, 'c++': c_ish, 'csharp': {}} errors = 0 for target in js: @@ -85,7 +86,7 @@ for target in js: 'target %s (%s) does not name header %s as a dependency' % ( target['name'], fn, m.group(1))) errors += 1 - if target['type'] == 'lib': + if target['type'] in ['lib', 'filegroup']: for fn in target['src']: language = target['language'] if produces_object(fn): diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index cd1757acec..9295a2a88e 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -4392,8 +4392,8 @@ "language": "c++", "name": "grpc++_test_config", "src": [ - "test/cpp/util/test_config.cc", - "test/cpp/util/test_config.h" + "test/cpp/util/test_config.h", + "test/cpp/util/test_config_cc.cc" ], "third_party": false, "type": "lib" @@ -6605,17 +6605,17 @@ "include/grpc++/support/stub_options.h", "include/grpc++/support/sync_stream.h", "include/grpc++/support/time.h", - "src/cpp/client/channel.cc", + "src/cpp/client/channel_cc.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", "src/cpp/client/create_channel_internal.h", "src/cpp/client/create_channel_posix.cc", - "src/cpp/client/credentials.cc", + "src/cpp/client/credentials_cc.cc", "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/common/channel_arguments.cc", - "src/cpp/common/completion_queue.cc", + "src/cpp/common/completion_queue_cc.cc", "src/cpp/common/core_codegen.cc", "src/cpp/common/rpc_method.cc", "src/cpp/server/async_generic_service.cc", @@ -6623,17 +6623,17 @@ "src/cpp/server/dynamic_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.h", "src/cpp/server/insecure_server_credentials.cc", - "src/cpp/server/server.cc", "src/cpp/server/server_builder.cc", + "src/cpp/server/server_cc.cc", "src/cpp/server/server_context.cc", "src/cpp/server/server_credentials.cc", "src/cpp/server/server_posix.cc", "src/cpp/server/thread_pool_interface.h", - "src/cpp/util/byte_buffer.cc", - "src/cpp/util/slice.cc", + "src/cpp/util/byte_buffer_cc.cc", + "src/cpp/util/slice_cc.cc", "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", - "src/cpp/util/time.cc" + "src/cpp/util/time_cc.cc" ], "third_party": false, "type": "filegroup" diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index c50fc4a86d..cd459ae194 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -464,7 +464,7 @@ - + @@ -474,7 +474,7 @@ - + @@ -482,7 +482,7 @@ - + @@ -496,25 +496,25 @@ - - + + - + - + - + diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index a68ac33157..30ad03941f 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -19,7 +19,7 @@ src\cpp\server - + src\cpp\client @@ -34,7 +34,7 @@ src\cpp\client - + src\cpp\client @@ -46,7 +46,7 @@ src\cpp\common - + src\cpp\common @@ -67,10 +67,10 @@ src\cpp\server - + src\cpp\server - + src\cpp\server @@ -82,10 +82,10 @@ src\cpp\server - + src\cpp\util - + src\cpp\util @@ -94,7 +94,7 @@ src\cpp\util - + src\cpp\util diff --git a/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj b/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj index 5eab788e4c..cf07e21da4 100644 --- a/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj @@ -150,7 +150,7 @@ - + diff --git a/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj.filters index b4d4134b05..73e36148f2 100644 --- a/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_config/grpc++_test_config.vcxproj.filters @@ -1,7 +1,7 @@ - + test\cpp\util diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index 3a4aa13527..527c5c6918 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -450,7 +450,7 @@ - + @@ -460,7 +460,7 @@ - + @@ -468,7 +468,7 @@ - + @@ -482,25 +482,25 @@ - - + + - + - + - + diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 56b434433b..6b9ca058c5 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -4,7 +4,7 @@ src\cpp\common - + src\cpp\client @@ -19,7 +19,7 @@ src\cpp\client - + src\cpp\client @@ -31,7 +31,7 @@ src\cpp\common - + src\cpp\common @@ -52,10 +52,10 @@ src\cpp\server - + src\cpp\server - + src\cpp\server @@ -67,10 +67,10 @@ src\cpp\server - + src\cpp\util - + src\cpp\util @@ -79,7 +79,7 @@ src\cpp\util - + src\cpp\util -- cgit v1.2.3 From 24096ce7beba67b815dc390da769af84c1fd4afa Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 24 Aug 2016 15:54:29 -0700 Subject: Support >16kib frame sizes in core --- include/grpc/impl/codegen/grpc_types.h | 5 +++ .../transport/chttp2/transport/chttp2_transport.c | 13 +++++++ src/core/ext/transport/chttp2/transport/frame.h | 2 -- .../ext/transport/chttp2/transport/hpack_encoder.c | 10 ++++-- .../ext/transport/chttp2/transport/hpack_encoder.h | 1 + src/core/ext/transport/chttp2/transport/internal.h | 2 ++ src/core/ext/transport/chttp2/transport/writing.c | 12 +++++-- test/core/end2end/tests/invoke_large_request.c | 42 ++++++++++++++++++++-- test/core/transport/chttp2/hpack_encoder_test.c | 5 +-- 9 files changed, 79 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index e5a82883be..d7f50f6314 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -142,6 +142,11 @@ typedef struct { /** How much memory to use for hpack encoding. Int valued, bytes. */ #define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \ "grpc.http2.hpack_table_size.encoder" +/** How big a frame are we willing to receive via HTTP2. + Min 16384, max 16777215. + 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" /** Default authority to pass if none specified on call construction. A string. * */ #define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority" diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 0e8dfb7d96..00999e3b94 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -408,6 +408,19 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, push_setting(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, (uint32_t)channel_args->args[i].value.integer); } + } else if (0 == strcmp(channel_args->args[i].key, + GRPC_ARG_HTTP2_MAX_FRAME_SIZE)) { + if (channel_args->args[i].type != GRPC_ARG_INTEGER) { + gpr_log(GPR_ERROR, "%s: must be an integer", + GRPC_ARG_HTTP2_MAX_FRAME_SIZE); + } else if (channel_args->args[i].value.integer < 16384 || + channel_args->args[i].value.integer > 16777215) { + gpr_log(GPR_ERROR, "%s: must be between 16384 and 16777215", + GRPC_ARG_HTTP2_MAX_FRAME_SIZE); + } else { + push_setting(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE, + (uint32_t)channel_args->args[i].value.integer); + } } } } diff --git a/src/core/ext/transport/chttp2/transport/frame.h b/src/core/ext/transport/chttp2/transport/frame.h index 7776609367..507aae4100 100644 --- a/src/core/ext/transport/chttp2/transport/frame.h +++ b/src/core/ext/transport/chttp2/transport/frame.h @@ -52,8 +52,6 @@ typedef struct grpc_chttp2_transport_parsing grpc_chttp2_transport_parsing; #define GRPC_CHTTP2_FRAME_GOAWAY 7 #define GRPC_CHTTP2_FRAME_WINDOW_UPDATE 8 -#define GRPC_CHTTP2_MAX_PAYLOAD_LENGTH ((1 << 14) - 1) - #define GRPC_CHTTP2_DATA_FLAG_END_STREAM 1 #define GRPC_CHTTP2_FLAG_ACK 1 #define GRPC_CHTTP2_DATA_FLAG_END_HEADERS 4 diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index 2cb8205d94..581471ba02 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -78,6 +78,8 @@ typedef struct { uint32_t stream_id; gpr_slice_buffer *output; grpc_transport_one_way_stats *stats; + /* maximum size of a frame */ + size_t max_frame_size; } framer_state; /* fills p (which is expected to be 9 bytes long) with a data frame header */ @@ -123,7 +125,7 @@ static void begin_frame(framer_state *st) { needed */ static void ensure_space(framer_state *st, size_t need_bytes) { if (st->output->length - st->output_length_at_start_of_frame + need_bytes <= - GRPC_CHTTP2_MAX_PAYLOAD_LENGTH) { + st->max_frame_size) { return; } finish_frame(st, 0, 0); @@ -149,8 +151,8 @@ static void add_header_data(framer_state *st, gpr_slice slice) { size_t len = GPR_SLICE_LENGTH(slice); size_t remaining; if (len == 0) return; - remaining = GRPC_CHTTP2_MAX_PAYLOAD_LENGTH + - st->output_length_at_start_of_frame - st->output->length; + remaining = st->max_frame_size + st->output_length_at_start_of_frame - + st->output->length; if (len <= remaining) { st->stats->header_bytes += len; gpr_slice_buffer_add(st->output, slice); @@ -542,6 +544,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size( void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, uint32_t stream_id, grpc_metadata_batch *metadata, int is_eof, + size_t max_frame_size, grpc_transport_one_way_stats *stats, gpr_slice_buffer *outbuf) { framer_state st; @@ -555,6 +558,7 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, st.output = outbuf; st.is_first_frame = 1; st.stats = stats; + st.max_frame_size = max_frame_size; /* Encode a metadata batch; store the returned values, representing a metadata element that needs to be unreffed back into the metadata diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 0f7b0b063a..4c3a931549 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -91,6 +91,7 @@ void grpc_chttp2_hpack_compressor_set_max_usable_size( void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, uint32_t id, grpc_metadata_batch *metadata, int is_eof, + size_t max_frame_size, grpc_transport_one_way_stats *stats, gpr_slice_buffer *outbuf); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index e1dcf5262a..d67c014e54 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -223,6 +223,8 @@ typedef struct { uint8_t is_client; /** callback for when writing is done */ grpc_closure done_cb; + /** maximum frame size */ + uint32_t max_frame_size; } grpc_chttp2_transport_writing; struct grpc_chttp2_transport_parsing { diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 8f7a1f55c6..80068744cc 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -51,6 +51,10 @@ int grpc_chttp2_unlocking_check_writes( GPR_TIMER_BEGIN("grpc_chttp2_unlocking_check_writes", 0); + transport_writing->max_frame_size = + transport_global + ->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]; + /* simple writes are queued to qbuf, and flushed here */ gpr_slice_buffer_swap(&transport_global->qbuf, &transport_writing->outbuf); GPR_ASSERT(transport_global->qbuf.count == 0); @@ -206,14 +210,15 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx, while ( grpc_chttp2_list_pop_writing_stream(transport_writing, &stream_writing)) { uint32_t max_outgoing = - (uint32_t)GPR_MIN(GRPC_CHTTP2_MAX_PAYLOAD_LENGTH, + (uint32_t)GPR_MIN(transport_writing->max_frame_size, GPR_MIN(stream_writing->outgoing_window, transport_writing->outgoing_window)); /* send initial metadata if it's available */ if (stream_writing->send_initial_metadata != NULL) { grpc_chttp2_encode_header( &transport_writing->hpack_compressor, stream_writing->id, - stream_writing->send_initial_metadata, 0, &stream_writing->stats, + stream_writing->send_initial_metadata, 0, + transport_writing->max_frame_size, &stream_writing->stats, &transport_writing->outbuf); stream_writing->send_initial_metadata = NULL; stream_writing->sent_initial_metadata = 1; @@ -303,7 +308,8 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx, } else { grpc_chttp2_encode_header( &transport_writing->hpack_compressor, stream_writing->id, - stream_writing->send_trailing_metadata, 1, &stream_writing->stats, + stream_writing->send_trailing_metadata, 1, + transport_writing->max_frame_size, &stream_writing->stats, &transport_writing->outbuf); } if (!transport_writing->is_client && !stream_writing->read_closed) { diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 9c9ca95129..5f01b447d7 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include "test/core/end2end/cq_verifier.h" @@ -101,9 +102,25 @@ static gpr_slice large_slice(void) { return slice; } -static void test_invoke_large_request(grpc_end2end_test_config config) { +static void test_invoke_large_request(grpc_end2end_test_config config, + int max_frame_size, int lookahead_bytes) { + char *name; + gpr_asprintf(&name, + "test_invoke_large_request:max_frame_size=%d:lookahead_bytes=%d", + max_frame_size, lookahead_bytes); + + grpc_arg args[2]; + args[0].type = GRPC_ARG_INTEGER; + args[0].key = GRPC_ARG_HTTP2_MAX_FRAME_SIZE; + args[0].value.integer = max_frame_size; + args[1].type = GRPC_ARG_INTEGER; + args[1].key = GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES; + args[1].value.integer = lookahead_bytes; + grpc_channel_args channel_args = {GPR_ARRAY_SIZE(args), args}; + grpc_end2end_test_fixture f = - begin_test(config, "test_invoke_large_request", NULL, NULL); + begin_test(config, name, &channel_args, &channel_args); + gpr_free(name); gpr_slice request_payload_slice = large_slice(); gpr_slice response_payload_slice = large_slice(); @@ -255,7 +272,26 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { } void invoke_large_request(grpc_end2end_test_config config) { - test_invoke_large_request(config); + test_invoke_large_request(config, 16384, 65536); + test_invoke_large_request(config, 32768, 65536); + + test_invoke_large_request(config, 1000000 - 1, 65536); + test_invoke_large_request(config, 1000000, 65536); + test_invoke_large_request(config, 1000000 + 1, 65536); + test_invoke_large_request(config, 1000000 + 2, 65536); + test_invoke_large_request(config, 1000000 + 3, 65536); + test_invoke_large_request(config, 1000000 + 4, 65536); + test_invoke_large_request(config, 1000000 + 5, 65536); + test_invoke_large_request(config, 1000000 + 6, 65536); + + test_invoke_large_request(config, 1000000 - 1, 2000000); + test_invoke_large_request(config, 1000000, 2000000); + test_invoke_large_request(config, 1000000 + 1, 2000000); + test_invoke_large_request(config, 1000000 + 2, 2000000); + test_invoke_large_request(config, 1000000 + 3, 2000000); + test_invoke_large_request(config, 1000000 + 4, 2000000); + test_invoke_large_request(config, 1000000 + 5, 2000000); + test_invoke_large_request(config, 1000000 + 6, 2000000); } void invoke_large_request_pre_init(void) {} diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c index 186bb6406f..1c1c74879b 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.c +++ b/test/core/transport/chttp2/hpack_encoder_test.c @@ -97,7 +97,7 @@ static void verify(size_t window_available, int eof, size_t expect_window_used, grpc_transport_one_way_stats stats; memset(&stats, 0, sizeof(stats)); - grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, eof, &stats, + grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, eof, 16384, &stats, &output); merged = grpc_slice_merge(output.slices, output.count); gpr_slice_buffer_destroy(&output); @@ -202,7 +202,8 @@ static void verify_table_size_change_match_elem_size(const char *key, grpc_transport_one_way_stats stats; memset(&stats, 0, sizeof(stats)); - grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, 0, &stats, &output); + grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, 0, 16384, &stats, + &output); gpr_slice_buffer_destroy(&output); grpc_metadata_batch_destroy(&b); -- cgit v1.2.3 From 7603d64982ea5de924218d600a851d6c8a4e6415 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 24 Aug 2016 18:23:24 -0700 Subject: Let tracing be enabled before starting an RPC by calling grpc_init on [GRPCCall load], instead of lazily. --- src/objective-c/GRPCClient/GRPCCall.m | 5 +++++ src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index da9473f9a2..b5d8309787 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -103,6 +103,11 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey"; @synthesize state = _state; +// TODO(jcanizales): If grpc_init is idempotent, this should be changed from load to initialize. ++ (void)load { + grpc_init(); +} + - (instancetype)init { return [self initWithHost:nil path:nil requestsWriter:nil]; } diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 97f6b89340..1339429660 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -245,11 +245,6 @@ } if (self = [super init]) { - static dispatch_once_t initialization; - dispatch_once(&initialization, ^{ - grpc_init(); - }); - // Each completion queue consumes one thread. There's a trade to be made between creating and // consuming too many threads and having contention of multiple calls in a single completion // queue. Currently we use a singleton queue. -- cgit v1.2.3 From b15811e36d5b1885293413219fb546f6d93ebf0f Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 26 Aug 2016 15:23:28 -0700 Subject: php: fix per_rpc_creds capital auth header key --- src/php/tests/interop/interop_client.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index bf40549a04..7f8354e236 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -197,7 +197,12 @@ function updateAuthMetadataCallback($context) $methodName = $context->method_name; $auth_credentials = ApplicationDefaultCredentials::getCredentials(); - return $auth_credentials->updateMetadata($metadata = [], $authUri); + $metadata = []; + $result = $auth_credentials->updateMetadata([], $authUri); + foreach ($result as $key => $value) { + $metadata[strtolower($key)] = $value; + } + return $metadata; } /** -- cgit v1.2.3 From 14e2a566c9a36c884c9d92be6bc506a8959254f3 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 26 Aug 2016 19:52:35 -0700 Subject: php: error out if metadata key is not legal --- package.xml | 4 +- src/php/ext/grpc/call.c | 3 + src/php/ext/grpc/call_credentials.c | 20 +--- src/php/tests/interop/interop_client.php | 30 ++--- src/php/tests/unit_tests/CallCredentials2Test.php | 65 +++++++++++ src/php/tests/unit_tests/CallCredentials3Test.php | 135 ---------------------- src/php/tests/unit_tests/CallTest.php | 24 +++- templates/package.xml.template | 4 +- 8 files changed, 118 insertions(+), 167 deletions(-) delete mode 100644 src/php/tests/unit_tests/CallCredentials3Test.php (limited to 'src') diff --git a/package.xml b/package.xml index 6e3aab7a76..7da3d48a07 100644 --- a/package.xml +++ b/package.xml @@ -22,7 +22,7 @@ BSD -- TBD +- Reject metadata keys which are not legal #7881 @@ -1173,7 +1173,7 @@ Update to wrap gRPC C Core version 0.10.0 2016-08-22 BSD -- TBD +- Reject metadata keys which are not legal #7881 diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index 66ca1513ed..31c59fe5ad 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -164,6 +164,9 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) { if (key_type1 != HASH_KEY_IS_STRING) { return false; } + if (!grpc_header_key_is_legal(key1, strlen(key1))) { + return false; + } inner_array_hash = Z_ARRVAL_P(inner_array); PHP_GRPC_HASH_FOREACH_VAL_START(inner_array_hash, value) if (Z_TYPE_P(value) != IS_STRING) { diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c index 6921a5df17..25c92c91fe 100644 --- a/src/php/ext/grpc/call_credentials.c +++ b/src/php/ext/grpc/call_credentials.c @@ -192,24 +192,16 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context, /* call the user callback function */ zend_call_function(state->fci, state->fci_cache TSRMLS_CC); - if (Z_TYPE_P(retval) != IS_ARRAY) { - zend_throw_exception(spl_ce_InvalidArgumentException, - "plugin callback must return metadata array", - 1 TSRMLS_CC); - return; - } - + grpc_status_code code = GRPC_STATUS_OK; grpc_metadata_array metadata; - if (!create_metadata_array(retval, &metadata)) { - zend_throw_exception(spl_ce_InvalidArgumentException, - "invalid metadata", 1 TSRMLS_CC); + + if (Z_TYPE_P(retval) != IS_ARRAY) { + code = GRPC_STATUS_INVALID_ARGUMENT; + } else if (!create_metadata_array(retval, &metadata)) { grpc_metadata_array_destroy(&metadata); - return; + code = GRPC_STATUS_INVALID_ARGUMENT; } - /* TODO: handle error */ - grpc_status_code code = GRPC_STATUS_OK; - /* Pass control back to core */ cb(user_data, metadata.metadata, metadata.count, code, NULL); } diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 7f8354e236..c94ba61296 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -54,6 +54,15 @@ function hardAssert($value, $error_message) } } +function hardAssertIfStatusOk($status) +{ + if ($status->code !== Grpc\STATUS_OK) { + echo "Call did not complete successfully. Status object:\n"; + var_dump($status); + exit(1); + } +} + /** * Run the empty_unary test. * @@ -62,7 +71,7 @@ function hardAssert($value, $error_message) function emptyUnary($stub) { list($result, $status) = $stub->EmptyCall(new grpc\testing\EmptyMessage())->wait(); - hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssertIfStatusOk($status); hardAssert($result !== null, 'Call completed with a null response'); } @@ -105,7 +114,7 @@ function performLargeUnary($stub, $fillUsername = false, $fillOauthScope = false } list($result, $status) = $stub->UnaryCall($request, [], $options)->wait(); - hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssertIfStatusOk($status); hardAssert($result !== null, 'Call returned a null response'); $payload = $result->getPayload(); hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, @@ -247,7 +256,7 @@ function clientStreaming($stub) $call->write($request); } list($result, $status) = $call->wait(); - hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssertIfStatusOk($status); hardAssert($result->getAggregatedPayloadSize() === 74922, 'aggregated_payload_size was incorrect'); } @@ -280,8 +289,7 @@ function serverStreaming($stub) 'Response '.$i.' had the wrong length'); $i += 1; } - hardAssert($call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($call->getStatus()); } /** @@ -317,8 +325,7 @@ function pingPong($stub) } $call->writesDone(); hardAssert($call->read() === null, 'Server returned too many responses'); - hardAssert($call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($call->getStatus()); } /** @@ -331,8 +338,7 @@ function emptyStream($stub) $call = $stub->FullDuplexCall(); $call->writesDone(); hardAssert($call->read() === null, 'Server returned too many responses'); - hardAssert($call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($call->getStatus()); } /** @@ -424,8 +430,7 @@ function customMetadata($stub) 'Incorrect initial metadata value'); list($result, $status) = $call->wait(); - hardAssert($status->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($status); $trailing_metadata = $call->getTrailingMetadata(); hardAssert(array_key_exists($ECHO_TRAILING_KEY, $trailing_metadata), @@ -440,8 +445,7 @@ function customMetadata($stub) $streaming_call->write($streaming_request); $streaming_call->writesDone(); - hardAssert($streaming_call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($streaming_call->getStatus()); $streaming_trailing_metadata = $streaming_call->getTrailingMetadata(); hardAssert(array_key_exists($ECHO_TRAILING_KEY, diff --git a/src/php/tests/unit_tests/CallCredentials2Test.php b/src/php/tests/unit_tests/CallCredentials2Test.php index a57e2b9b4e..b3b98a22ca 100644 --- a/src/php/tests/unit_tests/CallCredentials2Test.php +++ b/src/php/tests/unit_tests/CallCredentials2Test.php @@ -132,4 +132,69 @@ class CallCredentials2Test extends PHPUnit_Framework_TestCase unset($call); unset($server_call); } + + public function invalidKeyCallbackFunc($context) + { + $this->assertTrue(is_string($context->service_url)); + $this->assertTrue(is_string($context->method_name)); + + return ['K1' => ['v1']]; + } + + public function testCallbackWithInvalidKey() + { + $deadline = Grpc\Timeval::infFuture(); + $status_text = 'xyz'; + $call = new Grpc\Call($this->channel, + '/abc/dummy_method', + $deadline, + $this->host_override); + + $call_credentials = Grpc\CallCredentials::createFromPlugin( + array($this, 'invalidKeyCallbackFunc')); + $call->setCredentials($call_credentials); + + $event = $call->startBatch([ + Grpc\OP_SEND_INITIAL_METADATA => [], + Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, + Grpc\OP_RECV_STATUS_ON_CLIENT => true, + ]); + + $this->assertTrue($event->send_metadata); + $this->assertTrue($event->send_close); + $this->assertTrue($event->status->code == Grpc\STATUS_UNAUTHENTICATED); + } + + public function invalidReturnCallbackFunc($context) + { + $this->assertTrue(is_string($context->service_url)); + $this->assertTrue(is_string($context->method_name)); + + return "a string"; + } + + public function testCallbackWithInvalidReturnValue() + { + $deadline = Grpc\Timeval::infFuture(); + $status_text = 'xyz'; + $call = new Grpc\Call($this->channel, + '/abc/dummy_method', + $deadline, + $this->host_override); + + $call_credentials = Grpc\CallCredentials::createFromPlugin( + array($this, 'invalidReturnCallbackFunc')); + $call->setCredentials($call_credentials); + + $event = $call->startBatch([ + Grpc\OP_SEND_INITIAL_METADATA => [], + Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, + Grpc\OP_RECV_STATUS_ON_CLIENT => true, + ]); + + $this->assertTrue($event->send_metadata); + $this->assertTrue($event->send_close); + $this->assertTrue($event->status->code == Grpc\STATUS_UNAUTHENTICATED); + } + } diff --git a/src/php/tests/unit_tests/CallCredentials3Test.php b/src/php/tests/unit_tests/CallCredentials3Test.php deleted file mode 100644 index 8f5e109bf5..0000000000 --- a/src/php/tests/unit_tests/CallCredentials3Test.php +++ /dev/null @@ -1,135 +0,0 @@ -credentials = Grpc\ChannelCredentials::createSsl( - file_get_contents(dirname(__FILE__).'/../data/ca.pem')); - $server_credentials = Grpc\ServerCredentials::createSsl( - null, - file_get_contents(dirname(__FILE__).'/../data/server1.key'), - file_get_contents(dirname(__FILE__).'/../data/server1.pem')); - $this->server = new Grpc\Server(); - $this->port = $this->server->addSecureHttp2Port('0.0.0.0:0', - $server_credentials); - $this->server->start(); - $this->host_override = 'foo.test.google.fr'; - $this->channel = new Grpc\Channel( - 'localhost:'.$this->port, - [ - 'grpc.ssl_target_name_override' => $this->host_override, - 'grpc.default_authority' => $this->host_override, - 'credentials' => $this->credentials, - ] - ); - } - - public function tearDown() - { - unset($this->channel); - unset($this->server); - } - - public function callbackFunc($context) - { - $this->assertTrue(is_string($context->service_url)); - $this->assertTrue(is_string($context->method_name)); - - return ['k1' => ['v1'], 'k2' => ['v2']]; - } - - public function testCreateFromPlugin() - { - $deadline = Grpc\Timeval::infFuture(); - $status_text = 'xyz'; - $call = new Grpc\Call($this->channel, - '/abc/dummy_method', - $deadline, - $this->host_override); - - $call_credentials = Grpc\CallCredentials::createFromPlugin( - [$this, 'callbackFunc']); - $call->setCredentials($call_credentials); - - $event = $call->startBatch([ - Grpc\OP_SEND_INITIAL_METADATA => [], - Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, - ]); - - $this->assertTrue($event->send_metadata); - $this->assertTrue($event->send_close); - - $event = $this->server->requestCall(); - - $this->assertTrue(is_array($event->metadata)); - $metadata = $event->metadata; - $this->assertTrue(array_key_exists('k1', $metadata)); - $this->assertTrue(array_key_exists('k2', $metadata)); - $this->assertSame($metadata['k1'], ['v1']); - $this->assertSame($metadata['k2'], ['v2']); - - $this->assertSame('/abc/dummy_method', $event->method); - $server_call = $event->call; - - $event = $server_call->startBatch([ - Grpc\OP_SEND_INITIAL_METADATA => [], - Grpc\OP_SEND_STATUS_FROM_SERVER => [ - 'metadata' => [], - 'code' => Grpc\STATUS_OK, - 'details' => $status_text, - ], - Grpc\OP_RECV_CLOSE_ON_SERVER => true, - ]); - - $this->assertTrue($event->send_metadata); - $this->assertTrue($event->send_status); - $this->assertFalse($event->cancelled); - - $event = $call->startBatch([ - Grpc\OP_RECV_INITIAL_METADATA => true, - Grpc\OP_RECV_STATUS_ON_CLIENT => true, - ]); - - $this->assertSame([], $event->metadata); - $status = $event->status; - $this->assertSame([], $status->metadata); - $this->assertSame(Grpc\STATUS_OK, $status->code); - $this->assertSame($status_text, $status->details); - - unset($call); - unset($server_call); - } -} diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php index d736f51546..1205f0cd8e 100644 --- a/src/php/tests/unit_tests/CallTest.php +++ b/src/php/tests/unit_tests/CallTest.php @@ -113,7 +113,7 @@ class CallTest extends PHPUnit_Framework_TestCase /** * @expectedException InvalidArgumentException */ - public function testInvalidMetadataKey() + public function testInvalidStartBatchKey() { $batch = [ 'invalid' => ['key1' => 'value1'], @@ -121,6 +121,28 @@ class CallTest extends PHPUnit_Framework_TestCase $result = $this->call->startBatch($batch); } + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidMetadataStrKey() + { + $batch = [ + Grpc\OP_SEND_INITIAL_METADATA => ['Key' => ['value1', 'value2']], + ]; + $result = $this->call->startBatch($batch); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidMetadataIntKey() + { + $batch = [ + Grpc\OP_SEND_INITIAL_METADATA => [1 => ['value1', 'value2']], + ]; + $result = $this->call->startBatch($batch); + } + /** * @expectedException InvalidArgumentException */ diff --git a/templates/package.xml.template b/templates/package.xml.template index 65fef1892f..32ed3b633e 100644 --- a/templates/package.xml.template +++ b/templates/package.xml.template @@ -24,7 +24,7 @@ BSD - - TBD + - Reject metadata keys which are not legal #7881 @@ -291,7 +291,7 @@ 2016-08-22 BSD - - TBD + - Reject metadata keys which are not legal #7881 -- cgit v1.2.3 From 79cf53c992575308526a346d39011f83bbf2f2c9 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Mon, 29 Aug 2016 16:56:43 +0000 Subject: Lower-case example "Authorization" header name The HTTP/2 specification requires header names to be lower case. --- src/python/grpcio/grpc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 513839df7d..fb3900decc 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1078,7 +1078,7 @@ def access_token_call_credentials(access_token): Args: access_token: A string to place directly in the http request - authorization header, ie "Authorization: Bearer ". + authorization header, ie "authorization: Bearer ". Returns: A CallCredentials. -- cgit v1.2.3 From 38ba85ce48f450d4022547687e55cddbddafd8ab Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 29 Aug 2016 16:59:23 -0700 Subject: allow choosing config of ruby package builds from environment variable --- Rakefile | 6 ++++-- src/ruby/ext/grpc/extconf.rb | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/Rakefile b/Rakefile index 5b6f101d8f..cfd4181d7e 100755 --- a/Rakefile +++ b/Rakefile @@ -100,13 +100,15 @@ desc 'Build the native gem file under rake_compiler_dock' task 'gem:native' do verbose = ENV['V'] || '0' + grpc_config = ENV['GRPC_CONFIG'] || 'opt' + if RUBY_PLATFORM =~ /darwin/ FileUtils.touch 'grpc_c.32.ruby' FileUtils.touch 'grpc_c.64.ruby' - system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose}" + system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}" else Rake::Task['dlls'].execute - docker_for_windows "bundle && rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose}" + docker_for_windows "bundle && rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}" end end diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 6d65db8306..66c54aa3e0 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -91,6 +91,10 @@ if grpc_config == 'gcov' $LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic' end +if grpc_config == 'dbg' + $CFLAGS << ' -O0' +end + $LDFLAGS << ' -Wl,-wrap,memcpy' if RUBY_PLATFORM =~ /linux/ $LDFLAGS << ' -static' if windows -- cgit v1.2.3 From 7c5befd86b56a1eb4d6ed8312d5e722547f39e2d Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 1 Sep 2016 17:09:47 -0700 Subject: Change UnimplementedService to UnimplementedEchoService in echo.proto --- src/proto/grpc/testing/echo.proto | 2 +- test/cpp/end2end/async_end2end_test.cc | 4 ++-- test/cpp/end2end/end2end_test.cc | 4 ++-- test/cpp/end2end/hybrid_end2end_test.cc | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/proto/grpc/testing/echo.proto b/src/proto/grpc/testing/echo.proto index c596aabfcc..ca60a41b4f 100644 --- a/src/proto/grpc/testing/echo.proto +++ b/src/proto/grpc/testing/echo.proto @@ -42,7 +42,7 @@ service EchoTestService { rpc Unimplemented(EchoRequest) returns (EchoResponse); } -service UnimplementedService { +service UnimplementedEchoService { rpc Unimplemented(EchoRequest) returns (EchoResponse); } diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 4a8936d281..27673c4ea1 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -898,8 +898,8 @@ TEST_P(AsyncEnd2endTest, UnimplementedRpc) { GetChannelCredentials(GetParam().credentials_type, &args); std::shared_ptr channel = CreateCustomChannel(server_address_.str(), channel_creds, args); - std::unique_ptr stub; - stub = grpc::testing::UnimplementedService::NewStub(channel); + std::unique_ptr stub; + stub = grpc::testing::UnimplementedEchoService::NewStub(channel); EchoRequest send_request; EchoResponse recv_response; Status recv_status; diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 0f87ae3e44..683a71583a 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -967,8 +967,8 @@ TEST_P(End2endTest, ChannelStateTimeout) { // Talking to a non-existing service. TEST_P(End2endTest, NonExistingService) { ResetChannel(); - std::unique_ptr stub; - stub = grpc::testing::UnimplementedService::NewStub(channel_); + std::unique_ptr stub; + stub = grpc::testing::UnimplementedEchoService::NewStub(channel_); EchoRequest request; EchoResponse response; diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 7e0c0e8a7c..77b0e1f40e 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -346,7 +346,7 @@ class HybridEnd2endTest : public ::testing::Test { EXPECT_TRUE(s.ok()); } - grpc::testing::UnimplementedService::Service unimplemented_service_; + grpc::testing::UnimplementedEchoService::Service unimplemented_service_; std::vector> cqs_; std::unique_ptr stub_; std::unique_ptr server_; -- cgit v1.2.3 From 676565326c061597e5a0f15f5e43db7ddf37fd54 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 1 Sep 2016 18:50:13 -0700 Subject: destroy byte buffer reader after use --- src/csharp/ext/grpc_csharp_ext.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 3d0947c03d..068bf709b8 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -255,8 +255,10 @@ GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_batch_context_recv_message_length( } GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, ctx->recv_message)); + intptr_t result = (intptr_t)grpc_byte_buffer_length(reader.buffer_out); + grpc_byte_buffer_reader_destroy(&reader); - return (intptr_t)grpc_byte_buffer_length(reader.buffer_out); + return result; } /* @@ -279,6 +281,8 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer( offset += len; gpr_slice_unref(slice); } + + grpc_byte_buffer_reader_destroy(&reader); } GPR_EXPORT grpc_status_code GPR_CALLTYPE -- cgit v1.2.3 From a6c2179c3bfe1f49caedf1ecacfb043592d31315 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 2 Sep 2016 08:57:29 -0700 Subject: clang-format --- src/core/ext/transport/chttp2/transport/writing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 80068744cc..311b26e354 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -52,8 +52,8 @@ int grpc_chttp2_unlocking_check_writes( GPR_TIMER_BEGIN("grpc_chttp2_unlocking_check_writes", 0); transport_writing->max_frame_size = - transport_global - ->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]; + transport_global->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]; /* simple writes are queued to qbuf, and flushed here */ gpr_slice_buffer_swap(&transport_global->qbuf, &transport_writing->outbuf); -- cgit v1.2.3 From 3fa3d445488d25cf36c23c630f9df81e86be6ac4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 12:15:22 +0200 Subject: update Google.Apis.Auth to 1.16.0 for project.json projects --- src/csharp/Grpc.Auth/project.json | 2 +- templates/src/csharp/Grpc.Auth/project.json.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 30f0944693..19691cf9fa 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -23,7 +23,7 @@ }, "dependencies": { "Grpc.Core": "1.1.0-dev", - "Google.Apis.Auth": "1.15.0" + "Google.Apis.Auth": "1.16.0" }, "frameworks": { "net45": { }, diff --git a/templates/src/csharp/Grpc.Auth/project.json.template b/templates/src/csharp/Grpc.Auth/project.json.template index 19d4b42cf0..39b201ffb1 100644 --- a/templates/src/csharp/Grpc.Auth/project.json.template +++ b/templates/src/csharp/Grpc.Auth/project.json.template @@ -25,7 +25,7 @@ }, "dependencies": { "Grpc.Core": "${settings.csharp_version}", - "Google.Apis.Auth": "1.15.0" + "Google.Apis.Auth": "1.16.0" }, "frameworks": { "net45": { }, -- cgit v1.2.3 From 9ed40989251261c8fd5d4e47b09823873ca18827 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 15:40:15 +0200 Subject: update .csproj projects to Google.Apis.Auth to 1.16.0 --- src/csharp/Grpc.Auth/Grpc.Auth.csproj | 18 +++++++++++++--- src/csharp/Grpc.Auth/packages.config | 7 +++++-- .../Grpc.IntegrationTesting.Client.csproj | 18 +++++++++++++--- .../Grpc.IntegrationTesting.Client/packages.config | 7 +++++-- .../Grpc.IntegrationTesting.Server.csproj | 18 +++++++++++++--- .../Grpc.IntegrationTesting.Server/packages.config | 7 +++++-- .../Grpc.IntegrationTesting.csproj | 24 ++++++++++++++++------ src/csharp/Grpc.IntegrationTesting/packages.config | 9 +++++--- 8 files changed, 84 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Auth/Grpc.Auth.csproj b/src/csharp/Grpc.Auth/Grpc.Auth.csproj index 7a6955311a..a44aaf1fdd 100644 --- a/src/csharp/Grpc.Auth/Grpc.Auth.csproj +++ b/src/csharp/Grpc.Auth/Grpc.Auth.csproj @@ -49,14 +49,26 @@ ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + - ..\packages\Google.Apis.Core.1.15.0\lib\net45\Google.Apis.Core.dll + ..\packages\Google.Apis.Core.1.16.0\lib\net45\Google.Apis.Core.dll + + + ..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.PlatformServices.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.PlatformServices.dll diff --git a/src/csharp/Grpc.Auth/packages.config b/src/csharp/Grpc.Auth/packages.config index 738d3e6f3b..11c6375c63 100644 --- a/src/csharp/Grpc.Auth/packages.config +++ b/src/csharp/Grpc.Auth/packages.config @@ -1,7 +1,10 @@  - - + + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj b/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj index 6816b5c5a2..ae58073b52 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj +++ b/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj @@ -49,14 +49,26 @@ ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + - ..\packages\Google.Apis.Core.1.15.0\lib\net45\Google.Apis.Core.dll + ..\packages\Google.Apis.Core.1.16.0\lib\net45\Google.Apis.Core.dll + + + ..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.PlatformServices.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.PlatformServices.dll diff --git a/src/csharp/Grpc.IntegrationTesting.Client/packages.config b/src/csharp/Grpc.IntegrationTesting.Client/packages.config index 738d3e6f3b..11c6375c63 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/packages.config +++ b/src/csharp/Grpc.IntegrationTesting.Client/packages.config @@ -1,7 +1,10 @@  - - + + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj b/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj index 987387ca25..d5c40ba948 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj +++ b/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj @@ -49,14 +49,26 @@ ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + - ..\packages\Google.Apis.Core.1.15.0\lib\net45\Google.Apis.Core.dll + ..\packages\Google.Apis.Core.1.16.0\lib\net45\Google.Apis.Core.dll + + + ..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.PlatformServices.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.PlatformServices.dll diff --git a/src/csharp/Grpc.IntegrationTesting.Server/packages.config b/src/csharp/Grpc.IntegrationTesting.Server/packages.config index 738d3e6f3b..11c6375c63 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/packages.config +++ b/src/csharp/Grpc.IntegrationTesting.Server/packages.config @@ -1,7 +1,10 @@  - - + + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index e030b21eec..e88fa9f6c5 100644 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -63,17 +63,29 @@ ..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll + + ..\packages\CommandLineParser.Unofficial.2.0.275\lib\net45\CommandLineParser.Unofficial.dll + + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + - ..\packages\Google.Apis.Core.1.15.0\lib\net45\Google.Apis.Core.dll + ..\packages\Google.Apis.Core.1.16.0\lib\net45\Google.Apis.Core.dll + + + ..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.dll + + + ..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.PlatformServices.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.dll - ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll - - - ..\packages\CommandLineParser.Unofficial.2.0.275\lib\net45\CommandLineParser.Unofficial.dll + ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.PlatformServices.dll diff --git a/src/csharp/Grpc.IntegrationTesting/packages.config b/src/csharp/Grpc.IntegrationTesting/packages.config index 8bf9dd4937..56a7eecc88 100644 --- a/src/csharp/Grpc.IntegrationTesting/packages.config +++ b/src/csharp/Grpc.IntegrationTesting/packages.config @@ -2,12 +2,15 @@ - - + + + - + + + \ No newline at end of file -- cgit v1.2.3 From d059de7c557526939c9a31967cfecdd6f2217169 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 15:51:34 +0200 Subject: update Protobuf to 3.0.0 in project.json projects --- src/csharp/Grpc.Examples/project.json | 2 +- src/csharp/Grpc.HealthCheck/project.json | 2 +- src/csharp/Grpc.IntegrationTesting/project.json | 2 +- templates/src/csharp/Grpc.Examples/project.json.template | 2 +- templates/src/csharp/Grpc.HealthCheck/project.json.template | 2 +- templates/src/csharp/Grpc.IntegrationTesting/project.json.template | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Examples/project.json b/src/csharp/Grpc.Examples/project.json index 98bd5d852c..76236d6b3d 100644 --- a/src/csharp/Grpc.Examples/project.json +++ b/src/csharp/Grpc.Examples/project.json @@ -11,7 +11,7 @@ "Grpc.Core": { "target": "project" }, - "Google.Protobuf": "3.0.0-beta3" + "Google.Protobuf": "3.0.0" }, "frameworks": { "net45": { diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 7c062a7e40..75aa5135bf 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -23,7 +23,7 @@ }, "dependencies": { "Grpc.Core": "1.1.0-dev", - "Google.Protobuf": "3.0.0-beta3" + "Google.Protobuf": "3.0.0" }, "frameworks": { "net45": { diff --git a/src/csharp/Grpc.IntegrationTesting/project.json b/src/csharp/Grpc.IntegrationTesting/project.json index 9d706510b2..f1c6906276 100644 --- a/src/csharp/Grpc.IntegrationTesting/project.json +++ b/src/csharp/Grpc.IntegrationTesting/project.json @@ -57,7 +57,7 @@ "Grpc.Core": { "target": "project" }, - "Google.Protobuf": "3.0.0-beta3", + "Google.Protobuf": "3.0.0", "CommandLineParser.Unofficial": "2.0.275", "NUnit": "3.2.0", "NUnitLite": "3.2.0-*" diff --git a/templates/src/csharp/Grpc.Examples/project.json.template b/templates/src/csharp/Grpc.Examples/project.json.template index 117f842e01..ac532fa914 100644 --- a/templates/src/csharp/Grpc.Examples/project.json.template +++ b/templates/src/csharp/Grpc.Examples/project.json.template @@ -6,7 +6,7 @@ "Grpc.Core": { "target": "project" }, - "Google.Protobuf": "3.0.0-beta3" + "Google.Protobuf": "3.0.0" }, "frameworks": { "net45": { diff --git a/templates/src/csharp/Grpc.HealthCheck/project.json.template b/templates/src/csharp/Grpc.HealthCheck/project.json.template index cd2da0089b..2bd8481d4a 100644 --- a/templates/src/csharp/Grpc.HealthCheck/project.json.template +++ b/templates/src/csharp/Grpc.HealthCheck/project.json.template @@ -25,7 +25,7 @@ }, "dependencies": { "Grpc.Core": "${settings.csharp_version}", - "Google.Protobuf": "3.0.0-beta3" + "Google.Protobuf": "3.0.0" }, "frameworks": { "net45": { diff --git a/templates/src/csharp/Grpc.IntegrationTesting/project.json.template b/templates/src/csharp/Grpc.IntegrationTesting/project.json.template index 1cb5ca4ba3..0097b37225 100644 --- a/templates/src/csharp/Grpc.IntegrationTesting/project.json.template +++ b/templates/src/csharp/Grpc.IntegrationTesting/project.json.template @@ -9,7 +9,7 @@ "Grpc.Core": { "target": "project" }, - "Google.Protobuf": "3.0.0-beta3", + "Google.Protobuf": "3.0.0", "CommandLineParser.Unofficial": "2.0.275", "NUnit": "3.2.0", "NUnitLite": "3.2.0-*" -- cgit v1.2.3 From 350458f714433c82328ee805a3fc1e45fbd168d3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 16:04:02 +0200 Subject: update csproj files to Google.Protobuf to 3.0.0 --- src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj | 6 +++--- src/csharp/Grpc.Examples.Tests/packages.config | 4 ++-- src/csharp/Grpc.Examples/Grpc.Examples.csproj | 7 +++---- src/csharp/Grpc.Examples/packages.config | 4 ++-- src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj | 6 +++--- src/csharp/Grpc.HealthCheck.Tests/packages.config | 2 +- src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj | 7 +++---- src/csharp/Grpc.HealthCheck/packages.config | 2 +- src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj | 6 +++--- src/csharp/Grpc.IntegrationTesting/packages.config | 2 +- 10 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj index c8801a9413..a114d96127 100644 --- a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj +++ b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj @@ -36,9 +36,6 @@ - - ..\packages\Google.Protobuf.3.0.0-beta3\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - ..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll @@ -48,6 +45,9 @@ ..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll + + ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + diff --git a/src/csharp/Grpc.Examples.Tests/packages.config b/src/csharp/Grpc.Examples.Tests/packages.config index cc473eb34c..f14517d2e2 100644 --- a/src/csharp/Grpc.Examples.Tests/packages.config +++ b/src/csharp/Grpc.Examples.Tests/packages.config @@ -1,7 +1,7 @@  - - + + \ No newline at end of file diff --git a/src/csharp/Grpc.Examples/Grpc.Examples.csproj b/src/csharp/Grpc.Examples/Grpc.Examples.csproj index 4521649b6f..dcbef5fc0b 100644 --- a/src/csharp/Grpc.Examples/Grpc.Examples.csproj +++ b/src/csharp/Grpc.Examples/Grpc.Examples.csproj @@ -37,10 +37,6 @@ ..\keys\Grpc.snk - - False - ..\packages\Google.Protobuf.3.0.0-beta3\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - ..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll @@ -50,6 +46,9 @@ False ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll + + ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + diff --git a/src/csharp/Grpc.Examples/packages.config b/src/csharp/Grpc.Examples/packages.config index 8985ae4c77..d17347f08f 100644 --- a/src/csharp/Grpc.Examples/packages.config +++ b/src/csharp/Grpc.Examples/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj b/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj index aefacfbcc0..93c3b3a55f 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj +++ b/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj @@ -44,15 +44,15 @@ - - ..\packages\Google.Protobuf.3.0.0-beta3\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - ..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll ..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll + + ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + diff --git a/src/csharp/Grpc.HealthCheck.Tests/packages.config b/src/csharp/Grpc.HealthCheck.Tests/packages.config index 2bcfec8829..e796d6b135 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/packages.config +++ b/src/csharp/Grpc.HealthCheck.Tests/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj index e13416cc1a..54a2984964 100644 --- a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj +++ b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj @@ -38,10 +38,6 @@ ..\keys\Grpc.snk - - False - ..\packages\Google.Protobuf.3.0.0-beta3\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - @@ -53,6 +49,9 @@ + + ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + diff --git a/src/csharp/Grpc.HealthCheck/packages.config b/src/csharp/Grpc.HealthCheck/packages.config index 063094f775..f8e353bf26 100644 --- a/src/csharp/Grpc.HealthCheck/packages.config +++ b/src/csharp/Grpc.HealthCheck/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index e88fa9f6c5..55c926768b 100644 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -48,9 +48,6 @@ ..\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll - - ..\packages\Google.Protobuf.3.0.0-beta3\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll @@ -87,6 +84,9 @@ ..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.PlatformServices.dll + + ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + diff --git a/src/csharp/Grpc.IntegrationTesting/packages.config b/src/csharp/Grpc.IntegrationTesting/packages.config index 56a7eecc88..e0365420b2 100644 --- a/src/csharp/Grpc.IntegrationTesting/packages.config +++ b/src/csharp/Grpc.IntegrationTesting/packages.config @@ -5,7 +5,7 @@ - + -- cgit v1.2.3 From b9a6f792410a0d245a10eafe2bcc734e2e9dbd26 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 16:33:46 +0200 Subject: cleanup of project.json files --- src/csharp/Grpc.Auth/project.json | 7 +------ src/csharp/Grpc.Core/project.json | 3 --- src/csharp/Grpc.Examples.MathClient/project.json | 3 --- src/csharp/Grpc.Examples.MathServer/project.json | 3 --- src/csharp/Grpc.Examples/project.json | 3 --- src/csharp/Grpc.HealthCheck/project.json | 3 --- templates/src/csharp/Grpc.Auth/project.json.template | 7 +------ templates/src/csharp/Grpc.Core/project.json.template | 3 --- .../src/csharp/Grpc.Examples.MathClient/project.json.template | 3 --- .../src/csharp/Grpc.Examples.MathServer/project.json.template | 3 --- templates/src/csharp/Grpc.Examples/project.json.template | 3 --- templates/src/csharp/Grpc.HealthCheck/project.json.template | 3 --- 12 files changed, 2 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 19691cf9fa..595e29f50a 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -28,13 +28,8 @@ "frameworks": { "net45": { }, "netstandard1.5": { - "imports": [ - "portable-net45" - ], "dependencies": { - "Microsoft.NETCore.Portable.Compatibility": "1.0.1", - "NETStandard.Library": "1.6.0", - "System.Threading.Tasks": "4.0.11" + "NETStandard.Library": "1.6.0" } } } diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index f7e21a25dd..50c328abe1 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -36,9 +36,6 @@ "frameworks": { "net45": { }, "netstandard1.5": { - "imports": [ - "portable-net45" - ], "dependencies": { "NETStandard.Library": "1.6.0", "System.Threading.Thread": "4.0.0" diff --git a/src/csharp/Grpc.Examples.MathClient/project.json b/src/csharp/Grpc.Examples.MathClient/project.json index ad319478ab..c0725a1468 100644 --- a/src/csharp/Grpc.Examples.MathClient/project.json +++ b/src/csharp/Grpc.Examples.MathClient/project.json @@ -56,9 +56,6 @@ "frameworks": { "net45": { }, "netcoreapp1.0": { - "imports": [ - "portable-net45" - ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", "NETStandard.Library": "1.6.0" diff --git a/src/csharp/Grpc.Examples.MathServer/project.json b/src/csharp/Grpc.Examples.MathServer/project.json index ad319478ab..c0725a1468 100644 --- a/src/csharp/Grpc.Examples.MathServer/project.json +++ b/src/csharp/Grpc.Examples.MathServer/project.json @@ -56,9 +56,6 @@ "frameworks": { "net45": { }, "netcoreapp1.0": { - "imports": [ - "portable-net45" - ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", "NETStandard.Library": "1.6.0" diff --git a/src/csharp/Grpc.Examples/project.json b/src/csharp/Grpc.Examples/project.json index 76236d6b3d..ce0cfa860d 100644 --- a/src/csharp/Grpc.Examples/project.json +++ b/src/csharp/Grpc.Examples/project.json @@ -21,9 +21,6 @@ } }, "netcoreapp1.0": { - "imports": [ - "portable-net45" - ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", "NETStandard.Library": "1.6.0" diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 75aa5135bf..9d631229d8 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -33,9 +33,6 @@ } }, "netstandard1.5": { - "imports": [ - "portable-net45" - ], "dependencies": { "NETStandard.Library": "1.6.0" } diff --git a/templates/src/csharp/Grpc.Auth/project.json.template b/templates/src/csharp/Grpc.Auth/project.json.template index 39b201ffb1..939a0c8d28 100644 --- a/templates/src/csharp/Grpc.Auth/project.json.template +++ b/templates/src/csharp/Grpc.Auth/project.json.template @@ -30,13 +30,8 @@ "frameworks": { "net45": { }, "netstandard1.5": { - "imports": [ - "portable-net45" - ], "dependencies": { - "Microsoft.NETCore.Portable.Compatibility": "1.0.1", - "NETStandard.Library": "1.6.0", - "System.Threading.Tasks": "4.0.11" + "NETStandard.Library": "1.6.0" } } } diff --git a/templates/src/csharp/Grpc.Core/project.json.template b/templates/src/csharp/Grpc.Core/project.json.template index e6f8290200..ed5d649936 100644 --- a/templates/src/csharp/Grpc.Core/project.json.template +++ b/templates/src/csharp/Grpc.Core/project.json.template @@ -38,9 +38,6 @@ "frameworks": { "net45": { }, "netstandard1.5": { - "imports": [ - "portable-net45" - ], "dependencies": { "NETStandard.Library": "1.6.0", "System.Threading.Thread": "4.0.0" diff --git a/templates/src/csharp/Grpc.Examples.MathClient/project.json.template b/templates/src/csharp/Grpc.Examples.MathClient/project.json.template index 67151dbcfa..f0fc4b97da 100644 --- a/templates/src/csharp/Grpc.Examples.MathClient/project.json.template +++ b/templates/src/csharp/Grpc.Examples.MathClient/project.json.template @@ -10,9 +10,6 @@ "frameworks": { "net45": { }, "netcoreapp1.0": { - "imports": [ - "portable-net45" - ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", "NETStandard.Library": "1.6.0" diff --git a/templates/src/csharp/Grpc.Examples.MathServer/project.json.template b/templates/src/csharp/Grpc.Examples.MathServer/project.json.template index 67151dbcfa..f0fc4b97da 100644 --- a/templates/src/csharp/Grpc.Examples.MathServer/project.json.template +++ b/templates/src/csharp/Grpc.Examples.MathServer/project.json.template @@ -10,9 +10,6 @@ "frameworks": { "net45": { }, "netcoreapp1.0": { - "imports": [ - "portable-net45" - ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", "NETStandard.Library": "1.6.0" diff --git a/templates/src/csharp/Grpc.Examples/project.json.template b/templates/src/csharp/Grpc.Examples/project.json.template index ac532fa914..1e79c71710 100644 --- a/templates/src/csharp/Grpc.Examples/project.json.template +++ b/templates/src/csharp/Grpc.Examples/project.json.template @@ -16,9 +16,6 @@ } }, "netcoreapp1.0": { - "imports": [ - "portable-net45" - ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", "NETStandard.Library": "1.6.0" diff --git a/templates/src/csharp/Grpc.HealthCheck/project.json.template b/templates/src/csharp/Grpc.HealthCheck/project.json.template index 2bd8481d4a..46307dda00 100644 --- a/templates/src/csharp/Grpc.HealthCheck/project.json.template +++ b/templates/src/csharp/Grpc.HealthCheck/project.json.template @@ -35,9 +35,6 @@ } }, "netstandard1.5": { - "imports": [ - "portable-net45" - ], "dependencies": { "NETStandard.Library": "1.6.0" } -- cgit v1.2.3 From 06aff11d39df3f8f71fe30dd8c0048c1ddbd9abc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 17:26:49 +0200 Subject: upgrade Moq to version that supports netstandard1.3 --- src/csharp/Grpc.IntegrationTesting.Client/project.json | 3 +-- src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json | 3 +-- src/csharp/Grpc.IntegrationTesting.Server/project.json | 3 +-- src/csharp/Grpc.IntegrationTesting.StressClient/project.json | 3 +-- .../Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj | 9 ++++++--- src/csharp/Grpc.IntegrationTesting/packages.config | 3 ++- src/csharp/Grpc.IntegrationTesting/project.json | 7 ++----- .../csharp/Grpc.IntegrationTesting.Client/project.json.template | 3 +-- .../Grpc.IntegrationTesting.QpsWorker/project.json.template | 3 +-- .../csharp/Grpc.IntegrationTesting.Server/project.json.template | 3 +-- .../Grpc.IntegrationTesting.StressClient/project.json.template | 3 +-- .../src/csharp/Grpc.IntegrationTesting/project.json.template | 7 ++----- 12 files changed, 20 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.IntegrationTesting.Client/project.json b/src/csharp/Grpc.IntegrationTesting.Client/project.json index 287950720f..e54b5bd296 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Client/project.json @@ -59,8 +59,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json index 287950720f..e54b5bd296 100644 --- a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json +++ b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json @@ -59,8 +59,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/src/csharp/Grpc.IntegrationTesting.Server/project.json b/src/csharp/Grpc.IntegrationTesting.Server/project.json index 287950720f..e54b5bd296 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Server/project.json @@ -59,8 +59,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json index 287950720f..e54b5bd296 100644 --- a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json @@ -59,8 +59,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index 55c926768b..afd85fb484 100644 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -38,9 +38,6 @@ ..\keys\Grpc.snk - - ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll - @@ -87,6 +84,12 @@ ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + + ..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll + + + ..\packages\Moq.4.6.38-alpha\lib\net45\Moq.dll + diff --git a/src/csharp/Grpc.IntegrationTesting/packages.config b/src/csharp/Grpc.IntegrationTesting/packages.config index e0365420b2..a39fb3a23e 100644 --- a/src/csharp/Grpc.IntegrationTesting/packages.config +++ b/src/csharp/Grpc.IntegrationTesting/packages.config @@ -1,13 +1,14 @@  + - + diff --git a/src/csharp/Grpc.IntegrationTesting/project.json b/src/csharp/Grpc.IntegrationTesting/project.json index f1c6906276..abc217b092 100644 --- a/src/csharp/Grpc.IntegrationTesting/project.json +++ b/src/csharp/Grpc.IntegrationTesting/project.json @@ -59,14 +59,12 @@ }, "Google.Protobuf": "3.0.0", "CommandLineParser.Unofficial": "2.0.275", + "Moq": "4.6.38-alpha", "NUnit": "3.2.0", "NUnitLite": "3.2.0-*" }, "frameworks": { "net45": { - "dependencies": { - "Moq": "4.2.1510.2205" - }, "frameworkAssemblies": { "System.Runtime": "", "System.IO": "" @@ -74,8 +72,7 @@ }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/templates/src/csharp/Grpc.IntegrationTesting.Client/project.json.template b/templates/src/csharp/Grpc.IntegrationTesting.Client/project.json.template index 93151f2b89..40300407ba 100644 --- a/templates/src/csharp/Grpc.IntegrationTesting.Client/project.json.template +++ b/templates/src/csharp/Grpc.IntegrationTesting.Client/project.json.template @@ -11,8 +11,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/templates/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json.template b/templates/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json.template index 93151f2b89..40300407ba 100644 --- a/templates/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json.template +++ b/templates/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json.template @@ -11,8 +11,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/templates/src/csharp/Grpc.IntegrationTesting.Server/project.json.template b/templates/src/csharp/Grpc.IntegrationTesting.Server/project.json.template index 93151f2b89..40300407ba 100644 --- a/templates/src/csharp/Grpc.IntegrationTesting.Server/project.json.template +++ b/templates/src/csharp/Grpc.IntegrationTesting.Server/project.json.template @@ -11,8 +11,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/templates/src/csharp/Grpc.IntegrationTesting.StressClient/project.json.template b/templates/src/csharp/Grpc.IntegrationTesting.StressClient/project.json.template index 93151f2b89..40300407ba 100644 --- a/templates/src/csharp/Grpc.IntegrationTesting.StressClient/project.json.template +++ b/templates/src/csharp/Grpc.IntegrationTesting.StressClient/project.json.template @@ -11,8 +11,7 @@ "net45": { }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", diff --git a/templates/src/csharp/Grpc.IntegrationTesting/project.json.template b/templates/src/csharp/Grpc.IntegrationTesting/project.json.template index 0097b37225..6a32ddb2f3 100644 --- a/templates/src/csharp/Grpc.IntegrationTesting/project.json.template +++ b/templates/src/csharp/Grpc.IntegrationTesting/project.json.template @@ -11,14 +11,12 @@ }, "Google.Protobuf": "3.0.0", "CommandLineParser.Unofficial": "2.0.275", + "Moq": "4.6.38-alpha", "NUnit": "3.2.0", "NUnitLite": "3.2.0-*" }, "frameworks": { "net45": { - "dependencies": { - "Moq": "4.2.1510.2205" - }, "frameworkAssemblies": { "System.Runtime": "", "System.IO": "" @@ -26,8 +24,7 @@ }, "netcoreapp1.0": { "imports": [ - "portable-net45", - "net45" + "portable-net45" ], "dependencies": { "Microsoft.NETCore.App": "1.0.0", -- cgit v1.2.3 From 7b3cf071c36854ad032f0ce45ebcccc32035a7ab Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Sep 2016 18:10:56 +0200 Subject: address coreCLR TODO --- src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs b/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs index c17ede7561..ac6c8d0740 100644 --- a/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs @@ -48,8 +48,6 @@ namespace Grpc.IntegrationTesting { TestService.TestServiceClient unimplementedClient = new UnimplementedTestServiceClient(); - // TODO: replace Moq by some mocking library with CoreCLR support. -#if !NETCOREAPP1_0 [Test] public void ExpandedParamOverloadCanBeMocked() { @@ -72,7 +70,6 @@ namespace Grpc.IntegrationTesting Assert.AreSame(expected, mockClient.Object.UnaryCall(new SimpleRequest(), new CallOptions())); } -#endif [Test] public void DefaultMethodStubThrows_UnaryCall() -- cgit v1.2.3 From ecb12511edcf750ca8c2a8329c9211ab309d9590 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 5 Sep 2016 14:58:07 -0700 Subject: Fix fuzzing detected failure --- src/core/lib/channel/http_client_filter.c | 1 - .../22967e8ed837f03b76a980cc1d25054fb84b40e9 | Bin 0 -> 694 bytes .../3f464011f8620f227309f6b2c84df6fffb8ed962 | Bin 0 -> 794 bytes .../crash-15070b2a2719ed8a6cbbaac25da02b7085993648 | Bin 0 -> 304 bytes tools/run_tests/tests.json | 57 +++++++++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/22967e8ed837f03b76a980cc1d25054fb84b40e9 create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/3f464011f8620f227309f6b2c84df6fffb8ed962 create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/crash-15070b2a2719ed8a6cbbaac25da02b7085993648 (limited to 'src') diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index ef68cc86ea..edcc741ff6 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -233,7 +233,6 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, if (method == GRPC_MDELEM_METHOD_GET) { /* allocate memory to hold the entire payload */ calld->payload_bytes = gpr_malloc(op->send_message->length); - GPR_ASSERT(calld->payload_bytes); /* read slices of send_message and copy into payload_bytes */ calld->send_op = *op; diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/22967e8ed837f03b76a980cc1d25054fb84b40e9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/22967e8ed837f03b76a980cc1d25054fb84b40e9 new file mode 100644 index 0000000000..1aa57b990d Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/22967e8ed837f03b76a980cc1d25054fb84b40e9 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3f464011f8620f227309f6b2c84df6fffb8ed962 b/test/core/end2end/fuzzers/api_fuzzer_corpus/3f464011f8620f227309f6b2c84df6fffb8ed962 new file mode 100644 index 0000000000..385a724f3d Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/3f464011f8620f227309f6b2c84df6fffb8ed962 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-15070b2a2719ed8a6cbbaac25da02b7085993648 b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-15070b2a2719ed8a6cbbaac25da02b7085993648 new file mode 100644 index 0000000000..e21c7c6d39 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-15070b2a2719ed8a6cbbaac25da02b7085993648 differ diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index a59abba391..6ec7935c25 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -33037,6 +33037,25 @@ ], "uses_polling": false }, + { + "args": [ + "test/core/end2end/fuzzers/api_fuzzer_corpus/22967e8ed837f03b76a980cc1d25054fb84b40e9" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "api_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, { "args": [ "test/core/end2end/fuzzers/api_fuzzer_corpus/22c9ed2979d9963bce6500997f1e0433988e7e37" @@ -36001,6 +36020,25 @@ ], "uses_polling": false }, + { + "args": [ + "test/core/end2end/fuzzers/api_fuzzer_corpus/3f464011f8620f227309f6b2c84df6fffb8ed962" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "api_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, { "args": [ "test/core/end2end/fuzzers/api_fuzzer_corpus/3f47ad9ab401599f42d3c4f37ab9f702e3ff0fc9" @@ -49890,6 +49928,25 @@ ], "uses_polling": false }, + { + "args": [ + "test/core/end2end/fuzzers/api_fuzzer_corpus/crash-15070b2a2719ed8a6cbbaac25da02b7085993648" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "flaky": false, + "language": "c", + "name": "api_fuzzer_one_entry", + "platforms": [ + "linux" + ], + "uses_polling": false + }, { "args": [ "test/core/end2end/fuzzers/api_fuzzer_corpus/crash-1b9aeaf762bb1a972dda8f3a455df2628efd693b" -- cgit v1.2.3 From 47110750bc317eeac12ab89204c05755e8e84dd4 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 1 Sep 2016 13:44:00 -0700 Subject: php: minor error initializing a variable --- src/php/tests/interop/interop_client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index c94ba61296..94ceeda02c 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -108,7 +108,7 @@ function performLargeUnary($stub, $fillUsername = false, $fillOauthScope = false $request->setFillUsername($fillUsername); $request->setFillOauthScope($fillOauthScope); - $options = false; + $options = []; if ($callback) { $options['call_credentials_callback'] = $callback; } -- cgit v1.2.3 From cde12a523ac6dd2fc3fadab37834ef1a19f074e3 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 1 Sep 2016 22:03:20 -0700 Subject: php: use ssl hostname_override as auth audience uri if present --- src/php/lib/Grpc/BaseStub.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index 2fec1bd9cc..d850eebc78 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -41,6 +41,7 @@ namespace Grpc; class BaseStub { private $hostname; + private $hostname_override; private $channel; // a callback function @@ -75,6 +76,9 @@ class BaseStub } else { $opts['grpc.primary_user_agent'] = ''; } + if (!empty($opts['grpc.ssl_target_name_override'])) { + $this->hostname_override = $opts['grpc.ssl_target_name_override']; + } $opts['grpc.primary_user_agent'] .= 'grpc-php/'.$package_config['version']; if (!array_key_exists('credentials', $opts)) { @@ -173,7 +177,12 @@ class BaseStub } $service_name = substr($method, 0, $last_slash_idx); - return 'https://'.$this->hostname.$service_name; + if ($this->hostname_override) { + $hostname = $this->hostname_override; + } else { + $hostname = $this->hostname; + } + return 'https://'.$hostname.$service_name; } /** -- cgit v1.2.3