Merge github.com:grpc/grpc into authority

pull/9647/head
Craig Tiller 8 years ago
commit 2cecf27e2a
  1. 68
      BUILD
  2. 36
      CMakeLists.txt
  3. 50
      Makefile
  4. 2
      binding.gyp
  5. 44
      build.yaml
  6. 2
      config.m4
  7. 18
      gRPC-Core.podspec
  8. 9
      grpc.gemspec
  9. 2
      include/grpc++/server.h
  10. 2
      include/grpc/impl/codegen/grpc_types.h
  11. 9
      package.xml
  12. 61
      src/core/ext/census/trace_label.h
  13. 63
      src/core/ext/census/trace_propagation.h
  14. 45
      src/core/ext/census/trace_status.h
  15. 50
      src/core/ext/census/trace_string.h
  16. 42
      src/core/ext/census/tracing.c
  17. 124
      src/core/ext/census/tracing.h
  18. 44
      src/core/ext/client_channel/client_channel.c
  19. 2
      src/core/ext/client_channel/client_channel_plugin.c
  20. 51
      src/core/ext/client_channel/http_proxy.c
  21. 4
      src/core/ext/client_channel/http_proxy.h
  22. 25
      src/core/ext/client_channel/proxy_mapper.c
  23. 36
      src/core/ext/client_channel/proxy_mapper.h
  24. 52
      src/core/ext/client_channel/proxy_mapper_registry.c
  25. 16
      src/core/ext/client_channel/proxy_mapper_registry.h
  26. 20
      src/core/ext/client_channel/subchannel.c
  27. 3
      src/core/ext/client_channel/subchannel.h
  28. 171
      src/core/ext/lb_policy/grpclb/grpclb.c
  29. 77
      src/core/ext/lb_policy/grpclb/grpclb_channel.c
  30. 56
      src/core/ext/lb_policy/grpclb/grpclb_channel.h
  31. 107
      src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
  32. 7
      src/core/ext/lb_policy/round_robin/round_robin.c
  33. 171
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  34. 60
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  35. 9
      src/core/ext/transport/chttp2/transport/frame_rst_stream.c
  36. 3
      src/core/ext/transport/chttp2/transport/internal.h
  37. 28
      src/core/lib/iomgr/combiner.c
  38. 23
      src/core/lib/iomgr/combiner.h
  39. 2
      src/core/lib/iomgr/resource_quota.c
  40. 38
      src/core/lib/iomgr/sockaddr_utils.c
  41. 4
      src/core/lib/iomgr/sockaddr_utils.h
  42. 4
      src/core/lib/iomgr/udp_server.c
  43. 3
      src/core/lib/iomgr/udp_server.h
  44. 20
      src/core/lib/profiling/basic_timers.c
  45. 47
      src/core/lib/security/credentials/credentials.c
  46. 13
      src/core/lib/security/credentials/credentials.h
  47. 8
      src/core/lib/security/credentials/fake/fake_credentials.c
  48. 15
      src/core/lib/security/credentials/fake/fake_credentials.h
  49. 2
      src/core/lib/security/transport/client_auth_filter.c
  50. 70
      src/core/lib/security/transport/lb_targets_info.c
  51. 47
      src/core/lib/security/transport/lb_targets_info.h
  52. 141
      src/core/lib/security/transport/security_connector.c
  53. 7
      src/core/lib/security/transport/security_connector.h
  54. 4
      src/core/lib/security/transport/security_handshaker.c
  55. 6
      src/core/lib/slice/slice_intern.c
  56. 7
      src/core/lib/support/sync_posix.c
  57. 7
      src/core/lib/surface/call.c
  58. 2
      src/core/lib/surface/init_secure.c
  59. 1
      src/cpp/server/server_cc.cc
  60. 2
      src/csharp/ext/grpc_csharp_ext.c
  61. 2
      src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
  62. 2
      src/objective-c/!ProtoCompiler.podspec
  63. 3
      src/objective-c/tests/InteropTests.m
  64. 8
      src/objective-c/tests/run_tests.sh
  65. 5
      src/proto/grpc/testing/control.proto
  66. 2
      src/python/grpcio/grpc_core_dependencies.py
  67. 4
      src/python/grpcio_tests/commands.py
  68. 2
      templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template
  69. 29
      test/core/end2end/fake_resolver.c
  70. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d
  71. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110
  72. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a
  73. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/25c05b84c4b4f1a93f0f72d368c3c3644b564881
  74. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5
  75. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/30738789e20323323196dd3e6435fa278e73279e
  76. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf
  77. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3a3346314bb9ddaf14877b653cfd506b6ad34fab
  78. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c
  79. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341
  80. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73
  81. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7
  82. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200
  83. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644
  84. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b
  85. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6
  86. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c
  87. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/72031f24261c32d2e3bb2c7909a9315227172730
  88. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/783484ad9e15085e9039c7504aac71af1ad549a2
  89. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/78e43d163fc8226d72b979c0fe6e1593ef3cb542
  90. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7fb64b5785ebe699ca50327c88c1d8b99432fa23
  91. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1
  92. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d
  93. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41
  94. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f
  95. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660
  96. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/a270e4304cc0dcd2c67b78c0495dedb10419f0af
  97. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/bc42e00a7d67fb68df3cb5893908c04884b6ad5e
  98. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94
  99. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0
  100. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a
  101. Some files were not shown because too many files have changed in this diff Show More

68
BUILD

@ -63,7 +63,7 @@ grpc_cc_library(
deps = [ deps = [
"census", "census",
"grpc_base", "grpc_base",
"grpc_lb_policy_grpclb", "grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_pick_first", "grpc_lb_policy_pick_first",
"grpc_lb_policy_round_robin", "grpc_lb_policy_round_robin",
"grpc_load_reporting", "grpc_load_reporting",
@ -284,9 +284,15 @@ grpc_cc_library(
"src/core/ext/census/resource.h", "src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/rpc_metric_id.h",
"src/core/ext/census/trace_context.h", "src/core/ext/census/trace_context.h",
"src/core/ext/census/trace_label.h",
"src/core/ext/census/trace_propagation.h",
"src/core/ext/census/trace_status.h",
"src/core/ext/census/trace_string.h",
"src/core/ext/census/tracing.h",
], ],
external_deps = [ external_deps = [
"nanopb", "nanopb",
"libssl",
], ],
language = "c", language = "c",
public_hdrs = [ public_hdrs = [
@ -624,9 +630,9 @@ grpc_cc_library(
"src/core/lib/surface/completion_queue.h", "src/core/lib/surface/completion_queue.h",
"src/core/lib/surface/event_string.h", "src/core/lib/surface/event_string.h",
"src/core/lib/surface/init.h", "src/core/lib/surface/init.h",
"src/core/lib/surface/validate_metadata.h",
"src/core/lib/surface/lame_client.h", "src/core/lib/surface/lame_client.h",
"src/core/lib/surface/server.h", "src/core/lib/surface/server.h",
"src/core/lib/surface/validate_metadata.h",
"src/core/lib/transport/byte_stream.h", "src/core/lib/transport/byte_stream.h",
"src/core/lib/transport/connectivity_state.h", "src/core/lib/transport/connectivity_state.h",
"src/core/lib/transport/error_utils.h", "src/core/lib/transport/error_utils.h",
@ -665,7 +671,6 @@ grpc_cc_library(
grpc_cc_library( grpc_cc_library(
name = "grpc_client_channel", name = "grpc_client_channel",
language = "c",
srcs = [ srcs = [
"src/core/ext/client_channel/channel_connectivity.c", "src/core/ext/client_channel/channel_connectivity.c",
"src/core/ext/client_channel/client_channel.c", "src/core/ext/client_channel/client_channel.c",
@ -709,6 +714,7 @@ grpc_cc_library(
"src/core/ext/client_channel/subchannel_index.h", "src/core/ext/client_channel/subchannel_index.h",
"src/core/ext/client_channel/uri_parser.h", "src/core/ext/client_channel/uri_parser.h",
], ],
language = "c",
deps = [ deps = [
"grpc_base", "grpc_base",
], ],
@ -735,11 +741,13 @@ grpc_cc_library(
name = "grpc_lb_policy_grpclb", name = "grpc_lb_policy_grpclb",
srcs = [ srcs = [
"src/core/ext/lb_policy/grpclb/grpclb.c", "src/core/ext/lb_policy/grpclb/grpclb.c",
"src/core/ext/lb_policy/grpclb/grpclb_channel.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c", "src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
], ],
hdrs = [ hdrs = [
"src/core/ext/lb_policy/grpclb/grpclb.h", "src/core/ext/lb_policy/grpclb/grpclb.h",
"src/core/ext/lb_policy/grpclb/grpclb_channel.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h", "src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h", "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
], ],
@ -753,6 +761,31 @@ grpc_cc_library(
], ],
) )
grpc_cc_library(
name = "grpc_lb_policy_grpclb_secure",
srcs = [
"src/core/ext/lb_policy/grpclb/grpclb.c",
"src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c",
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
],
hdrs = [
"src/core/ext/lb_policy/grpclb/grpclb.h",
"src/core/ext/lb_policy/grpclb/grpclb_channel.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
],
external_deps = [
"nanopb",
],
language = "c",
deps = [
"grpc_base",
"grpc_client_channel",
"grpc_secure",
],
)
grpc_cc_library( grpc_cc_library(
name = "grpc_lb_policy_pick_first", name = "grpc_lb_policy_pick_first",
srcs = [ srcs = [
@ -837,6 +870,7 @@ grpc_cc_library(
"src/core/lib/security/credentials/ssl/ssl_credentials.c", "src/core/lib/security/credentials/ssl/ssl_credentials.c",
"src/core/lib/security/transport/client_auth_filter.c", "src/core/lib/security/transport/client_auth_filter.c",
"src/core/lib/security/transport/secure_endpoint.c", "src/core/lib/security/transport/secure_endpoint.c",
"src/core/lib/security/transport/lb_targets_info.c",
"src/core/lib/security/transport/security_connector.c", "src/core/lib/security/transport/security_connector.c",
"src/core/lib/security/transport/security_handshaker.c", "src/core/lib/security/transport/security_handshaker.c",
"src/core/lib/security/transport/server_auth_filter.c", "src/core/lib/security/transport/server_auth_filter.c",
@ -860,6 +894,7 @@ grpc_cc_library(
"src/core/lib/security/credentials/ssl/ssl_credentials.h", "src/core/lib/security/credentials/ssl/ssl_credentials.h",
"src/core/lib/security/transport/auth_filters.h", "src/core/lib/security/transport/auth_filters.h",
"src/core/lib/security/transport/secure_endpoint.h", "src/core/lib/security/transport/secure_endpoint.h",
"src/core/lib/security/transport/lb_targets_info.h",
"src/core/lib/security/transport/security_connector.h", "src/core/lib/security/transport/security_connector.h",
"src/core/lib/security/transport/security_handshaker.h", "src/core/lib/security/transport/security_handshaker.h",
"src/core/lib/security/transport/tsi_error.h", "src/core/lib/security/transport/tsi_error.h",
@ -943,22 +978,21 @@ grpc_cc_library(
) )
grpc_cc_library( grpc_cc_library(
name = "grpc_transport_chttp2_client_connector", name = "grpc_transport_chttp2_client_connector",
hdrs = [ srcs = [
"src/core/ext/transport/chttp2/client/chttp2_connector.h", "src/core/ext/transport/chttp2/client/chttp2_connector.c",
], ],
srcs = [ hdrs = [
"src/core/ext/transport/chttp2/client/chttp2_connector.c", "src/core/ext/transport/chttp2/client/chttp2_connector.h",
], ],
language = "c", language = "c",
deps = [ deps = [
"grpc_transport_chttp2", "grpc_base",
"grpc_base", "grpc_client_channel",
"grpc_client_channel", "grpc_transport_chttp2",
], ],
) )
grpc_cc_library( grpc_cc_library(
name = "grpc_transport_chttp2_client_insecure", name = "grpc_transport_chttp2_client_insecure",
srcs = [ srcs = [

@ -442,6 +442,9 @@ add_dependencies(buildtests_c multiple_server_queues_test)
add_dependencies(buildtests_c murmur_hash_test) add_dependencies(buildtests_c murmur_hash_test)
add_dependencies(buildtests_c no_server_test) add_dependencies(buildtests_c no_server_test)
add_dependencies(buildtests_c percent_encoding_test) add_dependencies(buildtests_c percent_encoding_test)
if(_gRPC_PLATFORM_LINUX)
add_dependencies(buildtests_c pollset_set_test)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c resolve_address_posix_test) add_dependencies(buildtests_c resolve_address_posix_test)
endif() endif()
@ -953,6 +956,7 @@ add_library(grpc
src/core/lib/security/credentials/plugin/plugin_credentials.c src/core/lib/security/credentials/plugin/plugin_credentials.c
src/core/lib/security/credentials/ssl/ssl_credentials.c src/core/lib/security/credentials/ssl/ssl_credentials.c
src/core/lib/security/transport/client_auth_filter.c src/core/lib/security/transport/client_auth_filter.c
src/core/lib/security/transport/lb_targets_info.c
src/core/lib/security/transport/secure_endpoint.c src/core/lib/security/transport/secure_endpoint.c
src/core/lib/security/transport/security_connector.c src/core/lib/security/transport/security_connector.c
src/core/lib/security/transport/security_handshaker.c src/core/lib/security/transport/security_handshaker.c
@ -993,6 +997,7 @@ add_library(grpc
src/core/ext/transport/chttp2/client/insecure/channel_create.c src/core/ext/transport/chttp2/client/insecure/channel_create.c
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
src/core/ext/lb_policy/grpclb/grpclb.c src/core/ext/lb_policy/grpclb/grpclb.c
src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
src/core/ext/lb_policy/grpclb/load_balancer_api.c src/core/ext/lb_policy/grpclb/load_balancer_api.c
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
third_party/nanopb/pb_common.c third_party/nanopb/pb_common.c
@ -1272,6 +1277,7 @@ add_library(grpc_cronet
src/core/lib/security/credentials/plugin/plugin_credentials.c src/core/lib/security/credentials/plugin/plugin_credentials.c
src/core/lib/security/credentials/ssl/ssl_credentials.c src/core/lib/security/credentials/ssl/ssl_credentials.c
src/core/lib/security/transport/client_auth_filter.c src/core/lib/security/transport/client_auth_filter.c
src/core/lib/security/transport/lb_targets_info.c
src/core/lib/security/transport/secure_endpoint.c src/core/lib/security/transport/secure_endpoint.c
src/core/lib/security/transport/security_connector.c src/core/lib/security/transport/security_connector.c
src/core/lib/security/transport/security_handshaker.c src/core/lib/security/transport/security_handshaker.c
@ -1773,6 +1779,7 @@ add_library(grpc_unsecure
src/core/ext/load_reporting/load_reporting.c src/core/ext/load_reporting/load_reporting.c
src/core/ext/load_reporting/load_reporting_filter.c src/core/ext/load_reporting/load_reporting_filter.c
src/core/ext/lb_policy/grpclb/grpclb.c src/core/ext/lb_policy/grpclb/grpclb.c
src/core/ext/lb_policy/grpclb/grpclb_channel.c
src/core/ext/lb_policy/grpclb/load_balancer_api.c src/core/ext/lb_policy/grpclb/load_balancer_api.c
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
third_party/nanopb/pb_common.c third_party/nanopb/pb_common.c
@ -6130,6 +6137,35 @@ target_link_libraries(percent_encoding_test
gpr gpr
) )
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(pollset_set_test
test/core/iomgr/pollset_set_test.c
)
target_include_directories(pollset_set_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${BORINGSSL_ROOT_DIR}/include
PRIVATE ${PROTOBUF_ROOT_DIR}/src
PRIVATE ${BENCHMARK_ROOT_DIR}/include
PRIVATE ${ZLIB_ROOT_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(pollset_set_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
gpr_test_util
gpr
)
endif()
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)

@ -212,6 +212,14 @@ CPPFLAGS_mutrace = -O3 -fno-omit-frame-pointer
LDFLAGS_mutrace = -rdynamic LDFLAGS_mutrace = -rdynamic
DEFINES_mutrace = NDEBUG DEFINES_mutrace = NDEBUG
VALID_CONFIG_counters = 1
CC_counters = $(DEFAULT_CC)
CXX_counters = $(DEFAULT_CXX)
LD_counters = $(DEFAULT_CC)
LDXX_counters = $(DEFAULT_CXX)
CPPFLAGS_counters = -O2 -DGPR_MU_COUNTERS
DEFINES_counters = NDEBUG
# General settings. # General settings.
@ -998,6 +1006,7 @@ no_server_test: $(BINDIR)/$(CONFIG)/no_server_test
percent_decode_fuzzer: $(BINDIR)/$(CONFIG)/percent_decode_fuzzer percent_decode_fuzzer: $(BINDIR)/$(CONFIG)/percent_decode_fuzzer
percent_encode_fuzzer: $(BINDIR)/$(CONFIG)/percent_encode_fuzzer percent_encode_fuzzer: $(BINDIR)/$(CONFIG)/percent_encode_fuzzer
percent_encoding_test: $(BINDIR)/$(CONFIG)/percent_encoding_test percent_encoding_test: $(BINDIR)/$(CONFIG)/percent_encoding_test
pollset_set_test: $(BINDIR)/$(CONFIG)/pollset_set_test
resolve_address_posix_test: $(BINDIR)/$(CONFIG)/resolve_address_posix_test resolve_address_posix_test: $(BINDIR)/$(CONFIG)/resolve_address_posix_test
resolve_address_test: $(BINDIR)/$(CONFIG)/resolve_address_test resolve_address_test: $(BINDIR)/$(CONFIG)/resolve_address_test
resource_quota_test: $(BINDIR)/$(CONFIG)/resource_quota_test resource_quota_test: $(BINDIR)/$(CONFIG)/resource_quota_test
@ -1345,6 +1354,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/murmur_hash_test \ $(BINDIR)/$(CONFIG)/murmur_hash_test \
$(BINDIR)/$(CONFIG)/no_server_test \ $(BINDIR)/$(CONFIG)/no_server_test \
$(BINDIR)/$(CONFIG)/percent_encoding_test \ $(BINDIR)/$(CONFIG)/percent_encoding_test \
$(BINDIR)/$(CONFIG)/pollset_set_test \
$(BINDIR)/$(CONFIG)/resolve_address_posix_test \ $(BINDIR)/$(CONFIG)/resolve_address_posix_test \
$(BINDIR)/$(CONFIG)/resolve_address_test \ $(BINDIR)/$(CONFIG)/resolve_address_test \
$(BINDIR)/$(CONFIG)/resource_quota_test \ $(BINDIR)/$(CONFIG)/resource_quota_test \
@ -1758,6 +1768,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/no_server_test || ( echo test no_server_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/no_server_test || ( echo test no_server_test failed ; exit 1 )
$(E) "[RUN] Testing percent_encoding_test" $(E) "[RUN] Testing percent_encoding_test"
$(Q) $(BINDIR)/$(CONFIG)/percent_encoding_test || ( echo test percent_encoding_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/percent_encoding_test || ( echo test percent_encoding_test failed ; exit 1 )
$(E) "[RUN] Testing pollset_set_test"
$(Q) $(BINDIR)/$(CONFIG)/pollset_set_test || ( echo test pollset_set_test failed ; exit 1 )
$(E) "[RUN] Testing resolve_address_posix_test" $(E) "[RUN] Testing resolve_address_posix_test"
$(Q) $(BINDIR)/$(CONFIG)/resolve_address_posix_test || ( echo test resolve_address_posix_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/resolve_address_posix_test || ( echo test resolve_address_posix_test failed ; exit 1 )
$(E) "[RUN] Testing resolve_address_test" $(E) "[RUN] Testing resolve_address_test"
@ -2794,6 +2806,7 @@ LIBGRPC_SRC = \
src/core/lib/security/credentials/plugin/plugin_credentials.c \ src/core/lib/security/credentials/plugin/plugin_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.c \ src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/transport/client_auth_filter.c \ src/core/lib/security/transport/client_auth_filter.c \
src/core/lib/security/transport/lb_targets_info.c \
src/core/lib/security/transport/secure_endpoint.c \ src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/security_connector.c \ src/core/lib/security/transport/security_connector.c \
src/core/lib/security/transport/security_handshaker.c \ src/core/lib/security/transport/security_handshaker.c \
@ -2834,6 +2847,7 @@ LIBGRPC_SRC = \
src/core/ext/transport/chttp2/client/insecure/channel_create.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
src/core/ext/lb_policy/grpclb/grpclb.c \ src/core/ext/lb_policy/grpclb/grpclb.c \
src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.c \
@ -3127,6 +3141,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/security/credentials/plugin/plugin_credentials.c \ src/core/lib/security/credentials/plugin/plugin_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.c \ src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/transport/client_auth_filter.c \ src/core/lib/security/transport/client_auth_filter.c \
src/core/lib/security/transport/lb_targets_info.c \
src/core/lib/security/transport/secure_endpoint.c \ src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/security_connector.c \ src/core/lib/security/transport/security_connector.c \
src/core/lib/security/transport/security_handshaker.c \ src/core/lib/security/transport/security_handshaker.c \
@ -3644,6 +3659,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/load_reporting/load_reporting.c \ src/core/ext/load_reporting/load_reporting.c \
src/core/ext/load_reporting/load_reporting_filter.c \ src/core/ext/load_reporting/load_reporting_filter.c \
src/core/ext/lb_policy/grpclb/grpclb.c \ src/core/ext/lb_policy/grpclb/grpclb.c \
src/core/ext/lb_policy/grpclb/grpclb_channel.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.c \
@ -11154,6 +11170,38 @@ endif
endif endif
POLLSET_SET_TEST_SRC = \
test/core/iomgr/pollset_set_test.c \
POLLSET_SET_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(POLLSET_SET_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/pollset_set_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/pollset_set_test: $(POLLSET_SET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(POLLSET_SET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/pollset_set_test
endif
$(OBJDIR)/$(CONFIG)/test/core/iomgr/pollset_set_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_pollset_set_test: $(POLLSET_SET_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(POLLSET_SET_TEST_OBJS:.o=.dep)
endif
endif
RESOLVE_ADDRESS_POSIX_TEST_SRC = \ RESOLVE_ADDRESS_POSIX_TEST_SRC = \
test/core/iomgr/resolve_address_posix_test.c \ test/core/iomgr/resolve_address_posix_test.c \
@ -17705,6 +17753,7 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly # This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this # installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first. # otherwise parallel compilation will fail if a source is compiled first.
src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c: $(OPENSSL_DEP)
src/core/ext/transport/chttp2/client/secure/secure_channel_create.c: $(OPENSSL_DEP) src/core/ext/transport/chttp2/client/secure/secure_channel_create.c: $(OPENSSL_DEP)
src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c: $(OPENSSL_DEP) src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c: $(OPENSSL_DEP)
src/core/ext/transport/cronet/client/secure/cronet_channel_create.c: $(OPENSSL_DEP) src/core/ext/transport/cronet/client/secure/cronet_channel_create.c: $(OPENSSL_DEP)
@ -17726,6 +17775,7 @@ src/core/lib/security/credentials/oauth2/oauth2_credentials.c: $(OPENSSL_DEP)
src/core/lib/security/credentials/plugin/plugin_credentials.c: $(OPENSSL_DEP) src/core/lib/security/credentials/plugin/plugin_credentials.c: $(OPENSSL_DEP)
src/core/lib/security/credentials/ssl/ssl_credentials.c: $(OPENSSL_DEP) src/core/lib/security/credentials/ssl/ssl_credentials.c: $(OPENSSL_DEP)
src/core/lib/security/transport/client_auth_filter.c: $(OPENSSL_DEP) src/core/lib/security/transport/client_auth_filter.c: $(OPENSSL_DEP)
src/core/lib/security/transport/lb_targets_info.c: $(OPENSSL_DEP)
src/core/lib/security/transport/secure_endpoint.c: $(OPENSSL_DEP) src/core/lib/security/transport/secure_endpoint.c: $(OPENSSL_DEP)
src/core/lib/security/transport/security_connector.c: $(OPENSSL_DEP) src/core/lib/security/transport/security_connector.c: $(OPENSSL_DEP)
src/core/lib/security/transport/security_handshaker.c: $(OPENSSL_DEP) src/core/lib/security/transport/security_handshaker.c: $(OPENSSL_DEP)

@ -758,6 +758,7 @@
'src/core/lib/security/credentials/plugin/plugin_credentials.c', 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
'src/core/lib/security/credentials/ssl/ssl_credentials.c', 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
'src/core/lib/security/transport/client_auth_filter.c', 'src/core/lib/security/transport/client_auth_filter.c',
'src/core/lib/security/transport/lb_targets_info.c',
'src/core/lib/security/transport/secure_endpoint.c', 'src/core/lib/security/transport/secure_endpoint.c',
'src/core/lib/security/transport/security_connector.c', 'src/core/lib/security/transport/security_connector.c',
'src/core/lib/security/transport/security_handshaker.c', 'src/core/lib/security/transport/security_handshaker.c',
@ -798,6 +799,7 @@
'src/core/ext/transport/chttp2/client/insecure/channel_create.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/lb_policy/grpclb/grpclb.c', 'src/core/ext/lb_policy/grpclb/grpclb.c',
'src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_common.c',

@ -31,6 +31,11 @@ filegroups:
- src/core/ext/census/resource.h - src/core/ext/census/resource.h
- src/core/ext/census/rpc_metric_id.h - src/core/ext/census/rpc_metric_id.h
- src/core/ext/census/trace_context.h - src/core/ext/census/trace_context.h
- src/core/ext/census/trace_label.h
- src/core/ext/census/trace_propagation.h
- src/core/ext/census/trace_status.h
- src/core/ext/census/trace_string.h
- src/core/ext/census/tracing.h
src: src:
- src/core/ext/census/base_resources.c - src/core/ext/census/base_resources.c
- src/core/ext/census/context.c - src/core/ext/census/context.c
@ -452,10 +457,28 @@ filegroups:
- name: grpc_lb_policy_grpclb - name: grpc_lb_policy_grpclb
headers: headers:
- src/core/ext/lb_policy/grpclb/grpclb.h - src/core/ext/lb_policy/grpclb/grpclb.h
- src/core/ext/lb_policy/grpclb/grpclb_channel.h
- src/core/ext/lb_policy/grpclb/load_balancer_api.h - src/core/ext/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h - src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src: src:
- src/core/ext/lb_policy/grpclb/grpclb.c - src/core/ext/lb_policy/grpclb/grpclb.c
- src/core/ext/lb_policy/grpclb/grpclb_channel.c
- src/core/ext/lb_policy/grpclb/load_balancer_api.c
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb
uses:
- grpc_base
- grpc_client_channel
- nanopb
- name: grpc_lb_policy_grpclb_secure
headers:
- src/core/ext/lb_policy/grpclb/grpclb.h
- src/core/ext/lb_policy/grpclb/grpclb_channel.h
- src/core/ext/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src:
- src/core/ext/lb_policy/grpclb/grpclb.c
- src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c
- src/core/ext/lb_policy/grpclb/load_balancer_api.c - src/core/ext/lb_policy/grpclb/load_balancer_api.c
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c - src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb plugin: grpc_lb_policy_grpclb
@ -518,6 +541,7 @@ filegroups:
- src/core/lib/security/credentials/plugin/plugin_credentials.h - src/core/lib/security/credentials/plugin/plugin_credentials.h
- src/core/lib/security/credentials/ssl/ssl_credentials.h - src/core/lib/security/credentials/ssl/ssl_credentials.h
- src/core/lib/security/transport/auth_filters.h - src/core/lib/security/transport/auth_filters.h
- src/core/lib/security/transport/lb_targets_info.h
- src/core/lib/security/transport/secure_endpoint.h - src/core/lib/security/transport/secure_endpoint.h
- src/core/lib/security/transport/security_connector.h - src/core/lib/security/transport/security_connector.h
- src/core/lib/security/transport/security_handshaker.h - src/core/lib/security/transport/security_handshaker.h
@ -541,6 +565,7 @@ filegroups:
- src/core/lib/security/credentials/plugin/plugin_credentials.c - src/core/lib/security/credentials/plugin/plugin_credentials.c
- src/core/lib/security/credentials/ssl/ssl_credentials.c - src/core/lib/security/credentials/ssl/ssl_credentials.c
- src/core/lib/security/transport/client_auth_filter.c - src/core/lib/security/transport/client_auth_filter.c
- src/core/lib/security/transport/lb_targets_info.c
- src/core/lib/security/transport/secure_endpoint.c - src/core/lib/security/transport/secure_endpoint.c
- src/core/lib/security/transport/security_connector.c - src/core/lib/security/transport/security_connector.c
- src/core/lib/security/transport/security_handshaker.c - src/core/lib/security/transport/security_handshaker.c
@ -909,7 +934,7 @@ libs:
- grpc_transport_chttp2_client_secure - grpc_transport_chttp2_client_secure
- grpc_transport_chttp2_server_insecure - grpc_transport_chttp2_server_insecure
- grpc_transport_chttp2_client_insecure - grpc_transport_chttp2_client_insecure
- grpc_lb_policy_grpclb - grpc_lb_policy_grpclb_secure
- grpc_lb_policy_pick_first - grpc_lb_policy_pick_first
- grpc_lb_policy_round_robin - grpc_lb_policy_round_robin
- grpc_resolver_dns_native - grpc_resolver_dns_native
@ -2504,6 +2529,20 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: pollset_set_test
build: test
language: c
src:
- test/core/iomgr/pollset_set_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
platforms:
- linux
- name: resolve_address_posix_test - name: resolve_address_posix_test
build: test build: test
language: c language: c
@ -3837,6 +3876,9 @@ configs:
basicprof: basicprof:
CPPFLAGS: -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC CPPFLAGS: -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
DEFINES: NDEBUG DEFINES: NDEBUG
counters:
CPPFLAGS: -O2 -DGPR_MU_COUNTERS
DEFINES: NDEBUG
dbg: dbg:
CPPFLAGS: -O0 CPPFLAGS: -O0
DEFINES: _DEBUG DEBUG DEFINES: _DEBUG DEBUG

@ -237,6 +237,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/security/credentials/plugin/plugin_credentials.c \ src/core/lib/security/credentials/plugin/plugin_credentials.c \
src/core/lib/security/credentials/ssl/ssl_credentials.c \ src/core/lib/security/credentials/ssl/ssl_credentials.c \
src/core/lib/security/transport/client_auth_filter.c \ src/core/lib/security/transport/client_auth_filter.c \
src/core/lib/security/transport/lb_targets_info.c \
src/core/lib/security/transport/secure_endpoint.c \ src/core/lib/security/transport/secure_endpoint.c \
src/core/lib/security/transport/security_connector.c \ src/core/lib/security/transport/security_connector.c \
src/core/lib/security/transport/security_handshaker.c \ src/core/lib/security/transport/security_handshaker.c \
@ -277,6 +278,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/transport/chttp2/client/insecure/channel_create.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
src/core/ext/lb_policy/grpclb/grpclb.c \ src/core/ext/lb_policy/grpclb/grpclb.c \
src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.c \

@ -388,6 +388,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/credentials/plugin/plugin_credentials.h', 'src/core/lib/security/credentials/plugin/plugin_credentials.h',
'src/core/lib/security/credentials/ssl/ssl_credentials.h', 'src/core/lib/security/credentials/ssl/ssl_credentials.h',
'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/auth_filters.h',
'src/core/lib/security/transport/lb_targets_info.h',
'src/core/lib/security/transport/secure_endpoint.h', 'src/core/lib/security/transport/secure_endpoint.h',
'src/core/lib/security/transport/security_connector.h', 'src/core/lib/security/transport/security_connector.h',
'src/core/lib/security/transport/security_handshaker.h', 'src/core/lib/security/transport/security_handshaker.h',
@ -420,6 +421,7 @@ Pod::Spec.new do |s|
'src/core/ext/client_channel/uri_parser.h', 'src/core/ext/client_channel/uri_parser.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/lb_policy/grpclb/grpclb.h', 'src/core/ext/lb_policy/grpclb/grpclb.h',
'src/core/ext/lb_policy/grpclb/grpclb_channel.h',
'src/core/ext/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'third_party/nanopb/pb.h', 'third_party/nanopb/pb.h',
@ -439,6 +441,11 @@ Pod::Spec.new do |s|
'src/core/ext/census/resource.h', 'src/core/ext/census/resource.h',
'src/core/ext/census/rpc_metric_id.h', 'src/core/ext/census/rpc_metric_id.h',
'src/core/ext/census/trace_context.h', 'src/core/ext/census/trace_context.h',
'src/core/ext/census/trace_label.h',
'src/core/ext/census/trace_propagation.h',
'src/core/ext/census/trace_status.h',
'src/core/ext/census/trace_string.h',
'src/core/ext/census/tracing.h',
'src/core/lib/surface/init.c', 'src/core/lib/surface/init.c',
'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_args.c',
'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack.c',
@ -596,6 +603,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/credentials/plugin/plugin_credentials.c', 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
'src/core/lib/security/credentials/ssl/ssl_credentials.c', 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
'src/core/lib/security/transport/client_auth_filter.c', 'src/core/lib/security/transport/client_auth_filter.c',
'src/core/lib/security/transport/lb_targets_info.c',
'src/core/lib/security/transport/secure_endpoint.c', 'src/core/lib/security/transport/secure_endpoint.c',
'src/core/lib/security/transport/security_connector.c', 'src/core/lib/security/transport/security_connector.c',
'src/core/lib/security/transport/security_handshaker.c', 'src/core/lib/security/transport/security_handshaker.c',
@ -636,6 +644,7 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/client/insecure/channel_create.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/lb_policy/grpclb/grpclb.c', 'src/core/ext/lb_policy/grpclb/grpclb.c',
'src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_common.c',
@ -813,6 +822,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/credentials/plugin/plugin_credentials.h', 'src/core/lib/security/credentials/plugin/plugin_credentials.h',
'src/core/lib/security/credentials/ssl/ssl_credentials.h', 'src/core/lib/security/credentials/ssl/ssl_credentials.h',
'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/auth_filters.h',
'src/core/lib/security/transport/lb_targets_info.h',
'src/core/lib/security/transport/secure_endpoint.h', 'src/core/lib/security/transport/secure_endpoint.h',
'src/core/lib/security/transport/security_connector.h', 'src/core/lib/security/transport/security_connector.h',
'src/core/lib/security/transport/security_handshaker.h', 'src/core/lib/security/transport/security_handshaker.h',
@ -845,6 +855,7 @@ Pod::Spec.new do |s|
'src/core/ext/client_channel/uri_parser.h', 'src/core/ext/client_channel/uri_parser.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/lb_policy/grpclb/grpclb.h', 'src/core/ext/lb_policy/grpclb/grpclb.h',
'src/core/ext/lb_policy/grpclb/grpclb_channel.h',
'src/core/ext/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'third_party/nanopb/pb.h', 'third_party/nanopb/pb.h',
@ -863,7 +874,12 @@ Pod::Spec.new do |s|
'src/core/ext/census/mlog.h', 'src/core/ext/census/mlog.h',
'src/core/ext/census/resource.h', 'src/core/ext/census/resource.h',
'src/core/ext/census/rpc_metric_id.h', 'src/core/ext/census/rpc_metric_id.h',
'src/core/ext/census/trace_context.h' 'src/core/ext/census/trace_context.h',
'src/core/ext/census/trace_label.h',
'src/core/ext/census/trace_propagation.h',
'src/core/ext/census/trace_status.h',
'src/core/ext/census/trace_string.h',
'src/core/ext/census/tracing.h'
end end
s.subspec 'Cronet-Interface' do |ss| s.subspec 'Cronet-Interface' do |ss|

@ -305,6 +305,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.h ) s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.h )
s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.h ) s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.h )
s.files += %w( src/core/lib/security/transport/auth_filters.h ) s.files += %w( src/core/lib/security/transport/auth_filters.h )
s.files += %w( src/core/lib/security/transport/lb_targets_info.h )
s.files += %w( src/core/lib/security/transport/secure_endpoint.h ) s.files += %w( src/core/lib/security/transport/secure_endpoint.h )
s.files += %w( src/core/lib/security/transport/security_connector.h ) s.files += %w( src/core/lib/security/transport/security_connector.h )
s.files += %w( src/core/lib/security/transport/security_handshaker.h ) s.files += %w( src/core/lib/security/transport/security_handshaker.h )
@ -337,6 +338,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/client_channel/uri_parser.h ) s.files += %w( src/core/ext/client_channel/uri_parser.h )
s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h )
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.h ) s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.h )
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb_channel.h )
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.h ) s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.h )
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h ) s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h )
s.files += %w( third_party/nanopb/pb.h ) s.files += %w( third_party/nanopb/pb.h )
@ -356,6 +358,11 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/census/resource.h ) s.files += %w( src/core/ext/census/resource.h )
s.files += %w( src/core/ext/census/rpc_metric_id.h ) s.files += %w( src/core/ext/census/rpc_metric_id.h )
s.files += %w( src/core/ext/census/trace_context.h ) s.files += %w( src/core/ext/census/trace_context.h )
s.files += %w( src/core/ext/census/trace_label.h )
s.files += %w( src/core/ext/census/trace_propagation.h )
s.files += %w( src/core/ext/census/trace_status.h )
s.files += %w( src/core/ext/census/trace_string.h )
s.files += %w( src/core/ext/census/tracing.h )
s.files += %w( src/core/lib/surface/init.c ) s.files += %w( src/core/lib/surface/init.c )
s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_args.c )
s.files += %w( src/core/lib/channel/channel_stack.c ) s.files += %w( src/core/lib/channel/channel_stack.c )
@ -513,6 +520,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.c ) s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.c )
s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.c ) s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.c )
s.files += %w( src/core/lib/security/transport/client_auth_filter.c ) s.files += %w( src/core/lib/security/transport/client_auth_filter.c )
s.files += %w( src/core/lib/security/transport/lb_targets_info.c )
s.files += %w( src/core/lib/security/transport/secure_endpoint.c ) s.files += %w( src/core/lib/security/transport/secure_endpoint.c )
s.files += %w( src/core/lib/security/transport/security_connector.c ) s.files += %w( src/core/lib/security/transport/security_connector.c )
s.files += %w( src/core/lib/security/transport/security_handshaker.c ) s.files += %w( src/core/lib/security/transport/security_handshaker.c )
@ -553,6 +561,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c )
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c )
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.c ) s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.c )
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c )
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.c ) s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.c )
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c ) s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c )
s.files += %w( third_party/nanopb/pb_common.c ) s.files += %w( third_party/nanopb/pb_common.c )

@ -88,6 +88,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
virtual void PreSynchronousRequest(ServerContext* context) = 0; virtual void PreSynchronousRequest(ServerContext* context) = 0;
/// Called after application callback for each synchronous server request /// Called after application callback for each synchronous server request
virtual void PostSynchronousRequest(ServerContext* context) = 0; virtual void PostSynchronousRequest(ServerContext* context) = 0;
/// Called before server is started.
virtual void PreServerStart(Server* server) {}
}; };
/// Set the global callback object. Can only be called once. Does not take /// Set the global callback object. Can only be called once. Does not take
/// ownership of callbacks, and expects the pointed to object to be alive /// ownership of callbacks, and expects the pointed to object to be alive

@ -179,6 +179,8 @@ typedef struct {
Larger values give lower CPU usage for large messages, but more head of line Larger values give lower CPU usage for large messages, but more head of line
blocking for small messages. */ blocking for small messages. */
#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size" #define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size"
/** Should BDP probing be performed? */
#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe"
/** Minimum time (in milliseconds) between successive ping frames being sent */ /** Minimum time (in milliseconds) between successive ping frames being sent */
#define GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS \ #define GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS \
"grpc.http2.min_time_between_pings_ms" "grpc.http2.min_time_between_pings_ms"

@ -314,6 +314,7 @@
<file baseinstalldir="/" name="src/core/lib/security/credentials/plugin/plugin_credentials.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/credentials/plugin/plugin_credentials.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/credentials/ssl/ssl_credentials.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/credentials/ssl/ssl_credentials.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/auth_filters.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/auth_filters.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/lb_targets_info.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/secure_endpoint.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/secure_endpoint.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/security_connector.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/security_connector.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.h" role="src" />
@ -346,6 +347,7 @@
<file baseinstalldir="/" name="src/core/ext/client_channel/uri_parser.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/client_channel/uri_parser.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb.h" role="src" /> <file baseinstalldir="/" name="third_party/nanopb/pb.h" role="src" />
@ -365,6 +367,11 @@
<file baseinstalldir="/" name="src/core/ext/census/resource.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/resource.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/rpc_metric_id.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/rpc_metric_id.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/trace_context.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/trace_context.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/trace_label.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/trace_propagation.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/trace_status.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/trace_string.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/tracing.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/init.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/init.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/channel_args.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/channel_stack.c" role="src" />
@ -522,6 +529,7 @@
<file baseinstalldir="/" name="src/core/lib/security/credentials/plugin/plugin_credentials.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/credentials/plugin/plugin_credentials.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/credentials/ssl/ssl_credentials.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/credentials/ssl/ssl_credentials.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/client_auth_filter.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/client_auth_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/lb_targets_info.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/secure_endpoint.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/secure_endpoint.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/security_connector.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/security_connector.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.c" role="src" />
@ -562,6 +570,7 @@
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" /> <file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" />

@ -0,0 +1,61 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
#define GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
#include "src/core/ext/census/trace_string.h"
/* Trace label (key/value pair) stores a label name and the label value. The
value can be one of trace_string/int64_t/bool. */
typedef struct trace_label {
trace_string key;
enum label_type {
/* Unknown value for debugging/error purposes */
LABEL_UNKNOWN = 0,
/* A string value */
LABEL_STRING = 1,
/* An integer value. */
LABEL_INT = 2,
/* A boolean value. */
LABEL_BOOL = 3,
} value_type;
union value {
trace_string label_str;
int64_t label_int;
bool label_bool;
} value;
} trace_label;
#endif

@ -0,0 +1,63 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
#define GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
#include "src/core/ext/census/tracing.h"
/* Encoding and decoding functions for receiving and sending trace contexts
over the wire. Only RPC libraries should be calling these
functions. These functions return the number of bytes encoded/decoded
(0 if a failure has occurred). buf_size indicates the size of the
input/output buffer. trace_span_context is a struct that includes the
trace ID, span ID, and a set of option flags (is_sampled, etc.). */
/* Converts a span context to a binary byte buffer. */
size_t trace_span_context_to_binary(const trace_span_context *ctxt,
uint8_t *buf, size_t buf_size);
/* Reads a binary byte buffer and populates a span context structure. */
size_t binary_to_trace_span_context(const uint8_t *buf, size_t buf_size,
trace_span_context *ctxt);
/* Converts a span context to an http metadata compatible string. */
size_t trace_span_context_to_http_format(const trace_span_context *ctxt,
char *buf, size_t buf_size);
/* Reads an http metadata compatible string and populates a span context
structure. */
size_t http_format_to_trace_span_context(const char *buf, size_t buf_size,
trace_span_context *ctxt);
#endif

@ -0,0 +1,45 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
#define GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
#include "src/core/ext/census/trace_string.h"
/* Stores a status code and status message for a trace. */
typedef struct trace_status {
int64_t errorCode;
trace_string errorMessage;
} trace_status;
#endif

@ -0,0 +1,50 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
#define GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
#include <grpc/slice.h>
/* String struct for tracing messages. Since this is a C API, we do not have
access to a string class. This is intended for use by higher level
languages which wrap around the C API, as most of them have a string class.
This will also be more efficient when copying, as we have an explicitly
specified length. Also, grpc_slice has reference counting which allows for
interning. */
typedef struct trace_string {
char *string;
size_t length;
} trace_string;
#endif

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -31,21 +31,41 @@
* *
*/ */
//#include "src/core/ext/census/tracing.h" #include "src/core/ext/census/tracing.h"
#include <grpc/census.h> #include <grpc/census.h>
#include <stdlib.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <openssl/rand.h>
#include "src/core/ext/census/mlog.h"
/* TODO(aveitch): These are all placeholder implementations. */ void trace_start_span(const trace_span_context *span_ctxt,
const trace_string name, const start_span_options *opts,
trace_span_context *new_span_ctxt,
bool has_remote_parent) {
// Noop implementation.
}
void trace_add_span_annotation(const trace_string description,
const trace_label *labels, const size_t n_labels,
trace_span_context *span_ctxt) {
// Noop implementation.
}
int census_trace_mask(const census_context *context) { void trace_add_span_network_event_annotation(const trace_string description,
abort(); const trace_label *labels,
return CENSUS_TRACE_MASK_NONE; const size_t n_labels,
const gpr_timespec timestamp,
bool sent, uint64_t id,
trace_span_context *span_ctxt) {
// Noop implementation.
} }
void census_set_trace_mask(int trace_mask) { abort(); } void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
trace_span_context *span_ctxt) {
// Noop implementation.
}
void census_trace_print(census_context *context, uint32_t type, void trace_end_span(const trace_status *status, trace_span_context *span_ctxt) {
const char *buffer, size_t n) { // Noop implementation.
abort();
} }

@ -0,0 +1,124 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_CENSUS_TRACING_H
#define GRPC_CORE_EXT_CENSUS_TRACING_H
#include <grpc/support/time.h>
#include <stdbool.h>
#include "src/core/ext/census/trace_context.h"
#include "src/core/ext/census/trace_label.h"
#include "src/core/ext/census/trace_status.h"
/* This is the low level tracing API that other languages will interface with.
This is not intended to be accessed by the end-user, therefore it has been
designed with performance in mind rather than ease of use. */
/* The tracing level. */
enum TraceLevel {
/* Annotations on this context will be silently discarded. */
NO_TRACING = 0,
/* Annotations will not be saved to a persistent store. They will be
available via local APIs only. This setting is not propagated to child
spans. */
TRANSIENT_TRACING = 1,
/* Annotations are recorded for the entire distributed trace and they are
saved to a persistent store. This setting is propagated to child spans. */
PERSISTENT_TRACING = 2,
};
typedef struct trace_span_context {
/* Trace span context stores Span ID, Trace ID, and option flags. */
/* Trace ID is 128 bits split into 2 64-bit chunks (hi and lo). */
uint64_t trace_id_hi;
uint64_t trace_id_lo;
/* Span ID is 64 bits. */
uint64_t span_id;
/* Span-options is 32-bit value which contains flag options. */
uint32_t span_options;
} trace_span_context;
typedef struct start_span_options {
/* If set, this will override the Span.local_start_time for the Span. */
gpr_timespec local_start_timestamp;
/* Linked spans can be used to identify spans that are linked to this span in
a different trace. This can be used (for example) in batching operations,
where a single batch handler processes multiple requests from different
traces. If set, points to a list of Spans are linked to the created Span.*/
trace_span_context *linked_spans;
/* The number of linked spans. */
size_t n_linked_spans;
} start_span_options;
/* Create a new child Span (or root if parent is NULL), with parent being the
designated Span. The child span will have the provided name and starting
span options (optional). The bool has_remote_parent marks whether the
context refers to a remote parent span or not. */
void trace_start_span(const trace_span_context *span_ctxt,
const trace_string name, const start_span_options *opts,
trace_span_context *new_span_ctxt,
bool has_remote_parent);
/* Add a new Annotation to the Span. Annotations consist of a description
(trace_string) and a set of n labels (trace_label). This can be populated
with arbitrary user data. */
void trace_add_span_annotation(const trace_string description,
const trace_label *labels, const size_t n_labels,
trace_span_context *span_ctxt);
/* Add a new NetworkEvent annotation to a Span. This function is only intended
to be used by RPC systems (either client or server), not by higher level
applications. The timestamp type will be system-defined, the sent argument
designates whether this is a network send event (client request, server
reply)or receive (server request, client reply). The id argument corresponds
to Span.Annotation.NetworkEvent.id from the data model, and serves to uniquely
identify each network message. */
void trace_add_span_network_event(const trace_string description,
const trace_label *labels,
const size_t n_labels,
const gpr_timespec timestamp, bool sent,
uint64_t id, trace_span_context *span_ctxt);
/* Add a set of labels to the Span. These will correspond to the field
Span.labels in the data model. */
void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
trace_span_context *span_ctxt);
/* Mark the end of Span Execution with the given status. Only the timing of the
first EndSpan call for a given Span will be recorded, and implementations are
free to ignore all further calls using the Span. EndSpanOptions can
optionally be NULL. */
void trace_end_span(const trace_status *status, trace_span_context *span_ctxt);
#endif

@ -44,8 +44,8 @@
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/ext/client_channel/http_connect_handshaker.h" #include "src/core/ext/client_channel/http_connect_handshaker.h"
#include "src/core/ext/client_channel/http_proxy.h"
#include "src/core/ext/client_channel/lb_policy_registry.h" #include "src/core/ext/client_channel/lb_policy_registry.h"
#include "src/core/ext/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/client_channel/resolver_registry.h" #include "src/core/ext/client_channel/resolver_registry.h"
#include "src/core/ext/client_channel/subchannel.h" #include "src/core/ext/client_channel/subchannel.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
@ -153,10 +153,6 @@ static void *method_parameters_create_from_json(const grpc_json *json) {
*/ */
typedef struct client_channel_channel_data { typedef struct client_channel_channel_data {
/** server name */
char *server_name;
/** HTTP CONNECT proxy to use, if any */
char *proxy_name;
/** resolver for this channel */ /** resolver for this channel */
grpc_resolver *resolver; grpc_resolver *resolver;
/** have we started resolving this channel */ /** have we started resolving this channel */
@ -317,17 +313,6 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg,
// Use pick_first if nothing was specified and we didn't select grpclb // Use pick_first if nothing was specified and we didn't select grpclb
// above. // above.
if (lb_policy_name == NULL) lb_policy_name = "pick_first"; if (lb_policy_name == NULL) lb_policy_name = "pick_first";
// If using a proxy, add channel arg for server in HTTP CONNECT request.
if (chand->proxy_name != NULL) {
grpc_arg new_arg;
new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER;
new_arg.type = GRPC_ARG_STRING;
new_arg.value.string = chand->server_name;
grpc_channel_args *tmp_args = chand->resolver_result;
chand->resolver_result =
grpc_channel_args_copy_and_add(chand->resolver_result, &new_arg, 1);
grpc_channel_args_destroy(exec_ctx, tmp_args);
}
// Instantiate LB policy. // Instantiate LB policy.
grpc_lb_policy_args lb_policy_args; grpc_lb_policy_args lb_policy_args;
lb_policy_args.args = chand->resolver_result; lb_policy_args.args = chand->resolver_result;
@ -542,24 +527,21 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(arg->type == GRPC_ARG_POINTER); GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
grpc_client_channel_factory_ref(arg->value.pointer.p); grpc_client_channel_factory_ref(arg->value.pointer.p);
chand->client_channel_factory = arg->value.pointer.p; chand->client_channel_factory = arg->value.pointer.p;
// Instantiate resolver. // Get server name to resolve, using proxy mapper if needed.
arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI); arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
GPR_ASSERT(arg != NULL); GPR_ASSERT(arg != NULL);
GPR_ASSERT(arg->type == GRPC_ARG_STRING); GPR_ASSERT(arg->type == GRPC_ARG_STRING);
grpc_uri *uri = grpc_uri_parse(arg->value.string, true); char *proxy_name = NULL;
if (uri == NULL) return GRPC_ERROR_CREATE("cannot parse server URI"); grpc_channel_args *new_args = NULL;
if (uri->path[0] == '\0') { grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
grpc_uri_destroy(uri); &proxy_name, &new_args);
return GRPC_ERROR_CREATE("server URI is missing path"); // Instantiate resolver.
}
chand->server_name =
gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
grpc_uri_destroy(uri);
chand->proxy_name = grpc_get_http_proxy_server();
char *name_to_resolve =
chand->proxy_name == NULL ? arg->value.string : chand->proxy_name;
chand->resolver = grpc_resolver_create( chand->resolver = grpc_resolver_create(
exec_ctx, name_to_resolve, args->channel_args, chand->interested_parties); exec_ctx, proxy_name != NULL ? proxy_name : arg->value.string,
new_args != NULL ? new_args : args->channel_args,
chand->interested_parties);
if (proxy_name != NULL) gpr_free(proxy_name);
if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
if (chand->resolver == NULL) { if (chand->resolver == NULL) {
return GRPC_ERROR_CREATE("resolver creation failed"); return GRPC_ERROR_CREATE("resolver creation failed");
} }
@ -570,8 +552,6 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx, static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) { grpc_channel_element *elem) {
channel_data *chand = elem->channel_data; channel_data *chand = elem->channel_data;
gpr_free(chand->server_name);
gpr_free(chand->proxy_name);
if (chand->resolver != NULL) { if (chand->resolver != NULL) {
grpc_resolver_shutdown(exec_ctx, chand->resolver); grpc_resolver_shutdown(exec_ctx, chand->resolver);
GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel"); GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");

@ -39,6 +39,7 @@
#include "src/core/ext/client_channel/client_channel.h" #include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/http_connect_handshaker.h" #include "src/core/ext/client_channel/http_connect_handshaker.h"
#include "src/core/ext/client_channel/http_proxy.h"
#include "src/core/ext/client_channel/lb_policy_registry.h" #include "src/core/ext/client_channel/lb_policy_registry.h"
#include "src/core/ext/client_channel/proxy_mapper_registry.h" #include "src/core/ext/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/client_channel/resolver_registry.h" #include "src/core/ext/client_channel/resolver_registry.h"
@ -82,6 +83,7 @@ void grpc_client_channel_init(void) {
grpc_lb_policy_registry_init(); grpc_lb_policy_registry_init();
grpc_resolver_registry_init(); grpc_resolver_registry_init();
grpc_proxy_mapper_registry_init(); grpc_proxy_mapper_registry_init();
grpc_register_http_proxy_mapper();
grpc_subchannel_index_init(); grpc_subchannel_index_init();
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN, grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN,
set_default_host_if_unset, NULL); set_default_host_if_unset, NULL);

@ -40,10 +40,13 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/ext/client_channel/http_connect_handshaker.h"
#include "src/core/ext/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/client_channel/uri_parser.h" #include "src/core/ext/client_channel/uri_parser.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/support/env.h" #include "src/core/lib/support/env.h"
char* grpc_get_http_proxy_server() { static char* grpc_get_http_proxy_server() {
char* uri_str = gpr_getenv("http_proxy"); char* uri_str = gpr_getenv("http_proxy");
if (uri_str == NULL) return NULL; if (uri_str == NULL) return NULL;
grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */); grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
@ -66,3 +69,49 @@ done:
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
return proxy_name; return proxy_name;
} }
static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
*name_to_resolve = grpc_get_http_proxy_server();
if (*name_to_resolve == NULL) return false;
grpc_uri* uri = grpc_uri_parse(server_uri, false /* suppress_errors */);
if (uri == NULL || uri->path[0] == '\0') {
gpr_log(GPR_ERROR,
"'http_proxy' environment variable set, but cannot "
"parse server URI '%s' -- not using proxy",
server_uri);
if (uri != NULL) grpc_uri_destroy(uri);
return false;
}
grpc_arg new_arg;
new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER;
new_arg.type = GRPC_ARG_STRING;
new_arg.value.string = uri->path[0] == '/' ? uri->path + 1 : uri->path;
*new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
grpc_uri_destroy(uri);
return true;
}
static bool proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
return false;
}
static void proxy_mapper_destroy(grpc_proxy_mapper* mapper) {}
static const grpc_proxy_mapper_vtable proxy_mapper_vtable = {
proxy_mapper_map_name, proxy_mapper_map_address, proxy_mapper_destroy};
static grpc_proxy_mapper proxy_mapper = {&proxy_mapper_vtable};
void grpc_register_http_proxy_mapper() {
grpc_proxy_mapper_register(true /* at_start */, &proxy_mapper);
}

@ -34,8 +34,6 @@
#ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H #ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H
#define GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H #define GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H
/// Returns the name of the proxy to use, or NULL if no proxy is configured. void grpc_register_http_proxy_mapper();
/// Caller takes ownership of result.
char* grpc_get_http_proxy_server();
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H */ #endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H */

@ -38,13 +38,24 @@ void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
mapper->vtable = vtable; mapper->vtable = vtable;
} }
bool grpc_proxy_mapper_map(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper, bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
const grpc_resolved_address* address, grpc_proxy_mapper* mapper,
const grpc_channel_args* args, const char* server_uri,
grpc_resolved_address** new_address, const grpc_channel_args* args,
grpc_channel_args** new_args) { char** name_to_resolve,
return mapper->vtable->map(exec_ctx, mapper, address, args, new_address, grpc_channel_args** new_args) {
new_args); return mapper->vtable->map_name(exec_ctx, mapper, server_uri, args,
name_to_resolve, new_args);
}
bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
return mapper->vtable->map_address(exec_ctx, mapper, address, args,
new_address, new_args);
} }
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper) { void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper) {

@ -43,15 +43,22 @@
typedef struct grpc_proxy_mapper grpc_proxy_mapper; typedef struct grpc_proxy_mapper grpc_proxy_mapper;
typedef struct { typedef struct {
/// Determines the proxy name to resolve for \a server_uri.
/// If no proxy is needed, returns false.
/// Otherwise, sets \a name_to_resolve, optionally sets \a new_args,
/// and returns true.
bool (*map_name)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
const char* server_uri, const grpc_channel_args* args,
char** name_to_resolve, grpc_channel_args** new_args);
/// Determines the proxy address to use to contact \a address. /// Determines the proxy address to use to contact \a address.
/// If no proxy is needed, returns false. /// If no proxy is needed, returns false.
/// Otherwise, sets \a new_address, optionally sets \a new_args, and /// Otherwise, sets \a new_address, optionally sets \a new_args, and
/// returns true. /// returns true.
bool (*map)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper, bool (*map_address)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
const grpc_resolved_address* address, const grpc_resolved_address* address,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_resolved_address** new_address, grpc_resolved_address** new_address,
grpc_channel_args** new_args); grpc_channel_args** new_args);
/// Destroys \a mapper. /// Destroys \a mapper.
void (*destroy)(grpc_proxy_mapper* mapper); void (*destroy)(grpc_proxy_mapper* mapper);
} grpc_proxy_mapper_vtable; } grpc_proxy_mapper_vtable;
@ -63,11 +70,20 @@ struct grpc_proxy_mapper {
void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable, void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
grpc_proxy_mapper* mapper); grpc_proxy_mapper* mapper);
bool grpc_proxy_mapper_map(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper, bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
const grpc_resolved_address* address, grpc_proxy_mapper* mapper,
const grpc_channel_args* args, const char* server_uri,
grpc_resolved_address** new_address, const grpc_channel_args* args,
grpc_channel_args** new_args); char** name_to_resolve,
grpc_channel_args** new_args);
bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args);
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper); void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper);
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_H */ #endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_H */

@ -61,15 +61,28 @@ static void grpc_proxy_mapper_list_register(grpc_proxy_mapper_list* list,
++list->num_mappers; ++list->num_mappers;
} }
static bool grpc_proxy_mapper_list_map(grpc_exec_ctx* exec_ctx, static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
grpc_proxy_mapper_list* list, grpc_proxy_mapper_list* list,
const grpc_resolved_address* address, const char* server_uri,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_resolved_address** new_address, char** name_to_resolve,
grpc_channel_args** new_args) { grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) { for (size_t i = 0; i < list->num_mappers; ++i) {
if (grpc_proxy_mapper_map(exec_ctx, list->list[i], address, args, if (grpc_proxy_mapper_map_name(exec_ctx, list->list[i], server_uri, args,
new_address, new_args)) { name_to_resolve, new_args)) {
return true;
}
}
return false;
}
static bool grpc_proxy_mapper_list_map_address(
grpc_exec_ctx* exec_ctx, grpc_proxy_mapper_list* list,
const grpc_resolved_address* address, const grpc_channel_args* args,
grpc_resolved_address** new_address, grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) {
if (grpc_proxy_mapper_map_address(exec_ctx, list->list[i], address, args,
new_address, new_args)) {
return true; return true;
} }
} }
@ -101,11 +114,20 @@ void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper) {
grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper); grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper);
} }
bool grpc_proxy_mappers_map(grpc_exec_ctx* exec_ctx, bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
const grpc_resolved_address* address, const char* server_uri,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_resolved_address** new_address, char** name_to_resolve,
grpc_channel_args** new_args) { grpc_channel_args** new_args) {
return grpc_proxy_mapper_list_map(exec_ctx, &g_proxy_mapper_list, address, return grpc_proxy_mapper_list_map_name(exec_ctx, &g_proxy_mapper_list,
args, new_address, new_args); server_uri, args, name_to_resolve,
new_args);
}
bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
return grpc_proxy_mapper_list_map_address(
exec_ctx, &g_proxy_mapper_list, address, args, new_address, new_args);
} }

@ -44,10 +44,16 @@ void grpc_proxy_mapper_registry_shutdown();
/// the list. Otherwise, it will be added to the end. /// the list. Otherwise, it will be added to the end.
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper); void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper);
bool grpc_proxy_mappers_map(grpc_exec_ctx* exec_ctx, bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
const grpc_resolved_address* address, const char* server_uri,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_resolved_address** new_address, char** name_to_resolve,
grpc_channel_args** new_args); grpc_channel_args** new_args);
bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args);
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */ #endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */

@ -336,8 +336,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
grpc_set_initial_connect_string(&addr, &c->initial_connect_string); grpc_set_initial_connect_string(&addr, &c->initial_connect_string);
grpc_resolved_address *new_address = NULL; grpc_resolved_address *new_address = NULL;
grpc_channel_args *new_args = NULL; grpc_channel_args *new_args = NULL;
if (grpc_proxy_mappers_map(exec_ctx, addr, args->args, &new_address, if (grpc_proxy_mappers_map_address(exec_ctx, addr, args->args, &new_address,
&new_args)) { &new_args)) {
GPR_ASSERT(new_address != NULL); GPR_ASSERT(new_address != NULL);
gpr_free(addr); gpr_free(addr);
addr = new_address; addr = new_address;
@ -788,7 +788,8 @@ grpc_call_stack *grpc_subchannel_call_get_call_stack(
return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call); return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call);
} }
static void grpc_uri_to_sockaddr(char *uri_str, grpc_resolved_address *addr) { static void grpc_uri_to_sockaddr(const char *uri_str,
grpc_resolved_address *addr) {
grpc_uri *uri = grpc_uri_parse(uri_str, 0 /* suppress_errors */); grpc_uri *uri = grpc_uri_parse(uri_str, 0 /* suppress_errors */);
GPR_ASSERT(uri != NULL); GPR_ASSERT(uri != NULL);
if (strcmp(uri->scheme, "ipv4") == 0) { if (strcmp(uri->scheme, "ipv4") == 0) {
@ -803,14 +804,19 @@ static void grpc_uri_to_sockaddr(char *uri_str, grpc_resolved_address *addr) {
void grpc_get_subchannel_address_arg(const grpc_channel_args *args, void grpc_get_subchannel_address_arg(const grpc_channel_args *args,
grpc_resolved_address *addr) { grpc_resolved_address *addr) {
const char *addr_uri_str = grpc_get_subchannel_address_uri_arg(args);
memset(addr, 0, sizeof(*addr));
if (*addr_uri_str != '\0') {
grpc_uri_to_sockaddr(addr_uri_str, addr);
}
}
const char *grpc_get_subchannel_address_uri_arg(const grpc_channel_args *args) {
const grpc_arg *addr_arg = const grpc_arg *addr_arg =
grpc_channel_args_find(args, GRPC_ARG_SUBCHANNEL_ADDRESS); grpc_channel_args_find(args, GRPC_ARG_SUBCHANNEL_ADDRESS);
GPR_ASSERT(addr_arg != NULL); // Should have been set by LB policy. GPR_ASSERT(addr_arg != NULL); // Should have been set by LB policy.
GPR_ASSERT(addr_arg->type == GRPC_ARG_STRING); GPR_ASSERT(addr_arg->type == GRPC_ARG_STRING);
memset(addr, 0, sizeof(*addr)); return addr_arg->value.string;
if (*addr_arg->value.string != '\0') {
grpc_uri_to_sockaddr(addr_arg->value.string, addr);
}
} }
grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr) { grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr) {

@ -178,6 +178,9 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
void grpc_get_subchannel_address_arg(const grpc_channel_args *args, void grpc_get_subchannel_address_arg(const grpc_channel_args *args,
grpc_resolved_address *addr); grpc_resolved_address *addr);
/// Returns the URI string for the address to connect to.
const char *grpc_get_subchannel_address_uri_arg(const grpc_channel_args *args);
/// Returns a new channel arg encoding the subchannel address as a string. /// Returns a new channel arg encoding the subchannel address as a string.
/// Caller is responsible for freeing the string. /// Caller is responsible for freeing the string.
grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr); grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr);

@ -112,11 +112,13 @@
#include "src/core/ext/client_channel/lb_policy_registry.h" #include "src/core/ext/client_channel/lb_policy_registry.h"
#include "src/core/ext/client_channel/parse_address.h" #include "src/core/ext/client_channel/parse_address.h"
#include "src/core/ext/lb_policy/grpclb/grpclb.h" #include "src/core/ext/lb_policy/grpclb/grpclb.h"
#include "src/core/ext/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/ext/lb_policy/grpclb/load_balancer_api.h" #include "src/core/ext/lb_policy/grpclb/load_balancer_api.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/slice/slice_hash_table.h"
#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/backoff.h" #include "src/core/lib/support/backoff.h"
@ -751,6 +753,96 @@ static void glb_rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
static void destroy_balancer_name(grpc_exec_ctx *exec_ctx,
void *balancer_name) {
gpr_free(balancer_name);
}
static void *copy_balancer_name(void *balancer_name) {
return gpr_strdup(balancer_name);
}
static grpc_slice_hash_table_entry targets_info_entry_create(
const char *address, const char *balancer_name) {
static const grpc_slice_hash_table_vtable vtable = {destroy_balancer_name,
copy_balancer_name};
grpc_slice_hash_table_entry entry;
entry.key = grpc_slice_from_copied_string(address);
entry.value = (void *)balancer_name;
entry.vtable = &vtable;
return entry;
}
/* Returns the target URI for the LB service whose addresses are in \a
* addresses. Using this URI, a bidirectional streaming channel will be created
* for the reception of load balancing updates.
*
* The output argument \a targets_info will be updated to contain a mapping of
* "LB server address" to "balancer name", as reported by the naming system.
* This mapping will be propagated via the channel arguments of the
* aforementioned LB streaming channel, to be used by the security connector for
* secure naming checks. The user is responsible for freeing \a targets_info. */
static char *get_lb_uri_target_addresses(grpc_exec_ctx *exec_ctx,
const grpc_lb_addresses *addresses,
grpc_slice_hash_table **targets_info) {
size_t num_grpclb_addrs = 0;
for (size_t i = 0; i < addresses->num_addresses; ++i) {
if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
}
/* All input addresses come from a resolver that claims they are LB services.
* It's the resolver's responsibility to make sure this policy is only
* instantiated and used in that case. Otherwise, something has gone wrong. */
GPR_ASSERT(num_grpclb_addrs > 0);
grpc_slice_hash_table_entry *targets_info_entries =
gpr_malloc(sizeof(*targets_info_entries) * num_grpclb_addrs);
/* construct a target ipvX://ip1:port1,ip2:port2,... from the addresses in \a
* addresses */
/* TODO(dgq): support mixed ip version */
char **addr_strs = gpr_malloc(sizeof(char *) * num_grpclb_addrs);
size_t addr_index = 0;
for (size_t i = 0; i < addresses->num_addresses; i++) {
if (addresses->addresses[i].user_data != NULL) {
gpr_log(GPR_ERROR,
"This LB policy doesn't support user data. It will be ignored");
}
if (addresses->addresses[i].is_balancer) {
char *addr_str;
GPR_ASSERT(grpc_sockaddr_to_string(
&addr_str, &addresses->addresses[i].address, true) > 0);
targets_info_entries[addr_index] = targets_info_entry_create(
addr_str, addresses->addresses[i].balancer_name);
addr_strs[addr_index++] = addr_str;
}
}
GPR_ASSERT(addr_index == num_grpclb_addrs);
size_t uri_path_len;
char *uri_path = gpr_strjoin_sep((const char **)addr_strs, num_grpclb_addrs,
",", &uri_path_len);
for (size_t i = 0; i < num_grpclb_addrs; i++) gpr_free(addr_strs[i]);
gpr_free(addr_strs);
char *target_uri_str = NULL;
/* TODO(dgq): Don't assume all addresses will share the scheme of the first
* one */
gpr_asprintf(&target_uri_str, "%s:%s",
grpc_sockaddr_get_uri_scheme(&addresses->addresses[0].address),
uri_path);
gpr_free(uri_path);
*targets_info =
grpc_slice_hash_table_create(num_grpclb_addrs, targets_info_entries);
for (size_t i = 0; i < num_grpclb_addrs; i++) {
grpc_slice_unref_internal(exec_ctx, targets_info_entries[i].key);
}
gpr_free(targets_info_entries);
return target_uri_str;
}
static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx, static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
grpc_lb_policy_factory *factory, grpc_lb_policy_factory *factory,
grpc_lb_policy_args *args) { grpc_lb_policy_args *args) {
@ -788,85 +880,30 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
} }
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
/* All input addresses in addresses come from a resolver that claims
* they are LB services. It's the resolver's responsibility to make sure
* this policy is only instantiated and used in that case.
*
* Create a client channel over them to communicate with a LB service */
glb_policy->cc_factory = args->client_channel_factory; glb_policy->cc_factory = args->client_channel_factory;
glb_policy->args = grpc_channel_args_copy(args->args); glb_policy->args = grpc_channel_args_copy(args->args);
GPR_ASSERT(glb_policy->cc_factory != NULL); GPR_ASSERT(glb_policy->cc_factory != NULL);
/* construct a target from the addresses in args, given in the form grpc_slice_hash_table *targets_info = NULL;
* ipvX://ip1:port1,ip2:port2,... /* Create a client channel over them to communicate with a LB service */
* TODO(dgq): support mixed ip version */ char *lb_service_target_addresses =
char **addr_strs = gpr_malloc(sizeof(char *) * num_grpclb_addrs); get_lb_uri_target_addresses(exec_ctx, addresses, &targets_info);
size_t addr_index = 0; grpc_channel_args *lb_channel_args =
for (size_t i = 0; i < addresses->num_addresses; i++) { get_lb_channel_args(exec_ctx, targets_info, args->args);
if (addresses->addresses[i].user_data != NULL) { glb_policy->lb_channel = grpc_lb_policy_grpclb_create_lb_channel(
gpr_log(GPR_ERROR, exec_ctx, lb_service_target_addresses, args->client_channel_factory,
"This LB policy doesn't support user data. It will be ignored"); lb_channel_args);
} grpc_slice_hash_table_unref(exec_ctx, targets_info);
if (addresses->addresses[i].is_balancer) { grpc_channel_args_destroy(exec_ctx, lb_channel_args);
if (addr_index == 0) { gpr_free(lb_service_target_addresses);
addr_strs[addr_index++] =
grpc_sockaddr_to_uri(&addresses->addresses[i].address);
} else {
GPR_ASSERT(grpc_sockaddr_to_string(&addr_strs[addr_index++],
&addresses->addresses[i].address,
true) > 0);
}
}
}
size_t uri_path_len;
char *target_uri_str = gpr_strjoin_sep((const char **)addr_strs,
num_grpclb_addrs, ",", &uri_path_len);
/* Create a channel to talk to the LBs.
*
* We strip out the channel arg for the LB policy name, since we want
* to use the default (pick_first) in this case.
*
* We also strip out the channel arg for the resolved addresses, since
* that will be generated by the name resolver used in the LB channel.
* Note that the LB channel will use the sockaddr resolver, so this
* won't actually generate a query to DNS (or some other name service).
* However, the addresses returned by the sockaddr resolver will have
* is_balancer=false, whereas our own addresses have is_balancer=true.
* We need the LB channel to return addresses with is_balancer=false
* so that it does not wind up recursively using the grpclb LB policy,
* as per the special case logic in client_channel.c.
*
* Finally, we also strip out the channel arg for the server URI,
* since that will be different for the LB channel than for the parent
* channel. (The client channel factory will re-add this arg with
* the right value.)
*/
static const char *keys_to_remove[] = {
GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI};
grpc_channel_args *new_args = grpc_channel_args_copy_and_remove(
args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove));
glb_policy->lb_channel = grpc_client_channel_factory_create_channel(
exec_ctx, glb_policy->cc_factory, target_uri_str,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
grpc_channel_args_destroy(exec_ctx, new_args);
gpr_free(target_uri_str);
for (size_t i = 0; i < num_grpclb_addrs; i++) {
gpr_free(addr_strs[i]);
}
gpr_free(addr_strs);
if (glb_policy->lb_channel == NULL) { if (glb_policy->lb_channel == NULL) {
gpr_free(glb_policy); gpr_free(glb_policy);
return NULL; return NULL;
} }
grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable); grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable);
gpr_mu_init(&glb_policy->mu); gpr_mu_init(&glb_policy->mu);
grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE, grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE,
"grpclb"); "grpclb");
return &glb_policy->base; return &glb_policy->base;
} }

@ -0,0 +1,77 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/support/string.h"
grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
grpc_client_channel_factory *client_channel_factory,
grpc_channel_args *args) {
grpc_channel *lb_channel = grpc_client_channel_factory_create_channel(
exec_ctx, client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, args);
return lb_channel;
}
grpc_channel_args *get_lb_channel_args(grpc_exec_ctx *exec_ctx,
grpc_slice_hash_table *targets_info,
const grpc_channel_args *args) {
/* We strip out the channel arg for the LB policy name, since we want
* to use the default (pick_first) in this case.
*
* We also strip out the channel arg for the resolved addresses, since
* that will be generated by the name resolver used in the LB channel.
* Note that the LB channel will use the sockaddr resolver, so this
* won't actually generate a query to DNS (or some other name service).
* However, the addresses returned by the sockaddr resolver will have
* is_balancer=false, whereas our own addresses have is_balancer=true.
* We need the LB channel to return addresses with is_balancer=false
* so that it does not wind up recursively using the grpclb LB policy,
* as per the special case logic in client_channel.c.
*
* Lastly, we also strip out the channel arg for the server URI,
* since that will be different for the LB channel than for the parent
* channel (the client channel factory will re-add this arg with
* the right value). */
static const char *keys_to_remove[] = {
GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI};
return grpc_channel_args_copy_and_remove(args, keys_to_remove,
GPR_ARRAY_SIZE(keys_to_remove));
}

@ -0,0 +1,56 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H
#define GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H
#include "src/core/ext/client_channel/lb_policy_factory.h"
#include "src/core/lib/slice/slice_hash_table.h"
/** Create the channel used for communicating with an LB service.
* Note that an LB *service* may be comprised of several LB *servers*.
*
* \a lb_service_target_addresses is the target URI containing the addresses
* from resolving the LB service's name (eg, ipv4:10.0.0.1:1234,10.2.3.4:9876).
* \a client_channel_factory will be used for the creation of the LB channel,
* alongside the channel args passed in \a args. */
grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
grpc_client_channel_factory *client_channel_factory,
grpc_channel_args *args);
grpc_channel_args *get_lb_channel_args(grpc_exec_ctx *exec_ctx,
grpc_slice_hash_table *targets_info,
const grpc_channel_args *args);
#endif /* GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H */

@ -0,0 +1,107 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/transport/lb_targets_info.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/support/string.h"
grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
grpc_client_channel_factory *client_channel_factory,
grpc_channel_args *args) {
grpc_channel_args *new_args = args;
grpc_channel_credentials *channel_credentials =
grpc_channel_credentials_find_in_args(args);
if (channel_credentials != NULL) {
/* Substitute the channel credentials with a version without call
* credentials: the load balancer is not necessarily trusted to handle
* bearer token credentials */
static const char *keys_to_remove[] = {GRPC_ARG_CHANNEL_CREDENTIALS};
grpc_channel_credentials *creds_sans_call_creds =
grpc_channel_credentials_duplicate_without_call_credentials(
channel_credentials);
GPR_ASSERT(creds_sans_call_creds != NULL);
grpc_arg args_to_add[] = {
grpc_channel_credentials_to_arg(creds_sans_call_creds)};
/* Create the new set of channel args */
new_args = grpc_channel_args_copy_and_add_and_remove(
args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add,
GPR_ARRAY_SIZE(args_to_add));
grpc_channel_credentials_unref(exec_ctx, creds_sans_call_creds);
}
grpc_channel *lb_channel = grpc_client_channel_factory_create_channel(
exec_ctx, client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
if (channel_credentials != NULL) {
grpc_channel_args_destroy(exec_ctx, new_args);
}
return lb_channel;
}
grpc_channel_args *get_lb_channel_args(grpc_exec_ctx *exec_ctx,
grpc_slice_hash_table *targets_info,
const grpc_channel_args *args) {
const grpc_arg targets_info_arg =
grpc_lb_targets_info_create_channel_arg(targets_info);
/* We strip out the channel arg for the LB policy name, since we want
* to use the default (pick_first) in this case.
*
* We also strip out the channel arg for the resolved addresses, since
* that will be generated by the name resolver used in the LB channel.
* Note that the LB channel will use the sockaddr resolver, so this
* won't actually generate a query to DNS (or some other name service).
* However, the addresses returned by the sockaddr resolver will have
* is_balancer=false, whereas our own addresses have is_balancer=true.
* We need the LB channel to return addresses with is_balancer=false
* so that it does not wind up recursively using the grpclb LB policy,
* as per the special case logic in client_channel.c.
*
* Lastly, we also strip out the channel arg for the server URI,
* since that will be different for the LB channel than for the parent
* channel (the client channel factory will re-add this arg with
* the right value). */
static const char *keys_to_remove[] = {
GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI};
/* Add the targets info table to be used for secure naming */
return grpc_channel_args_copy_and_add_and_remove(
args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &targets_info_arg,
1);
}

@ -739,6 +739,13 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
sc_args.args = new_args; sc_args.args = new_args;
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel( grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
exec_ctx, args->client_channel_factory, &sc_args); exec_ctx, args->client_channel_factory, &sc_args);
if (grpc_lb_round_robin_trace) {
char *address_uri =
grpc_sockaddr_to_uri(&addresses->addresses[i].address);
gpr_log(GPR_DEBUG, "Created subchannel %p for address uri %s",
(void *)subchannel, address_uri);
gpr_free(address_uri);
}
grpc_channel_args_destroy(exec_ctx, new_args); grpc_channel_args_destroy(exec_ctx, new_args);
if (subchannel != NULL) { if (subchannel != NULL) {

@ -40,10 +40,15 @@
#include "src/core/ext/client_channel/client_channel.h" #include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/resolver_registry.h" #include "src/core/ext/client_channel/resolver_registry.h"
#include "src/core/ext/client_channel/uri_parser.h"
#include "src/core/ext/transport/chttp2/client/chttp2_connector.h" #include "src/core/ext/transport/chttp2/client/chttp2_connector.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/transport/lb_targets_info.h"
#include "src/core/lib/security/transport/security_connector.h" #include "src/core/lib/security/transport/security_connector.h"
#include "src/core/lib/slice/slice_hash_table.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel.h"
@ -53,12 +58,114 @@ static void client_channel_factory_ref(
static void client_channel_factory_unref( static void client_channel_factory_unref(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {} grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {}
static grpc_subchannel_args *get_secure_naming_subchannel_args(
grpc_exec_ctx *exec_ctx, const grpc_subchannel_args *args) {
grpc_channel_credentials *channel_credentials =
grpc_channel_credentials_find_in_args(args->args);
if (channel_credentials == NULL) {
gpr_log(GPR_ERROR,
"Can't create subchannel: channel credentials missing for secure "
"channel.");
return NULL;
}
// Make sure security connector does not already exist in args.
if (grpc_security_connector_find_in_args(args->args) != NULL) {
gpr_log(GPR_ERROR,
"Can't create subchannel: security connector already present in "
"channel args.");
return NULL;
}
// To which address are we connecting? By default, use the server URI.
const grpc_arg *server_uri_arg =
grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
GPR_ASSERT(server_uri_arg != NULL);
GPR_ASSERT(server_uri_arg->type == GRPC_ARG_STRING);
const char *server_uri_str = server_uri_arg->value.string;
GPR_ASSERT(server_uri_str != NULL);
grpc_uri *server_uri =
grpc_uri_parse(server_uri_str, true /* supress errors */);
GPR_ASSERT(server_uri != NULL);
const char *server_uri_path;
server_uri_path =
server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path;
const grpc_slice_hash_table *targets_info =
grpc_lb_targets_info_find_in_args(args->args);
char *target_name_to_check = NULL;
if (targets_info != NULL) { // LB channel
// Find the balancer name for the target.
const char *target_uri_str =
grpc_get_subchannel_address_uri_arg(args->args);
grpc_uri *target_uri =
grpc_uri_parse(target_uri_str, false /* suppress errors */);
GPR_ASSERT(target_uri != NULL);
if (target_uri->path[0] != '\0') { // "path" may be empty
const grpc_slice key = grpc_slice_from_static_string(
target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
const char *value = grpc_slice_hash_table_get(targets_info, key);
if (value != NULL) target_name_to_check = gpr_strdup(value);
grpc_slice_unref_internal(exec_ctx, key);
}
if (target_name_to_check == NULL) {
// If the target name to check hasn't already been set, fall back to using
// SERVER_URI
target_name_to_check = gpr_strdup(server_uri_path);
}
grpc_uri_destroy(target_uri);
} else { // regular channel: the secure name is the original server URI.
target_name_to_check = gpr_strdup(server_uri_path);
}
grpc_uri_destroy(server_uri);
GPR_ASSERT(target_name_to_check != NULL);
grpc_channel_security_connector *subchannel_security_connector = NULL;
// Create the security connector using the credentials and target name.
grpc_channel_args *new_args_from_connector = NULL;
const grpc_security_status security_status =
grpc_channel_credentials_create_security_connector(
exec_ctx, channel_credentials, target_name_to_check, args->args,
&subchannel_security_connector, &new_args_from_connector);
if (security_status != GRPC_SECURITY_OK) {
gpr_log(GPR_ERROR,
"Failed to create secure subchannel for secure name '%s'",
target_name_to_check);
gpr_free(target_name_to_check);
return NULL;
}
gpr_free(target_name_to_check);
grpc_arg new_security_connector_arg =
grpc_security_connector_to_arg(&subchannel_security_connector->base);
grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
new_args_from_connector != NULL ? new_args_from_connector : args->args,
&new_security_connector_arg, 1);
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base,
"lb_channel_create");
if (new_args_from_connector != NULL) {
grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
}
grpc_subchannel_args *final_sc_args = gpr_malloc(sizeof(*final_sc_args));
memcpy(final_sc_args, args, sizeof(*args));
final_sc_args->args = new_args;
return final_sc_args;
}
static grpc_subchannel *client_channel_factory_create_subchannel( static grpc_subchannel *client_channel_factory_create_subchannel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory, grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const grpc_subchannel_args *args) { const grpc_subchannel_args *args) {
grpc_subchannel_args *subchannel_args =
get_secure_naming_subchannel_args(exec_ctx, args);
if (subchannel_args == NULL) {
gpr_log(
GPR_ERROR,
"Failed to create subchannel arguments during subchannel creation.");
return NULL;
}
grpc_connector *connector = grpc_chttp2_connector_create(); grpc_connector *connector = grpc_chttp2_connector_create();
grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args); grpc_subchannel *s =
grpc_subchannel_create(exec_ctx, connector, subchannel_args);
grpc_connector_unref(exec_ctx, connector); grpc_connector_unref(exec_ctx, connector);
grpc_channel_args_destroy(exec_ctx,
(grpc_channel_args *)subchannel_args->args);
gpr_free(subchannel_args);
return s; return s;
} }
@ -91,10 +198,10 @@ static const grpc_client_channel_factory_vtable client_channel_factory_vtable =
static grpc_client_channel_factory client_channel_factory = { static grpc_client_channel_factory client_channel_factory = {
&client_channel_factory_vtable}; &client_channel_factory_vtable};
/* Create a secure client channel: // Create a secure client channel:
Asynchronously: - resolve target // Asynchronously: - resolve target
- connect to it (trying alternatives as presented) // - connect to it (trying alternatives as presented)
- perform handshakes */ // - perform handshakes
grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds, grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
const char *target, const char *target,
const grpc_channel_args *args, const grpc_channel_args *args,
@ -103,47 +210,25 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
GRPC_API_TRACE( GRPC_API_TRACE(
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, " "grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
"reserved=%p)", "reserved=%p)",
4, (creds, target, args, reserved)); 4, ((void *)creds, target, (void *)args, (void *)reserved));
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);
// Make sure security connector does not already exist in args. grpc_channel *channel = NULL;
if (grpc_find_security_connector_in_args(args) != NULL) { if (creds != NULL) {
gpr_log(GPR_ERROR, "Cannot set security context in channel args."); // Add channel args containing the client channel factory and channel
// credentials.
grpc_arg args_to_add[] = {
grpc_client_channel_factory_create_channel_arg(&client_channel_factory),
grpc_channel_credentials_to_arg(creds)};
grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
// Create channel.
channel = client_channel_factory_create_channel(
&exec_ctx, &client_channel_factory, target,
GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
// Clean up.
grpc_channel_args_destroy(&exec_ctx, new_args);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
return grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL,
"Security connector exists in channel args.");
}
// Create security connector and construct new channel args.
grpc_channel_security_connector *security_connector;
grpc_channel_args *new_args_from_connector;
if (grpc_channel_credentials_create_security_connector(
&exec_ctx, creds, target, args, &security_connector,
&new_args_from_connector) != GRPC_SECURITY_OK) {
grpc_exec_ctx_finish(&exec_ctx);
return grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL, "Failed to create security connector.");
}
// Add channel args containing the client channel factory and security
// connector.
grpc_arg args_to_add[2];
args_to_add[0] =
grpc_client_channel_factory_create_channel_arg(&client_channel_factory);
args_to_add[1] = grpc_security_connector_to_arg(&security_connector->base);
grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
new_args_from_connector != NULL ? new_args_from_connector : args,
args_to_add, GPR_ARRAY_SIZE(args_to_add));
if (new_args_from_connector != NULL) {
grpc_channel_args_destroy(&exec_ctx, new_args_from_connector);
} }
// Create channel.
grpc_channel *channel = client_channel_factory_create_channel(
&exec_ctx, &client_channel_factory, target,
GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
// Clean up.
GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &security_connector->base,
"secure_client_channel_factory_create_channel");
grpc_channel_args_destroy(&exec_ctx, new_args);
grpc_exec_ctx_finish(&exec_ctx);
return channel != NULL ? channel return channel != NULL ? channel
: grpc_lame_client_channel_create( : grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL, target, GRPC_STATUS_INTERNAL,

@ -168,7 +168,7 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_map_destroy(&t->stream_map); grpc_chttp2_stream_map_destroy(&t->stream_map);
grpc_connectivity_state_destroy(exec_ctx, &t->channel_callback.state_tracker); grpc_connectivity_state_destroy(exec_ctx, &t->channel_callback.state_tracker);
grpc_combiner_destroy(exec_ctx, t->combiner); GRPC_COMBINER_UNREF(exec_ctx, t->combiner, "chttp2_transport");
cancel_pings(exec_ctx, t, GRPC_ERROR_CREATE("Transport destroyed")); cancel_pings(exec_ctx, t, GRPC_ERROR_CREATE("Transport destroyed"));
@ -292,6 +292,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
t->sent_local_settings = 0; t->sent_local_settings = 0;
t->write_buffer_size = DEFAULT_WINDOW; t->write_buffer_size = DEFAULT_WINDOW;
t->enable_bdp_probe = true;
if (is_client) { if (is_client) {
grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string( grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string(
@ -358,6 +359,10 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer( t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
&channel_args->args[i], &channel_args->args[i],
(grpc_integer_options){0, 0, MAX_WRITE_BUFFER_SIZE}); (grpc_integer_options){0, 0, MAX_WRITE_BUFFER_SIZE});
} else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) {
t->enable_bdp_probe = grpc_channel_arg_get_integer(
&channel_args->args[i], (grpc_integer_options){1, 0, 1});
} else { } else {
static const struct { static const struct {
const char *channel_arg_name; const char *channel_arg_name;
@ -1908,33 +1913,36 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer, grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
&t->read_action_locked); &t->read_action_locked);
if (need_bdp_ping) { if (t->enable_bdp_probe) {
GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping"); if (need_bdp_ping) {
grpc_bdp_estimator_schedule_ping(&t->bdp_estimator); GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
send_ping_locked(exec_ctx, t, grpc_bdp_estimator_schedule_ping(&t->bdp_estimator);
GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE, send_ping_locked(exec_ctx, t,
&t->start_bdp_ping_locked, &t->finish_bdp_ping_locked); GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE,
} &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked);
int64_t estimate = -1;
if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) {
double target = 1 + log2((double)estimate);
double memory_pressure = grpc_resource_quota_get_memory_pressure(
grpc_resource_user_quota(grpc_endpoint_get_resource_user(t->ep)));
if (memory_pressure > 0.8) {
target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1);
} }
double bdp_error = target - grpc_pid_controller_last(&t->pid_controller);
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); int64_t estimate = -1;
gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) {
double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; double target = 1 + log2((double)estimate);
if (dt > 0.1) { double memory_pressure = grpc_resource_quota_get_memory_pressure(
dt = 0.1; grpc_resource_user_quota(grpc_endpoint_get_resource_user(t->ep)));
if (memory_pressure > 0.8) {
target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1);
}
double bdp_error =
target - grpc_pid_controller_last(&t->pid_controller);
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update);
double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9;
if (dt > 0.1) {
dt = 0.1;
}
double log2_bdp_guess =
grpc_pid_controller_update(&t->pid_controller, bdp_error, dt);
update_bdp(exec_ctx, t, pow(2, log2_bdp_guess));
t->last_pid_update = now;
} }
double log2_bdp_guess =
grpc_pid_controller_update(&t->pid_controller, bdp_error, dt);
update_bdp(exec_ctx, t, pow(2, log2_bdp_guess));
t->last_pid_update = now;
} }
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
} else { } else {

@ -109,8 +109,13 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
(((uint32_t)p->reason_bytes[3])); (((uint32_t)p->reason_bytes[3]));
grpc_error *error = GRPC_ERROR_NONE; grpc_error *error = GRPC_ERROR_NONE;
if (reason != GRPC_HTTP2_NO_ERROR || s->header_frames_received < 2) { if (reason != GRPC_HTTP2_NO_ERROR || s->header_frames_received < 2) {
error = grpc_error_set_int(GRPC_ERROR_CREATE("RST_STREAM"), char *message;
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason); gpr_asprintf(&message, "Received RST_STREAM with error code %d", reason);
error = grpc_error_set_int(
grpc_error_set_str(GRPC_ERROR_CREATE("RST_STREAM"),
GRPC_ERROR_STR_GRPC_MESSAGE, message),
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
gpr_free(message);
} }
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, error); grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, error);
} }

@ -227,6 +227,9 @@ struct grpc_chttp2_transport {
/** is there a read request to the endpoint outstanding? */ /** is there a read request to the endpoint outstanding? */
uint8_t endpoint_reading; uint8_t endpoint_reading;
/** should we probe bdp? */
bool enable_bdp_probe;
/** various lists of streams */ /** various lists of streams */
grpc_chttp2_stream_list lists[STREAM_LIST_COUNT]; grpc_chttp2_stream_list lists[STREAM_LIST_COUNT];

@ -72,6 +72,7 @@ struct grpc_combiner {
bool final_list_covered_by_poller; bool final_list_covered_by_poller;
grpc_closure_list final_list; grpc_closure_list final_list;
grpc_closure offload; grpc_closure offload;
gpr_refcount refs;
}; };
static void combiner_exec_uncovered(grpc_exec_ctx *exec_ctx, static void combiner_exec_uncovered(grpc_exec_ctx *exec_ctx,
@ -126,6 +127,7 @@ static bool is_covered_by_poller(grpc_combiner *lock) {
grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue) { grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue) {
grpc_combiner *lock = gpr_malloc(sizeof(*lock)); grpc_combiner *lock = gpr_malloc(sizeof(*lock));
gpr_ref_init(&lock->refs, 1);
lock->next_combiner_on_this_exec_ctx = NULL; lock->next_combiner_on_this_exec_ctx = NULL;
lock->time_to_execute_final_list = false; lock->time_to_execute_final_list = false;
lock->optional_workqueue = optional_workqueue; lock->optional_workqueue = optional_workqueue;
@ -152,7 +154,7 @@ static void really_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
gpr_free(lock); gpr_free(lock);
} }
void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { static void start_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED); gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED);
GRPC_COMBINER_TRACE(gpr_log( GRPC_COMBINER_TRACE(gpr_log(
GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state)); GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state));
@ -161,6 +163,30 @@ void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
} }
} }
#ifdef GRPC_COMBINER_REFCOUNT_DEBUG
#define GRPC_COMBINER_DEBUG_SPAM(op, delta) \
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, \
"combiner[%p] %s %" PRIdPTR " --> %" PRIdPTR " %s", lock, (op), \
gpr_atm_no_barrier_load(&lock->refs.count), \
gpr_atm_no_barrier_load(&lock->refs.count) + (delta), reason);
#else
#define GRPC_COMBINER_DEBUG_SPAM(op, delta)
#endif
void grpc_combiner_unref(grpc_exec_ctx *exec_ctx,
grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM("UNREF", -1);
if (gpr_unref(&lock->refs)) {
start_destroy(exec_ctx, lock);
}
}
grpc_combiner *grpc_combiner_ref(grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM(" REF", 1);
gpr_ref(&lock->refs);
return lock;
}
static void push_last_on_exec_ctx(grpc_exec_ctx *exec_ctx, static void push_last_on_exec_ctx(grpc_exec_ctx *exec_ctx,
grpc_combiner *lock) { grpc_combiner *lock) {
lock->next_combiner_on_this_exec_ctx = NULL; lock->next_combiner_on_this_exec_ctx = NULL;

@ -48,8 +48,27 @@
// Initialize the lock, with an optional workqueue to shift load to when // Initialize the lock, with an optional workqueue to shift load to when
// necessary // necessary
grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue); grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue);
// Destroy the lock
void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock); //#define GRPC_COMBINER_REFCOUNT_DEBUG
#ifdef GRPC_COMBINER_REFCOUNT_DEBUG
#define GRPC_COMBINER_DEBUG_ARGS \
, const char *file, int line, const char *reason
#define GRPC_COMBINER_REF(combiner, reason) \
grpc_combiner_ref((combiner), __FILE__, __LINE__, (reason))
#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
grpc_combiner_unref((exec_ctx), (combiner), __FILE__, __LINE__, (reason))
#else
#define GRPC_COMBINER_DEBUG_ARGS
#define GRPC_COMBINER_REF(combiner, reason) grpc_combiner_ref((combiner))
#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
grpc_combiner_unref((exec_ctx), (combiner))
#endif
// Ref/unref the lock, for when we're sharing the lock ownership
// Prefer to use the macros above
grpc_combiner *grpc_combiner_ref(grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS);
void grpc_combiner_unref(grpc_exec_ctx *exec_ctx,
grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS);
// Fetch a scheduler to schedule closures against // Fetch a scheduler to schedule closures against
grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *lock, grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *lock,
bool covered_by_poller); bool covered_by_poller);

@ -599,7 +599,7 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) {
void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx, void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx,
grpc_resource_quota *resource_quota) { grpc_resource_quota *resource_quota) {
if (gpr_unref(&resource_quota->refs)) { if (gpr_unref(&resource_quota->refs)) {
grpc_combiner_destroy(exec_ctx, resource_quota->combiner); GRPC_COMBINER_UNREF(exec_ctx, resource_quota->combiner, "resource_quota");
gpr_free(resource_quota->name); gpr_free(resource_quota->name);
gpr_free(resource_quota); gpr_free(resource_quota);
} }

@ -190,31 +190,37 @@ int grpc_sockaddr_to_string(char **out,
} }
char *grpc_sockaddr_to_uri(const grpc_resolved_address *resolved_addr) { char *grpc_sockaddr_to_uri(const grpc_resolved_address *resolved_addr) {
char *temp;
char *result;
grpc_resolved_address addr_normalized; grpc_resolved_address addr_normalized;
const struct sockaddr *addr;
if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) { if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
resolved_addr = &addr_normalized; resolved_addr = &addr_normalized;
} }
const char *scheme = grpc_sockaddr_get_uri_scheme(resolved_addr);
if (scheme == NULL || strcmp("unix", scheme) == 0) {
return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr);
}
char *path = NULL;
char *uri_str = NULL;
if (grpc_sockaddr_to_string(&path, resolved_addr,
false /* suppress errors */) &&
scheme != NULL) {
gpr_asprintf(&uri_str, "%s:%s", scheme, path);
}
gpr_free(path);
return uri_str != NULL ? uri_str : NULL;
}
addr = (const struct sockaddr *)resolved_addr->addr; const char *grpc_sockaddr_get_uri_scheme(
const grpc_resolved_address *resolved_addr) {
const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
switch (addr->sa_family) { switch (addr->sa_family) {
case AF_INET: case AF_INET:
grpc_sockaddr_to_string(&temp, resolved_addr, 0); return "ipv4";
gpr_asprintf(&result, "ipv4:%s", temp);
gpr_free(temp);
return result;
case AF_INET6: case AF_INET6:
grpc_sockaddr_to_string(&temp, resolved_addr, 0); return "ipv6";
gpr_asprintf(&result, "ipv6:%s", temp); case AF_UNIX:
gpr_free(temp); return "unix";
return result;
default:
return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr);
} }
return NULL;
} }
int grpc_sockaddr_get_port(const grpc_resolved_address *resolved_addr) { int grpc_sockaddr_get_port(const grpc_resolved_address *resolved_addr) {

@ -84,6 +84,10 @@ int grpc_sockaddr_set_port(const grpc_resolved_address *addr, int port);
int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr, int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr,
int normalize); int normalize);
/* Returns the URI string corresponding to \a addr */
char *grpc_sockaddr_to_uri(const grpc_resolved_address *addr); char *grpc_sockaddr_to_uri(const grpc_resolved_address *addr);
/* Returns the URI scheme corresponding to \a addr */
const char *grpc_sockaddr_get_uri_scheme(const grpc_resolved_address *addr);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ #endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */

@ -178,7 +178,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
/* Call the orphan_cb to signal that the FD is about to be closed and /* Call the orphan_cb to signal that the FD is about to be closed and
* should no longer be used. */ * should no longer be used. */
GPR_ASSERT(sp->orphan_cb); GPR_ASSERT(sp->orphan_cb);
sp->orphan_cb(sp->emfd); sp->orphan_cb(exec_ctx, sp->emfd);
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL, grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
"udp_listener_shutdown"); "udp_listener_shutdown");
@ -204,7 +204,7 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
if (s->active_ports) { if (s->active_ports) {
for (sp = s->head; sp; sp = sp->next) { for (sp = s->head; sp; sp = sp->next) {
GPR_ASSERT(sp->orphan_cb); GPR_ASSERT(sp->orphan_cb);
sp->orphan_cb(sp->emfd); sp->orphan_cb(exec_ctx, sp->emfd);
grpc_fd_shutdown(exec_ctx, sp->emfd, grpc_fd_shutdown(exec_ctx, sp->emfd,
GRPC_ERROR_CREATE("Server destroyed")); GRPC_ERROR_CREATE("Server destroyed"));
} }

@ -54,7 +54,8 @@ typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx,
grpc_fd *emfd); grpc_fd *emfd);
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */ /* Called when the grpc_fd is about to be orphaned (and the FD closed). */
typedef void (*grpc_udp_server_orphan_cb)(grpc_fd *emfd); typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx *exec_ctx,
grpc_fd *emfd);
/* Create a server, initially not bound to any ports */ /* Create a server, initially not bound to any ports */
grpc_udp_server *grpc_udp_server_create(void); grpc_udp_server *grpc_udp_server_create(void);

@ -43,6 +43,9 @@
#include <grpc/support/thd.h> #include <grpc/support/thd.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "src/core/lib/support/env.h"
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;
@ -74,7 +77,7 @@ typedef struct gpr_timer_log_list {
static __thread gpr_timer_log *g_thread_log; static __thread gpr_timer_log *g_thread_log;
static gpr_once g_once_init = GPR_ONCE_INIT; static gpr_once g_once_init = GPR_ONCE_INIT;
static FILE *output_file; static FILE *output_file;
static const char *output_filename = "latency_trace.txt"; static const char *output_filename_or_null = NULL;
static pthread_mutex_t g_mu; static pthread_mutex_t g_mu;
static pthread_cond_t g_cv; static pthread_cond_t g_cv;
static gpr_timer_log_list g_in_progress_logs; static gpr_timer_log_list g_in_progress_logs;
@ -85,6 +88,17 @@ static __thread int g_thread_id;
static int g_next_thread_id; static int g_next_thread_id;
static int g_writing_enabled = 1; static int g_writing_enabled = 1;
static const char *output_filename() {
if (output_filename_or_null == NULL) {
output_filename_or_null = gpr_getenv("LATENCY_TRACE");
if (output_filename_or_null == NULL ||
strlen(output_filename_or_null) == 0) {
output_filename_or_null = "latency_trace.txt";
}
}
return output_filename_or_null;
}
static int timer_log_push_back(gpr_timer_log_list *list, gpr_timer_log *log) { static int timer_log_push_back(gpr_timer_log_list *list, gpr_timer_log *log) {
if (list->head == NULL) { if (list->head == NULL) {
list->head = list->tail = log; list->head = list->tail = log;
@ -134,7 +148,7 @@ static void timer_log_remove(gpr_timer_log_list *list, gpr_timer_log *log) {
static void write_log(gpr_timer_log *log) { static void write_log(gpr_timer_log *log) {
size_t i; size_t i;
if (output_file == NULL) { if (output_file == NULL) {
output_file = fopen(output_filename, "w"); output_file = fopen(output_filename(), "w");
} }
for (i = 0; i < log->num_entries; i++) { for (i = 0; i < log->num_entries; i++) {
gpr_timer_entry *entry = &(log->log[i]); gpr_timer_entry *entry = &(log->log[i]);
@ -198,7 +212,7 @@ static void finish_writing(void) {
} }
void gpr_timers_set_log_filename(const char *filename) { void gpr_timers_set_log_filename(const char *filename) {
output_filename = filename; output_filename_or_null = filename;
} }
static void init_output() { static void init_output() {

@ -160,6 +160,53 @@ grpc_channel_credentials_duplicate_without_call_credentials(
} }
} }
static void credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
grpc_channel_credentials_unref(exec_ctx, p);
}
static void *credentials_pointer_arg_copy(void *p) {
return grpc_channel_credentials_ref(p);
}
static int credentials_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
static const grpc_arg_pointer_vtable credentials_pointer_vtable = {
credentials_pointer_arg_copy, credentials_pointer_arg_destroy,
credentials_pointer_cmp};
grpc_arg grpc_channel_credentials_to_arg(
grpc_channel_credentials *credentials) {
grpc_arg result;
result.type = GRPC_ARG_POINTER;
result.key = GRPC_ARG_CHANNEL_CREDENTIALS;
result.value.pointer.vtable = &credentials_pointer_vtable;
result.value.pointer.p = credentials;
return result;
}
grpc_channel_credentials *grpc_channel_credentials_from_arg(
const grpc_arg *arg) {
if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return NULL;
if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
GRPC_ARG_CHANNEL_CREDENTIALS);
return NULL;
}
return arg->value.pointer.p;
}
grpc_channel_credentials *grpc_channel_credentials_find_in_args(
const grpc_channel_args *args) {
size_t i;
if (args == NULL) return NULL;
for (i = 0; i < args->num_args; i++) {
grpc_channel_credentials *credentials =
grpc_channel_credentials_from_arg(&args->args[i]);
if (credentials != NULL) return credentials;
}
return NULL;
}
grpc_server_credentials *grpc_server_credentials_ref( grpc_server_credentials *grpc_server_credentials_ref(
grpc_server_credentials *creds) { grpc_server_credentials *creds) {
if (creds == NULL) return NULL; if (creds == NULL) return NULL;

@ -100,6 +100,8 @@ void grpc_override_well_known_credentials_path_getter(
/* --- grpc_channel_credentials. --- */ /* --- grpc_channel_credentials. --- */
#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
typedef struct { typedef struct {
void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c); void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c);
@ -140,6 +142,17 @@ grpc_channel_credentials *
grpc_channel_credentials_duplicate_without_call_credentials( grpc_channel_credentials_duplicate_without_call_credentials(
grpc_channel_credentials *creds); grpc_channel_credentials *creds);
/* Util to encapsulate the channel credentials in a channel arg. */
grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials *credentials);
/* Util to get the channel credentials from a channel arg. */
grpc_channel_credentials *grpc_channel_credentials_from_arg(
const grpc_arg *arg);
/* Util to find the channel credentials from channel args. */
grpc_channel_credentials *grpc_channel_credentials_find_in_args(
const grpc_channel_args *args);
/* --- grpc_credentials_md. --- */ /* --- grpc_credentials_md. --- */
typedef struct { typedef struct {

@ -35,13 +35,13 @@
#include <string.h> #include <string.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/executor.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/support/string.h"
/* -- Fake transport security credentials. -- */ /* -- Fake transport security credentials. -- */
static grpc_security_status fake_transport_security_create_security_connector( static grpc_security_status fake_transport_security_create_security_connector(
@ -49,7 +49,7 @@ static grpc_security_status fake_transport_security_create_security_connector(
grpc_call_credentials *call_creds, const char *target, grpc_call_credentials *call_creds, const char *target,
const grpc_channel_args *args, grpc_channel_security_connector **sc, const grpc_channel_args *args, grpc_channel_security_connector **sc,
grpc_channel_args **new_args) { grpc_channel_args **new_args) {
*sc = grpc_fake_channel_security_connector_create(call_creds); *sc = grpc_fake_channel_security_connector_create(call_creds, target, args);
return GRPC_SECURITY_OK; return GRPC_SECURITY_OK;
} }

@ -38,6 +38,21 @@
/* -- Fake transport security credentials. -- */ /* -- Fake transport security credentials. -- */
/* Used to verify the target names given to the fake transport security
* connector.
*
* Its syntax by example:
* For LB channels:
* "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
* For regular channels:
* "backend_taget_1,backend_target_2,..."
*
* That is to say, LB channels have a heading list of LB targets separated from
* the list of backend targets by a semicolon. For non-LB channels, only the
* latter is present. */
#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
"grpc.test_only.fake_security.expected_target"
/* Creates a fake transport security credentials object for testing. */ /* Creates a fake transport security credentials object for testing. */
grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void); grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void);

@ -335,7 +335,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem, grpc_channel_element *elem,
grpc_channel_element_args *args) { grpc_channel_element_args *args) {
grpc_security_connector *sc = grpc_security_connector *sc =
grpc_find_security_connector_in_args(args->channel_args); grpc_security_connector_find_in_args(args->channel_args);
grpc_auth_context *auth_context = grpc_auth_context *auth_context =
grpc_find_auth_context_in_args(args->channel_args); grpc_find_auth_context_in_args(args->channel_args);

@ -0,0 +1,70 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/security/transport/lb_targets_info.h"
/* Channel arg key for the mapping of LB server addresses to their names for
* secure naming purposes. */
#define GRPC_ARG_LB_SECURE_NAMING_MAP "grpc.lb_secure_naming_map"
static void *targets_info_copy(void *p) { return grpc_slice_hash_table_ref(p); }
static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) {
grpc_slice_hash_table_unref(exec_ctx, p);
}
static int targets_info_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = {
targets_info_copy, targets_info_destroy, targets_info_cmp};
grpc_arg grpc_lb_targets_info_create_channel_arg(
grpc_slice_hash_table *targets_info) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
arg.key = GRPC_ARG_LB_SECURE_NAMING_MAP;
arg.value.pointer.p = targets_info;
arg.value.pointer.vtable = &server_to_balancer_names_vtable;
return arg;
}
grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
const grpc_channel_args *args) {
const grpc_arg *targets_info_arg =
grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP);
if (targets_info_arg != NULL) {
GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER);
return targets_info_arg->value.pointer.p;
}
return NULL;
}

@ -0,0 +1,47 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H
#define GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H
#include "src/core/lib/slice/slice_hash_table.h"
/** Return a channel argument containing \a targets_info. */
grpc_arg grpc_lb_targets_info_create_channel_arg(
grpc_slice_hash_table *targets_info);
/** Return the instance of targets info in \a args or NULL */
grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
const grpc_channel_args *args);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */

@ -43,10 +43,13 @@
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/ext/transport/chttp2/alpn/alpn.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
#include "src/core/lib/security/transport/lb_targets_info.h"
#include "src/core/lib/security/transport/secure_endpoint.h" #include "src/core/lib/security/transport/secure_endpoint.h"
#include "src/core/lib/security/transport/security_handshaker.h" #include "src/core/lib/security/transport/security_handshaker.h"
#include "src/core/lib/support/env.h" #include "src/core/lib/support/env.h"
@ -205,23 +208,23 @@ static const grpc_arg_pointer_vtable connector_pointer_vtable = {
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) { grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) {
grpc_arg result; grpc_arg result;
result.type = GRPC_ARG_POINTER; result.type = GRPC_ARG_POINTER;
result.key = GRPC_SECURITY_CONNECTOR_ARG; result.key = GRPC_ARG_SECURITY_CONNECTOR;
result.value.pointer.vtable = &connector_pointer_vtable; result.value.pointer.vtable = &connector_pointer_vtable;
result.value.pointer.p = sc; result.value.pointer.p = sc;
return result; return result;
} }
grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) { grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) {
if (strcmp(arg->key, GRPC_SECURITY_CONNECTOR_ARG)) return NULL; if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return NULL;
if (arg->type != GRPC_ARG_POINTER) { if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
GRPC_SECURITY_CONNECTOR_ARG); GRPC_ARG_SECURITY_CONNECTOR);
return NULL; return NULL;
} }
return arg->value.pointer.p; return arg->value.pointer.p;
} }
grpc_security_connector *grpc_find_security_connector_in_args( grpc_security_connector *grpc_security_connector_find_in_args(
const grpc_channel_args *args) { const grpc_channel_args *args) {
size_t i; size_t i;
if (args == NULL) return NULL; if (args == NULL) return NULL;
@ -235,11 +238,21 @@ grpc_security_connector *grpc_find_security_connector_in_args(
/* -- Fake implementation. -- */ /* -- Fake implementation. -- */
typedef struct {
grpc_channel_security_connector base;
char *target;
char *expected_targets;
bool is_lb_channel;
} grpc_fake_channel_security_connector;
static void fake_channel_destroy(grpc_exec_ctx *exec_ctx, static void fake_channel_destroy(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc) { grpc_security_connector *sc) {
grpc_channel_security_connector *c = (grpc_channel_security_connector *)sc; grpc_fake_channel_security_connector *c =
grpc_call_credentials_unref(exec_ctx, c->request_metadata_creds); (grpc_fake_channel_security_connector *)sc;
gpr_free(sc); grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
gpr_free(c->target);
gpr_free(c->expected_targets);
gpr_free(c);
} }
static void fake_server_destroy(grpc_exec_ctx *exec_ctx, static void fake_server_destroy(grpc_exec_ctx *exec_ctx,
@ -247,6 +260,68 @@ static void fake_server_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(sc); gpr_free(sc);
} }
static bool fake_check_target(const char *target_type, const char *target,
const char *set_str) {
GPR_ASSERT(target_type != NULL);
GPR_ASSERT(target != NULL);
char **set = NULL;
size_t set_size = 0;
gpr_string_split(set_str, ",", &set, &set_size);
bool found = false;
for (size_t i = 0; i < set_size; ++i) {
if (set[i] != NULL && strcmp(target, set[i]) == 0) found = true;
}
for (size_t i = 0; i < set_size; ++i) {
gpr_free(set[i]);
}
gpr_free(set);
return found;
}
static void fake_secure_name_check(const char *target,
const char *expected_targets,
bool is_lb_channel) {
if (expected_targets == NULL) return;
char **lbs_and_backends = NULL;
size_t lbs_and_backends_size = 0;
bool success = false;
gpr_string_split(expected_targets, ";", &lbs_and_backends,
&lbs_and_backends_size);
if (lbs_and_backends_size > 2 || lbs_and_backends_size == 0) {
gpr_log(GPR_ERROR, "Invalid expected targets arg value: '%s'",
expected_targets);
goto done;
}
if (is_lb_channel) {
if (lbs_and_backends_size != 2) {
gpr_log(GPR_ERROR,
"Invalid expected targets arg value: '%s'. Expectations for LB "
"channels must be of the form 'be1,be2,be3,...;lb1,lb2,...",
expected_targets);
goto done;
}
if (!fake_check_target("LB", target, lbs_and_backends[1])) {
gpr_log(GPR_ERROR, "LB target '%s' not found in expected set '%s'",
target, lbs_and_backends[1]);
goto done;
}
success = true;
} else {
if (!fake_check_target("Backend", target, lbs_and_backends[0])) {
gpr_log(GPR_ERROR, "Backend target '%s' not found in expected set '%s'",
target, lbs_and_backends[0]);
goto done;
}
success = true;
}
done:
for (size_t i = 0; i < lbs_and_backends_size; ++i) {
gpr_free(lbs_and_backends[i]);
}
gpr_free(lbs_and_backends);
if (!success) abort();
}
static void fake_check_peer(grpc_exec_ctx *exec_ctx, static void fake_check_peer(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, tsi_peer peer, grpc_security_connector *sc, tsi_peer peer,
grpc_auth_context **auth_context, grpc_auth_context **auth_context,
@ -277,12 +352,28 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx,
grpc_auth_context_add_cstring_property( grpc_auth_context_add_cstring_property(
*auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME, *auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_FAKE_TRANSPORT_SECURITY_TYPE); GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
end: end:
grpc_closure_sched(exec_ctx, on_peer_checked, error); grpc_closure_sched(exec_ctx, on_peer_checked, error);
tsi_peer_destruct(&peer); tsi_peer_destruct(&peer);
} }
static void fake_channel_check_peer(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, tsi_peer peer,
grpc_auth_context **auth_context,
grpc_closure *on_peer_checked) {
fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
grpc_fake_channel_security_connector *c =
(grpc_fake_channel_security_connector *)sc;
fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel);
}
static void fake_server_check_peer(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, tsi_peer peer,
grpc_auth_context **auth_context,
grpc_closure *on_peer_checked) {
fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
}
static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx, static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx,
grpc_channel_security_connector *sc, grpc_channel_security_connector *sc,
const char *host, const char *host,
@ -313,22 +404,32 @@ static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx,
} }
static grpc_security_connector_vtable fake_channel_vtable = { static grpc_security_connector_vtable fake_channel_vtable = {
fake_channel_destroy, fake_check_peer}; fake_channel_destroy, fake_channel_check_peer};
static grpc_security_connector_vtable fake_server_vtable = {fake_server_destroy, static grpc_security_connector_vtable fake_server_vtable = {
fake_check_peer}; fake_server_destroy, fake_server_check_peer};
grpc_channel_security_connector *grpc_fake_channel_security_connector_create( grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_call_credentials *request_metadata_creds) { grpc_call_credentials *request_metadata_creds, const char *target,
grpc_channel_security_connector *c = gpr_malloc(sizeof(*c)); const grpc_channel_args *args) {
grpc_fake_channel_security_connector *c = gpr_malloc(sizeof(*c));
memset(c, 0, sizeof(*c)); memset(c, 0, sizeof(*c));
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->base.vtable = &fake_channel_vtable; c->base.base.vtable = &fake_channel_vtable;
c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds); c->base.request_metadata_creds =
c->check_call_host = fake_channel_check_call_host; grpc_call_credentials_ref(request_metadata_creds);
c->add_handshakers = fake_channel_add_handshakers; c->base.check_call_host = fake_channel_check_call_host;
return c; c->base.add_handshakers = fake_channel_add_handshakers;
c->target = gpr_strdup(target);
const grpc_arg *expected_target_arg =
grpc_channel_args_find(args, GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS);
if (expected_target_arg != NULL) {
GPR_ASSERT(expected_target_arg->type == GRPC_ARG_STRING);
c->expected_targets = gpr_strdup(expected_target_arg->value.string);
}
c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != NULL);
return &c->base;
} }
grpc_server_security_connector *grpc_fake_server_security_connector_create( grpc_server_security_connector *grpc_fake_server_security_connector_create(

@ -57,7 +57,7 @@ typedef enum { GRPC_SECURITY_OK = 0, GRPC_SECURITY_ERROR } grpc_security_status;
typedef struct grpc_security_connector grpc_security_connector; typedef struct grpc_security_connector grpc_security_connector;
#define GRPC_SECURITY_CONNECTOR_ARG "grpc.security_connector" #define GRPC_ARG_SECURITY_CONNECTOR "grpc.security_connector"
typedef struct { typedef struct {
void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc); void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc);
@ -115,7 +115,7 @@ grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc);
grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg); grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg);
/* Util to find the connector from channel args. */ /* Util to find the connector from channel args. */
grpc_security_connector *grpc_find_security_connector_in_args( grpc_security_connector *grpc_security_connector_find_in_args(
const grpc_channel_args *args); const grpc_channel_args *args);
/* --- channel_security_connector object. --- /* --- channel_security_connector object. ---
@ -175,7 +175,8 @@ void grpc_server_security_connector_add_handshakers(
/* For TESTING ONLY! /* For TESTING ONLY!
Creates a fake connector that emulates real channel security. */ Creates a fake connector that emulates real channel security. */
grpc_channel_security_connector *grpc_fake_channel_security_connector_create( grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_call_credentials *request_metadata_creds); grpc_call_credentials *request_metadata_creds, const char *target,
const grpc_channel_args *args);
/* For TESTING ONLY! /* For TESTING ONLY!
Creates a fake connector that emulates real server security. */ Creates a fake connector that emulates real server security. */

@ -451,7 +451,7 @@ static void client_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory, grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory,
const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) { const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
grpc_channel_security_connector *security_connector = grpc_channel_security_connector *security_connector =
(grpc_channel_security_connector *)grpc_find_security_connector_in_args( (grpc_channel_security_connector *)grpc_security_connector_find_in_args(
args); args);
grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector, grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector,
handshake_mgr); handshake_mgr);
@ -461,7 +461,7 @@ static void server_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *hf, grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *hf,
const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) { const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
grpc_server_security_connector *security_connector = grpc_server_security_connector *security_connector =
(grpc_server_security_connector *)grpc_find_security_connector_in_args( (grpc_server_security_connector *)grpc_security_connector_find_in_args(
args); args);
grpc_server_security_connector_add_handshakers(exec_ctx, security_connector, grpc_server_security_connector_add_handshakers(exec_ctx, security_connector,
handshake_mgr); handshake_mgr);

@ -215,7 +215,9 @@ bool grpc_slice_is_interned(grpc_slice slice) {
} }
grpc_slice grpc_slice_intern(grpc_slice slice) { grpc_slice grpc_slice_intern(grpc_slice slice) {
GPR_TIMER_BEGIN("grpc_slice_intern", 0);
if (GRPC_IS_STATIC_METADATA_STRING(slice)) { if (GRPC_IS_STATIC_METADATA_STRING(slice)) {
GPR_TIMER_END("grpc_slice_intern", 0);
return slice; return slice;
} }
@ -225,6 +227,7 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)];
if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT && if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT &&
grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) { grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) {
GPR_TIMER_END("grpc_slice_intern", 0);
return grpc_static_slice_table[ent.idx]; return grpc_static_slice_table[ent.idx];
} }
} }
@ -247,7 +250,7 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
/* and treat this as if we were never here... sshhh */ /* and treat this as if we were never here... sshhh */
} else { } else {
gpr_mu_unlock(&shard->mu); gpr_mu_unlock(&shard->mu);
GPR_TIMER_END("grpc_mdstr_from_buffer", 0); GPR_TIMER_END("grpc_slice_intern", 0);
return materialize(s); return materialize(s);
} }
} }
@ -275,6 +278,7 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
gpr_mu_unlock(&shard->mu); gpr_mu_unlock(&shard->mu);
GPR_TIMER_END("grpc_slice_intern", 0);
return materialize(s); return materialize(s);
} }

@ -42,11 +42,18 @@
#include <time.h> #include <time.h>
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#ifdef GPR_MU_COUNTERS
gpr_atm grpc_mu_locks = 0;
#endif
void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); } void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); }
void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); } void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); }
void gpr_mu_lock(gpr_mu* mu) { void gpr_mu_lock(gpr_mu* mu) {
#ifdef GPR_MU_COUNTERS
gpr_atm_no_barrier_fetch_add(&grpc_mu_locks, 1);
#endif
GPR_TIMER_BEGIN("gpr_mu_lock", 0); GPR_TIMER_BEGIN("gpr_mu_lock", 0);
GPR_ASSERT(pthread_mutex_lock(mu) == 0); GPR_ASSERT(pthread_mutex_lock(mu) == 0);
GPR_TIMER_END("gpr_mu_lock", 0); GPR_TIMER_END("gpr_mu_lock", 0);

@ -897,7 +897,7 @@ static void recv_common_filter(grpc_exec_ctx *exec_ctx, grpc_call *call,
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, msg); error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, msg);
gpr_free(msg); gpr_free(msg);
grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message); grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message);
} else { } else if (error != GRPC_ERROR_NONE) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, ""); error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "");
} }
@ -1483,6 +1483,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
} }
bctl->send_final_op = 1; bctl->send_final_op = 1;
call->sent_final_op = 1; call->sent_final_op = 1;
GPR_ASSERT(call->send_extra_metadata_count == 0);
call->send_extra_metadata_count = 1; call->send_extra_metadata_count = 1;
call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem( call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem(
exec_ctx, call->channel, op->data.send_status_from_server.status); exec_ctx, call->channel, op->data.send_status_from_server.status);
@ -1511,6 +1512,10 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
(int)op->data.send_status_from_server.trailing_metadata_count, (int)op->data.send_status_from_server.trailing_metadata_count,
op->data.send_status_from_server.trailing_metadata, 1, 1, NULL, op->data.send_status_from_server.trailing_metadata, 1, 1, NULL,
0)) { 0)) {
for (int n = 0; n < call->send_extra_metadata_count; n++) {
GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md);
}
call->send_extra_metadata_count = 0;
error = GRPC_CALL_ERROR_INVALID_METADATA; error = GRPC_CALL_ERROR_INVALID_METADATA;
goto done_with_error; goto done_with_error;
} }

@ -56,7 +56,7 @@ static bool maybe_prepend_client_auth_filter(
grpc_channel_stack_builder_get_channel_arguments(builder); grpc_channel_stack_builder_get_channel_arguments(builder);
if (args) { if (args) {
for (size_t i = 0; i < args->num_args; i++) { for (size_t i = 0; i < args->num_args; i++) {
if (0 == strcmp(GRPC_SECURITY_CONNECTOR_ARG, args->args[i].key)) { if (0 == strcmp(GRPC_ARG_SECURITY_CONNECTOR, args->args[i].key)) {
return grpc_channel_stack_builder_prepend_filter( return grpc_channel_stack_builder_prepend_filter(
builder, &grpc_client_auth_filter, NULL, NULL); builder, &grpc_client_auth_filter, NULL, NULL);
} }

@ -478,6 +478,7 @@ int Server::AddListeningPort(const grpc::string& addr,
bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
GPR_ASSERT(!started_); GPR_ASSERT(!started_);
global_callbacks_->PreServerStart(this);
started_ = true; started_ = true;
grpc_server_start(server_); grpc_server_start(server_);

@ -761,7 +761,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
ops[nops].data.send_message.send_message = ctx->send_message; ops[nops].data.send_message.send_message = ctx->send_message;
ops[nops].flags = write_flags; ops[nops].flags = write_flags;
ops[nops].reserved = NULL; ops[nops].reserved = NULL;
nops ++; nops++;
} }
if (send_empty_initial_metadata) { if (send_empty_initial_metadata) {
ops[nops].op = GRPC_OP_SEND_INITIAL_METADATA; ops[nops].op = GRPC_OP_SEND_INITIAL_METADATA;

@ -101,7 +101,7 @@ Pod::Spec.new do |s|
s.preserve_paths = plugin s.preserve_paths = plugin
# Restrict the protoc version to the one supported by this plugin. # Restrict the protoc version to the one supported by this plugin.
s.dependency '!ProtoCompiler', '3.0.2' s.dependency '!ProtoCompiler', '3.1.0'
# For the Protobuf dependency not to complain: # For the Protobuf dependency not to complain:
s.ios.deployment_target = '7.1' s.ios.deployment_target = '7.1'
s.osx.deployment_target = '10.9' s.osx.deployment_target = '10.9'

@ -36,7 +36,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them. # before them.
s.name = '!ProtoCompiler' s.name = '!ProtoCompiler'
v = '3.0.2' v = '3.1.0'
s.version = v s.version = v
s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files'
s.description = <<-DESC s.description = <<-DESC

@ -169,6 +169,8 @@
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
} }
#ifndef GRPC_COMPILE_WITH_CRONET
// TODO (mxyan): Fix this test
- (void)testResponsesOverMaxSizeFailWithActionableMessage { - (void)testResponsesOverMaxSizeFailWithActionableMessage {
XCTAssertNotNil(self.class.host); XCTAssertNotNil(self.class.host);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"]; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"];
@ -189,6 +191,7 @@
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
} }
#endif
- (void)testResponsesOver4MBAreAcceptedIfOptedIn { - (void)testResponsesOver4MBAreAcceptedIfOptedIn {
XCTAssertNotNil(self.class.host); XCTAssertNotNil(self.class.host);

@ -61,3 +61,11 @@ xcodebuild \
test \ test \
| egrep "$XCODEBUILD_FILTER" \ | egrep "$XCODEBUILD_FILTER" \
| egrep -v "(GPBDictionary|GPBArray)" - | egrep -v "(GPBDictionary|GPBArray)" -
xcodebuild \
-workspace Tests.xcworkspace \
-scheme InteropTestsRemoteWithCronet \
-destination name="iPhone 6" \
test \
| egrep "$XCODEBUILD_FILTER" \
| egrep -v "(GPBDictionary|GPBArray)" -

@ -139,7 +139,10 @@ message ServerConfig {
int32 async_server_threads = 7; int32 async_server_threads = 7;
// Specify the number of cores to limit server to, if desired // Specify the number of cores to limit server to, if desired
int32 core_limit = 8; int32 core_limit = 8;
// payload config, used in generic server // payload config, used in generic server.
// Note this must NOT be used in proto (non-generic) servers. For proto servers,
// 'response sizes' must be configured from the 'response_size' field of the
// 'SimpleRequest' objects in RPC requests.
PayloadConfig payload_config = 9; PayloadConfig payload_config = 9;
// Specify the cores we should run the server on, if desired // Specify the cores we should run the server on, if desired

@ -231,6 +231,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/security/credentials/plugin/plugin_credentials.c', 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
'src/core/lib/security/credentials/ssl/ssl_credentials.c', 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
'src/core/lib/security/transport/client_auth_filter.c', 'src/core/lib/security/transport/client_auth_filter.c',
'src/core/lib/security/transport/lb_targets_info.c',
'src/core/lib/security/transport/secure_endpoint.c', 'src/core/lib/security/transport/secure_endpoint.c',
'src/core/lib/security/transport/security_connector.c', 'src/core/lib/security/transport/security_connector.c',
'src/core/lib/security/transport/security_handshaker.c', 'src/core/lib/security/transport/security_handshaker.c',
@ -271,6 +272,7 @@ CORE_SOURCE_FILES = [
'src/core/ext/transport/chttp2/client/insecure/channel_create.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/lb_policy/grpclb/grpclb.c', 'src/core/ext/lb_policy/grpclb/grpclb.c',
'src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_common.c',

@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Provides distutils command classes for the gRPC Python setup process.""" """Provides distutils command classes for the gRPC Python setup process."""
import distutils from distutils import errors as _errors
import glob import glob
import os import os
import os.path import os.path
@ -186,7 +186,7 @@ class RunInterop(test.test):
def finalize_options(self): def finalize_options(self):
if self.client and self.server: if self.client and self.server:
raise DistutilsOptionError( raise _errors.DistutilsOptionError(
'you may only specify one of client or server') 'you may only specify one of client or server')
def run(self): def run(self):

@ -103,7 +103,7 @@
s.preserve_paths = plugin s.preserve_paths = plugin
# Restrict the protoc version to the one supported by this plugin. # Restrict the protoc version to the one supported by this plugin.
s.dependency '!ProtoCompiler', '3.0.2' s.dependency '!ProtoCompiler', '3.1.0'
# For the Protobuf dependency not to complain: # For the Protobuf dependency not to complain:
s.ios.deployment_target = '7.1' s.ios.deployment_target = '7.1'
s.osx.deployment_target = '10.9' s.osx.deployment_target = '10.9'

@ -154,12 +154,34 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
grpc_uri_get_query_arg(args->uri, "lb_enabled"); grpc_uri_get_query_arg(args->uri, "lb_enabled");
const bool lb_enabled = const bool lb_enabled =
lb_enabled_qpart != NULL && strcmp("0", lb_enabled_qpart) != 0; lb_enabled_qpart != NULL && strcmp("0", lb_enabled_qpart) != 0;
// Get the balancer's names.
const char* balancer_names =
grpc_uri_get_query_arg(args->uri, "balancer_names");
grpc_slice_buffer balancer_names_parts;
grpc_slice_buffer_init(&balancer_names_parts);
if (balancer_names != NULL) {
const grpc_slice balancer_names_slice =
grpc_slice_from_copied_string(balancer_names);
grpc_slice_split(balancer_names_slice, ",", &balancer_names_parts);
grpc_slice_unref(balancer_names_slice);
}
// Construct addresses. // Construct addresses.
grpc_slice path_slice = grpc_slice path_slice =
grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing);
grpc_slice_buffer path_parts; grpc_slice_buffer path_parts;
grpc_slice_buffer_init(&path_parts); grpc_slice_buffer_init(&path_parts);
grpc_slice_split(path_slice, ",", &path_parts); grpc_slice_split(path_slice, ",", &path_parts);
if (balancer_names_parts.count > 0 &&
path_parts.count != balancer_names_parts.count) {
gpr_log(GPR_ERROR,
"Balancer names present but mismatched with number of addresses: "
"%lu balancer names != %lu addresses",
(unsigned long)balancer_names_parts.count,
(unsigned long)path_parts.count);
return NULL;
}
grpc_lb_addresses* addresses = grpc_lb_addresses* addresses =
grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */); grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */);
bool errors_found = false; bool errors_found = false;
@ -171,10 +193,15 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
errors_found = true; errors_found = true;
} }
gpr_free(part_str); gpr_free(part_str);
addresses->addresses[i].is_balancer = lb_enabled;
if (errors_found) break; if (errors_found) break;
addresses->addresses[i].is_balancer = lb_enabled;
addresses->addresses[i].balancer_name =
balancer_names_parts.count > 0
? grpc_dump_slice(balancer_names_parts.slices[i], GPR_DUMP_ASCII)
: NULL;
} }
grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts); grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts);
grpc_slice_buffer_destroy_internal(exec_ctx, &balancer_names_parts);
grpc_slice_unref(path_slice); grpc_slice_unref(path_slice);
if (errors_found) { if (errors_found) {
grpc_lb_addresses_destroy(exec_ctx, addresses); grpc_lb_addresses_destroy(exec_ctx, addresses);

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

Loading…
Cancel
Save