Merge github.com:grpc/grpc into we-are-never-ever-ever

pull/5944/head
Craig Tiller 9 years ago
commit 09694b984e
  1. 37
      BUILD
  2. 254
      Makefile
  3. 2
      PYTHON-MANIFEST.in
  4. 115
      build.yaml
  5. 57
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  6. 24
      src/core/ext/transport/chttp2/transport/frame_data.c
  7. 2
      src/core/ext/transport/chttp2/transport/frame_data.h
  8. 8
      src/core/ext/transport/chttp2/transport/frame_rst_stream.c
  9. 4
      src/core/ext/transport/chttp2/transport/frame_rst_stream.h
  10. 12
      src/core/ext/transport/chttp2/transport/frame_window_update.c
  11. 4
      src/core/ext/transport/chttp2/transport/frame_window_update.h
  12. 6
      src/core/ext/transport/chttp2/transport/hpack_encoder.c
  13. 2
      src/core/ext/transport/chttp2/transport/hpack_encoder.h
  14. 41
      src/core/ext/transport/chttp2/transport/hpack_parser.c
  15. 24
      src/core/ext/transport/chttp2/transport/hpack_table.c
  16. 8
      src/core/ext/transport/chttp2/transport/internal.h
  17. 34
      src/core/ext/transport/chttp2/transport/parsing.c
  18. 42
      src/core/ext/transport/chttp2/transport/writing.c
  19. 14
      src/core/lib/channel/channel_args.h
  20. 43
      src/core/lib/client_config/lb_policies/pick_first.c
  21. 59
      src/core/lib/client_config/lb_policies/round_robin.c
  22. 5
      src/core/lib/client_config/lb_policy_factory.c
  23. 15
      src/core/lib/client_config/lb_policy_factory.h
  24. 4
      src/core/lib/client_config/lb_policy_registry.c
  25. 3
      src/core/lib/client_config/lb_policy_registry.h
  26. 23
      src/core/lib/client_config/resolvers/dns_resolver.c
  27. 52
      src/core/lib/client_config/resolvers/sockaddr_resolver.c
  28. 26
      src/core/lib/client_config/resolvers/zookeeper_resolver.c
  29. 16
      src/core/lib/http/parser.c
  30. 2
      src/core/lib/iomgr/pollset_set_windows.c
  31. 7
      src/core/lib/json/json_reader.c
  32. 5
      src/core/lib/surface/call.c
  33. 19
      src/core/lib/transport/transport.c
  34. 20
      src/core/lib/transport/transport.h
  35. 11
      src/csharp/Grpc.IntegrationTesting/BenchmarkServiceImpl.cs
  36. 195
      src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
  37. 71
      src/csharp/Grpc.IntegrationTesting/GenericService.cs
  38. 1
      src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj
  39. 12
      src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs
  40. 65
      src/csharp/Grpc.IntegrationTesting/ServerRunners.cs
  41. 2
      src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
  42. 3
      src/python/grpcio/precompiled.py
  43. 15
      src/ruby/ext/grpc/rb_byte_buffer.c
  44. 14
      src/ruby/ext/grpc/rb_call.c
  45. 32
      templates/BUILD.template
  46. 5
      templates/Makefile.template
  47. 4
      templates/tools/dockerfile/clang_update.include
  48. 4
      templates/tools/dockerfile/gcp_api_libraries.include
  49. 40
      templates/tools/dockerfile/grpc_interop_stress_cxx/Dockerfile.template
  50. 43
      templates/tools/dockerfile/test/fuzzer/Dockerfile.template
  51. 44
      templates/tools/fuzzer/runners.template
  52. 2
      templates/vsprojects/buildtests_c.sln.template
  53. 2
      templates/vsprojects/grpc.sln.template
  54. 2
      templates/vsprojects/vcxproj.template
  55. 8
      test/core/client_config/lb_policies_test.c
  56. 1
      test/core/client_config/uri_corpus/042dc4512fa3d391c5170cf3aa61e6a638f84342
  57. 1
      test/core/client_config/uri_corpus/0e9bbe975f2027e8c39c89f85f667530368e7d11
  58. 1
      test/core/client_config/uri_corpus/14b57bcbf1e17b1db1de491ef2ba3768f704b7dc
  59. 2
      test/core/client_config/uri_corpus/1794310671a060eead6e5ee66ac978a18ec7e84f
  60. 1
      test/core/client_config/uri_corpus/1d30b2a79afbaf2828ff42b9a9647e942ba1ab80
  61. 3
      test/core/client_config/uri_corpus/1fcf5d9c333b70596cf5ba04d1f7affdf445b971
  62. 1
      test/core/client_config/uri_corpus/23162c8a8936e20b195404c21337ee734d02a6bc
  63. 1
      test/core/client_config/uri_corpus/23f3198b815ca60bdadcaae682b9f965dda387f1
  64. 2
      test/core/client_config/uri_corpus/2ef3893b43f1f60b77b59ce06a6bce9815d78eaf
  65. 1
      test/core/client_config/uri_corpus/356c3c129e203b5c74550b4209764d74b9caefce
  66. 4
      test/core/client_config/uri_corpus/3b58860f3451d3e7aad99690a8d39782ca5116fc
  67. 1
      test/core/client_config/uri_corpus/47b5228404451fc9d4071fa69192514bb4ce33c1
  68. 4
      test/core/client_config/uri_corpus/636c5606fc23713a1bae88c8899c0541cfad4fd8
  69. 1
      test/core/client_config/uri_corpus/63fe493b270b17426d77a27cbf3abac5b2c2794a
  70. 1
      test/core/client_config/uri_corpus/655300a902b62662296a8e46bfb04fbcb07182cb
  71. 1
      test/core/client_config/uri_corpus/6b70979a70a038ff6607d6cf85485ee95baf58e6
  72. 2
      test/core/client_config/uri_corpus/7314ab3545a7535a26e0e8aad67caea5534d68b1
  73. 1
      test/core/client_config/uri_corpus/884dcaee2908ffe5f12b65b8eba81016099c4266
  74. 2
      test/core/client_config/uri_corpus/96c8d266b7dc037288ef305c996608270f72e7fb
  75. 1
      test/core/client_config/uri_corpus/975536c71ade4800415a7e9c2f1b45c35a6d5ea8
  76. 1
      test/core/client_config/uri_corpus/99750aa67d30beaea8af565c829d4999aa8cb91b
  77. 1
      test/core/client_config/uri_corpus/a1f0f9b75bb354eb063d7cba4fcfa2d0b88d63de
  78. 1
      test/core/client_config/uri_corpus/a296eb3d1d436ed7df7195b10aa3c4de3896f98d
  79. 1
      test/core/client_config/uri_corpus/a8b8e66050b424f1b8c07d46f868199fb7f60e38
  80. 1
      test/core/client_config/uri_corpus/af55baf8c8855e563befdf1eefbcbd46c5ddb8d2
  81. 1
      test/core/client_config/uri_corpus/b3c0bf66c2bf5d24ef1daf4cc5a9d6d5bd0e8bfd
  82. 1
      test/core/client_config/uri_corpus/ceb4e2264ba7a8d5be47d276b37ec09489e00245
  83. 1
      test/core/client_config/uri_corpus/cf4395958f5bfb46fd6f535a39657d016c75114c
  84. 1
      test/core/client_config/uri_corpus/d46668372b7e20154a89409a7430a28e642afdca
  85. 1
      test/core/client_config/uri_corpus/d6fe7412a0a1d1c733160246f3fa425f4f97682a
  86. 1
      test/core/client_config/uri_corpus/dns.txt
  87. 4
      test/core/client_config/uri_corpus/ea02d9fea9bad5b89cf353a0169238f584177e71
  88. 1
      test/core/client_config/uri_corpus/ec4731dddf94ed3ea92ae4d5a71f145ab6e3f6ee
  89. 1
      test/core/client_config/uri_corpus/ed2f78646f19fc47dd85ff0877c232b71913ece2
  90. 2
      test/core/client_config/uri_corpus/f6889f4a6350fea1596a3adea5cdac02bd5d1ff3
  91. 1
      test/core/client_config/uri_corpus/f6f3bd030f0d321efe7c51ca3f057de23509af67
  92. 2
      test/core/client_config/uri_corpus/f97598cff03306af3c70400608fec47268b5075d
  93. 1
      test/core/client_config/uri_corpus/f9e1ec1fc642b575bc9955618b7065747f56b101
  94. 1
      test/core/client_config/uri_corpus/fe0630a3aeed2ec6f474f362e4c839478290d5c4
  95. 1
      test/core/client_config/uri_corpus/ipv4.txt
  96. 1
      test/core/client_config/uri_corpus/ipv6.txt
  97. 1
      test/core/client_config/uri_corpus/unix.txt
  98. 52
      test/core/client_config/uri_fuzzer_test.c
  99. 2
      test/core/http/corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427
  100. 2
      test/core/http/corpus/05e613853d64a9669ea3cf41b0de777dc24931ba
  101. Some files were not shown because too many files have changed in this diff Show More

37
BUILD

@ -41,6 +41,7 @@ package(default_visibility = ["//visibility:public"])
cc_library(
name = "gpr",
srcs = [
@ -154,6 +155,7 @@ cc_library(
)
cc_library(
name = "grpc",
srcs = [
@ -294,10 +296,6 @@ cc_library(
"src/core/lib/tsi/ssl_types.h",
"src/core/lib/tsi/transport_security.h",
"src/core/lib/tsi/transport_security_interface.h",
"third_party/nanopb/pb.h",
"third_party/nanopb/pb_common.h",
"third_party/nanopb/pb_decode.h",
"third_party/nanopb/pb_encode.h",
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
"src/core/ext/transport/chttp2/client/secure/secure_channel_create.c",
"src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
@ -459,9 +457,6 @@ cc_library(
"src/core/lib/tsi/fake_transport_security.c",
"src/core/lib/tsi/ssl_transport_security.c",
"src/core/lib/tsi/transport_security.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",
],
hdrs = [
"include/grpc/byte_buffer.h",
@ -486,6 +481,7 @@ cc_library(
"//external:libssl",
"//external:zlib",
":gpr",
"//external:nanopb",
],
copts = [
"-std=gnu99",
@ -493,6 +489,7 @@ cc_library(
)
cc_library(
name = "grpc_codegen_lib",
srcs = [
@ -529,6 +526,7 @@ cc_library(
)
cc_library(
name = "grpc_unsecure",
srcs = [
@ -655,10 +653,6 @@ cc_library(
"src/core/lib/transport/static_metadata.h",
"src/core/lib/transport/transport.h",
"src/core/lib/transport/transport_impl.h",
"third_party/nanopb/pb.h",
"third_party/nanopb/pb_common.h",
"third_party/nanopb/pb_decode.h",
"third_party/nanopb/pb_encode.h",
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
"src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
"src/core/ext/transport/chttp2/transport/alpn.c",
@ -800,9 +794,6 @@ cc_library(
"src/core/lib/transport/static_metadata.c",
"src/core/lib/transport/transport.c",
"src/core/lib/transport/transport_op_string.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",
],
hdrs = [
"include/grpc/byte_buffer.h",
@ -824,6 +815,7 @@ cc_library(
],
deps = [
":gpr",
"//external:nanopb",
],
copts = [
"-std=gnu99",
@ -831,6 +823,7 @@ cc_library(
)
cc_library(
name = "grpc_zookeeper",
srcs = [
@ -851,6 +844,7 @@ cc_library(
)
cc_library(
name = "grpc++",
srcs = [
@ -983,6 +977,7 @@ cc_library(
)
cc_library(
name = "grpc++_codegen_lib",
srcs = [
@ -1046,10 +1041,12 @@ cc_library(
".",
],
deps = [
"//external:protobuf_clib",
],
)
cc_library(
name = "grpc++_unsecure",
srcs = [
@ -1174,6 +1171,7 @@ cc_library(
)
cc_library(
name = "grpc_plugin_support",
srcs = [
@ -1225,6 +1223,7 @@ cc_library(
)
cc_library(
name = "grpc_csharp_ext",
srcs = [
@ -1244,6 +1243,7 @@ cc_library(
objc_library(
name = "gpr_objc",
srcs = [
@ -1357,6 +1357,7 @@ objc_library(
)
objc_library(
name = "grpc_objc",
srcs = [
@ -1521,9 +1522,6 @@ objc_library(
"src/core/lib/tsi/fake_transport_security.c",
"src/core/lib/tsi/ssl_transport_security.c",
"src/core/lib/tsi/transport_security.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",
],
hdrs = [
"include/grpc/byte_buffer.h",
@ -1676,10 +1674,6 @@ objc_library(
"src/core/lib/tsi/ssl_types.h",
"src/core/lib/tsi/transport_security.h",
"src/core/lib/tsi/transport_security_interface.h",
"third_party/nanopb/pb.h",
"third_party/nanopb/pb_common.h",
"third_party/nanopb/pb_decode.h",
"third_party/nanopb/pb_encode.h",
],
includes = [
"include",
@ -1688,6 +1682,7 @@ objc_library(
deps = [
":gpr_objc",
"//external:libssl_objc",
"//external:nanopb",
],
sdk_dylibs = ["libz"],
)

@ -95,6 +95,16 @@ LDXX_opt = $(DEFAULT_CXX)
CPPFLAGS_opt = -O2
DEFINES_opt = NDEBUG
VALID_CONFIG_asan-trace-cmp = 1
REQUIRE_CUSTOM_LIBRARIES_asan-trace-cmp = 1
CC_asan-trace-cmp = clang
CXX_asan-trace-cmp = clang++
LD_asan-trace-cmp = clang
LDXX_asan-trace-cmp = clang++
CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan-trace-cmp = -fsanitize=address
DEFINES_asan-trace-cmp += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
VALID_CONFIG_dbg = 1
CC_dbg = $(DEFAULT_CC)
CXX_dbg = $(DEFAULT_CXX)
@ -109,7 +119,7 @@ CC_easan = clang
CXX_easan = clang++
LD_easan = clang
LDXX_easan = clang++
CPPFLAGS_easan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS_easan = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_easan = -fsanitize=address
DEFINES_easan = _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER
DEFINES_easan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
@ -120,7 +130,7 @@ CC_asan = clang
CXX_asan = clang++
LD_asan = clang
LDXX_asan = clang++
CPPFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS_asan = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan = -fsanitize=address
DEFINES_asan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
@ -130,7 +140,7 @@ CC_msan = clang
CXX_msan = clang++
LD_msan = clang
LDXX_msan = clang++
CPPFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS_msan = -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
DEFINES_msan = NDEBUG
DEFINES_msan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=4
@ -159,7 +169,7 @@ CC_asan-noleaks = clang
CXX_asan-noleaks = clang++
LD_asan-noleaks = clang
LDXX_asan-noleaks = clang++
CPPFLAGS_asan-noleaks = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan-noleaks = -fsanitize=address
DEFINES_asan-noleaks += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
@ -177,7 +187,7 @@ CC_ubsan = clang
CXX_ubsan = clang++
LD_ubsan = clang
LDXX_ubsan = clang++
CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument
CPPFLAGS_ubsan = -O1 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument
LDFLAGS_ubsan = -fsanitize=undefined
DEFINES_ubsan = NDEBUG
DEFINES_ubsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=1.5
@ -926,14 +936,20 @@ grpc_jwt_verifier_test: $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test
grpc_print_google_default_creds_token: $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token
grpc_security_connector_test: $(BINDIR)/$(CONFIG)/grpc_security_connector_test
grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
hpack_parser_fuzzer_test: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
http_fuzzer_test: $(BINDIR)/$(CONFIG)/http_fuzzer_test
http_parser_test: $(BINDIR)/$(CONFIG)/http_parser_test
httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test
httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test
httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test
init_test: $(BINDIR)/$(CONFIG)/init_test
internal_api_canary_iomgr_test: $(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test
internal_api_canary_support_test: $(BINDIR)/$(CONFIG)/internal_api_canary_support_test
internal_api_canary_transport_test: $(BINDIR)/$(CONFIG)/internal_api_canary_transport_test
invalid_call_argument_test: $(BINDIR)/$(CONFIG)/invalid_call_argument_test
json_fuzzer_test: $(BINDIR)/$(CONFIG)/json_fuzzer_test
json_rewrite: $(BINDIR)/$(CONFIG)/json_rewrite
json_rewrite_test: $(BINDIR)/$(CONFIG)/json_rewrite_test
json_stream_error_test: $(BINDIR)/$(CONFIG)/json_stream_error_test
@ -967,6 +983,7 @@ transport_connectivity_state_test: $(BINDIR)/$(CONFIG)/transport_connectivity_st
transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test
transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test
udp_server_test: $(BINDIR)/$(CONFIG)/udp_server_test
uri_fuzzer_test: $(BINDIR)/$(CONFIG)/uri_fuzzer_test
uri_parser_test: $(BINDIR)/$(CONFIG)/uri_parser_test
workqueue_test: $(BINDIR)/$(CONFIG)/workqueue_test
alarm_cpp_test: $(BINDIR)/$(CONFIG)/alarm_cpp_test
@ -1243,6 +1260,9 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/httpcli_test \
$(BINDIR)/$(CONFIG)/httpscli_test \
$(BINDIR)/$(CONFIG)/init_test \
$(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test \
$(BINDIR)/$(CONFIG)/internal_api_canary_support_test \
$(BINDIR)/$(CONFIG)/internal_api_canary_transport_test \
$(BINDIR)/$(CONFIG)/invalid_call_argument_test \
$(BINDIR)/$(CONFIG)/json_rewrite \
$(BINDIR)/$(CONFIG)/json_rewrite_test \
@ -7822,6 +7842,38 @@ endif
endif
HPACK_PARSER_FUZZER_TEST_SRC = \
test/core/transport/chttp2/hpack_parser_fuzzer_test.c \
HPACK_PARSER_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HPACK_PARSER_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test: $(HPACK_PARSER_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(HPACK_PARSER_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/transport/chttp2/hpack_parser_fuzzer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_hpack_parser_fuzzer_test: $(HPACK_PARSER_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HPACK_PARSER_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
HPACK_PARSER_TEST_SRC = \
test/core/transport/chttp2/hpack_parser_test.c \
@ -7886,6 +7938,38 @@ endif
endif
HTTP_FUZZER_TEST_SRC = \
test/core/http/fuzzer.c \
HTTP_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_fuzzer_test: $(HTTP_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(HTTP_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/http_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/http/fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_fuzzer_test: $(HTTP_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
HTTP_PARSER_TEST_SRC = \
test/core/http/parser_test.c \
@ -8046,6 +8130,102 @@ endif
endif
INTERNAL_API_CANARY_IOMGR_TEST_SRC = \
test/core/internal_api_canaries/iomgr.c \
INTERNAL_API_CANARY_IOMGR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INTERNAL_API_CANARY_IOMGR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test: $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test
endif
$(OBJDIR)/$(CONFIG)/test/core/internal_api_canaries/iomgr.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_internal_api_canary_iomgr_test: $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS:.o=.dep)
endif
endif
INTERNAL_API_CANARY_SUPPORT_TEST_SRC = \
test/core/internal_api_canaries/iomgr.c \
INTERNAL_API_CANARY_SUPPORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INTERNAL_API_CANARY_SUPPORT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/internal_api_canary_support_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/internal_api_canary_support_test: $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/internal_api_canary_support_test
endif
$(OBJDIR)/$(CONFIG)/test/core/internal_api_canaries/iomgr.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_internal_api_canary_support_test: $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS:.o=.dep)
endif
endif
INTERNAL_API_CANARY_TRANSPORT_TEST_SRC = \
test/core/internal_api_canaries/iomgr.c \
INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INTERNAL_API_CANARY_TRANSPORT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/internal_api_canary_transport_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/internal_api_canary_transport_test: $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/internal_api_canary_transport_test
endif
$(OBJDIR)/$(CONFIG)/test/core/internal_api_canaries/iomgr.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_internal_api_canary_transport_test: $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS:.o=.dep)
endif
endif
INVALID_CALL_ARGUMENT_TEST_SRC = \
test/core/end2end/invalid_call_argument_test.c \
@ -8078,6 +8258,38 @@ endif
endif
JSON_FUZZER_TEST_SRC = \
test/core/json/fuzzer.c \
JSON_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/json_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/json_fuzzer_test: $(JSON_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(JSON_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/json_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/json/fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_json_fuzzer_test: $(JSON_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(JSON_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
JSON_REWRITE_SRC = \
test/core/json/json_rewrite.c \
@ -9134,6 +9346,38 @@ endif
endif
URI_FUZZER_TEST_SRC = \
test/core/client_config/uri_fuzzer_test.c \
URI_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(URI_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/uri_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/uri_fuzzer_test: $(URI_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(URI_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/uri_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/client_config/uri_fuzzer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_uri_fuzzer_test: $(URI_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(URI_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
URI_PARSER_TEST_SRC = \
test/core/client_config/uri_parser_test.c \

@ -2,8 +2,10 @@ recursive-include src/python/grpcio/grpc *.c *.h *.py *.pyx *.pxd *.pxi *.python
recursive-exclude src/python/grpcio/grpc/_cython *.so *.pyd
graft src/python/grpcio/tests
graft src/core
graft src/boringssl
graft include/grpc
graft third_party/boringssl
graft third_party/nanopb
graft third_party/zlib
include src/python/grpcio/commands.py
include src/python/grpcio/grpc_version.py

@ -1589,6 +1589,18 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: hpack_parser_fuzzer_test
build: fuzzer
language: c
src:
- test/core/transport/chttp2/hpack_parser_fuzzer_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/transport/chttp2/hpack_parser_corpus
- name: hpack_parser_test
build: test
language: c
@ -1609,6 +1621,18 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: http_fuzzer_test
build: fuzzer
language: c
src:
- test/core/http/fuzzer.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/http/corpus
- name: http_parser_test
build: test
language: c
@ -1667,6 +1691,39 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: internal_api_canary_iomgr_test
build: test
run: false
language: c
src:
- test/core/internal_api_canaries/iomgr.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: internal_api_canary_support_test
build: test
run: false
language: c
src:
- test/core/internal_api_canaries/iomgr.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: internal_api_canary_transport_test
build: test
run: false
language: c
src:
- test/core/internal_api_canaries/iomgr.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: invalid_call_argument_test
build: test
language: c
@ -1677,6 +1734,18 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: json_fuzzer_test
build: fuzzer
language: c
src:
- test/core/json/fuzzer.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/json/corpus
- name: json_rewrite
build: test
run: false
@ -2040,6 +2109,18 @@ targets:
- mac
- linux
- posix
- name: uri_fuzzer_test
build: fuzzer
language: c
src:
- test/core/client_config/uri_fuzzer_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/client_config/uri_corpus
- name: uri_parser_test
build: test
language: c
@ -2821,8 +2902,8 @@ vspackages:
configs:
asan:
CC: clang
CPPFLAGS: -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument
-DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer
-Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++
LD: clang
LDFLAGS: -fsanitize=address
@ -2834,8 +2915,8 @@ configs:
timeout_multiplier: 3
asan-noleaks:
CC: clang
CPPFLAGS: -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument
-DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer
-Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++
LD: clang
LDFLAGS: -fsanitize=address
@ -2844,6 +2925,19 @@ configs:
test_environ:
ASAN_OPTIONS: detect_leaks=0:color=always
timeout_multiplier: 3
asan-trace-cmp:
CC: clang
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize=address
-fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++
LD: clang
LDFLAGS: -fsanitize=address
LDXX: clang++
compile_the_world: true
test_environ:
ASAN_OPTIONS: detect_leaks=1:color=always
LSAN_OPTIONS: suppressions=tools/lsan_suppressions.txt:report_objects=1
timeout_multiplier: 3
basicprof:
CPPFLAGS: -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
DEFINES: NDEBUG
@ -2852,8 +2946,8 @@ configs:
DEFINES: _DEBUG DEBUG
easan:
CC: clang
CPPFLAGS: -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument
-DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer
-Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++
DEFINES: _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER
LD: clang
@ -2902,9 +2996,9 @@ configs:
valgrind: --tool=memcheck --leak-check=full
msan:
CC: clang
CPPFLAGS: -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer
-DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument
-fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins
-fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
-Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++
DEFINES: NDEBUG
LD: clang
@ -2937,7 +3031,8 @@ configs:
timeout_multiplier: 5
ubsan:
CC: clang
CPPFLAGS: -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument
CPPFLAGS: -O1 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer
-Wno-unused-command-line-argument
CXX: clang++
DEFINES: NDEBUG
LD: clang

@ -758,23 +758,35 @@ static void maybe_start_some_streams(
}
}
#define CLOSURE_BARRIER_STATS_BIT (1 << 0)
#define CLOSURE_BARRIER_FAILURE_BIT (1 << 1)
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16)
static grpc_closure *add_closure_barrier(grpc_closure *closure) {
closure->final_data += 2;
closure->final_data += CLOSURE_BARRIER_FIRST_REF_BIT;
return closure;
}
void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global,
grpc_closure **pclosure, int success) {
grpc_closure *closure = *pclosure;
if (closure == NULL) {
return;
}
closure->final_data -= 2;
closure->final_data -= CLOSURE_BARRIER_FIRST_REF_BIT;
if (!success) {
closure->final_data |= 1;
closure->final_data |= CLOSURE_BARRIER_FAILURE_BIT;
}
if (closure->final_data < 2) {
grpc_exec_ctx_enqueue(exec_ctx, closure, closure->final_data == 0, NULL);
if (closure->final_data < CLOSURE_BARRIER_FIRST_REF_BIT) {
if (closure->final_data & CLOSURE_BARRIER_STATS_BIT) {
grpc_transport_move_stats(&stream_global->stats,
stream_global->collecting_stats);
stream_global->collecting_stats = NULL;
}
grpc_exec_ctx_enqueue(
exec_ctx, closure,
(closure->final_data & CLOSURE_BARRIER_FAILURE_BIT) == 0, NULL);
}
*pclosure = NULL;
}
@ -807,7 +819,13 @@ static void perform_stream_op_locked(
}
/* use final_data as a barrier until enqueue time; the inital counter is
dropped at the end of this function */
on_complete->final_data = 2;
on_complete->final_data = CLOSURE_BARRIER_FIRST_REF_BIT;
if (op->collect_stats != NULL) {
GPR_ASSERT(stream_global->collecting_stats == NULL);
stream_global->collecting_stats = op->collect_stats;
on_complete->final_data |= CLOSURE_BARRIER_STATS_BIT;
}
if (op->cancel_with_status != GRPC_STATUS_OK) {
cancel_from_api(exec_ctx, transport_global, stream_global,
@ -840,7 +858,8 @@ static void perform_stream_op_locked(
}
} else {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_initial_metadata_finished, 0);
exec_ctx, stream_global,
&stream_global->send_initial_metadata_finished, 0);
}
}
@ -850,7 +869,7 @@ static void perform_stream_op_locked(
stream_global->send_message_finished = add_closure_barrier(on_complete);
if (stream_global->write_closed) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_message_finished, 0);
exec_ctx, stream_global, &stream_global->send_message_finished, 0);
} else {
stream_global->send_message = op->send_message;
if (stream_global->id != 0) {
@ -870,7 +889,8 @@ static void perform_stream_op_locked(
}
if (stream_global->write_closed) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_trailing_metadata_finished,
exec_ctx, stream_global,
&stream_global->send_trailing_metadata_finished,
grpc_metadata_batch_is_empty(op->send_trailing_metadata));
} else if (stream_global->id != 0) {
/* TODO(ctiller): check if there's flow control for any outstanding
@ -909,7 +929,7 @@ static void perform_stream_op_locked(
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
}
grpc_chttp2_complete_closure_step(exec_ctx, &on_complete, 1);
grpc_chttp2_complete_closure_step(exec_ctx, stream_global, &on_complete, 1);
GPR_TIMER_END("perform_stream_op_locked", 0);
}
@ -1080,7 +1100,8 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx,
&stream_global->received_trailing_metadata,
stream_global->recv_trailing_metadata);
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->recv_trailing_metadata_finished, 1);
exec_ctx, stream_global,
&stream_global->recv_trailing_metadata_finished, 1);
}
}
}
@ -1131,7 +1152,8 @@ static void cancel_from_api(grpc_exec_ctx *exec_ctx,
&transport_global->qbuf,
grpc_chttp2_rst_stream_create(
stream_global->id,
(uint32_t)grpc_chttp2_grpc_status_to_http2_error(status)));
(uint32_t)grpc_chttp2_grpc_status_to_http2_error(status),
&stream_global->stats.outgoing));
}
grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global, status,
NULL);
@ -1179,10 +1201,12 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_initial_metadata_finished, 0);
exec_ctx, stream_global, &stream_global->send_initial_metadata_finished,
0);
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_trailing_metadata_finished, 0);
grpc_chttp2_complete_closure_step(exec_ctx,
exec_ctx, stream_global, &stream_global->send_trailing_metadata_finished,
0);
grpc_chttp2_complete_closure_step(exec_ctx, stream_global,
&stream_global->send_message_finished, 0);
}
@ -1319,7 +1343,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx,
gpr_slice_buffer_add(
&transport_global->qbuf,
grpc_chttp2_rst_stream_create(stream_global->id, GRPC_CHTTP2_NO_ERROR));
grpc_chttp2_rst_stream_create(stream_global->id, GRPC_CHTTP2_NO_ERROR,
&stream_global->stats.outgoing));
if (optional_message) {
gpr_slice_ref(*optional_message);

@ -113,11 +113,13 @@ grpc_byte_stream *grpc_chttp2_incoming_frame_queue_pop(
void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
uint32_t write_bytes, int is_eof,
grpc_transport_one_way_stats *stats,
gpr_slice_buffer *outbuf) {
gpr_slice hdr;
uint8_t *p;
static const size_t header_size = 9;
hdr = gpr_slice_malloc(9);
hdr = gpr_slice_malloc(header_size);
p = GPR_SLICE_START_PTR(hdr);
GPR_ASSERT(write_bytes < (1 << 24));
*p++ = (uint8_t)(write_bytes >> 16);
@ -132,6 +134,9 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
gpr_slice_buffer_add(outbuf, hdr);
gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf);
stats->framing_bytes += header_size;
stats->data_bytes += write_bytes;
}
grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
@ -156,6 +161,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
switch (p->state) {
fh_0:
case GRPC_CHTTP2_DATA_FH_0:
stream_parsing->stats.incoming.framing_bytes++;
p->frame_type = *cur;
switch (p->frame_type) {
case 0:
@ -174,6 +180,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_1:
stream_parsing->stats.incoming.framing_bytes++;
p->frame_size = ((uint32_t)*cur) << 24;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_2;
@ -181,6 +188,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_2:
stream_parsing->stats.incoming.framing_bytes++;
p->frame_size |= ((uint32_t)*cur) << 16;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_3;
@ -188,6 +196,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_3:
stream_parsing->stats.incoming.framing_bytes++;
p->frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_4;
@ -195,6 +204,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_4:
stream_parsing->stats.incoming.framing_bytes++;
p->frame_size |= ((uint32_t)*cur);
p->state = GRPC_CHTTP2_DATA_FRAME;
++cur;
@ -215,7 +225,9 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
if ((uint32_t)(end - cur) == p->frame_size) {
uint32_t remaining = (uint32_t)(end - cur);
if (remaining == p->frame_size) {
stream_parsing->stats.incoming.data_bytes += p->frame_size;
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
@ -224,7 +236,8 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
p->parsing_frame = NULL;
p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK;
} else if ((uint32_t)(end - cur) > p->frame_size) {
} else if (remaining > p->frame_size) {
stream_parsing->stats.incoming.data_bytes += p->frame_size;
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg),
@ -235,11 +248,12 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
cur += p->frame_size;
goto fh_0; /* loop */
} else {
GPR_ASSERT(remaining <= p->frame_size);
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
GPR_ASSERT((size_t)(end - cur) <= p->frame_size);
p->frame_size -= (uint32_t)(end - cur);
p->frame_size -= remaining;
stream_parsing->stats.incoming.data_bytes += remaining;
return GRPC_CHTTP2_PARSE_OK;
}
}

@ -41,6 +41,7 @@
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/byte_stream.h"
#include "src/core/lib/transport/transport.h"
typedef enum {
GRPC_CHTTP2_DATA_FH_0,
@ -96,6 +97,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
uint32_t write_bytes, int is_eof,
grpc_transport_one_way_stats *stats,
gpr_slice_buffer *outbuf);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */

@ -38,8 +38,11 @@
#include "src/core/ext/transport/chttp2/transport/frame.h"
gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code) {
gpr_slice slice = gpr_slice_malloc(13);
gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
grpc_transport_one_way_stats *stats) {
static const size_t frame_size = 13;
gpr_slice slice = gpr_slice_malloc(frame_size);
stats->framing_bytes += frame_size;
uint8_t *p = GPR_SLICE_START_PTR(slice);
*p++ = 0;
@ -84,6 +87,7 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
cur++;
p->byte++;
}
stream_parsing->stats.incoming.framing_bytes += (uint64_t)(end - cur);
if (p->byte == 4) {
GPR_ASSERT(is_last);

@ -37,13 +37,15 @@
#include <grpc/support/slice.h>
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/transport.h"
typedef struct {
uint8_t byte;
uint8_t reason_bytes[4];
} grpc_chttp2_rst_stream_parser;
gpr_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code);
gpr_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code,
grpc_transport_one_way_stats *stats);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags);

@ -36,9 +36,11 @@
#include <grpc/support/log.h>
gpr_slice grpc_chttp2_window_update_create(uint32_t id,
uint32_t window_update) {
gpr_slice slice = gpr_slice_malloc(13);
gpr_slice grpc_chttp2_window_update_create(
uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) {
static const size_t frame_size = 13;
gpr_slice slice = gpr_slice_malloc(frame_size);
stats->header_bytes += frame_size;
uint8_t *p = GPR_SLICE_START_PTR(slice);
GPR_ASSERT(window_update);
@ -87,6 +89,10 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
p->byte++;
}
if (stream_parsing != NULL) {
stream_parsing->stats.incoming.framing_bytes += (uint32_t)(end - cur);
}
if (p->byte == 4) {
uint32_t received_update = p->amount;
if (received_update == 0 || (received_update & 0x80000000u)) {

@ -37,6 +37,7 @@
#include <grpc/support/slice.h>
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/transport.h"
typedef struct {
uint8_t byte;
@ -44,7 +45,8 @@ typedef struct {
uint32_t amount;
} grpc_chttp2_window_update_parser;
gpr_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta);
gpr_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta,
grpc_transport_one_way_stats *stats);
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags);

@ -74,6 +74,7 @@ typedef struct {
/* output stream id */
uint32_t stream_id;
gpr_slice_buffer *output;
grpc_transport_one_way_stats *stats;
} framer_state;
/* fills p (which is expected to be 9 bytes long) with a data frame header */
@ -102,6 +103,7 @@ static void finish_frame(framer_state *st, int is_header_boundary,
st->stream_id, st->output->length - st->output_length_at_start_of_frame,
(uint8_t)((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
(is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
st->stats->framing_bytes += 9;
st->is_first_frame = 0;
}
@ -147,8 +149,10 @@ static void add_header_data(framer_state *st, gpr_slice slice) {
remaining = GRPC_CHTTP2_MAX_PAYLOAD_LENGTH +
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);
} else {
st->stats->header_bytes += remaining;
gpr_slice_buffer_add(st->output, gpr_slice_split_head(&slice, remaining));
finish_frame(st, 0, 0);
begin_frame(st);
@ -535,6 +539,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,
grpc_transport_one_way_stats *stats,
gpr_slice_buffer *outbuf) {
framer_state st;
grpc_linked_mdelem *l;
@ -546,6 +551,7 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c,
st.stream_id = stream_id;
st.output = outbuf;
st.is_first_frame = 1;
st.stats = stats;
/* Encode a metadata batch; store the returned values, representing
a metadata element that needs to be unreffed back into the metadata

@ -40,6 +40,7 @@
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
#define GRPC_CHTTP2_HPACKC_NUM_FILTERS 256
#define GRPC_CHTTP2_HPACKC_NUM_VALUES 256
@ -90,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,
grpc_transport_one_way_stats *stats,
gpr_slice_buffer *outbuf);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */

@ -52,6 +52,8 @@
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/support/string.h"
extern int grpc_http_trace;
typedef enum {
NOT_BINARY,
B64_BYTE0,
@ -723,7 +725,9 @@ static int finish_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (md == NULL) {
gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
if (grpc_http_trace) {
gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
}
return 0;
}
GRPC_MDELEM_REF(md);
@ -919,7 +923,9 @@ static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
/* finish parsing a max table size change */
static int finish_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
if (grpc_http_trace) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
}
return grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index) &&
parse_begin(p, cur, end);
}
@ -960,7 +966,9 @@ static int parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end) {
GPR_ASSERT(cur != end);
gpr_log(GPR_DEBUG, "Illegal hpack op code %d", *cur);
if (grpc_http_trace) {
gpr_log(GPR_DEBUG, "Illegal hpack op code %d", *cur);
}
return parse_error(p, cur, end);
}
@ -1069,10 +1077,12 @@ static int parse_value4(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
}
error:
gpr_log(GPR_ERROR,
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x on byte 5",
*p->parsing.value, *cur);
if (grpc_http_trace) {
gpr_log(GPR_ERROR,
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x on byte 5",
*p->parsing.value, *cur);
}
return parse_error(p, cur, end);
}
@ -1094,10 +1104,12 @@ static int parse_value5up(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
return parse_next(p, cur + 1, end);
}
gpr_log(GPR_ERROR,
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x sometime after byte 5",
*p->parsing.value, *cur);
if (grpc_http_trace) {
gpr_log(GPR_ERROR,
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x sometime after byte 5",
*p->parsing.value, *cur);
}
return parse_error(p, cur, end);
}
@ -1329,7 +1341,9 @@ static is_binary_header is_binary_literal_header(grpc_chttp2_hpack_parser *p) {
static is_binary_header is_binary_indexed_header(grpc_chttp2_hpack_parser *p) {
grpc_mdelem *elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (!elem) {
gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
if (grpc_http_trace) {
gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
}
return ERROR_HEADER;
}
return grpc_is_binary_header(
@ -1412,6 +1426,9 @@ grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
grpc_chttp2_hpack_parser *parser = hpack_parser;
GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0);
if (stream_parsing != NULL) {
stream_parsing->stats.incoming.header_bytes += GPR_SLICE_LENGTH(slice);
}
if (!grpc_chttp2_hpack_parser_parse(parser, GPR_SLICE_START_PTR(slice),
GPR_SLICE_END_PTR(slice))) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);

@ -41,6 +41,8 @@
#include "src/core/lib/support/murmur_hash.h"
extern int grpc_http_trace;
static struct {
const char *key;
const char *value;
@ -264,12 +266,16 @@ int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
return 1;
}
if (bytes > tbl->max_bytes) {
gpr_log(GPR_ERROR,
"Attempt to make hpack table %d bytes when max is %d bytes", bytes,
tbl->max_bytes);
if (grpc_http_trace) {
gpr_log(GPR_ERROR,
"Attempt to make hpack table %d bytes when max is %d bytes",
bytes, tbl->max_bytes);
}
return 0;
}
gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
if (grpc_http_trace) {
gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
}
while (tbl->mem_used > bytes) {
evict1(tbl);
}
@ -293,10 +299,12 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
if (tbl->current_table_bytes > tbl->max_bytes) {
gpr_log(GPR_ERROR,
"HPACK max table size reduced to %d but not reflected by hpack "
"stream (still at %d)",
tbl->max_bytes, tbl->current_table_bytes);
if (grpc_http_trace) {
gpr_log(GPR_ERROR,
"HPACK max table size reduced to %d but not reflected by hpack "
"stream (still at %d)",
tbl->max_bytes, tbl->current_table_bytes);
}
return 0;
}

@ -394,6 +394,9 @@ typedef struct {
grpc_metadata_batch *recv_trailing_metadata;
grpc_closure *recv_trailing_metadata_finished;
grpc_transport_stream_stats *collecting_stats;
grpc_transport_stream_stats stats;
/** when the application requests writes be closed, the write_closed is
'queued'; when the close is flow controlled into the send path, we are
'sending' it; when the write has been performed it is 'sent' */
@ -435,6 +438,8 @@ typedef struct {
gpr_slice fetching_slice;
size_t stream_fetched;
grpc_closure finished_fetch;
/** stats gathered during the write */
grpc_transport_one_way_stats stats;
} grpc_chttp2_stream_writing;
struct grpc_chttp2_stream_parsing {
@ -460,6 +465,8 @@ struct grpc_chttp2_stream_parsing {
int64_t outgoing_window;
/** number of bytes received - reset at end of parse thread execution */
int64_t received_bytes;
/** stats gathered during the parse */
grpc_transport_stream_stats stats;
/** incoming metadata */
grpc_chttp2_incoming_metadata_buffer metadata_buffer[2];
@ -635,6 +642,7 @@ void grpc_chttp2_parsing_become_skip_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global,
grpc_closure **pclosure, int success);
#define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"

@ -171,6 +171,9 @@ void grpc_chttp2_publish_reads(
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
}
/* flush stats to global stream state */
grpc_transport_move_stats(&stream_parsing->stats, &stream_global->stats);
/* update outgoing flow control window */
was_zero = stream_global->outgoing_window <= 0;
GRPC_CHTTP2_FLOW_MOVE_STREAM("parsed", transport_global, stream_global,
@ -544,8 +547,13 @@ static int init_data_frame_parser(
grpc_chttp2_parsing_lookup_stream(transport_parsing,
transport_parsing->incoming_stream_id);
grpc_chttp2_parse_error err = GRPC_CHTTP2_PARSE_OK;
if (!stream_parsing || stream_parsing->received_close)
if (stream_parsing == NULL) {
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
}
stream_parsing->stats.incoming.framing_bytes += 9;
if (stream_parsing->received_close) {
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
}
if (err == GRPC_CHTTP2_PARSE_OK) {
err = update_incoming_window(exec_ctx, transport_parsing, stream_parsing);
}
@ -566,7 +574,8 @@ static int init_data_frame_parser(
gpr_slice_buffer_add(
&transport_parsing->qbuf,
grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
GRPC_CHTTP2_PROTOCOL_ERROR));
GRPC_CHTTP2_PROTOCOL_ERROR,
&stream_parsing->stats.outgoing));
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
case GRPC_CHTTP2_CONNECTION_ERROR:
return 0;
@ -717,6 +726,7 @@ static int init_header_frame_parser(
transport_parsing->incoming_stream = stream_parsing;
}
GPR_ASSERT(stream_parsing != NULL && (via_accept == 0 || via_accept == 1));
stream_parsing->stats.incoming.framing_bytes += 9;
if (stream_parsing->received_close) {
gpr_log(GPR_ERROR, "skipping already closed grpc_chttp2_stream header");
transport_parsing->incoming_stream = NULL;
@ -752,9 +762,14 @@ static int init_window_update_frame_parser(
&transport_parsing->simple.window_update,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags);
if (transport_parsing->incoming_stream_id) {
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
if (transport_parsing->incoming_stream_id != 0) {
grpc_chttp2_stream_parsing *stream_parsing =
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
if (stream_parsing == NULL) {
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
}
stream_parsing->stats.incoming.framing_bytes += 9;
}
transport_parsing->parser = grpc_chttp2_window_update_parser_parse;
transport_parsing->parser_data = &transport_parsing->simple.window_update;
@ -778,11 +793,13 @@ static int init_rst_stream_parser(
&transport_parsing->simple.rst_stream,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags);
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
grpc_chttp2_stream_parsing *stream_parsing =
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
if (!transport_parsing->incoming_stream) {
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
}
stream_parsing->stats.incoming.framing_bytes += 9;
transport_parsing->parser = grpc_chttp2_rst_stream_parser_parse;
transport_parsing->parser_data = &transport_parsing->simple.rst_stream;
return ok;
@ -856,7 +873,8 @@ static int parse_frame_slice(grpc_exec_ctx *exec_ctx,
gpr_slice_buffer_add(
&transport_parsing->qbuf,
grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
GRPC_CHTTP2_PROTOCOL_ERROR));
GRPC_CHTTP2_PROTOCOL_ERROR,
&stream_parsing->stats.outgoing));
}
return 1;
case GRPC_CHTTP2_CONNECTION_ERROR:

@ -161,8 +161,10 @@ int grpc_chttp2_unlocking_check_writes(
transport_global->announce_incoming_window, UINT32_MAX);
GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", transport_global,
announce_incoming_window, announced);
gpr_slice_buffer_add(&transport_writing->outbuf,
grpc_chttp2_window_update_create(0, announced));
grpc_transport_one_way_stats throwaway_stats;
gpr_slice_buffer_add(
&transport_writing->outbuf,
grpc_chttp2_window_update_create(0, announced, &throwaway_stats));
}
GPR_TIMER_END("grpc_chttp2_unlocking_check_writes", 0);
@ -205,7 +207,8 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
if (stream_writing->send_initial_metadata != NULL) {
grpc_chttp2_encode_header(
&transport_writing->hpack_compressor, stream_writing->id,
stream_writing->send_initial_metadata, 0, &transport_writing->outbuf);
stream_writing->send_initial_metadata, 0, &stream_writing->stats,
&transport_writing->outbuf);
stream_writing->send_initial_metadata = NULL;
stream_writing->sent_initial_metadata = 1;
}
@ -216,7 +219,8 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
gpr_slice_buffer_add(
&transport_writing->outbuf,
grpc_chttp2_window_update_create(stream_writing->id,
stream_writing->announce_window));
stream_writing->announce_window,
&stream_writing->stats));
GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", transport_writing, stream_writing,
announce_window, announce);
stream_writing->announce_window = 0;
@ -255,7 +259,8 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
stream_writing->send_trailing_metadata);
grpc_chttp2_encode_data(
stream_writing->id, &stream_writing->flow_controlled_buffer,
send_bytes, is_last_frame, &transport_writing->outbuf);
send_bytes, is_last_frame, &stream_writing->stats,
&transport_writing->outbuf);
GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", transport_writing,
stream_writing, outgoing_window,
send_bytes);
@ -281,19 +286,20 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
stream_writing->send_trailing_metadata != NULL) {
if (grpc_metadata_batch_is_empty(
stream_writing->send_trailing_metadata)) {
grpc_chttp2_encode_data(stream_writing->id,
&stream_writing->flow_controlled_buffer, 0, 1,
&transport_writing->outbuf);
grpc_chttp2_encode_data(
stream_writing->id, &stream_writing->flow_controlled_buffer, 0, 1,
&stream_writing->stats, &transport_writing->outbuf);
} else {
grpc_chttp2_encode_header(&transport_writing->hpack_compressor,
stream_writing->id,
stream_writing->send_trailing_metadata, 1,
&transport_writing->outbuf);
grpc_chttp2_encode_header(
&transport_writing->hpack_compressor, stream_writing->id,
stream_writing->send_trailing_metadata, 1, &stream_writing->stats,
&transport_writing->outbuf);
}
if (!transport_writing->is_client && !stream_writing->read_closed) {
gpr_slice_buffer_add(&transport_writing->outbuf,
grpc_chttp2_rst_stream_create(
stream_writing->id, GRPC_CHTTP2_NO_ERROR));
stream_writing->id, GRPC_CHTTP2_NO_ERROR,
&stream_writing->stats));
}
stream_writing->send_trailing_metadata = NULL;
stream_writing->sent_trailing_metadata = 1;
@ -328,17 +334,21 @@ void grpc_chttp2_cleanup_writing(
transport_global, transport_writing, &stream_global, &stream_writing)) {
if (stream_writing->sent_initial_metadata) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_initial_metadata_finished, 1);
exec_ctx, stream_global,
&stream_global->send_initial_metadata_finished, 1);
}
grpc_transport_move_one_way_stats(&stream_writing->stats,
&stream_global->stats.outgoing);
if (stream_writing->sent_message) {
GPR_ASSERT(stream_writing->send_message == NULL);
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_message_finished, 1);
exec_ctx, stream_global, &stream_global->send_message_finished, 1);
stream_writing->sent_message = 0;
}
if (stream_writing->sent_trailing_metadata) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_trailing_metadata_finished, 1);
exec_ctx, stream_global,
&stream_global->send_trailing_metadata_finished, 1);
}
if (stream_writing->sent_trailing_metadata) {
grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global,

@ -37,23 +37,23 @@
#include <grpc/compression.h>
#include <grpc/grpc.h>
/* Copy some arguments */
/** Copy the arguments in \a src into a new instance */
grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src);
/* Copy some arguments, stably sorting keys */
grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a);
/** Copy the arguments in \a src into a new instance, stably sorting keys */
grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *src);
/** Copy some arguments and add the to_add parameter in the end.
If to_add is NULL, it is equivalent to call grpc_channel_args_copy. */
/** Copy the arguments in \a src and append \a to_add. If \a to_add is NULL, it
* is equivalent to calling \a grpc_channel_args_copy. */
grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src,
const grpc_arg *to_add,
size_t num_to_add);
/** Copy args from a then args from b into a new channel args */
/** Concatenate args from \a a and \a b into a new instance */
grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a,
const grpc_channel_args *b);
/** Destroy arguments created by grpc_channel_args_copy */
/** Destroy arguments created by \a grpc_channel_args_copy */
void grpc_channel_args_destroy(grpc_channel_args *a);
/** Reads census_enabled settings from channel args. Returns 1 if census_enabled

@ -32,11 +32,11 @@
*/
#include "src/core/lib/client_config/lb_policies/pick_first.h"
#include "src/core/lib/client_config/lb_policy_factory.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/client_config/lb_policy_factory.h"
#include "src/core/lib/transport/connectivity_state.h"
typedef struct pending_pick {
@ -391,19 +391,42 @@ static void pick_first_factory_ref(grpc_lb_policy_factory *factory) {}
static void pick_first_factory_unref(grpc_lb_policy_factory *factory) {}
static grpc_lb_policy *create_pick_first(grpc_lb_policy_factory *factory,
static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
grpc_lb_policy_factory *factory,
grpc_lb_policy_args *args) {
if (args->num_subchannels == 0) return NULL;
GPR_ASSERT(args->addresses != NULL);
GPR_ASSERT(args->subchannel_factory != NULL);
if (args->addresses->naddrs == 0) return NULL;
pick_first_lb_policy *p = gpr_malloc(sizeof(*p));
memset(p, 0, sizeof(*p));
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable);
p->subchannels =
gpr_malloc(sizeof(grpc_subchannel *) * args->num_subchannels);
p->num_subchannels = args->num_subchannels;
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
"pick_first");
memcpy(p->subchannels, args->subchannels,
sizeof(grpc_subchannel *) * args->num_subchannels);
gpr_malloc(sizeof(grpc_subchannel *) * args->addresses->naddrs);
memset(p->subchannels, 0, sizeof(*p->subchannels) * args->addresses->naddrs);
grpc_subchannel_args sc_args;
size_t subchannel_idx = 0;
for (size_t i = 0; i < args->addresses->naddrs; i++) {
memset(&sc_args, 0, sizeof(grpc_subchannel_args));
sc_args.addr = (struct sockaddr *)(args->addresses->addrs[i].addr);
sc_args.addr_len = (size_t)args->addresses->addrs[i].len;
grpc_subchannel *subchannel = grpc_subchannel_factory_create_subchannel(
exec_ctx, args->subchannel_factory, &sc_args);
if (subchannel != NULL) {
p->subchannels[subchannel_idx++] = subchannel;
}
}
if (subchannel_idx == 0) {
gpr_free(p->subchannels);
gpr_free(p);
return NULL;
}
p->num_subchannels = subchannel_idx;
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable);
grpc_closure_init(&p->connectivity_changed, pf_connectivity_changed, p);
gpr_mu_init(&p->mu);
return &p->base;

@ -496,30 +496,47 @@ static void round_robin_factory_ref(grpc_lb_policy_factory *factory) {}
static void round_robin_factory_unref(grpc_lb_policy_factory *factory) {}
static grpc_lb_policy *create_round_robin(grpc_lb_policy_factory *factory,
static grpc_lb_policy *create_round_robin(grpc_exec_ctx *exec_ctx,
grpc_lb_policy_factory *factory,
grpc_lb_policy_args *args) {
size_t i;
GPR_ASSERT(args->addresses != NULL);
GPR_ASSERT(args->subchannel_factory != NULL);
round_robin_lb_policy *p = gpr_malloc(sizeof(*p));
GPR_ASSERT(args->num_subchannels > 0);
memset(p, 0, sizeof(*p));
grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable);
p->num_subchannels = args->num_subchannels;
p->subchannels = gpr_malloc(sizeof(*p->subchannels) * p->num_subchannels);
memset(p->subchannels, 0, sizeof(*p->subchannels) * p->num_subchannels);
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
"round_robin");
gpr_mu_init(&p->mu);
for (i = 0; i < args->num_subchannels; i++) {
subchannel_data *sd = gpr_malloc(sizeof(*sd));
memset(sd, 0, sizeof(*sd));
p->subchannels[i] = sd;
sd->policy = p;
sd->index = i;
sd->subchannel = args->subchannels[i];
grpc_closure_init(&sd->connectivity_changed_closure,
rr_connectivity_changed, sd);
p->subchannels =
gpr_malloc(sizeof(*p->subchannels) * args->addresses->naddrs);
memset(p->subchannels, 0, sizeof(*p->subchannels) * args->addresses->naddrs);
grpc_subchannel_args sc_args;
size_t subchannel_idx = 0;
for (size_t i = 0; i < args->addresses->naddrs; i++) {
memset(&sc_args, 0, sizeof(grpc_subchannel_args));
sc_args.addr = (struct sockaddr *)(args->addresses->addrs[i].addr);
sc_args.addr_len = (size_t)args->addresses->addrs[i].len;
grpc_subchannel *subchannel = grpc_subchannel_factory_create_subchannel(
exec_ctx, args->subchannel_factory, &sc_args);
if (subchannel != NULL) {
subchannel_data *sd = gpr_malloc(sizeof(*sd));
memset(sd, 0, sizeof(*sd));
p->subchannels[subchannel_idx] = sd;
sd->policy = p;
sd->index = subchannel_idx;
sd->subchannel = subchannel;
++subchannel_idx;
grpc_closure_init(&sd->connectivity_changed_closure,
rr_connectivity_changed, sd);
}
}
if (subchannel_idx == 0) {
gpr_free(p->subchannels);
gpr_free(p);
return NULL;
}
p->num_subchannels = subchannel_idx;
/* The (dummy node) root of the ready list */
p->ready_list.subchannel = NULL;
@ -527,6 +544,10 @@ static grpc_lb_policy *create_round_robin(grpc_lb_policy_factory *factory,
p->ready_list.next = NULL;
p->ready_list_last_pick = &p->ready_list;
grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable);
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
"round_robin");
gpr_mu_init(&p->mu);
return &p->base;
}

@ -42,7 +42,8 @@ void grpc_lb_policy_factory_unref(grpc_lb_policy_factory* factory) {
}
grpc_lb_policy* grpc_lb_policy_factory_create_lb_policy(
grpc_lb_policy_factory* factory, grpc_lb_policy_args* args) {
grpc_exec_ctx* exec_ctx, grpc_lb_policy_factory* factory,
grpc_lb_policy_args* args) {
if (factory == NULL) return NULL;
return factory->vtable->create_lb_policy(factory, args);
return factory->vtable->create_lb_policy(exec_ctx, factory, args);
}

@ -35,7 +35,10 @@
#define GRPC_CORE_LIB_CLIENT_CONFIG_LB_POLICY_FACTORY_H
#include "src/core/lib/client_config/lb_policy.h"
#include "src/core/lib/client_config/subchannel.h"
#include "src/core/lib/client_config/subchannel_factory.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/exec_ctx.h"
typedef struct grpc_lb_policy_factory grpc_lb_policy_factory;
typedef struct grpc_lb_policy_factory_vtable grpc_lb_policy_factory_vtable;
@ -47,8 +50,8 @@ struct grpc_lb_policy_factory {
};
typedef struct grpc_lb_policy_args {
grpc_subchannel **subchannels;
size_t num_subchannels;
grpc_resolved_addresses *addresses;
grpc_subchannel_factory *subchannel_factory;
} grpc_lb_policy_args;
struct grpc_lb_policy_factory_vtable {
@ -56,7 +59,8 @@ struct grpc_lb_policy_factory_vtable {
void (*unref)(grpc_lb_policy_factory *factory);
/** Implementation of grpc_lb_policy_factory_create_lb_policy */
grpc_lb_policy *(*create_lb_policy)(grpc_lb_policy_factory *factory,
grpc_lb_policy *(*create_lb_policy)(grpc_exec_ctx *exec_ctx,
grpc_lb_policy_factory *factory,
grpc_lb_policy_args *args);
/** Name for the LB policy this factory implements */
@ -68,6 +72,7 @@ void grpc_lb_policy_factory_unref(grpc_lb_policy_factory *factory);
/** Create a lb_policy instance. */
grpc_lb_policy *grpc_lb_policy_factory_create_lb_policy(
grpc_lb_policy_factory *factory, grpc_lb_policy_args *args);
grpc_exec_ctx *exec_ctx, grpc_lb_policy_factory *factory,
grpc_lb_policy_args *args);
#endif /* GRPC_CORE_LIB_CLIENT_CONFIG_LB_POLICY_FACTORY_H */

@ -79,10 +79,10 @@ static grpc_lb_policy_factory *lookup_factory(const char *name) {
return NULL;
}
grpc_lb_policy *grpc_lb_policy_create(const char *name,
grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name,
grpc_lb_policy_args *args) {
grpc_lb_policy_factory *factory = lookup_factory(name);
grpc_lb_policy *lb_policy =
grpc_lb_policy_factory_create_lb_policy(factory, args);
grpc_lb_policy_factory_create_lb_policy(exec_ctx, factory, args);
return lb_policy;
}

@ -35,6 +35,7 @@
#define GRPC_CORE_LIB_CLIENT_CONFIG_LB_POLICY_REGISTRY_H
#include "src/core/lib/client_config/lb_policy_factory.h"
#include "src/core/lib/iomgr/exec_ctx.h"
/** Initialize the registry and set \a default_factory as the factory to be
* returned when no name is provided in a lookup */
@ -48,7 +49,7 @@ void grpc_register_lb_policy(grpc_lb_policy_factory *factory);
*
* If \a name is NULL, the default factory from \a grpc_lb_policy_registry_init
* will be returned. */
grpc_lb_policy *grpc_lb_policy_create(const char *name,
grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name,
grpc_lb_policy_args *args);
#endif /* GRPC_CORE_LIB_CLIENT_CONFIG_LB_POLICY_REGISTRY_H */

@ -162,38 +162,23 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
grpc_resolved_addresses *addresses) {
dns_resolver *r = arg;
grpc_client_config *config = NULL;
grpc_subchannel **subchannels;
grpc_subchannel_args args;
grpc_lb_policy *lb_policy;
size_t i;
gpr_mu_lock(&r->mu);
GPR_ASSERT(r->resolving);
r->resolving = 0;
if (addresses != NULL) {
grpc_lb_policy_args lb_policy_args;
config = grpc_client_config_create();
subchannels = gpr_malloc(sizeof(grpc_subchannel *) * addresses->naddrs);
size_t naddrs = 0;
for (i = 0; i < addresses->naddrs; i++) {
memset(&args, 0, sizeof(args));
args.addr = (struct sockaddr *)(addresses->addrs[i].addr);
args.addr_len = (size_t)addresses->addrs[i].len;
grpc_subchannel *subchannel = grpc_subchannel_factory_create_subchannel(
exec_ctx, r->subchannel_factory, &args);
if (subchannel != NULL) {
subchannels[naddrs++] = subchannel;
}
}
memset(&lb_policy_args, 0, sizeof(lb_policy_args));
lb_policy_args.subchannels = subchannels;
lb_policy_args.num_subchannels = naddrs;
lb_policy = grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
lb_policy_args.addresses = addresses;
lb_policy_args.subchannel_factory = r->subchannel_factory;
lb_policy =
grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args);
if (lb_policy != NULL) {
grpc_client_config_set_lb_policy(config, lb_policy);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction");
}
grpc_resolved_addresses_destroy(addresses);
gpr_free(subchannels);
} else {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);

@ -58,11 +58,7 @@ typedef struct {
char *lb_policy_name;
/** the addresses that we've 'resolved' */
struct sockaddr_storage *addrs;
/** the corresponding length of the addresses */
size_t *addrs_len;
/** how many elements in \a addrs */
size_t num_addrs;
grpc_resolved_addresses *addresses;
/** mutex guarding the rest of the state */
gpr_mu mu;
@ -125,28 +121,14 @@ static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
sockaddr_resolver *r) {
grpc_client_config *cfg;
grpc_lb_policy *lb_policy;
grpc_lb_policy_args lb_policy_args;
grpc_subchannel **subchannels;
grpc_subchannel_args args;
if (r->next_completion != NULL && !r->published) {
size_t i;
cfg = grpc_client_config_create();
subchannels = gpr_malloc(sizeof(grpc_subchannel *) * r->num_addrs);
for (i = 0; i < r->num_addrs; i++) {
memset(&args, 0, sizeof(args));
args.addr = (struct sockaddr *)&r->addrs[i];
args.addr_len = r->addrs_len[i];
subchannels[i] = grpc_subchannel_factory_create_subchannel(
exec_ctx, r->subchannel_factory, &args);
}
grpc_client_config *cfg = grpc_client_config_create();
grpc_lb_policy_args lb_policy_args;
memset(&lb_policy_args, 0, sizeof(lb_policy_args));
lb_policy_args.subchannels = subchannels;
lb_policy_args.num_subchannels = r->num_addrs;
lb_policy = grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
gpr_free(subchannels);
lb_policy_args.addresses = r->addresses;
lb_policy_args.subchannel_factory = r->subchannel_factory;
grpc_lb_policy *lb_policy =
grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args);
grpc_client_config_set_lb_policy(cfg, lb_policy);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "sockaddr");
r->published = 1;
@ -160,8 +142,7 @@ static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
sockaddr_resolver *r = (sockaddr_resolver *)gr;
gpr_mu_destroy(&r->mu);
grpc_subchannel_factory_unref(exec_ctx, r->subchannel_factory);
gpr_free(r->addrs);
gpr_free(r->addrs_len);
grpc_resolved_addresses_destroy(r->addresses);
gpr_free(r->lb_policy_name);
gpr_free(r);
}
@ -269,7 +250,6 @@ static void do_nothing(void *ignored) {}
static grpc_resolver *sockaddr_create(
grpc_resolver_args *args, const char *default_lb_policy_name,
int parse(grpc_uri *uri, struct sockaddr_storage *dst, size_t *len)) {
size_t i;
int errors_found = 0; /* GPR_FALSE */
sockaddr_resolver *r;
gpr_slice path_slice;
@ -309,15 +289,18 @@ static grpc_resolver *sockaddr_create(
gpr_slice_buffer_init(&path_parts);
gpr_slice_split(path_slice, ",", &path_parts);
r->num_addrs = path_parts.count;
r->addrs = gpr_malloc(sizeof(struct sockaddr_storage) * r->num_addrs);
r->addrs_len = gpr_malloc(sizeof(*r->addrs_len) * r->num_addrs);
r->addresses = gpr_malloc(sizeof(grpc_resolved_addresses));
r->addresses->naddrs = path_parts.count;
r->addresses->addrs =
gpr_malloc(sizeof(grpc_resolved_address) * r->addresses->naddrs);
for (i = 0; i < r->num_addrs; i++) {
for (size_t i = 0; i < r->addresses->naddrs; i++) {
grpc_uri ith_uri = *args->uri;
char *part_str = gpr_dump_slice(path_parts.slices[i], GPR_DUMP_ASCII);
ith_uri.path = part_str;
if (!parse(&ith_uri, &r->addrs[i], &r->addrs_len[i])) {
if (!parse(&ith_uri,
(struct sockaddr_storage *)(&r->addresses->addrs[i].addr),
&r->addresses->addrs[i].len)) {
errors_found = 1; /* GPR_TRUE */
}
gpr_free(part_str);
@ -328,8 +311,7 @@ static grpc_resolver *sockaddr_create(
gpr_slice_unref(path_slice);
if (errors_found) {
gpr_free(r->lb_policy_name);
gpr_free(r->addrs);
gpr_free(r->addrs_len);
grpc_resolved_addresses_destroy(r->addresses);
gpr_free(r);
return NULL;
}

@ -184,28 +184,22 @@ static void zookeeper_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
grpc_resolved_addresses *addresses) {
zookeeper_resolver *r = arg;
grpc_client_config *config = NULL;
grpc_subchannel **subchannels;
grpc_subchannel_args args;
grpc_lb_policy *lb_policy;
size_t i;
if (addresses != NULL) {
grpc_lb_policy_args lb_policy_args;
config = grpc_client_config_create();
subchannels = gpr_malloc(sizeof(grpc_subchannel *) * addresses->naddrs);
for (i = 0; i < addresses->naddrs; i++) {
memset(&args, 0, sizeof(args));
args.addr = (struct sockaddr *)(addresses->addrs[i].addr);
args.addr_len = addresses->addrs[i].len;
subchannels[i] = grpc_subchannel_factory_create_subchannel(
exec_ctx, r->subchannel_factory, &args);
lb_policy_args.addresses = addresses;
lb_policy_args.subchannel_factory = r->subchannel_factory;
lb_policy =
grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args);
if (lb_policy != NULL) {
grpc_client_config_set_lb_policy(config, lb_policy);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction");
}
lb_policy_args.subchannels = subchannels;
lb_policy_args.num_subchannels = addresses->naddrs;
lb_policy = grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
grpc_client_config_set_lb_policy(config, lb_policy);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction");
grpc_resolved_addresses_destroy(addresses);
gpr_free(subchannels);
}
gpr_mu_lock(&r->mu);
GPR_ASSERT(r->resolving == 1);

@ -39,6 +39,8 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
extern int grpc_http_trace;
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
memcpy(out, buffer, length);
@ -72,7 +74,7 @@ static int handle_response_line(grpc_http_parser *parser) {
return 1;
error:
gpr_log(GPR_ERROR, "Failed parsing response line");
if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
return 0;
}
@ -125,7 +127,7 @@ static int handle_request_line(grpc_http_parser *parser) {
return 1;
error:
gpr_log(GPR_ERROR, "Failed parsing request line");
if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
return 0;
}
@ -150,7 +152,8 @@ static int add_header(grpc_http_parser *parser) {
GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') {
gpr_log(GPR_ERROR, "Continued header lines not supported yet");
if (grpc_http_trace)
gpr_log(GPR_ERROR, "Continued header lines not supported yet");
goto error;
}
@ -158,7 +161,7 @@ static int add_header(grpc_http_parser *parser) {
cur++;
}
if (cur == end) {
gpr_log(GPR_ERROR, "Didn't find ':' in header string");
if (grpc_http_trace) gpr_log(GPR_ERROR, "Didn't find ':' in header string");
goto error;
}
GPR_ASSERT(cur >= beg);
@ -249,8 +252,9 @@ static int addbyte(grpc_http_parser *parser, uint8_t byte) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
if (grpc_http_trace)
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return 0;
}
parser->cur_line[parser->cur_line_length] = byte;

@ -37,7 +37,7 @@
#include "src/core/lib/iomgr/pollset_set_windows.h"
grpc_pollset_set* grpc_pollset_set_create(pollset_set) { return NULL; }
grpc_pollset_set* grpc_pollset_set_create(void) { return NULL; }
void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}

@ -280,13 +280,14 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
break;
case GRPC_JSON_STATE_OBJECT_KEY_STRING:
GPR_ASSERT(reader->unicode_high_surrogate == 0);
if (reader->unicode_high_surrogate != 0)
return GRPC_JSON_PARSE_ERROR;
if (c == '"') {
reader->state = GRPC_JSON_STATE_OBJECT_KEY_END;
json_reader_set_key(reader);
json_reader_string_clear(reader);
} else {
if (c <= 0x001f) return GRPC_JSON_PARSE_ERROR;
if (c < 32) return GRPC_JSON_PARSE_ERROR;
json_reader_string_add_char(reader, c);
}
break;
@ -362,6 +363,8 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
reader->in_object = 0;
reader->in_array = 1;
break;
default:
return GRPC_JSON_PARSE_ERROR;
}
break;

@ -174,6 +174,9 @@ struct grpc_call {
/* Received call statuses from various sources */
received_status status[STATUS_SOURCE_COUNT];
/* Call stats: only valid after trailing metadata received */
grpc_transport_stream_stats stats;
/* Compression algorithm for the call */
grpc_compression_algorithm compression_algorithm;
/* Supported encodings (compression algorithms), a bitset */
@ -1371,6 +1374,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
bctl->recv_final_op = 1;
stream_op.recv_trailing_metadata =
&call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */];
stream_op.collect_stats = &call->stats;
break;
case GRPC_OP_RECV_CLOSE_ON_SERVER:
/* Flag validation: currently allow no flags */
@ -1392,6 +1396,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
bctl->recv_final_op = 1;
stream_op.recv_trailing_metadata =
&call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */];
stream_op.collect_stats = &call->stats;
break;
}
}

@ -35,6 +35,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/transport/transport_impl.h"
#ifdef GRPC_STREAM_REFCOUNT_DEBUG
@ -76,6 +77,24 @@ void grpc_stream_ref_init(grpc_stream_refcount *refcount, int initial_refs,
grpc_closure_init(&refcount->destroy, cb, cb_arg);
}
static void move64(uint64_t *from, uint64_t *to) {
*to += *from;
*from = 0;
}
void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats *from,
grpc_transport_one_way_stats *to) {
move64(&from->framing_bytes, &to->framing_bytes);
move64(&from->data_bytes, &to->data_bytes);
move64(&from->header_bytes, &to->header_bytes);
}
void grpc_transport_move_stats(grpc_transport_stream_stats *from,
grpc_transport_stream_stats *to) {
grpc_transport_move_one_way_stats(&from->incoming, &to->incoming);
grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing);
}
size_t grpc_transport_stream_size(grpc_transport *transport) {
return transport->vtable->sizeof_stream;
}

@ -78,6 +78,23 @@ void grpc_stream_unref(grpc_exec_ctx *exec_ctx, grpc_stream_refcount *refcount);
grpc_stream_ref_init(rc, ir, cb, cb_arg)
#endif
typedef struct {
uint64_t framing_bytes;
uint64_t data_bytes;
uint64_t header_bytes;
} grpc_transport_one_way_stats;
typedef struct grpc_transport_stream_stats {
grpc_transport_one_way_stats incoming;
grpc_transport_one_way_stats outgoing;
} grpc_transport_stream_stats;
void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats *from,
grpc_transport_one_way_stats *to);
void grpc_transport_move_stats(grpc_transport_stream_stats *from,
grpc_transport_stream_stats *to);
/* Transport stream op: a set of operations to perform on a transport
against a single stream */
typedef struct grpc_transport_stream_op {
@ -104,6 +121,9 @@ typedef struct grpc_transport_stream_op {
*/
grpc_metadata_batch *recv_trailing_metadata;
/** Collect any stats into provided buffer, zero internal stat counters */
grpc_transport_stream_stats *collect_stats;
/** Should be enqueued when all requested operations (excluding recv_message
and recv_initial_metadata which have their own closures) in a given batch
have been completed. */

@ -1,6 +1,6 @@
#region Copyright notice and license
// Copyright 2015, Google Inc.
// Copyright 2015-2016, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -46,16 +46,13 @@ namespace Grpc.Testing
/// </summary>
public class BenchmarkServiceImpl : BenchmarkService.IBenchmarkService
{
private readonly int responseSize;
public BenchmarkServiceImpl(int responseSize)
public BenchmarkServiceImpl()
{
this.responseSize = responseSize;
}
public Task<SimpleResponse> UnaryCall(SimpleRequest request, ServerCallContext context)
{
var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) };
var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) };
return Task.FromResult(response);
}
@ -63,7 +60,7 @@ namespace Grpc.Testing
{
await requestStream.ForEachAsync(async request =>
{
var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) };
var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) };
await responseStream.WriteAsync(response);
});
}

@ -41,6 +41,7 @@ using System.Threading;
using System.Threading.Tasks;
using Google.Protobuf;
using Grpc.Core;
using Grpc.Core.Logging;
using Grpc.Core.Utils;
using NUnit.Framework;
using Grpc.Testing;
@ -50,42 +51,65 @@ namespace Grpc.IntegrationTesting
/// <summary>
/// Helper methods to start client runners for performance testing.
/// </summary>
public static class ClientRunners
public class ClientRunners
{
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<ClientRunners>();
/// <summary>
/// Creates a started client runner.
/// </summary>
public static IClientRunner CreateStarted(ClientConfig config)
{
Logger.Debug("ClientConfig: {0}", config);
string target = config.ServerTargets.Single();
GrpcPreconditions.CheckArgument(config.LoadParams.LoadCase == LoadParams.LoadOneofCase.ClosedLoop);
GrpcPreconditions.CheckArgument(config.LoadParams.LoadCase == LoadParams.LoadOneofCase.ClosedLoop,
"Only closed loop scenario supported for C#");
GrpcPreconditions.CheckArgument(config.ClientChannels == 1, "ClientConfig.ClientChannels needs to be 1");
var credentials = config.SecurityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure;
var channel = new Channel(target, credentials);
if (config.OutstandingRpcsPerChannel != 0)
{
Logger.Warning("ClientConfig.OutstandingRpcsPerChannel is not supported for C#. Ignoring the value");
}
if (config.AsyncClientThreads != 0)
{
Logger.Warning("ClientConfig.AsyncClientThreads is not supported for C#. Ignoring the value");
}
if (config.CoreLimit != 0)
{
Logger.Warning("ClientConfig.CoreLimit is not supported for C#. Ignoring the value");
}
if (config.CoreList.Count > 0)
{
Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value");
}
switch (config.RpcType)
var credentials = config.SecurityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure;
List<ChannelOption> channelOptions = null;
if (config.SecurityParams != null && config.SecurityParams.ServerHostOverride != "")
{
case RpcType.UNARY:
return new SyncUnaryClientRunner(channel,
config.PayloadConfig.SimpleParams.ReqSize,
config.HistogramParams);
case RpcType.STREAMING:
default:
throw new ArgumentException("Unsupported RpcType.");
channelOptions = new List<ChannelOption>
{
new ChannelOption(ChannelOptions.SslTargetNameOverride, config.SecurityParams.ServerHostOverride)
};
}
var channel = new Channel(target, credentials, channelOptions);
return new ClientRunnerImpl(channel,
config.ClientType,
config.RpcType,
config.PayloadConfig,
config.HistogramParams);
}
}
/// <summary>
/// Client that starts synchronous unary calls in a closed loop.
/// </summary>
public class SyncUnaryClientRunner : IClientRunner
public class ClientRunnerImpl : IClientRunner
{
const double SecondsToNanos = 1e9;
readonly Channel channel;
readonly int payloadSize;
readonly ClientType clientType;
readonly RpcType rpcType;
readonly PayloadConfig payloadConfig;
readonly Histogram histogram;
readonly BenchmarkService.IBenchmarkServiceClient client;
@ -93,15 +117,19 @@ namespace Grpc.IntegrationTesting
readonly CancellationTokenSource stoppedCts;
readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch();
public SyncUnaryClientRunner(Channel channel, int payloadSize, HistogramParams histogramParams)
public ClientRunnerImpl(Channel channel, ClientType clientType, RpcType rpcType, PayloadConfig payloadConfig, HistogramParams histogramParams)
{
this.channel = GrpcPreconditions.CheckNotNull(channel);
this.payloadSize = payloadSize;
this.clientType = clientType;
this.rpcType = rpcType;
this.payloadConfig = payloadConfig;
this.histogram = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible);
this.stoppedCts = new CancellationTokenSource();
this.client = BenchmarkService.NewClient(channel);
this.runnerTask = Task.Factory.StartNew(Run, TaskCreationOptions.LongRunning);
var threadBody = GetThreadBody();
this.runnerTask = Task.Factory.StartNew(threadBody, TaskCreationOptions.LongRunning);
}
public ClientStats GetStats(bool reset)
@ -126,12 +154,9 @@ namespace Grpc.IntegrationTesting
await channel.ShutdownAsync();
}
private void Run()
private void RunClosedLoopUnary()
{
var request = new SimpleRequest
{
Payload = CreateZerosPayload(payloadSize)
};
var request = CreateSimpleRequest();
var stopwatch = new Stopwatch();
while (!stoppedCts.Token.IsCancellationRequested)
@ -145,6 +170,124 @@ namespace Grpc.IntegrationTesting
}
}
private async Task RunClosedLoopUnaryAsync()
{
var request = CreateSimpleRequest();
var stopwatch = new Stopwatch();
while (!stoppedCts.Token.IsCancellationRequested)
{
stopwatch.Restart();
await client.UnaryCallAsync(request);
stopwatch.Stop();
// spec requires data point in nanoseconds.
histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos);
}
}
private async Task RunClosedLoopStreamingAsync()
{
var request = CreateSimpleRequest();
var stopwatch = new Stopwatch();
using (var call = client.StreamingCall())
{
while (!stoppedCts.Token.IsCancellationRequested)
{
stopwatch.Restart();
await call.RequestStream.WriteAsync(request);
await call.ResponseStream.MoveNext();
stopwatch.Stop();
// spec requires data point in nanoseconds.
histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos);
}
// finish the streaming call
await call.RequestStream.CompleteAsync();
Assert.IsFalse(await call.ResponseStream.MoveNext());
}
}
private async Task RunGenericClosedLoopStreamingAsync()
{
var request = CreateByteBufferRequest();
var stopwatch = new Stopwatch();
var callDetails = new CallInvocationDetails<byte[], byte[]>(channel, GenericService.StreamingCallMethod, new CallOptions());
using (var call = Calls.AsyncDuplexStreamingCall(callDetails))
{
while (!stoppedCts.Token.IsCancellationRequested)
{
stopwatch.Restart();
await call.RequestStream.WriteAsync(request);
await call.ResponseStream.MoveNext();
stopwatch.Stop();
// spec requires data point in nanoseconds.
histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos);
}
// finish the streaming call
await call.RequestStream.CompleteAsync();
Assert.IsFalse(await call.ResponseStream.MoveNext());
}
}
private Action GetThreadBody()
{
if (payloadConfig.PayloadCase == PayloadConfig.PayloadOneofCase.BytebufParams)
{
GrpcPreconditions.CheckArgument(clientType == ClientType.ASYNC_CLIENT, "Generic client only supports async API");
GrpcPreconditions.CheckArgument(rpcType == RpcType.STREAMING, "Generic client only supports streaming calls");
return () =>
{
RunGenericClosedLoopStreamingAsync().Wait();
};
}
GrpcPreconditions.CheckNotNull(payloadConfig.SimpleParams);
if (clientType == ClientType.SYNC_CLIENT)
{
GrpcPreconditions.CheckArgument(rpcType == RpcType.UNARY, "Sync client can only be used for Unary calls in C#");
return RunClosedLoopUnary;
}
else if (clientType == ClientType.ASYNC_CLIENT)
{
switch (rpcType)
{
case RpcType.UNARY:
return () =>
{
RunClosedLoopUnaryAsync().Wait();
};
case RpcType.STREAMING:
return () =>
{
RunClosedLoopStreamingAsync().Wait();
};
}
}
throw new ArgumentException("Unsupported configuration.");
}
private SimpleRequest CreateSimpleRequest()
{
GrpcPreconditions.CheckNotNull(payloadConfig.SimpleParams);
return new SimpleRequest
{
Payload = CreateZerosPayload(payloadConfig.SimpleParams.ReqSize),
ResponseSize = payloadConfig.SimpleParams.RespSize
};
}
private byte[] CreateByteBufferRequest()
{
return new byte[payloadConfig.BytebufParams.ReqSize];
}
private static Payload CreateZerosPayload(int size)
{
return new Payload { Body = ByteString.CopyFrom(new byte[size]) };

@ -0,0 +1,71 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Google.Protobuf;
using Grpc.Core;
using Grpc.Core.Utils;
using NUnit.Framework;
using Grpc.Testing;
namespace Grpc.IntegrationTesting
{
/// <summary>
/// Utility methods for defining and calling a service that doesn't use protobufs
/// for serialization/deserialization.
/// </summary>
public static class GenericService
{
readonly static Marshaller<byte[]> ByteArrayMarshaller = new Marshaller<byte[]>((b) => b, (b) => b);
public readonly static Method<byte[], byte[]> StreamingCallMethod = new Method<byte[], byte[]>(
MethodType.DuplexStreaming,
"grpc.testing.BenchmarkService",
"StreamingCall",
ByteArrayMarshaller,
ByteArrayMarshaller
);
public static ServerServiceDefinition BindHandler(DuplexStreamingServerMethod<byte[], byte[]> handler)
{
return ServerServiceDefinition.CreateBuilder(StreamingCallMethod.ServiceName)
.AddMethod(StreamingCallMethod, handler).Build();
}
}
}

@ -120,6 +120,7 @@
<Compile Include="WorkerServiceImpl.cs" />
<Compile Include="QpsWorker.cs" />
<Compile Include="WallClockStopwatch.cs" />
<Compile Include="GenericService.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

@ -55,14 +55,7 @@ namespace Grpc.IntegrationTesting
{
var serverConfig = new ServerConfig
{
ServerType = ServerType.ASYNC_SERVER,
PayloadConfig = new PayloadConfig
{
SimpleParams = new SimpleProtoParams
{
RespSize = 100
}
}
ServerType = ServerType.ASYNC_SERVER
};
serverRunner = ServerRunners.CreateStarted(serverConfig);
}
@ -88,7 +81,8 @@ namespace Grpc.IntegrationTesting
{
SimpleParams = new SimpleProtoParams
{
ReqSize = 100
ReqSize = 100,
RespSize = 100
}
},
HistogramParams = new HistogramParams

@ -41,6 +41,7 @@ using System.Threading;
using System.Threading.Tasks;
using Google.Protobuf;
using Grpc.Core;
using Grpc.Core.Logging;
using Grpc.Core.Utils;
using NUnit.Framework;
using Grpc.Testing;
@ -50,27 +51,78 @@ namespace Grpc.IntegrationTesting
/// <summary>
/// Helper methods to start server runners for performance testing.
/// </summary>
public static class ServerRunners
public class ServerRunners
{
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<ServerRunners>();
/// <summary>
/// Creates a started server runner.
/// </summary>
public static IServerRunner CreateStarted(ServerConfig config)
{
GrpcPreconditions.CheckArgument(config.ServerType == ServerType.ASYNC_SERVER);
Logger.Debug("ServerConfig: {0}", config);
var credentials = config.SecurityParams != null ? TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure;
// TODO: qps_driver needs to setup payload properly...
int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0;
if (config.AsyncServerThreads != 0)
{
Logger.Warning("ServerConfig.AsyncServerThreads is not supported for C#. Ignoring the value");
}
if (config.CoreLimit != 0)
{
Logger.Warning("ServerConfig.CoreLimit is not supported for C#. Ignoring the value");
}
if (config.CoreList.Count > 0)
{
Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value");
}
ServerServiceDefinition service = null;
if (config.ServerType == ServerType.ASYNC_SERVER)
{
GrpcPreconditions.CheckArgument(config.PayloadConfig == null,
"ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server.");
service = BenchmarkService.BindService(new BenchmarkServiceImpl());
}
else if (config.ServerType == ServerType.ASYNC_GENERIC_SERVER)
{
var genericService = new GenericServiceImpl(config.PayloadConfig.BytebufParams.RespSize);
service = GenericService.BindHandler(genericService.StreamingCall);
}
else
{
throw new ArgumentException("Unsupported ServerType");
}
var server = new Server
{
Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) },
Services = { service },
Ports = { new ServerPort("[::]", config.Port, credentials) }
};
server.Start();
return new ServerRunnerImpl(server);
}
private class GenericServiceImpl
{
readonly byte[] response;
public GenericServiceImpl(int responseSize)
{
this.response = new byte[responseSize];
}
/// <summary>
/// Generic streaming call handler.
/// </summary>
public async Task StreamingCall(IAsyncStreamReader<byte[]> requestStream, IServerStreamWriter<byte[]> responseStream, ServerCallContext context)
{
await requestStream.ForEachAsync(async request =>
{
await responseStream.WriteAsync(response);
});
}
}
}
/// <summary>
@ -119,6 +171,5 @@ namespace Grpc.IntegrationTesting
{
return server.ShutdownAsync();
}
}
}
}

@ -54,7 +54,9 @@
GRPC_XMACRO_ITEM.
#endif
#if TARGET_OS_IPHONE
GRPC_XMACRO_ITEM(isCell, IsWWAN)
#endif
GRPC_XMACRO_ITEM(reachable, Reachable)
GRPC_XMACRO_ITEM(transientConnection, TransientConnection)
GRPC_XMACRO_ITEM(connectionRequired, ConnectionRequired)

@ -91,6 +91,9 @@ class BuildTaggedExt(setuptools.Command):
def update_setup_arguments(setup_arguments):
if not USE_PRECOMPILED_BINARIES:
sys.stderr.write('not using precompiled extension')
return
url = '{}/{}.so'.format(BINARIES_REPOSITORY, _tagged_ext_name('cygrpc'))
target_path = os.path.join(PYTHON_STEM, 'grpc/_cython/cygrpc.so')
try:

@ -50,21 +50,18 @@ grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char *string, size_t length) {
}
VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
size_t length = 0;
char *string = NULL;
size_t offset = 0;
VALUE rb_string;
grpc_byte_buffer_reader reader;
gpr_slice next;
if (buffer == NULL) {
return Qnil;
}
length = grpc_byte_buffer_length(buffer);
string = xmalloc(length + 1);
rb_string = rb_str_buf_new(grpc_byte_buffer_length(buffer));
grpc_byte_buffer_reader_init(&reader, buffer);
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
rb_str_cat(rb_string, (const char *) GPR_SLICE_START_PTR(next),
GPR_SLICE_LENGTH(next));
gpr_slice_unref(next);
}
return rb_str_new(string, length);
return rb_string;
}

@ -551,13 +551,26 @@ static void grpc_run_batch_stack_init(run_batch_stack *st,
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
* cleaned up */
static void grpc_run_batch_stack_cleanup(run_batch_stack *st) {
size_t i = 0;
grpc_metadata_array_destroy(&st->send_metadata);
grpc_metadata_array_destroy(&st->send_trailing_metadata);
grpc_metadata_array_destroy(&st->recv_metadata);
grpc_metadata_array_destroy(&st->recv_trailing_metadata);
if (st->recv_status_details != NULL) {
gpr_free(st->recv_status_details);
}
if (st->recv_message != NULL) {
grpc_byte_buffer_destroy(st->recv_message);
}
for (i = 0; i < st->op_num; i++) {
if (st->ops[i].op == GRPC_OP_SEND_MESSAGE) {
grpc_byte_buffer_destroy(st->ops[i].data.send_message);
}
}
}
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
@ -643,7 +656,6 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
break;
case GRPC_OP_SEND_MESSAGE:
rb_struct_aset(result, sym_send_message, Qtrue);
grpc_byte_buffer_destroy(st->ops[i].data.send_message);
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
rb_struct_aset(result, sym_send_close, Qtrue);

@ -49,7 +49,9 @@
]
if target_dict.get('build', None) == 'protoc':
deps.append("//external:protobuf_compiler")
if target_dict['name'] == 'grpc++_unsecure' or target_dict['name'] == 'grpc++':
if (target_dict['name'] == 'grpc++_unsecure' or
target_dict['name'] == 'grpc++' or
target_dict['name'] == 'grpc++_codegen_lib'):
deps.append("//external:protobuf_clib")
elif target_dict['name'] == 'grpc':
deps.append("//external:zlib")
@ -60,7 +62,7 @@
deps.append(':%s' % (d))
return deps
%>
% for lib in libs:
% if lib.build in ("all", "protoc"):
${cc_library(lib)}
@ -80,13 +82,19 @@
% endfor
<%def name="cc_library(lib)">
<%
lib_hdrs = lib.get("headers", [])
hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')]
srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')]
uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src)
%>
cc_library(
name = "${lib.name}",
srcs = [
% for hdr in lib.get("headers", []):
% for hdr in hdrs:
"${hdr}",
% endfor
% for src in lib.src:
% for src in srcs:
"${src}",
% endfor
],
@ -103,6 +111,9 @@
% for dep in get_deps(lib):
"${dep}",
% endfor
% if uses_nanopb:
"//external:nanopb",
% endif
],
% if lib.name in ("grpc", "grpc_unsecure"):
copts = [
@ -113,10 +124,16 @@
</%def>
<%def name="objc_library(lib)">
<%
lib_hdrs = lib.get("headers", [])
hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')]
srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')]
uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src)
%>
objc_library(
name = "${lib.name}_objc",
srcs = [
% for src in lib.src:
% for src in srcs:
"${src}",
% endfor
],
@ -124,7 +141,7 @@
% for hdr in lib.get("public_headers", []):
"${hdr}",
% endfor
% for hdr in lib.get("headers", []):
% for hdr in hdrs:
"${hdr}",
% endfor
],
@ -138,6 +155,9 @@
% endfor
% if lib.get('secure', False):
"//external:libssl_objc",
% endif
% if uses_nanopb:
"//external:nanopb",
% endif
],
% if lib.get("baselib", false):

@ -1737,7 +1737,7 @@
$(LIBDIR)/$(CONFIG)/lib${dep}.a\
% endfor
% if tgt.language == "c++" or tgt.boringssl:
% if tgt.language == "c++" or tgt.boringssl or tgt.build == 'fuzzer':
## C++ targets specificies.
% if tgt.build == 'protoc':
$(E) "[HOSTLD] Linking $@"
@ -1790,6 +1790,9 @@
$(GTEST_LIB)\
% elif tgt.language == 'c++' and tgt.build == 'benchmark':
$(GTEST_LIB)\
% endif
% if tgt.build == 'fuzzer':
-lFuzzer\
% endif
-o $(BINDIR)/$(CONFIG)/${tgt.name}
% if tgt.build == 'protoc' or tgt.language == 'c++':

@ -1,5 +1,5 @@
#=================
# Update clang to a version with improved tsan
# Update clang to a version with improved tsan and fuzzing capabilities
RUN apt-get update && apt-get -y install python cmake && apt-get clean
@ -29,4 +29,4 @@ RUN cd llvm-build && cmake ${'\\'}
-DCMAKE_INSTALL_PREFIX:STRING=/usr ${'\\'}
-DLLVM_TARGETS_TO_BUILD:STRING=X86 ${'\\'}
../llvm
RUN make -C llvm-build && make -C llvm-build install && rm -rf llvm-build
RUN make -C llvm-build -j 12 && make -C llvm-build install && rm -rf llvm-build

@ -0,0 +1,4 @@
# Google Cloud platform API libraries
RUN apt-get update && apt-get install -y python-pip && apt-get clean
RUN pip install --upgrade google-api-python-client

@ -0,0 +1,40 @@
%YAML 1.2
--- |
# Copyright 2015-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.
FROM debian:jessie
<%include file="../apt_get_basic.include"/>
<%include file="../ccache_setup.include"/>
<%include file="../cxx_deps.include"/>
<%include file="../gcp_api_libraries.include"/>
<%include file="../clang_update.include"/>
# Define the default command.
CMD ["bash"]

@ -0,0 +1,43 @@
%YAML 1.2
--- |
# Copyright 2015-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.
FROM debian:jessie
<%include file="../../apt_get_basic.include"/>
<%include file="../../cxx_deps.include"/>
<%include file="../../clang_update.include"/>
<%include file="../../run_tests_addons.include"/>
RUN clang++ -c -g -O2 -std=c++11 llvm/lib/Fuzzer/*.cpp -IFuzzer
RUN ar ruv libFuzzer.a Fuzzer*.o
RUN mv libFuzzer.a /usr/lib
RUN rm -f Fuzzer*.o
# Define the default command.
CMD ["bash"]

@ -0,0 +1,44 @@
%YAML 1.2
---
foreach: targets
cond: selected.build == 'fuzzer'
output_name: ${selected.name}.sh
template: |
#!/bin/bash
# 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.
#
flags="-max_total_time=3600 -jobs=3 -workers=3"
if [ "$config" == "asan-trace-cmp" ]
then
flags="-use_traces=1 $flags"
fi
bins/$config/${selected.name} $flags fuzzer_output ${' '.join(selected.corpus_dirs)}

@ -2,6 +2,6 @@
--- |
<%namespace file="sln_defs.include" import="gen_solution"/>\
<%
solution_projects = [p for p in vsprojects if p.build != 'protoc' and p.language == 'c' and not p.boringssl and not p.zlib]
solution_projects = [p for p in vsprojects if p.build not in ['protoc', 'fuzzer'] and p.language == 'c' and not p.boringssl and not p.zlib]
%>\
${gen_solution(solution_projects, use_dlls='yes')}

@ -2,6 +2,6 @@
--- |
<%namespace file="sln_defs.include" import="gen_solution"/>\
<%
solution_projects = [p for p in vsprojects if p.build not in ['protoc', 'test'] and p.language in ['c', 'c++'] and p.vs_proj_dir == '.' and not (p.build == 'private' and p.language == 'c++')]
solution_projects = [p for p in vsprojects if p.build not in ['protoc', 'test', 'fuzzer'] and p.language in ['c', 'c++'] and p.vs_proj_dir == '.' and not (p.build == 'private' and p.language == 'c++')]
%>\
${gen_solution(solution_projects, use_dlls='yes')}

@ -2,12 +2,14 @@
---
foreach: vsprojects
output_name: ${selected.vs_proj_dir}/${selected.name}/${selected.name}.vcxproj
cond: selected.build not in ['fuzzer']
template: |
<%namespace file="vcxproj_defs.include" import="gen_project"/>\
${gen_project(selected.name, vsprojects)}
---
foreach: vsprojects
output_name: ${selected.vs_proj_dir}/${selected.name}/${selected.name}.vcxproj.filters
cond: selected.build not in ['fuzzer']
template: |
<%namespace file="vcxproj.filters_defs.include" import="gen_filters"/>\
${gen_filters(selected.name, vsprojects)}

@ -873,6 +873,7 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
}
int main(int argc, char **argv) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
test_spec *spec;
size_t i;
const size_t NUM_ITERS = 10;
@ -882,9 +883,9 @@ int main(int argc, char **argv) {
grpc_init();
grpc_lb_round_robin_trace = 1;
GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", NULL) ==
NULL);
GPR_ASSERT(grpc_lb_policy_create(NULL, NULL) == NULL);
GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist",
NULL) == NULL);
GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, NULL, NULL) == NULL);
spec = test_spec_create(NUM_ITERS, NUM_SERVERS);
/* everything is fine, all servers stay up the whole time and life's peachy */
@ -936,6 +937,7 @@ int main(int argc, char **argv) {
test_pending_calls(4);
test_ping();
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}

@ -0,0 +1,52 @@
/*
*
* Copyright 2015-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 <stdint.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/client_config/uri_parser.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
char *s = gpr_malloc(size + 1);
memcpy(s, data, size);
s[size] = 0;
grpc_uri *x;
if ((x = grpc_uri_parse(s, 1))) {
grpc_uri_destroy(x);
}
gpr_free(s);
return 0;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save