Merge branch 'master' into uv_portability_fix

pull/11871/head
murgatroid99 8 years ago
commit 75f678a5b2
  1. 6
      .github/CODEOWNERS
  2. 315
      BUILD
  3. 168
      CMakeLists.txt
  4. 171
      Makefile
  5. 17
      OWNERS
  6. 5
      bazel/OWNERS
  7. 5
      bazel/cc_grpc_library.bzl
  8. 8
      bazel/generate_cc.bzl
  9. 2
      bazel/grpc_build_system.bzl
  10. 4
      binding.gyp
  11. 44
      build.yaml
  12. 5
      config.m4
  13. 5
      config.w32
  14. 11
      doc/environment_variables.md
  15. 2
      examples/BUILD
  16. 10
      gRPC-Core.podspec
  17. 7
      grpc.gemspec
  18. 2
      include/grpc++/impl/codegen/config_protobuf.h
  19. 4
      include/grpc++/impl/codegen/core_codegen.h
  20. 4
      include/grpc++/impl/codegen/core_codegen_interface.h
  21. 60
      include/grpc++/impl/codegen/proto_utils.h
  22. 42
      include/grpc++/impl/codegen/server_interface.h
  23. 5
      include/grpc++/impl/codegen/status.h
  24. 8
      include/grpc++/security/credentials.h
  25. 3
      include/grpc++/server.h
  26. 2
      package.json
  27. 7
      package.xml
  28. 4
      src/core/ext/filters/client_channel/OWNERS
  29. 12
      src/core/ext/filters/client_channel/client_channel.c
  30. 4
      src/core/ext/filters/client_channel/client_channel_plugin.c
  31. 3
      src/core/ext/filters/client_channel/lb_policy.c
  32. 6
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
  33. 5
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
  34. 166
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
  35. 3
      src/core/ext/filters/client_channel/resolver.c
  36. 4
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c
  37. 1
      src/core/ext/filters/client_channel/subchannel.c
  38. 7
      src/core/ext/filters/client_channel/subchannel_index.c
  39. 12
      src/core/ext/filters/client_channel/subchannel_index.h
  40. 2
      src/core/ext/filters/http/http_filters_plugin.c
  41. 6
      src/core/ext/transport/chttp2/transport/chttp2_plugin.c
  42. 10
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  43. 1
      src/core/ext/transport/chttp2/transport/internal.h
  44. 29
      src/core/ext/transport/inproc/inproc_plugin.c
  45. 1277
      src/core/ext/transport/inproc/inproc_transport.c
  46. 41
      src/core/ext/transport/inproc/inproc_transport.h
  47. 2
      src/core/lib/channel/channel_stack.c
  48. 2
      src/core/lib/channel/channel_stack_builder.c
  49. 191
      src/core/lib/compression/stream_compression.c
  50. 90
      src/core/lib/compression/stream_compression.h
  51. 22
      src/core/lib/debug/trace.c
  52. 11
      src/core/lib/debug/trace.h
  53. 2
      src/core/lib/http/parser.c
  54. 2
      src/core/lib/iomgr/closure.c
  55. 3
      src/core/lib/iomgr/combiner.c
  56. 3
      src/core/lib/iomgr/error.c
  57. 25
      src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c
  58. 56
      src/core/lib/iomgr/ev_epollex_linux.c
  59. 25
      src/core/lib/iomgr/ev_epollsig_linux.c
  60. 11
      src/core/lib/iomgr/ev_posix.c
  61. 4
      src/core/lib/iomgr/ev_posix.h
  62. 2
      src/core/lib/iomgr/ev_windows.c
  63. 2
      src/core/lib/iomgr/iomgr_posix.c
  64. 2
      src/core/lib/iomgr/iomgr_uv.c
  65. 3
      src/core/lib/iomgr/pollset_uv.c
  66. 3
      src/core/lib/iomgr/pollset_windows.c
  67. 3
      src/core/lib/iomgr/resource_quota.c
  68. 2
      src/core/lib/iomgr/tcp_posix.c
  69. 2
      src/core/lib/iomgr/tcp_uv.c
  70. 2
      src/core/lib/iomgr/tcp_windows.c
  71. 79
      src/core/lib/iomgr/timer_generic.c
  72. 21
      src/core/lib/iomgr/timer_manager.c
  73. 5
      src/core/lib/iomgr/timer_uv.c
  74. 2
      src/core/lib/security/context/security_context.c
  75. 7
      src/core/lib/security/credentials/jwt/jwt_credentials.c
  76. 3
      src/core/lib/security/transport/secure_endpoint.c
  77. 8
      src/core/lib/security/transport/security_connector.c
  78. 4
      src/core/lib/support/log_linux.c
  79. 2
      src/core/lib/surface/api_trace.c
  80. 6
      src/core/lib/surface/call.c
  81. 636
      src/core/lib/surface/completion_queue.c
  82. 3
      src/core/lib/surface/completion_queue.h
  83. 42
      src/core/lib/surface/init.c
  84. 10
      src/core/lib/surface/init_secure.c
  85. 8
      src/core/lib/surface/server.c
  86. 3
      src/core/lib/transport/bdp_estimator.c
  87. 3
      src/core/lib/transport/connectivity_state.c
  88. 3
      src/core/lib/transport/metadata.c
  89. 3
      src/core/lib/transport/transport.c
  90. 4
      src/core/plugin_registry/grpc_cronet_plugin_registry.c
  91. 8
      src/core/plugin_registry/grpc_plugin_registry.c
  92. 4
      src/core/plugin_registry/grpc_unsecure_plugin_registry.c
  93. 248
      src/core/tsi/fake_transport_security.c
  94. 2
      src/core/tsi/fake_transport_security.h
  95. 40
      src/core/tsi/gts_transport_security.c
  96. 37
      src/core/tsi/gts_transport_security.h
  97. 2
      src/core/tsi/transport_security.c
  98. 5
      src/cpp/common/core_codegen.cc
  99. 9
      src/cpp/server/server_cc.cc
  100. 23
      src/cpp/thread_manager/thread_manager.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,6 @@
# Auto-generated by the tools/mkowners/mkowners.py tool
# Uses OWNERS files in different modules throughout the
# repository as the source of truth for module ownership.
/**/OWNERS @markdroth @nicolasnoble @ctiller
/bazel/** @nicolasnoble @dgquintas @ctiller
/src/core/ext/filters/client_channel/** @markdroth @dgquintas @ctiller

315
BUILD

@ -40,9 +40,154 @@ core_version = "4.0.0-dev"
version = "1.5.0-dev" version = "1.5.0-dev"
GPR_PUBLIC_HDRS = [
"include/grpc/support/alloc.h",
"include/grpc/support/atm.h",
"include/grpc/support/atm_gcc_atomic.h",
"include/grpc/support/atm_gcc_sync.h",
"include/grpc/support/atm_windows.h",
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
"include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
"include/grpc/support/port_platform.h",
"include/grpc/support/string_util.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",
"include/grpc/support/sync_windows.h",
"include/grpc/support/thd.h",
"include/grpc/support/time.h",
"include/grpc/support/tls.h",
"include/grpc/support/tls_gcc.h",
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
]
GRPC_PUBLIC_HDRS = [
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
"include/grpc/load_reporting.h",
"include/grpc/grpc.h",
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security_constants.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
"include/grpc/support/workaround_list.h",
]
GRPC_SECURE_PUBLIC_HDRS = [
"include/grpc/grpc_security.h",
]
# TODO(ctiller): layer grpc atop grpc_unsecure, layer grpc++ atop grpc++_unsecure
GRPCXX_SRCS = [
"src/cpp/client/channel_cc.cc",
"src/cpp/client/client_context.cc",
"src/cpp/client/create_channel.cc",
"src/cpp/client/create_channel_internal.cc",
"src/cpp/client/create_channel_posix.cc",
"src/cpp/client/credentials_cc.cc",
"src/cpp/client/generic_stub.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/channel_filter.cc",
"src/cpp/common/completion_queue_cc.cc",
"src/cpp/common/core_codegen.cc",
"src/cpp/common/resource_quota_cc.cc",
"src/cpp/common/rpc_method.cc",
"src/cpp/common/version_cc.cc",
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/channel_argument_option.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
"src/cpp/server/health/default_health_check_service.cc",
"src/cpp/server/health/health.pb.c",
"src/cpp/server/health/health_check_service.cc",
"src/cpp/server/health/health_check_service_server_builder_option.cc",
"src/cpp/server/server_builder.cc",
"src/cpp/server/server_cc.cc",
"src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc",
"src/cpp/server/server_posix.cc",
"src/cpp/thread_manager/thread_manager.cc",
"src/cpp/util/byte_buffer_cc.cc",
"src/cpp/util/slice_cc.cc",
"src/cpp/util/status.cc",
"src/cpp/util/string_ref.cc",
"src/cpp/util/time_cc.cc",
]
GRPCXX_HDRS = [
"src/cpp/client/create_channel_internal.h",
"src/cpp/common/channel_filter.h",
"src/cpp/server/dynamic_thread_pool.h",
"src/cpp/server/health/default_health_check_service.h",
"src/cpp/server/health/health.pb.h",
"src/cpp/server/thread_pool_interface.h",
"src/cpp/thread_manager/thread_manager.h",
]
GRPCXX_PUBLIC_HDRS = [
"include/grpc++/alarm.h",
"include/grpc++/channel.h",
"include/grpc++/client_context.h",
"include/grpc++/completion_queue.h",
"include/grpc++/create_channel.h",
"include/grpc++/create_channel_posix.h",
"include/grpc++/ext/health_check_service_server_builder_option.h",
"include/grpc++/generic/async_generic_service.h",
"include/grpc++/generic/generic_stub.h",
"include/grpc++/grpc++.h",
"include/grpc++/health_check_service_interface.h",
"include/grpc++/impl/call.h",
"include/grpc++/impl/channel_argument_option.h",
"include/grpc++/impl/client_unary_call.h",
"include/grpc++/impl/codegen/core_codegen.h",
"include/grpc++/impl/grpc_library.h",
"include/grpc++/impl/method_handler_impl.h",
"include/grpc++/impl/rpc_method.h",
"include/grpc++/impl/rpc_service_method.h",
"include/grpc++/impl/serialization_traits.h",
"include/grpc++/impl/server_builder_option.h",
"include/grpc++/impl/server_builder_plugin.h",
"include/grpc++/impl/server_initializer.h",
"include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h",
"include/grpc++/security/auth_metadata_processor.h",
"include/grpc++/security/credentials.h",
"include/grpc++/security/server_credentials.h",
"include/grpc++/server.h",
"include/grpc++/server_builder.h",
"include/grpc++/server_context.h",
"include/grpc++/server_posix.h",
"include/grpc++/support/async_stream.h",
"include/grpc++/support/async_unary_call.h",
"include/grpc++/support/byte_buffer.h",
"include/grpc++/support/channel_arguments.h",
"include/grpc++/support/config.h",
"include/grpc++/support/slice.h",
"include/grpc++/support/status.h",
"include/grpc++/support/status_code_enum.h",
"include/grpc++/support/string_ref.h",
"include/grpc++/support/stub_options.h",
"include/grpc++/support/sync_stream.h",
"include/grpc++/support/time.h",
]
grpc_cc_library( grpc_cc_library(
name = "gpr", name = "gpr",
language = "c", language = "c",
public_hdrs = GPR_PUBLIC_HDRS,
standalone = True, standalone = True,
deps = [ deps = [
"gpr_base", "gpr_base",
@ -57,6 +202,7 @@ grpc_cc_library(
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c", "src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
], ],
language = "c", language = "c",
public_hdrs = GRPC_PUBLIC_HDRS,
standalone = True, standalone = True,
deps = [ deps = [
"grpc_common", "grpc_common",
@ -70,6 +216,7 @@ grpc_cc_library(
"src/core/plugin_registry/grpc_plugin_registry.c", "src/core/plugin_registry/grpc_plugin_registry.c",
], ],
language = "c", language = "c",
public_hdrs = GRPC_PUBLIC_HDRS + GRPC_SECURE_PUBLIC_HDRS,
standalone = True, standalone = True,
deps = [ deps = [
"grpc_common", "grpc_common",
@ -114,6 +261,7 @@ grpc_cc_library(
"src/cpp/server/secure_server_credentials.h", "src/cpp/server/secure_server_credentials.h",
], ],
language = "c++", language = "c++",
public_hdrs = GRPCXX_PUBLIC_HDRS,
standalone = True, standalone = True,
deps = [ deps = [
"gpr", "gpr",
@ -379,34 +527,7 @@ grpc_cc_library(
"src/core/lib/support/tmpfile.h", "src/core/lib/support/tmpfile.h",
], ],
language = "c", language = "c",
public_hdrs = [ public_hdrs = GPR_PUBLIC_HDRS,
"include/grpc/support/alloc.h",
"include/grpc/support/atm.h",
"include/grpc/support/atm_gcc_atomic.h",
"include/grpc/support/atm_gcc_sync.h",
"include/grpc/support/atm_windows.h",
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
"include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
"include/grpc/support/port_platform.h",
"include/grpc/support/string_util.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",
"include/grpc/support/sync_windows.h",
"include/grpc/support/thd.h",
"include/grpc/support/time.h",
"include/grpc/support/tls.h",
"include/grpc/support/tls_gcc.h",
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
],
deps = [ deps = [
"gpr_codegen", "gpr_codegen",
], ],
@ -434,6 +555,7 @@ grpc_cc_library(
name = "grpc_trace", name = "grpc_trace",
srcs = ["src/core/lib/debug/trace.c"], srcs = ["src/core/lib/debug/trace.c"],
hdrs = ["src/core/lib/debug/trace.h"], hdrs = ["src/core/lib/debug/trace.h"],
language = "c",
deps = [":gpr"], deps = [":gpr"],
) )
@ -449,6 +571,7 @@ grpc_cc_library(
"src/core/lib/channel/handshaker_registry.c", "src/core/lib/channel/handshaker_registry.c",
"src/core/lib/compression/compression.c", "src/core/lib/compression/compression.c",
"src/core/lib/compression/message_compress.c", "src/core/lib/compression/message_compress.c",
"src/core/lib/compression/stream_compression.c",
"src/core/lib/http/format_request.c", "src/core/lib/http/format_request.c",
"src/core/lib/http/httpcli.c", "src/core/lib/http/httpcli.c",
"src/core/lib/http/parser.c", "src/core/lib/http/parser.c",
@ -575,6 +698,7 @@ grpc_cc_library(
"src/core/lib/channel/handshaker_registry.h", "src/core/lib/channel/handshaker_registry.h",
"src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/algorithm_metadata.h",
"src/core/lib/compression/message_compress.h", "src/core/lib/compression/message_compress.h",
"src/core/lib/compression/stream_compression.h",
"src/core/lib/http/format_request.h", "src/core/lib/http/format_request.h",
"src/core/lib/http/httpcli.h", "src/core/lib/http/httpcli.h",
"src/core/lib/http/parser.h", "src/core/lib/http/parser.h",
@ -680,19 +804,7 @@ grpc_cc_library(
"zlib", "zlib",
], ],
language = "c", language = "c",
public_hdrs = [ public_hdrs = GRPC_PUBLIC_HDRS,
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
"include/grpc/load_reporting.h",
"include/grpc/grpc.h",
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security_constants.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
"include/grpc/support/workaround_list.h",
],
deps = [ deps = [
"gpr_base", "gpr_base",
"grpc_codegen", "grpc_codegen",
@ -713,6 +825,7 @@ grpc_cc_library(
grpc_cc_library( grpc_cc_library(
name = "grpc_common", name = "grpc_common",
language = "c",
deps = [ deps = [
"grpc_base", "grpc_base",
# standard plugins # standard plugins
@ -727,6 +840,7 @@ grpc_cc_library(
"grpc_resolver_sockaddr", "grpc_resolver_sockaddr",
"grpc_transport_chttp2_client_insecure", "grpc_transport_chttp2_client_insecure",
"grpc_transport_chttp2_server_insecure", "grpc_transport_chttp2_server_insecure",
"grpc_transport_inproc",
"grpc_workaround_cronet_compression_filter", "grpc_workaround_cronet_compression_filter",
"grpc_server_backward_compatibility", "grpc_server_backward_compatibility",
], ],
@ -1084,9 +1198,7 @@ grpc_cc_library(
"src/core/lib/security/util/json_util.h", "src/core/lib/security/util/json_util.h",
], ],
language = "c", language = "c",
public_hdrs = [ public_hdrs = GRPC_SECURE_PUBLIC_HDRS,
"include/grpc/grpc_security.h",
],
deps = [ deps = [
"grpc_base", "grpc_base",
"grpc_transport_chttp2_alpn", "grpc_transport_chttp2_alpn",
@ -1274,16 +1386,33 @@ grpc_cc_library(
], ],
) )
grpc_cc_library(
name = "grpc_transport_inproc",
srcs = [
"src/core/ext/transport/inproc/inproc_plugin.c",
"src/core/ext/transport/inproc/inproc_transport.c",
],
hdrs = [
"src/core/ext/transport/inproc/inproc_transport.h",
],
language = "c",
deps = [
"grpc_base",
],
)
grpc_cc_library( grpc_cc_library(
name = "tsi", name = "tsi",
srcs = [ srcs = [
"src/core/tsi/fake_transport_security.c", "src/core/tsi/fake_transport_security.c",
"src/core/tsi/gts_transport_security.c",
"src/core/tsi/ssl_transport_security.c", "src/core/tsi/ssl_transport_security.c",
"src/core/tsi/transport_security.c", "src/core/tsi/transport_security.c",
"src/core/tsi/transport_security_adapter.c", "src/core/tsi/transport_security_adapter.c",
], ],
hdrs = [ hdrs = [
"src/core/tsi/fake_transport_security.h", "src/core/tsi/fake_transport_security.h",
"src/core/tsi/gts_transport_security.h",
"src/core/tsi/ssl_transport_security.h", "src/core/tsi/ssl_transport_security.h",
"src/core/tsi/ssl_types.h", "src/core/tsi/ssl_types.h",
"src/core/tsi/transport_security.h", "src/core/tsi/transport_security.h",
@ -1296,107 +1425,11 @@ grpc_cc_library(
language = "c", language = "c",
deps = [ deps = [
"gpr", "gpr",
"grpc_base",
"grpc_trace", "grpc_trace",
], ],
) )
# TODO(ctiller): layer grpc atop grpc_unsecure, layer grpc++ atop grpc++_unsecure
GRPCXX_SRCS = [
"src/cpp/client/channel_cc.cc",
"src/cpp/client/client_context.cc",
"src/cpp/client/create_channel.cc",
"src/cpp/client/create_channel_internal.cc",
"src/cpp/client/create_channel_posix.cc",
"src/cpp/client/credentials_cc.cc",
"src/cpp/client/generic_stub.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/channel_filter.cc",
"src/cpp/common/completion_queue_cc.cc",
"src/cpp/common/core_codegen.cc",
"src/cpp/common/resource_quota_cc.cc",
"src/cpp/common/rpc_method.cc",
"src/cpp/common/version_cc.cc",
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/channel_argument_option.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
"src/cpp/server/health/default_health_check_service.cc",
"src/cpp/server/health/health.pb.c",
"src/cpp/server/health/health_check_service.cc",
"src/cpp/server/health/health_check_service_server_builder_option.cc",
"src/cpp/server/server_builder.cc",
"src/cpp/server/server_cc.cc",
"src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc",
"src/cpp/server/server_posix.cc",
"src/cpp/thread_manager/thread_manager.cc",
"src/cpp/util/byte_buffer_cc.cc",
"src/cpp/util/slice_cc.cc",
"src/cpp/util/status.cc",
"src/cpp/util/string_ref.cc",
"src/cpp/util/time_cc.cc",
]
GRPCXX_HDRS = [
"src/cpp/client/create_channel_internal.h",
"src/cpp/common/channel_filter.h",
"src/cpp/server/dynamic_thread_pool.h",
"src/cpp/server/health/default_health_check_service.h",
"src/cpp/server/health/health.pb.h",
"src/cpp/server/thread_pool_interface.h",
"src/cpp/thread_manager/thread_manager.h",
]
GRPCXX_PUBLIC_HDRS = [
"include/grpc++/alarm.h",
"include/grpc++/channel.h",
"include/grpc++/client_context.h",
"include/grpc++/completion_queue.h",
"include/grpc++/create_channel.h",
"include/grpc++/create_channel_posix.h",
"include/grpc++/ext/health_check_service_server_builder_option.h",
"include/grpc++/generic/async_generic_service.h",
"include/grpc++/generic/generic_stub.h",
"include/grpc++/grpc++.h",
"include/grpc++/health_check_service_interface.h",
"include/grpc++/impl/call.h",
"include/grpc++/impl/channel_argument_option.h",
"include/grpc++/impl/client_unary_call.h",
"include/grpc++/impl/codegen/core_codegen.h",
"include/grpc++/impl/grpc_library.h",
"include/grpc++/impl/method_handler_impl.h",
"include/grpc++/impl/rpc_method.h",
"include/grpc++/impl/rpc_service_method.h",
"include/grpc++/impl/serialization_traits.h",
"include/grpc++/impl/server_builder_option.h",
"include/grpc++/impl/server_builder_plugin.h",
"include/grpc++/impl/server_initializer.h",
"include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h",
"include/grpc++/security/auth_metadata_processor.h",
"include/grpc++/security/credentials.h",
"include/grpc++/security/server_credentials.h",
"include/grpc++/server.h",
"include/grpc++/server_builder.h",
"include/grpc++/server_context.h",
"include/grpc++/server_posix.h",
"include/grpc++/support/async_stream.h",
"include/grpc++/support/async_unary_call.h",
"include/grpc++/support/byte_buffer.h",
"include/grpc++/support/channel_arguments.h",
"include/grpc++/support/config.h",
"include/grpc++/support/slice.h",
"include/grpc++/support/status.h",
"include/grpc++/support/status_code_enum.h",
"include/grpc++/support/string_ref.h",
"include/grpc++/support/stub_options.h",
"include/grpc++/support/sync_stream.h",
"include/grpc++/support/time.h",
]
grpc_cc_library( grpc_cc_library(
name = "grpc++_base", name = "grpc++_base",
srcs = GRPCXX_SRCS, srcs = GRPCXX_SRCS,

@ -528,6 +528,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c socket_utils_test) add_dependencies(buildtests_c socket_utils_test)
endif() endif()
add_dependencies(buildtests_c status_conversion_test) add_dependencies(buildtests_c status_conversion_test)
add_dependencies(buildtests_c stream_compression_test)
add_dependencies(buildtests_c stream_owned_slice_test) add_dependencies(buildtests_c stream_owned_slice_test)
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 tcp_client_posix_test) add_dependencies(buildtests_c tcp_client_posix_test)
@ -599,6 +600,7 @@ add_dependencies(buildtests_c h2_ssl_proxy_test)
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 h2_uds_test) add_dependencies(buildtests_c h2_uds_test)
endif() endif()
add_dependencies(buildtests_c inproc_test)
add_dependencies(buildtests_c h2_census_nosec_test) add_dependencies(buildtests_c h2_census_nosec_test)
add_dependencies(buildtests_c h2_compress_nosec_test) add_dependencies(buildtests_c h2_compress_nosec_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@ -619,6 +621,7 @@ add_dependencies(buildtests_c h2_sockpair_1byte_nosec_test)
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 h2_uds_nosec_test) add_dependencies(buildtests_c h2_uds_nosec_test)
endif() endif()
add_dependencies(buildtests_c inproc_nosec_test)
add_dependencies(buildtests_c api_fuzzer_one_entry) add_dependencies(buildtests_c api_fuzzer_one_entry)
add_dependencies(buildtests_c client_fuzzer_one_entry) add_dependencies(buildtests_c client_fuzzer_one_entry)
add_dependencies(buildtests_c hpack_parser_fuzzer_test_one_entry) add_dependencies(buildtests_c hpack_parser_fuzzer_test_one_entry)
@ -748,6 +751,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx server_crash_test) add_dependencies(buildtests_cxx server_crash_test)
endif() endif()
add_dependencies(buildtests_cxx server_crash_test_client) add_dependencies(buildtests_cxx server_crash_test_client)
add_dependencies(buildtests_cxx server_request_call_test)
add_dependencies(buildtests_cxx shutdown_test) add_dependencies(buildtests_cxx shutdown_test)
add_dependencies(buildtests_cxx status_test) add_dependencies(buildtests_cxx status_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@ -952,6 +956,7 @@ add_library(grpc
src/core/lib/channel/handshaker_registry.c src/core/lib/channel/handshaker_registry.c
src/core/lib/compression/compression.c src/core/lib/compression/compression.c
src/core/lib/compression/message_compress.c src/core/lib/compression/message_compress.c
src/core/lib/compression/stream_compression.c
src/core/lib/http/format_request.c src/core/lib/http/format_request.c
src/core/lib/http/httpcli.c src/core/lib/http/httpcli.c
src/core/lib/http/parser.c src/core/lib/http/parser.c
@ -1120,6 +1125,7 @@ add_library(grpc
src/core/lib/security/util/json_util.c src/core/lib/security/util/json_util.c
src/core/lib/surface/init_secure.c src/core/lib/surface/init_secure.c
src/core/tsi/fake_transport_security.c src/core/tsi/fake_transport_security.c
src/core/tsi/gts_transport_security.c
src/core/tsi/ssl_transport_security.c src/core/tsi/ssl_transport_security.c
src/core/tsi/transport_security.c src/core/tsi/transport_security.c
src/core/tsi/transport_security_adapter.c src/core/tsi/transport_security_adapter.c
@ -1151,6 +1157,8 @@ add_library(grpc
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
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/transport/inproc/inproc_plugin.c
src/core/ext/transport/inproc/inproc_transport.c
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c
@ -1291,6 +1299,7 @@ add_library(grpc_cronet
src/core/lib/channel/handshaker_registry.c src/core/lib/channel/handshaker_registry.c
src/core/lib/compression/compression.c src/core/lib/compression/compression.c
src/core/lib/compression/message_compress.c src/core/lib/compression/message_compress.c
src/core/lib/compression/stream_compression.c
src/core/lib/http/format_request.c src/core/lib/http/format_request.c
src/core/lib/http/httpcli.c src/core/lib/http/httpcli.c
src/core/lib/http/parser.c src/core/lib/http/parser.c
@ -1483,6 +1492,7 @@ add_library(grpc_cronet
src/core/lib/security/util/json_util.c src/core/lib/security/util/json_util.c
src/core/lib/surface/init_secure.c src/core/lib/surface/init_secure.c
src/core/tsi/fake_transport_security.c src/core/tsi/fake_transport_security.c
src/core/tsi/gts_transport_security.c
src/core/tsi/ssl_transport_security.c src/core/tsi/ssl_transport_security.c
src/core/tsi/transport_security.c src/core/tsi/transport_security.c
src/core/tsi/transport_security_adapter.c src/core/tsi/transport_security_adapter.c
@ -1610,6 +1620,7 @@ add_library(grpc_test_util
src/core/lib/channel/handshaker_registry.c src/core/lib/channel/handshaker_registry.c
src/core/lib/compression/compression.c src/core/lib/compression/compression.c
src/core/lib/compression/message_compress.c src/core/lib/compression/message_compress.c
src/core/lib/compression/stream_compression.c
src/core/lib/http/format_request.c src/core/lib/http/format_request.c
src/core/lib/http/httpcli.c src/core/lib/http/httpcli.c
src/core/lib/http/parser.c src/core/lib/http/parser.c
@ -1872,6 +1883,7 @@ add_library(grpc_unsecure
src/core/lib/channel/handshaker_registry.c src/core/lib/channel/handshaker_registry.c
src/core/lib/compression/compression.c src/core/lib/compression/compression.c
src/core/lib/compression/message_compress.c src/core/lib/compression/message_compress.c
src/core/lib/compression/stream_compression.c
src/core/lib/http/format_request.c src/core/lib/http/format_request.c
src/core/lib/http/httpcli.c src/core/lib/http/httpcli.c
src/core/lib/http/parser.c src/core/lib/http/parser.c
@ -2041,6 +2053,8 @@ add_library(grpc_unsecure
src/core/ext/filters/client_channel/subchannel_index.c src/core/ext/filters/client_channel/subchannel_index.c
src/core/ext/filters/client_channel/uri_parser.c src/core/ext/filters/client_channel/uri_parser.c
src/core/ext/filters/deadline/deadline_filter.c src/core/ext/filters/deadline/deadline_filter.c
src/core/ext/transport/inproc/inproc_plugin.c
src/core/ext/transport/inproc/inproc_transport.c
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c
@ -2528,6 +2542,7 @@ add_library(grpc++_cronet
src/core/lib/channel/handshaker_registry.c src/core/lib/channel/handshaker_registry.c
src/core/lib/compression/compression.c src/core/lib/compression/compression.c
src/core/lib/compression/message_compress.c src/core/lib/compression/message_compress.c
src/core/lib/compression/stream_compression.c
src/core/lib/http/format_request.c src/core/lib/http/format_request.c
src/core/lib/http/httpcli.c src/core/lib/http/httpcli.c
src/core/lib/http/parser.c src/core/lib/http/parser.c
@ -8175,6 +8190,37 @@ target_link_libraries(status_conversion_test
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
add_executable(stream_compression_test
test/core/compression/stream_compression_test.c
)
target_include_directories(stream_compression_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 ${CARES_BUILD_INCLUDE_DIR}
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CARES_PLATFORM_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(stream_compression_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(stream_owned_slice_test add_executable(stream_owned_slice_test
test/core/transport/stream_owned_slice_test.c test/core/transport/stream_owned_slice_test.c
) )
@ -11405,6 +11451,7 @@ target_link_libraries(qps_interarrival_test
grpc grpc
gpr_test_util gpr_test_util
gpr gpr
grpc++_test_config
${_gRPC_GFLAGS_LIBRARIES} ${_gRPC_GFLAGS_LIBRARIES}
) )
@ -11756,6 +11803,7 @@ target_link_libraries(secure_sync_unary_ping_pong_test
grpc grpc
gpr_test_util gpr_test_util
gpr gpr
grpc++_test_config
${_gRPC_GFLAGS_LIBRARIES} ${_gRPC_GFLAGS_LIBRARIES}
) )
@ -11988,6 +12036,62 @@ target_link_libraries(server_crash_test_client
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
add_executable(server_request_call_test
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.grpc.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.h
test/cpp/server/server_request_call_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
protobuf_generate_grpc_cpp(
src/proto/grpc/testing/echo_messages.proto
)
protobuf_generate_grpc_cpp(
src/proto/grpc/testing/echo.proto
)
target_include_directories(server_request_call_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 ${CARES_BUILD_INCLUDE_DIR}
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CARES_PLATFORM_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(server_request_call_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc++_test_util
grpc_test_util
gpr_test_util
grpc++
grpc
gpr
${_gRPC_GFLAGS_LIBRARIES}
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(shutdown_test add_executable(shutdown_test
test/cpp/end2end/shutdown_test.cc test/cpp/end2end/shutdown_test.cc
third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googletest/src/gtest-all.cc
@ -13355,6 +13459,38 @@ endif()
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
add_executable(inproc_test
test/core/end2end/fixtures/inproc.c
)
target_include_directories(inproc_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 ${CARES_BUILD_INCLUDE_DIR}
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CARES_PLATFORM_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(inproc_test
${_gRPC_ALLTARGETS_LIBRARIES}
end2end_tests
grpc_test_util
grpc
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_census_nosec_test add_executable(h2_census_nosec_test
test/core/end2end/fixtures/h2_census.c test/core/end2end/fixtures/h2_census.c
) )
@ -13809,6 +13945,38 @@ endif()
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
add_executable(inproc_nosec_test
test/core/end2end/fixtures/inproc.c
)
target_include_directories(inproc_nosec_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 ${CARES_BUILD_INCLUDE_DIR}
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CARES_PLATFORM_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(inproc_nosec_test
${_gRPC_ALLTARGETS_LIBRARIES}
end2end_nosec_tests
grpc_test_util_unsecure
grpc_unsecure
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(api_fuzzer_one_entry add_executable(api_fuzzer_one_entry
test/core/end2end/fuzzers/api_fuzzer.c test/core/end2end/fuzzers/api_fuzzer.c
test/core/util/one_corpus_entry_fuzzer.c test/core/util/one_corpus_entry_fuzzer.c

@ -1075,6 +1075,7 @@ sockaddr_utils_test: $(BINDIR)/$(CONFIG)/sockaddr_utils_test
socket_utils_test: $(BINDIR)/$(CONFIG)/socket_utils_test socket_utils_test: $(BINDIR)/$(CONFIG)/socket_utils_test
ssl_server_fuzzer: $(BINDIR)/$(CONFIG)/ssl_server_fuzzer ssl_server_fuzzer: $(BINDIR)/$(CONFIG)/ssl_server_fuzzer
status_conversion_test: $(BINDIR)/$(CONFIG)/status_conversion_test status_conversion_test: $(BINDIR)/$(CONFIG)/status_conversion_test
stream_compression_test: $(BINDIR)/$(CONFIG)/stream_compression_test
stream_owned_slice_test: $(BINDIR)/$(CONFIG)/stream_owned_slice_test stream_owned_slice_test: $(BINDIR)/$(CONFIG)/stream_owned_slice_test
tcp_client_posix_test: $(BINDIR)/$(CONFIG)/tcp_client_posix_test tcp_client_posix_test: $(BINDIR)/$(CONFIG)/tcp_client_posix_test
tcp_client_uv_test: $(BINDIR)/$(CONFIG)/tcp_client_uv_test tcp_client_uv_test: $(BINDIR)/$(CONFIG)/tcp_client_uv_test
@ -1166,6 +1167,7 @@ server_builder_test: $(BINDIR)/$(CONFIG)/server_builder_test
server_context_test_spouse_test: $(BINDIR)/$(CONFIG)/server_context_test_spouse_test server_context_test_spouse_test: $(BINDIR)/$(CONFIG)/server_context_test_spouse_test
server_crash_test: $(BINDIR)/$(CONFIG)/server_crash_test server_crash_test: $(BINDIR)/$(CONFIG)/server_crash_test
server_crash_test_client: $(BINDIR)/$(CONFIG)/server_crash_test_client server_crash_test_client: $(BINDIR)/$(CONFIG)/server_crash_test_client
server_request_call_test: $(BINDIR)/$(CONFIG)/server_request_call_test
shutdown_test: $(BINDIR)/$(CONFIG)/shutdown_test shutdown_test: $(BINDIR)/$(CONFIG)/shutdown_test
status_test: $(BINDIR)/$(CONFIG)/status_test status_test: $(BINDIR)/$(CONFIG)/status_test
streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test
@ -1243,6 +1245,7 @@ h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test
h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test
h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test
inproc_test: $(BINDIR)/$(CONFIG)/inproc_test
h2_census_nosec_test: $(BINDIR)/$(CONFIG)/h2_census_nosec_test h2_census_nosec_test: $(BINDIR)/$(CONFIG)/h2_census_nosec_test
h2_compress_nosec_test: $(BINDIR)/$(CONFIG)/h2_compress_nosec_test h2_compress_nosec_test: $(BINDIR)/$(CONFIG)/h2_compress_nosec_test
h2_fd_nosec_test: $(BINDIR)/$(CONFIG)/h2_fd_nosec_test h2_fd_nosec_test: $(BINDIR)/$(CONFIG)/h2_fd_nosec_test
@ -1257,6 +1260,7 @@ h2_sockpair_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test
h2_sockpair+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test h2_sockpair+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test
h2_sockpair_1byte_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test h2_sockpair_1byte_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test
h2_uds_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds_nosec_test h2_uds_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds_nosec_test
inproc_nosec_test: $(BINDIR)/$(CONFIG)/inproc_nosec_test
api_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry api_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry
client_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry client_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry
hpack_parser_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry hpack_parser_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry
@ -1443,6 +1447,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/sockaddr_utils_test \ $(BINDIR)/$(CONFIG)/sockaddr_utils_test \
$(BINDIR)/$(CONFIG)/socket_utils_test \ $(BINDIR)/$(CONFIG)/socket_utils_test \
$(BINDIR)/$(CONFIG)/status_conversion_test \ $(BINDIR)/$(CONFIG)/status_conversion_test \
$(BINDIR)/$(CONFIG)/stream_compression_test \
$(BINDIR)/$(CONFIG)/stream_owned_slice_test \ $(BINDIR)/$(CONFIG)/stream_owned_slice_test \
$(BINDIR)/$(CONFIG)/tcp_client_posix_test \ $(BINDIR)/$(CONFIG)/tcp_client_posix_test \
$(BINDIR)/$(CONFIG)/tcp_client_uv_test \ $(BINDIR)/$(CONFIG)/tcp_client_uv_test \
@ -1492,6 +1497,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test \ $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \ $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \
$(BINDIR)/$(CONFIG)/h2_uds_test \ $(BINDIR)/$(CONFIG)/h2_uds_test \
$(BINDIR)/$(CONFIG)/inproc_test \
$(BINDIR)/$(CONFIG)/h2_census_nosec_test \ $(BINDIR)/$(CONFIG)/h2_census_nosec_test \
$(BINDIR)/$(CONFIG)/h2_compress_nosec_test \ $(BINDIR)/$(CONFIG)/h2_compress_nosec_test \
$(BINDIR)/$(CONFIG)/h2_fd_nosec_test \ $(BINDIR)/$(CONFIG)/h2_fd_nosec_test \
@ -1506,6 +1512,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test \ $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test \
$(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test \ $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uds_nosec_test \ $(BINDIR)/$(CONFIG)/h2_uds_nosec_test \
$(BINDIR)/$(CONFIG)/inproc_nosec_test \
$(BINDIR)/$(CONFIG)/api_fuzzer_one_entry \ $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/client_fuzzer_one_entry \ $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry \ $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry \
@ -1589,6 +1596,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/server_context_test_spouse_test \ $(BINDIR)/$(CONFIG)/server_context_test_spouse_test \
$(BINDIR)/$(CONFIG)/server_crash_test \ $(BINDIR)/$(CONFIG)/server_crash_test \
$(BINDIR)/$(CONFIG)/server_crash_test_client \ $(BINDIR)/$(CONFIG)/server_crash_test_client \
$(BINDIR)/$(CONFIG)/server_request_call_test \
$(BINDIR)/$(CONFIG)/shutdown_test \ $(BINDIR)/$(CONFIG)/shutdown_test \
$(BINDIR)/$(CONFIG)/status_test \ $(BINDIR)/$(CONFIG)/status_test \
$(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \
@ -1703,6 +1711,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/server_context_test_spouse_test \ $(BINDIR)/$(CONFIG)/server_context_test_spouse_test \
$(BINDIR)/$(CONFIG)/server_crash_test \ $(BINDIR)/$(CONFIG)/server_crash_test \
$(BINDIR)/$(CONFIG)/server_crash_test_client \ $(BINDIR)/$(CONFIG)/server_crash_test_client \
$(BINDIR)/$(CONFIG)/server_request_call_test \
$(BINDIR)/$(CONFIG)/shutdown_test \ $(BINDIR)/$(CONFIG)/shutdown_test \
$(BINDIR)/$(CONFIG)/status_test \ $(BINDIR)/$(CONFIG)/status_test \
$(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \
@ -1925,6 +1934,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/socket_utils_test || ( echo test socket_utils_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/socket_utils_test || ( echo test socket_utils_test failed ; exit 1 )
$(E) "[RUN] Testing status_conversion_test" $(E) "[RUN] Testing status_conversion_test"
$(Q) $(BINDIR)/$(CONFIG)/status_conversion_test || ( echo test status_conversion_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/status_conversion_test || ( echo test status_conversion_test failed ; exit 1 )
$(E) "[RUN] Testing stream_compression_test"
$(Q) $(BINDIR)/$(CONFIG)/stream_compression_test || ( echo test stream_compression_test failed ; exit 1 )
$(E) "[RUN] Testing stream_owned_slice_test" $(E) "[RUN] Testing stream_owned_slice_test"
$(Q) $(BINDIR)/$(CONFIG)/stream_owned_slice_test || ( echo test stream_owned_slice_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/stream_owned_slice_test || ( echo test stream_owned_slice_test failed ; exit 1 )
$(E) "[RUN] Testing tcp_client_posix_test" $(E) "[RUN] Testing tcp_client_posix_test"
@ -2095,6 +2106,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/server_context_test_spouse_test || ( echo test server_context_test_spouse_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/server_context_test_spouse_test || ( echo test server_context_test_spouse_test failed ; exit 1 )
$(E) "[RUN] Testing server_crash_test" $(E) "[RUN] Testing server_crash_test"
$(Q) $(BINDIR)/$(CONFIG)/server_crash_test || ( echo test server_crash_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/server_crash_test || ( echo test server_crash_test failed ; exit 1 )
$(E) "[RUN] Testing server_request_call_test"
$(Q) $(BINDIR)/$(CONFIG)/server_request_call_test || ( echo test server_request_call_test failed ; exit 1 )
$(E) "[RUN] Testing shutdown_test" $(E) "[RUN] Testing shutdown_test"
$(Q) $(BINDIR)/$(CONFIG)/shutdown_test || ( echo test shutdown_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/shutdown_test || ( echo test shutdown_test failed ; exit 1 )
$(E) "[RUN] Testing status_test" $(E) "[RUN] Testing status_test"
@ -2887,6 +2900,7 @@ LIBGRPC_SRC = \
src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.c \
src/core/lib/compression/compression.c \ src/core/lib/compression/compression.c \
src/core/lib/compression/message_compress.c \ src/core/lib/compression/message_compress.c \
src/core/lib/compression/stream_compression.c \
src/core/lib/http/format_request.c \ src/core/lib/http/format_request.c \
src/core/lib/http/httpcli.c \ src/core/lib/http/httpcli.c \
src/core/lib/http/parser.c \ src/core/lib/http/parser.c \
@ -3055,6 +3069,7 @@ LIBGRPC_SRC = \
src/core/lib/security/util/json_util.c \ src/core/lib/security/util/json_util.c \
src/core/lib/surface/init_secure.c \ src/core/lib/surface/init_secure.c \
src/core/tsi/fake_transport_security.c \ src/core/tsi/fake_transport_security.c \
src/core/tsi/gts_transport_security.c \
src/core/tsi/ssl_transport_security.c \ src/core/tsi/ssl_transport_security.c \
src/core/tsi/transport_security.c \ src/core/tsi/transport_security.c \
src/core/tsi/transport_security_adapter.c \ src/core/tsi/transport_security_adapter.c \
@ -3086,6 +3101,8 @@ LIBGRPC_SRC = \
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
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/transport/inproc/inproc_plugin.c \
src/core/ext/transport/inproc/inproc_transport.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
@ -3224,6 +3241,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.c \
src/core/lib/compression/compression.c \ src/core/lib/compression/compression.c \
src/core/lib/compression/message_compress.c \ src/core/lib/compression/message_compress.c \
src/core/lib/compression/stream_compression.c \
src/core/lib/http/format_request.c \ src/core/lib/http/format_request.c \
src/core/lib/http/httpcli.c \ src/core/lib/http/httpcli.c \
src/core/lib/http/parser.c \ src/core/lib/http/parser.c \
@ -3416,6 +3434,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/security/util/json_util.c \ src/core/lib/security/util/json_util.c \
src/core/lib/surface/init_secure.c \ src/core/lib/surface/init_secure.c \
src/core/tsi/fake_transport_security.c \ src/core/tsi/fake_transport_security.c \
src/core/tsi/gts_transport_security.c \
src/core/tsi/ssl_transport_security.c \ src/core/tsi/ssl_transport_security.c \
src/core/tsi/transport_security.c \ src/core/tsi/transport_security.c \
src/core/tsi/transport_security_adapter.c \ src/core/tsi/transport_security_adapter.c \
@ -3540,6 +3559,7 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.c \
src/core/lib/compression/compression.c \ src/core/lib/compression/compression.c \
src/core/lib/compression/message_compress.c \ src/core/lib/compression/message_compress.c \
src/core/lib/compression/stream_compression.c \
src/core/lib/http/format_request.c \ src/core/lib/http/format_request.c \
src/core/lib/http/httpcli.c \ src/core/lib/http/httpcli.c \
src/core/lib/http/parser.c \ src/core/lib/http/parser.c \
@ -3774,6 +3794,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.c \
src/core/lib/compression/compression.c \ src/core/lib/compression/compression.c \
src/core/lib/compression/message_compress.c \ src/core/lib/compression/message_compress.c \
src/core/lib/compression/stream_compression.c \
src/core/lib/http/format_request.c \ src/core/lib/http/format_request.c \
src/core/lib/http/httpcli.c \ src/core/lib/http/httpcli.c \
src/core/lib/http/parser.c \ src/core/lib/http/parser.c \
@ -3943,6 +3964,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/subchannel_index.c \
src/core/ext/filters/client_channel/uri_parser.c \ src/core/ext/filters/client_channel/uri_parser.c \
src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/filters/deadline/deadline_filter.c \
src/core/ext/transport/inproc/inproc_plugin.c \
src/core/ext/transport/inproc/inproc_transport.c \
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \
@ -4414,6 +4437,7 @@ LIBGRPC++_CRONET_SRC = \
src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.c \
src/core/lib/compression/compression.c \ src/core/lib/compression/compression.c \
src/core/lib/compression/message_compress.c \ src/core/lib/compression/message_compress.c \
src/core/lib/compression/stream_compression.c \
src/core/lib/http/format_request.c \ src/core/lib/http/format_request.c \
src/core/lib/http/httpcli.c \ src/core/lib/http/httpcli.c \
src/core/lib/http/parser.c \ src/core/lib/http/parser.c \
@ -12257,6 +12281,38 @@ endif
endif endif
STREAM_COMPRESSION_TEST_SRC = \
test/core/compression/stream_compression_test.c \
STREAM_COMPRESSION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STREAM_COMPRESSION_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/stream_compression_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/stream_compression_test: $(STREAM_COMPRESSION_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) $(STREAM_COMPRESSION_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)/stream_compression_test
endif
$(OBJDIR)/$(CONFIG)/test/core/compression/stream_compression_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_stream_compression_test: $(STREAM_COMPRESSION_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(STREAM_COMPRESSION_TEST_OBJS:.o=.dep)
endif
endif
STREAM_OWNED_SLICE_TEST_SRC = \ STREAM_OWNED_SLICE_TEST_SRC = \
test/core/transport/stream_owned_slice_test.c \ test/core/transport/stream_owned_slice_test.c \
@ -15398,16 +15454,16 @@ $(BINDIR)/$(CONFIG)/qps_interarrival_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/qps_interarrival_test: $(PROTOBUF_DEP) $(QPS_INTERARRIVAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/qps_interarrival_test: $(PROTOBUF_DEP) $(QPS_INTERARRIVAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(QPS_INTERARRIVAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_interarrival_test $(Q) $(LDXX) $(LDFLAGS) $(QPS_INTERARRIVAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_interarrival_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_interarrival_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_interarrival_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
deps_qps_interarrival_test: $(QPS_INTERARRIVAL_TEST_OBJS:.o=.dep) deps_qps_interarrival_test: $(QPS_INTERARRIVAL_TEST_OBJS:.o=.dep)
@ -15719,16 +15775,16 @@ $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(SECURE_SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(SECURE_SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(SECURE_SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test $(Q) $(LDXX) $(LDFLAGS) $(SECURE_SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/secure_sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/secure_sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
deps_secure_sync_unary_ping_pong_test: $(SECURE_SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep) deps_secure_sync_unary_ping_pong_test: $(SECURE_SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep)
@ -15961,6 +16017,56 @@ endif
endif endif
SERVER_REQUEST_CALL_TEST_SRC = \
$(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \
test/cpp/server/server_request_call_test.cc \
SERVER_REQUEST_CALL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_REQUEST_CALL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/server_request_call_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
$(BINDIR)/$(CONFIG)/server_request_call_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/server_request_call_test: $(PROTOBUF_DEP) $(SERVER_REQUEST_CALL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(SERVER_REQUEST_CALL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/server_request_call_test
endif
endif
$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/echo_messages.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/echo.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/cpp/server/server_request_call_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_server_request_call_test: $(SERVER_REQUEST_CALL_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(SERVER_REQUEST_CALL_TEST_OBJS:.o=.dep)
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/server/server_request_call_test.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc
SHUTDOWN_TEST_SRC = \ SHUTDOWN_TEST_SRC = \
test/cpp/end2end/shutdown_test.cc \ test/cpp/end2end/shutdown_test.cc \
@ -18297,6 +18403,38 @@ endif
endif endif
INPROC_TEST_SRC = \
test/core/end2end/fixtures/inproc.c \
INPROC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INPROC_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/inproc_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/inproc_test: $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(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) $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(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)/inproc_test
endif
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/inproc.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_inproc_test: $(INPROC_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INPROC_TEST_OBJS:.o=.dep)
endif
endif
H2_CENSUS_NOSEC_TEST_SRC = \ H2_CENSUS_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_census.c \ test/core/end2end/fixtures/h2_census.c \
@ -18577,6 +18715,26 @@ ifneq ($(NO_DEPS),true)
endif endif
INPROC_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/inproc.c \
INPROC_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INPROC_NOSEC_TEST_SRC))))
$(BINDIR)/$(CONFIG)/inproc_nosec_test: $(INPROC_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INPROC_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/inproc_nosec_test
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/inproc.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_inproc_nosec_test: $(INPROC_NOSEC_TEST_OBJS:.o=.dep)
ifneq ($(NO_DEPS),true)
-include $(INPROC_NOSEC_TEST_OBJS:.o=.dep)
endif
API_FUZZER_ONE_ENTRY_SRC = \ API_FUZZER_ONE_ENTRY_SRC = \
test/core/end2end/fuzzers/api_fuzzer.c \ test/core/end2end/fuzzers/api_fuzzer.c \
test/core/util/one_corpus_entry_fuzzer.c \ test/core/util/one_corpus_entry_fuzzer.c \
@ -19073,6 +19231,7 @@ src/core/lib/surface/init_secure.c: $(OPENSSL_DEP)
src/core/plugin_registry/grpc_cronet_plugin_registry.c: $(OPENSSL_DEP) src/core/plugin_registry/grpc_cronet_plugin_registry.c: $(OPENSSL_DEP)
src/core/plugin_registry/grpc_plugin_registry.c: $(OPENSSL_DEP) src/core/plugin_registry/grpc_plugin_registry.c: $(OPENSSL_DEP)
src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP) src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/gts_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP) src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/transport_security.c: $(OPENSSL_DEP) src/core/tsi/transport_security.c: $(OPENSSL_DEP)
src/core/tsi/transport_security_adapter.c: $(OPENSSL_DEP) src/core/tsi/transport_security_adapter.c: $(OPENSSL_DEP)

@ -0,0 +1,17 @@
# Top level ownership
# nothing listed here until GitHub CODEOWNERS gets better
# we need:
# 1. owners to be able to self-approve
# 2. authors to be able to select approvers
# OWNERS file approvers
# POLICY: at least three owners are needed before adding any OWNERS
# REASON: GitHub does not recognize an author as able to give approval
# for a change; without this policy authors that are owners would
# be forced to rely on one reviewer, which would consequently
# lead to a bus factor of one to changes to that code
@markdroth **/OWNERS
@nicolasnoble **/OWNERS
@ctiller **/OWNERS

@ -0,0 +1,5 @@
set noparent
@nicolasnoble
@dgquintas
@ctiller

@ -12,9 +12,8 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mo
srcs: a single proto_library, which wraps the .proto files with services. srcs: a single proto_library, which wraps the .proto files with services.
deps: a list of C++ proto_library (or cc_proto_library) which provides deps: a list of C++ proto_library (or cc_proto_library) which provides
the compiled code of any message that the services depend on. the compiled code of any message that the services depend on.
well_known_protos: The target from protobuf library that exports well well_known_protos: Should this library additionally depend on well known
known protos. Currently it will only work if the value is protos
"@com_google_protobuf//:well_known_protos"
use_external: When True the grpc deps are prefixed with //external. This use_external: When True the grpc deps are prefixed with //external. This
allows grpc to be used as a dependency in other bazel projects. allows grpc to be used as a dependency in other bazel projects.
generate_mock: When true GMOCk code for client stub is generated. generate_mock: When true GMOCk code for client stub is generated.

@ -57,7 +57,7 @@ def generate_cc_impl(ctx):
return struct(files=set(out_files)) return struct(files=set(out_files))
generate_cc = rule( _generate_cc = rule(
attrs = { attrs = {
"srcs": attr.label_list( "srcs": attr.label_list(
mandatory = True, mandatory = True,
@ -90,3 +90,9 @@ generate_cc = rule(
output_to_genfiles = True, output_to_genfiles = True,
implementation = generate_cc_impl, implementation = generate_cc_impl,
) )
def generate_cc(well_known_protos, **kwargs):
if well_known_protos:
_generate_cc(well_known_protos="@com_google_protobuf//:well_known_protos", **kwargs)
else:
_generate_cc(**kwargs)

@ -52,7 +52,7 @@ def grpc_proto_plugin(name, srcs = [], deps = []):
load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library") load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library")
def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = None, def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False,
has_services = True, use_external = False, generate_mock = False): has_services = True, use_external = False, generate_mock = False):
cc_grpc_library( cc_grpc_library(
name = name, name = name,

@ -645,6 +645,7 @@
'src/core/lib/channel/handshaker_registry.c', 'src/core/lib/channel/handshaker_registry.c',
'src/core/lib/compression/compression.c', 'src/core/lib/compression/compression.c',
'src/core/lib/compression/message_compress.c', 'src/core/lib/compression/message_compress.c',
'src/core/lib/compression/stream_compression.c',
'src/core/lib/http/format_request.c', 'src/core/lib/http/format_request.c',
'src/core/lib/http/httpcli.c', 'src/core/lib/http/httpcli.c',
'src/core/lib/http/parser.c', 'src/core/lib/http/parser.c',
@ -813,6 +814,7 @@
'src/core/lib/security/util/json_util.c', 'src/core/lib/security/util/json_util.c',
'src/core/lib/surface/init_secure.c', 'src/core/lib/surface/init_secure.c',
'src/core/tsi/fake_transport_security.c', 'src/core/tsi/fake_transport_security.c',
'src/core/tsi/gts_transport_security.c',
'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/ssl_transport_security.c',
'src/core/tsi/transport_security.c', 'src/core/tsi/transport_security.c',
'src/core/tsi/transport_security_adapter.c', 'src/core/tsi/transport_security_adapter.c',
@ -844,6 +846,8 @@
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
'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/transport/inproc/inproc_plugin.c',
'src/core/ext/transport/inproc/inproc_transport.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',

@ -191,6 +191,7 @@ filegroups:
- src/core/lib/channel/handshaker_registry.h - src/core/lib/channel/handshaker_registry.h
- src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/algorithm_metadata.h
- src/core/lib/compression/message_compress.h - src/core/lib/compression/message_compress.h
- src/core/lib/compression/stream_compression.h
- src/core/lib/http/format_request.h - src/core/lib/http/format_request.h
- src/core/lib/http/httpcli.h - src/core/lib/http/httpcli.h
- src/core/lib/http/parser.h - src/core/lib/http/parser.h
@ -301,6 +302,7 @@ filegroups:
- src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c - src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c - src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/http/format_request.c - src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c - src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c - src/core/lib/http/parser.c
@ -844,6 +846,15 @@ filegroups:
- grpc_base - grpc_base
- grpc_transport_chttp2 - grpc_transport_chttp2
- grpc_http_filters - grpc_http_filters
- name: grpc_transport_inproc
headers:
- src/core/ext/transport/inproc/inproc_transport.h
src:
- src/core/ext/transport/inproc/inproc_plugin.c
- src/core/ext/transport/inproc/inproc_transport.c
plugin: grpc_inproc_plugin
uses:
- grpc_base
- name: grpc_workaround_cronet_compression_filter - name: grpc_workaround_cronet_compression_filter
headers: headers:
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h - src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h
@ -866,6 +877,7 @@ filegroups:
- name: tsi - name: tsi
headers: headers:
- src/core/tsi/fake_transport_security.h - src/core/tsi/fake_transport_security.h
- src/core/tsi/gts_transport_security.h
- src/core/tsi/ssl_transport_security.h - src/core/tsi/ssl_transport_security.h
- src/core/tsi/ssl_types.h - src/core/tsi/ssl_types.h
- src/core/tsi/transport_security.h - src/core/tsi/transport_security.h
@ -873,14 +885,17 @@ filegroups:
- src/core/tsi/transport_security_interface.h - src/core/tsi/transport_security_interface.h
src: src:
- src/core/tsi/fake_transport_security.c - src/core/tsi/fake_transport_security.c
- src/core/tsi/gts_transport_security.c
- src/core/tsi/ssl_transport_security.c - src/core/tsi/ssl_transport_security.c
- src/core/tsi/transport_security.c - src/core/tsi/transport_security.c
- src/core/tsi/transport_security_adapter.c - src/core/tsi/transport_security_adapter.c
deps: deps:
- gpr - gpr
plugin: grpc_tsi_gts
secure: true secure: true
uses: uses:
- grpc_trace - grpc_trace
- grpc_base
- name: grpc++_base - name: grpc++_base
language: c++ language: c++
public_headers: public_headers:
@ -1072,6 +1087,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_transport_inproc
- grpc_lb_policy_grpclb_secure - 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
@ -1175,6 +1191,7 @@ libs:
- grpc_base - grpc_base
- grpc_transport_chttp2_server_insecure - grpc_transport_chttp2_server_insecure
- grpc_transport_chttp2_client_insecure - grpc_transport_chttp2_client_insecure
- grpc_transport_inproc
- grpc_resolver_dns_ares - grpc_resolver_dns_ares
- grpc_resolver_dns_native - grpc_resolver_dns_native
- grpc_resolver_sockaddr - grpc_resolver_sockaddr
@ -3001,6 +3018,16 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: stream_compression_test
build: test
language: c
src:
- test/core/compression/stream_compression_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: stream_owned_slice_test - name: stream_owned_slice_test
build: test build: test
language: c language: c
@ -4165,6 +4192,7 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- grpc++_test_config
platforms: platforms:
- mac - mac
- linux - linux
@ -4283,6 +4311,7 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- grpc++_test_config
platforms: platforms:
- mac - mac
- linux - linux
@ -4360,6 +4389,21 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: server_request_call_test
gtest: true
build: test
language: c++
src:
- src/proto/grpc/testing/echo_messages.proto
- src/proto/grpc/testing/echo.proto
- test/cpp/server/server_request_call_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- gpr_test_util
- grpc++
- grpc
- gpr
- name: shutdown_test - name: shutdown_test
gtest: true gtest: true
build: test build: test

@ -95,6 +95,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.c \
src/core/lib/compression/compression.c \ src/core/lib/compression/compression.c \
src/core/lib/compression/message_compress.c \ src/core/lib/compression/message_compress.c \
src/core/lib/compression/stream_compression.c \
src/core/lib/http/format_request.c \ src/core/lib/http/format_request.c \
src/core/lib/http/httpcli.c \ src/core/lib/http/httpcli.c \
src/core/lib/http/parser.c \ src/core/lib/http/parser.c \
@ -263,6 +264,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/security/util/json_util.c \ src/core/lib/security/util/json_util.c \
src/core/lib/surface/init_secure.c \ src/core/lib/surface/init_secure.c \
src/core/tsi/fake_transport_security.c \ src/core/tsi/fake_transport_security.c \
src/core/tsi/gts_transport_security.c \
src/core/tsi/ssl_transport_security.c \ src/core/tsi/ssl_transport_security.c \
src/core/tsi/transport_security.c \ src/core/tsi/transport_security.c \
src/core/tsi/transport_security_adapter.c \ src/core/tsi/transport_security_adapter.c \
@ -294,6 +296,8 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
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/transport/inproc/inproc_plugin.c \
src/core/ext/transport/inproc/inproc_transport.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
@ -673,6 +677,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/insecure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/insecure)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/debug) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/debug)

@ -72,6 +72,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\channel\\handshaker_registry.c " + "src\\core\\lib\\channel\\handshaker_registry.c " +
"src\\core\\lib\\compression\\compression.c " + "src\\core\\lib\\compression\\compression.c " +
"src\\core\\lib\\compression\\message_compress.c " + "src\\core\\lib\\compression\\message_compress.c " +
"src\\core\\lib\\compression\\stream_compression.c " +
"src\\core\\lib\\http\\format_request.c " + "src\\core\\lib\\http\\format_request.c " +
"src\\core\\lib\\http\\httpcli.c " + "src\\core\\lib\\http\\httpcli.c " +
"src\\core\\lib\\http\\parser.c " + "src\\core\\lib\\http\\parser.c " +
@ -240,6 +241,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\security\\util\\json_util.c " + "src\\core\\lib\\security\\util\\json_util.c " +
"src\\core\\lib\\surface\\init_secure.c " + "src\\core\\lib\\surface\\init_secure.c " +
"src\\core\\tsi\\fake_transport_security.c " + "src\\core\\tsi\\fake_transport_security.c " +
"src\\core\\tsi\\gts_transport_security.c " +
"src\\core\\tsi\\ssl_transport_security.c " + "src\\core\\tsi\\ssl_transport_security.c " +
"src\\core\\tsi\\transport_security.c " + "src\\core\\tsi\\transport_security.c " +
"src\\core\\tsi\\transport_security_adapter.c " + "src\\core\\tsi\\transport_security_adapter.c " +
@ -271,6 +273,8 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\transport\\chttp2\\server\\insecure\\server_chttp2_posix.c " + "src\\core\\ext\\transport\\chttp2\\server\\insecure\\server_chttp2_posix.c " +
"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\\transport\\inproc\\inproc_plugin.c " +
"src\\core\\ext\\transport\\inproc\\inproc_transport.c " +
"src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\client_load_reporting_filter.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\client_load_reporting_filter.c " +
"src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb.c " +
"src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.c " +
@ -685,6 +689,7 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\insecure"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\insecure");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\secure"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\secure");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression");

@ -50,18 +50,23 @@ some configuration as environment variables that can be set.
- channel_stack_builder - traces information about channel stacks being built - channel_stack_builder - traces information about channel stacks being built
- http - traces state in the http2 transport engine - http - traces state in the http2 transport engine
- http1 - traces HTTP/1.x operations performed by gRPC - http1 - traces HTTP/1.x operations performed by gRPC
- inproc - traces the in-process transport
- flowctl - traces http2 flow control - flowctl - traces http2 flow control
- op_failure - traces error information when failure is pushed onto a - op_failure - traces error information when failure is pushed onto a
completion queue completion queue
- round_robin - traces the round_robin load balancing policy - round_robin - traces the round_robin load balancing policy
- pick_first - traces the pick first load balancing policy
- resource_quota - trace resource quota objects internals
- glb - traces the grpclb load balancer - glb - traces the grpclb load balancer
- queue_pluck - queue_pluck
- queue_timeout - queue_timeout
- server_channel - lightweight trace of significant server channel events - server_channel - lightweight trace of significant server channel events
- secure_endpoint - traces bytes flowing through encrypted channels - secure_endpoint - traces bytes flowing through encrypted channels
- timer - timers (alarms) in the grpc internals - timer - timers (alarms) in the grpc internals
- timer_check - more detailed trace of timer logic in grpc internals
- transport_security - traces metadata about secure channel establishment - transport_security - traces metadata about secure channel establishment
- tcp - traces bytes in and out of a channel - tcp - traces bytes in and out of a channel
- tsi - traces tsi transport security
The following tracers will only run in binaries built in DEBUG mode. This is The following tracers will only run in binaries built in DEBUG mode. This is
accomplished by invoking `CONFIG=dbg make <target>` accomplished by invoking `CONFIG=dbg make <target>`
@ -74,6 +79,7 @@ some configuration as environment variables that can be set.
- stream_refcount - stream_refcount
- workqueue_refcount - workqueue_refcount
- fd_refcount - fd_refcount
- cq_refcount
- auth_context_refcount - auth_context_refcount
- security_connector_refcount - security_connector_refcount
- resolver_refcount - resolver_refcount
@ -83,6 +89,11 @@ some configuration as environment variables that can be set.
'all' can additionally be used to turn all traces on. 'all' can additionally be used to turn all traces on.
Individual traces can be disabled by prefixing them with '-'. Individual traces can be disabled by prefixing them with '-'.
'refcount' will turn on all of the tracers for refcount debugging.
if 'list_tracers' is present, then all of the available tracers will be
printed when the program starts up.
Example: Example:
export GRPC_TRACE=all,-pending_tags export GRPC_TRACE=all,-pending_tags

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
licenses(["notice"]) # 3-clause BSD
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//bazel:grpc_build_system.bzl", "grpc_proto_library") load("//bazel:grpc_build_system.bzl", "grpc_proto_library")

@ -254,6 +254,7 @@ Pod::Spec.new do |s|
'src/core/lib/channel/handshaker_registry.h', 'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/algorithm_metadata.h',
'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/message_compress.h',
'src/core/lib/compression/stream_compression.h',
'src/core/lib/http/format_request.h', 'src/core/lib/http/format_request.h',
'src/core/lib/http/httpcli.h', 'src/core/lib/http/httpcli.h',
'src/core/lib/http/parser.h', 'src/core/lib/http/parser.h',
@ -398,6 +399,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/tsi_error.h', 'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h', 'src/core/lib/security/util/json_util.h',
'src/core/tsi/fake_transport_security.h', 'src/core/tsi/fake_transport_security.h',
'src/core/tsi/gts_transport_security.h',
'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/ssl_transport_security.h',
'src/core/tsi/ssl_types.h', 'src/core/tsi/ssl_types.h',
'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security.h',
@ -424,6 +426,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/uri_parser.h', 'src/core/ext/filters/client_channel/uri_parser.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/transport/inproc/inproc_transport.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h',
@ -467,6 +470,7 @@ Pod::Spec.new do |s|
'src/core/lib/channel/handshaker_registry.c', 'src/core/lib/channel/handshaker_registry.c',
'src/core/lib/compression/compression.c', 'src/core/lib/compression/compression.c',
'src/core/lib/compression/message_compress.c', 'src/core/lib/compression/message_compress.c',
'src/core/lib/compression/stream_compression.c',
'src/core/lib/http/format_request.c', 'src/core/lib/http/format_request.c',
'src/core/lib/http/httpcli.c', 'src/core/lib/http/httpcli.c',
'src/core/lib/http/parser.c', 'src/core/lib/http/parser.c',
@ -635,6 +639,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/util/json_util.c', 'src/core/lib/security/util/json_util.c',
'src/core/lib/surface/init_secure.c', 'src/core/lib/surface/init_secure.c',
'src/core/tsi/fake_transport_security.c', 'src/core/tsi/fake_transport_security.c',
'src/core/tsi/gts_transport_security.c',
'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/ssl_transport_security.c',
'src/core/tsi/transport_security.c', 'src/core/tsi/transport_security.c',
'src/core/tsi/transport_security_adapter.c', 'src/core/tsi/transport_security_adapter.c',
@ -666,6 +671,8 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
'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/transport/inproc/inproc_plugin.c',
'src/core/ext/transport/inproc/inproc_transport.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
@ -732,6 +739,7 @@ Pod::Spec.new do |s|
'src/core/lib/channel/handshaker_registry.h', 'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/algorithm_metadata.h',
'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/message_compress.h',
'src/core/lib/compression/stream_compression.h',
'src/core/lib/http/format_request.h', 'src/core/lib/http/format_request.h',
'src/core/lib/http/httpcli.h', 'src/core/lib/http/httpcli.h',
'src/core/lib/http/parser.h', 'src/core/lib/http/parser.h',
@ -876,6 +884,7 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/tsi_error.h', 'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h', 'src/core/lib/security/util/json_util.h',
'src/core/tsi/fake_transport_security.h', 'src/core/tsi/fake_transport_security.h',
'src/core/tsi/gts_transport_security.h',
'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/ssl_transport_security.h',
'src/core/tsi/ssl_types.h', 'src/core/tsi/ssl_types.h',
'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security.h',
@ -902,6 +911,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/uri_parser.h', 'src/core/ext/filters/client_channel/uri_parser.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/transport/inproc/inproc_transport.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h',

@ -186,6 +186,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/handshaker_registry.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h )
s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h )
s.files += %w( src/core/lib/compression/message_compress.h ) s.files += %w( src/core/lib/compression/message_compress.h )
s.files += %w( src/core/lib/compression/stream_compression.h )
s.files += %w( src/core/lib/http/format_request.h ) s.files += %w( src/core/lib/http/format_request.h )
s.files += %w( src/core/lib/http/httpcli.h ) s.files += %w( src/core/lib/http/httpcli.h )
s.files += %w( src/core/lib/http/parser.h ) s.files += %w( src/core/lib/http/parser.h )
@ -330,6 +331,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/transport/tsi_error.h ) s.files += %w( src/core/lib/security/transport/tsi_error.h )
s.files += %w( src/core/lib/security/util/json_util.h ) s.files += %w( src/core/lib/security/util/json_util.h )
s.files += %w( src/core/tsi/fake_transport_security.h ) s.files += %w( src/core/tsi/fake_transport_security.h )
s.files += %w( src/core/tsi/gts_transport_security.h )
s.files += %w( src/core/tsi/ssl_transport_security.h ) s.files += %w( src/core/tsi/ssl_transport_security.h )
s.files += %w( src/core/tsi/ssl_types.h ) s.files += %w( src/core/tsi/ssl_types.h )
s.files += %w( src/core/tsi/transport_security.h ) s.files += %w( src/core/tsi/transport_security.h )
@ -356,6 +358,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h )
s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.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/transport/inproc/inproc_transport.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h )
@ -403,6 +406,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/handshaker_registry.c ) s.files += %w( src/core/lib/channel/handshaker_registry.c )
s.files += %w( src/core/lib/compression/compression.c ) s.files += %w( src/core/lib/compression/compression.c )
s.files += %w( src/core/lib/compression/message_compress.c ) s.files += %w( src/core/lib/compression/message_compress.c )
s.files += %w( src/core/lib/compression/stream_compression.c )
s.files += %w( src/core/lib/http/format_request.c ) s.files += %w( src/core/lib/http/format_request.c )
s.files += %w( src/core/lib/http/httpcli.c ) s.files += %w( src/core/lib/http/httpcli.c )
s.files += %w( src/core/lib/http/parser.c ) s.files += %w( src/core/lib/http/parser.c )
@ -571,6 +575,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/util/json_util.c ) s.files += %w( src/core/lib/security/util/json_util.c )
s.files += %w( src/core/lib/surface/init_secure.c ) s.files += %w( src/core/lib/surface/init_secure.c )
s.files += %w( src/core/tsi/fake_transport_security.c ) s.files += %w( src/core/tsi/fake_transport_security.c )
s.files += %w( src/core/tsi/gts_transport_security.c )
s.files += %w( src/core/tsi/ssl_transport_security.c ) s.files += %w( src/core/tsi/ssl_transport_security.c )
s.files += %w( src/core/tsi/transport_security.c ) s.files += %w( src/core/tsi/transport_security.c )
s.files += %w( src/core/tsi/transport_security_adapter.c ) s.files += %w( src/core/tsi/transport_security_adapter.c )
@ -602,6 +607,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c ) s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.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.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/transport/inproc/inproc_plugin.c )
s.files += %w( src/core/ext/transport/inproc/inproc_transport.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c )

@ -19,8 +19,6 @@
#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H #ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H
#define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H #define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H
#define GRPC_OPEN_SOURCE_PROTO
#ifndef GRPC_CUSTOM_PROTOBUF_INT64 #ifndef GRPC_CUSTOM_PROTOBUF_INT64
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64 #define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64

@ -60,6 +60,10 @@ class CoreCodegen final : public CoreCodegenInterface {
void gpr_cv_signal(gpr_cv* cv) override; void gpr_cv_signal(gpr_cv* cv) override;
void gpr_cv_broadcast(gpr_cv* cv) override; void gpr_cv_broadcast(gpr_cv* cv) override;
grpc_call_error grpc_call_cancel_with_status(grpc_call* call,
grpc_status_code status,
const char* description,
void* reserved) override;
void grpc_call_ref(grpc_call* call) override; void grpc_call_ref(grpc_call* call) override;
void grpc_call_unref(grpc_call* call) override; void grpc_call_unref(grpc_call* call) override;
virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) override; virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) override;

@ -89,6 +89,10 @@ class CoreCodegenInterface {
virtual grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, virtual grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
void (*destroy)(void*), void (*destroy)(void*),
void* user_data) = 0; void* user_data) = 0;
virtual grpc_call_error grpc_call_cancel_with_status(grpc_call* call,
grpc_status_code status,
const char* description,
void* reserved) = 0;
virtual void grpc_call_ref(grpc_call* call) = 0; virtual void grpc_call_ref(grpc_call* call) = 0;
virtual void grpc_call_unref(grpc_call* call) = 0; virtual void grpc_call_unref(grpc_call* call) = 0;
virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) = 0; virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) = 0;

@ -39,7 +39,8 @@ class GrpcBufferWriterPeer;
const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024; const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024;
class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream { class GrpcBufferWriter final
: public ::grpc::protobuf::io::ZeroCopyOutputStream {
public: public:
explicit GrpcBufferWriter(grpc_byte_buffer** bp, int block_size) explicit GrpcBufferWriter(grpc_byte_buffer** bp, int block_size)
: block_size_(block_size), byte_count_(0), have_backup_(false) { : block_size_(block_size), byte_count_(0), have_backup_(false) {
@ -87,8 +88,6 @@ class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
grpc::protobuf::int64 ByteCount() const override { return byte_count_; } grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
grpc_slice_buffer* SliceBuffer() { return slice_buffer_; }
private: private:
friend class GrpcBufferWriterPeer; friend class GrpcBufferWriterPeer;
const int block_size_; const int block_size_;
@ -99,7 +98,8 @@ class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
grpc_slice slice_; grpc_slice slice_;
}; };
class GrpcBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { class GrpcBufferReader final
: public ::grpc::protobuf::io::ZeroCopyInputStream {
public: public:
explicit GrpcBufferReader(grpc_byte_buffer* buffer) explicit GrpcBufferReader(grpc_byte_buffer* buffer)
: byte_count_(0), backup_count_(0), status_() { : byte_count_(0), backup_count_(0), status_() {
@ -160,7 +160,7 @@ class GrpcBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream {
return byte_count_ - backup_count_; return byte_count_ - backup_count_;
} }
protected: private:
int64_t byte_count_; int64_t byte_count_;
int64_t backup_count_; int64_t backup_count_;
grpc_byte_buffer_reader reader_; grpc_byte_buffer_reader reader_;
@ -168,12 +168,14 @@ class GrpcBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream {
Status status_; Status status_;
}; };
template <class BufferWriter, class T> } // namespace internal
Status GenericSerialize(const grpc::protobuf::Message& msg,
template <class T>
class SerializationTraits<T, typename std::enable_if<std::is_base_of<
grpc::protobuf::Message, T>::value>::type> {
public:
static Status Serialize(const grpc::protobuf::Message& msg,
grpc_byte_buffer** bp, bool* own_buffer) { grpc_byte_buffer** bp, bool* own_buffer) {
static_assert(
std::is_base_of<protobuf::io::ZeroCopyOutputStream, BufferWriter>::value,
"BufferWriter must be a subclass of io::ZeroCopyOutputStream");
*own_buffer = true; *own_buffer = true;
int byte_size = msg.ByteSize(); int byte_size = msg.ByteSize();
if (byte_size <= internal::kGrpcBufferWriterMaxBufferLength) { if (byte_size <= internal::kGrpcBufferWriterMaxBufferLength) {
@ -185,25 +187,22 @@ Status GenericSerialize(const grpc::protobuf::Message& msg,
g_core_codegen_interface->grpc_slice_unref(slice); g_core_codegen_interface->grpc_slice_unref(slice);
return g_core_codegen_interface->ok(); return g_core_codegen_interface->ok();
} else { } else {
BufferWriter writer(bp, internal::kGrpcBufferWriterMaxBufferLength); internal::GrpcBufferWriter writer(
bp, internal::kGrpcBufferWriterMaxBufferLength);
return msg.SerializeToZeroCopyStream(&writer) return msg.SerializeToZeroCopyStream(&writer)
? g_core_codegen_interface->ok() ? g_core_codegen_interface->ok()
: Status(StatusCode::INTERNAL, "Failed to serialize message"); : Status(StatusCode::INTERNAL, "Failed to serialize message");
} }
} }
template <class BufferReader, class T> static Status Deserialize(grpc_byte_buffer* buffer,
Status GenericDeserialize(grpc_byte_buffer* buffer,
grpc::protobuf::Message* msg) { grpc::protobuf::Message* msg) {
static_assert(
std::is_base_of<protobuf::io::ZeroCopyInputStream, BufferReader>::value,
"BufferReader must be a subclass of io::ZeroCopyInputStream");
if (buffer == nullptr) { if (buffer == nullptr) {
return Status(StatusCode::INTERNAL, "No payload"); return Status(StatusCode::INTERNAL, "No payload");
} }
Status result = g_core_codegen_interface->ok(); Status result = g_core_codegen_interface->ok();
{ {
BufferReader reader(buffer); internal::GrpcBufferReader reader(buffer);
if (!reader.status().ok()) { if (!reader.status().ok()) {
return reader.status(); return reader.status();
} }
@ -218,33 +217,8 @@ Status GenericDeserialize(grpc_byte_buffer* buffer,
} }
g_core_codegen_interface->grpc_byte_buffer_destroy(buffer); g_core_codegen_interface->grpc_byte_buffer_destroy(buffer);
return result; return result;
}
} // namespace internal
// this is needed so the following class does not conflict with protobuf
// serializers that utilize internal-only tools.
#ifdef GRPC_OPEN_SOURCE_PROTO
// This class provides a protobuf serializer. It translates between protobuf
// objects and grpc_byte_buffers. More information about SerializationTraits can
// be found in include/grpc++/impl/codegen/serialization_traits.h.
template <class T>
class SerializationTraits<T, typename std::enable_if<std::is_base_of<
grpc::protobuf::Message, T>::value>::type> {
public:
static Status Serialize(const grpc::protobuf::Message& msg,
grpc_byte_buffer** bp, bool* own_buffer) {
return internal::GenericSerialize<internal::GrpcBufferWriter, T>(
msg, bp, own_buffer);
}
static Status Deserialize(grpc_byte_buffer* buffer,
grpc::protobuf::Message* msg) {
return internal::GenericDeserialize<internal::GrpcBufferReader, T>(buffer,
msg);
} }
}; };
#endif
} // namespace grpc } // namespace grpc

@ -28,6 +28,7 @@
namespace grpc { namespace grpc {
class AsyncGenericService; class AsyncGenericService;
class Channel;
class GenericServerContext; class GenericServerContext;
class ServerCompletionQueue; class ServerCompletionQueue;
class ServerContext; class ServerContext;
@ -176,22 +177,49 @@ class ServerInterface : public internal::CallHook {
ServerCompletionQueue* notification_cq, void* tag, ServerCompletionQueue* notification_cq, void* tag,
Message* request) Message* request)
: RegisteredAsyncRequest(server, context, stream, call_cq, tag), : RegisteredAsyncRequest(server, context, stream, call_cq, tag),
registered_method_(registered_method),
server_(server),
context_(context),
stream_(stream),
call_cq_(call_cq),
notification_cq_(notification_cq),
tag_(tag),
request_(request) { request_(request) {
IssueRequest(registered_method, &payload_, notification_cq); IssueRequest(registered_method, &payload_, notification_cq);
} }
bool FinalizeResult(void** tag, bool* status) override { bool FinalizeResult(void** tag, bool* status) override {
bool serialization_status = if (*status) {
*status && payload_ && if (payload_ == nullptr ||
SerializationTraits<Message>::Deserialize(payload_, request_).ok(); !SerializationTraits<Message>::Deserialize(payload_, request_)
bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status); .ok()) {
*status = serialization_status && *status; // If deserialization fails, we cancel the call and instantiate
return ret; // a new instance of ourselves to request another call. We then
// return false, which prevents the call from being returned to
// the application.
g_core_codegen_interface->grpc_call_cancel_with_status(
call_, GRPC_STATUS_INTERNAL, "Unable to parse request", nullptr);
g_core_codegen_interface->grpc_call_unref(call_);
new PayloadAsyncRequest(registered_method_, server_, context_,
stream_, call_cq_, notification_cq_, tag_,
request_);
delete this;
return false;
}
}
return RegisteredAsyncRequest::FinalizeResult(tag, status);
} }
private: private:
grpc_byte_buffer* payload_; void* const registered_method_;
ServerInterface* const server_;
ServerContext* const context_;
internal::ServerAsyncStreamingInterface* const stream_;
CompletionQueue* const call_cq_;
ServerCompletionQueue* const notification_cq_;
void* const tag_;
Message* const request_; Message* const request_;
grpc_byte_buffer* payload_;
}; };
class GenericAsyncRequest : public BaseAsyncRequest { class GenericAsyncRequest : public BaseAsyncRequest {

@ -63,6 +63,11 @@ class Status {
/// Is the status OK? /// Is the status OK?
bool ok() const { return code_ == StatusCode::OK; } bool ok() const { return code_ == StatusCode::OK; }
// Ignores any errors. This method does nothing except potentially suppress
// complaints from any tools that are checking that errors are not dropped on
// the floor.
void IgnoreError() const {}
private: private:
StatusCode code_; StatusCode code_;
grpc::string error_message_; grpc::string error_message_;

@ -132,13 +132,17 @@ std::shared_ptr<ChannelCredentials> SslCredentials(
/// services. /// services.
std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials(); std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials();
/// Constant for maximum auth token lifetime.
constexpr long kMaxAuthTokenLifetimeSecs = 3600;
/// Builds Service Account JWT Access credentials. /// Builds Service Account JWT Access credentials.
/// json_key is the JSON key string containing the client's private key. /// json_key is the JSON key string containing the client's private key.
/// token_lifetime_seconds is the lifetime in seconds of each Json Web Token /// token_lifetime_seconds is the lifetime in seconds of each Json Web Token
/// (JWT) created with this credentials. It should not exceed /// (JWT) created with this credentials. It should not exceed
/// \a grpc_max_auth_token_lifetime or will be cropped to this value. /// \a kMaxAuthTokenLifetimeSecs or will be cropped to this value.
std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials( std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials(
const grpc::string& json_key, long token_lifetime_seconds); const grpc::string& json_key,
long token_lifetime_seconds = kMaxAuthTokenLifetimeSecs);
/// Builds refresh token credentials. /// Builds refresh token credentials.
/// json_refresh_token is the JSON string containing the refresh token along /// json_refresh_token is the JSON string containing the refresh token along

@ -95,6 +95,9 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
return health_check_service_.get(); return health_check_service_.get();
} }
/// Establish a channel for in-process communication
std::shared_ptr<Channel> InProcessChannel(const ChannelArguments& args);
private: private:
friend class AsyncGenericService; friend class AsyncGenericService;
friend class ServerBuilder; friend class ServerBuilder;

@ -56,7 +56,7 @@
}, },
"binary": { "binary": {
"module_name": "grpc_node", "module_name": "grpc_node",
"module_path": "src/node/extension_binary", "module_path": "src/node/extension_binary/{node_abi}-{platform}-{arch}",
"host": "https://storage.googleapis.com/", "host": "https://storage.googleapis.com/",
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}", "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
"package_name": "{node_abi}-{platform}-{arch}.tar.gz" "package_name": "{node_abi}-{platform}-{arch}.tar.gz"

@ -200,6 +200,7 @@
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/algorithm_metadata.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/compression/algorithm_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/message_compress.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/compression/message_compress.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/stream_compression.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/format_request.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/http/format_request.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/httpcli.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/http/httpcli.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/parser.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/http/parser.h" role="src" />
@ -344,6 +345,7 @@
<file baseinstalldir="/" name="src/core/lib/security/transport/tsi_error.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/transport/tsi_error.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/util/json_util.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/util/json_util.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/fake_transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/gts_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_types.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl_types.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security.h" role="src" />
@ -370,6 +372,7 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.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/transport/inproc/inproc_transport.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h" role="src" />
@ -417,6 +420,7 @@
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/compression.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/compression/compression.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/message_compress.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/compression/message_compress.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/stream_compression.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/format_request.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/http/format_request.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/httpcli.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/http/httpcli.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/parser.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/http/parser.c" role="src" />
@ -585,6 +589,7 @@
<file baseinstalldir="/" name="src/core/lib/security/util/json_util.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/security/util/json_util.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/init_secure.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/init_secure.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/fake_transport_security.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/gts_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.c" role="src" />
@ -616,6 +621,8 @@
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.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.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/transport/inproc/inproc_plugin.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c" role="src" />

@ -0,0 +1,4 @@
set noparent
@markdroth
@dgquintas
@ctiller

@ -52,7 +52,8 @@
/* Client channel implementation */ /* Client channel implementation */
grpc_tracer_flag grpc_client_channel_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_client_channel_trace =
GRPC_TRACER_INITIALIZER(false, "client_channel");
/************************************************************************* /*************************************************************************
* METHOD-CONFIG TABLE * METHOD-CONFIG TABLE
@ -370,6 +371,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
grpc_error_string(error)); grpc_error_string(error));
} }
// Extract the following fields from the resolver result, if non-NULL. // Extract the following fields from the resolver result, if non-NULL.
bool lb_policy_updated = false;
char *lb_policy_name = NULL; char *lb_policy_name = NULL;
bool lb_policy_name_changed = false; bool lb_policy_name_changed = false;
grpc_lb_policy *new_lb_policy = NULL; grpc_lb_policy *new_lb_policy = NULL;
@ -424,6 +426,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
strcmp(chand->info_lb_policy_name, lb_policy_name) != 0; strcmp(chand->info_lb_policy_name, lb_policy_name) != 0;
if (chand->lb_policy != NULL && !lb_policy_name_changed) { if (chand->lb_policy != NULL && !lb_policy_name_changed) {
// Continue using the same LB policy. Update with new addresses. // Continue using the same LB policy. Update with new addresses.
lb_policy_updated = true;
grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args); grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args);
} else { } else {
// Instantiate new LB policy. // Instantiate new LB policy.
@ -569,8 +572,11 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
} }
watch_lb_policy_locked(exec_ctx, chand, new_lb_policy, state); watch_lb_policy_locked(exec_ctx, chand, new_lb_policy, state);
} }
set_channel_connectivity_state_locked( if (!lb_policy_updated) {
exec_ctx, chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver"); set_channel_connectivity_state_locked(exec_ctx, chand, state,
GRPC_ERROR_REF(state_error),
"new_lb+resolver");
}
grpc_resolver_next_locked(exec_ctx, chand->resolver, grpc_resolver_next_locked(exec_ctx, chand->resolver,
&chand->resolver_result, &chand->resolver_result,
&chand->on_resolver_result_changed); &chand->on_resolver_result_changed);

@ -78,9 +78,9 @@ void grpc_client_channel_init(void) {
GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter,
(void *)&grpc_client_channel_filter); (void *)&grpc_client_channel_filter);
grpc_http_connect_register_handshaker_factory(); grpc_http_connect_register_handshaker_factory();
grpc_register_tracer("client_channel", &grpc_client_channel_trace); grpc_register_tracer(&grpc_client_channel_trace);
#ifndef NDEBUG #ifndef NDEBUG
grpc_register_tracer("resolver_refcount", &grpc_trace_resolver_refcount); grpc_register_tracer(&grpc_trace_resolver_refcount);
#endif #endif
} }

@ -22,7 +22,8 @@
#define WEAK_REF_BITS 16 #define WEAK_REF_BITS 16
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_lb_policy_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_lb_policy_refcount =
GRPC_TRACER_INITIALIZER(false, "lb_policy_refcount");
#endif #endif
void grpc_lb_policy_init(grpc_lb_policy *policy, void grpc_lb_policy_init(grpc_lb_policy *policy,

@ -123,7 +123,7 @@
#define GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS 120 #define GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS 120
#define GRPC_GRPCLB_RECONNECT_JITTER 0.2 #define GRPC_GRPCLB_RECONNECT_JITTER 0.2
grpc_tracer_flag grpc_lb_glb_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_lb_glb_trace = GRPC_TRACER_INITIALIZER(false, "glb");
/* add lb_token of selected subchannel (address) to the call's initial /* add lb_token of selected subchannel (address) to the call's initial
* metadata */ * metadata */
@ -1879,9 +1879,9 @@ static bool maybe_add_client_load_reporting_filter(
void grpc_lb_policy_grpclb_init() { void grpc_lb_policy_grpclb_init() {
grpc_register_lb_policy(grpc_glb_lb_factory_create()); grpc_register_lb_policy(grpc_glb_lb_factory_create());
grpc_register_tracer("glb", &grpc_lb_glb_trace); grpc_register_tracer(&grpc_lb_glb_trace);
#ifndef NDEBUG #ifndef NDEBUG
grpc_register_tracer("lb_policy_refcount", &grpc_trace_lb_policy_refcount); grpc_register_tracer(&grpc_trace_lb_policy_refcount);
#endif #endif
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,

@ -28,7 +28,8 @@
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/connectivity_state.h"
grpc_tracer_flag grpc_lb_pick_first_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_lb_pick_first_trace =
GRPC_TRACER_INITIALIZER(false, "pick_first");
typedef struct pending_pick { typedef struct pending_pick {
struct pending_pick *next; struct pending_pick *next;
@ -707,7 +708,7 @@ static grpc_lb_policy_factory *pick_first_lb_factory_create() {
void grpc_lb_policy_pick_first_init() { void grpc_lb_policy_pick_first_init() {
grpc_register_lb_policy(pick_first_lb_factory_create()); grpc_register_lb_policy(pick_first_lb_factory_create());
grpc_register_tracer("pick_first", &grpc_lb_pick_first_trace); grpc_register_tracer(&grpc_lb_pick_first_trace);
} }
void grpc_lb_policy_pick_first_shutdown() {} void grpc_lb_policy_pick_first_shutdown() {}

@ -37,7 +37,8 @@
#include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/static_metadata.h"
grpc_tracer_flag grpc_lb_round_robin_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_lb_round_robin_trace =
GRPC_TRACER_INITIALIZER(false, "round_robin");
/** List of entities waiting for a pick. /** List of entities waiting for a pick.
* *
@ -141,6 +142,21 @@ struct rr_subchannel_list {
bool shutting_down; bool shutting_down;
}; };
static rr_subchannel_list *rr_subchannel_list_create(round_robin_lb_policy *p,
size_t num_subchannels) {
rr_subchannel_list *subchannel_list = gpr_zalloc(sizeof(*subchannel_list));
subchannel_list->policy = p;
subchannel_list->subchannels =
gpr_zalloc(sizeof(subchannel_data) * num_subchannels);
subchannel_list->num_subchannels = num_subchannels;
gpr_ref_init(&subchannel_list->refcount, 1);
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_INFO, "[RR %p] Created subchannel list %p for %lu subchannels",
(void *)p, (void *)subchannel_list, (unsigned long)num_subchannels);
}
return subchannel_list;
}
static void rr_subchannel_list_destroy(grpc_exec_ctx *exec_ctx, static void rr_subchannel_list_destroy(grpc_exec_ctx *exec_ctx,
rr_subchannel_list *subchannel_list) { rr_subchannel_list *subchannel_list) {
GPR_ASSERT(subchannel_list->shutting_down); GPR_ASSERT(subchannel_list->shutting_down);
@ -158,6 +174,7 @@ static void rr_subchannel_list_destroy(grpc_exec_ctx *exec_ctx,
if (sd->user_data != NULL) { if (sd->user_data != NULL) {
GPR_ASSERT(sd->user_data_vtable != NULL); GPR_ASSERT(sd->user_data_vtable != NULL);
sd->user_data_vtable->destroy(exec_ctx, sd->user_data); sd->user_data_vtable->destroy(exec_ctx, sd->user_data);
sd->user_data = NULL;
} }
} }
gpr_free(subchannel_list->subchannels); gpr_free(subchannel_list->subchannels);
@ -169,9 +186,9 @@ static void rr_subchannel_list_ref(rr_subchannel_list *subchannel_list,
gpr_ref_non_zero(&subchannel_list->refcount); gpr_ref_non_zero(&subchannel_list->refcount);
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count); const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
gpr_log(GPR_INFO, "[RR %p] subchannel_list %p REF %lu->%lu", gpr_log(GPR_INFO, "[RR %p] subchannel_list %p REF %lu->%lu (%s)",
(void *)subchannel_list->policy, (void *)subchannel_list, (void *)subchannel_list->policy, (void *)subchannel_list,
(unsigned long)(count - 1), (unsigned long)count); (unsigned long)(count - 1), (unsigned long)count, reason);
} }
} }
@ -181,9 +198,9 @@ static void rr_subchannel_list_unref(grpc_exec_ctx *exec_ctx,
const bool done = gpr_unref(&subchannel_list->refcount); const bool done = gpr_unref(&subchannel_list->refcount);
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count); const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
gpr_log(GPR_INFO, "[RR %p] subchannel_list %p UNREF %lu->%lu", gpr_log(GPR_INFO, "[RR %p] subchannel_list %p UNREF %lu->%lu (%s)",
(void *)subchannel_list->policy, (void *)subchannel_list, (void *)subchannel_list->policy, (void *)subchannel_list,
(unsigned long)(count + 1), (unsigned long)count); (unsigned long)(count + 1), (unsigned long)count, reason);
} }
if (done) { if (done) {
rr_subchannel_list_destroy(exec_ctx, subchannel_list); rr_subchannel_list_destroy(exec_ctx, subchannel_list);
@ -192,19 +209,13 @@ static void rr_subchannel_list_unref(grpc_exec_ctx *exec_ctx,
/** Mark \a subchannel_list as discarded. Unsubscribes all its subchannels. The /** Mark \a subchannel_list as discarded. Unsubscribes all its subchannels. The
* watcher's callback will ultimately unref \a subchannel_list. */ * watcher's callback will ultimately unref \a subchannel_list. */
static void rr_subchannel_list_shutdown(grpc_exec_ctx *exec_ctx, static void rr_subchannel_list_shutdown_and_unref(
rr_subchannel_list *subchannel_list, grpc_exec_ctx *exec_ctx, rr_subchannel_list *subchannel_list,
const char *reason) { const char *reason) {
if (subchannel_list->shutting_down) { GPR_ASSERT(!subchannel_list->shutting_down);
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "Subchannel list %p already shutting down", gpr_log(GPR_DEBUG, "[RR %p] Shutting down subchannel_list %p (%s)",
(void *)subchannel_list); (void *)subchannel_list->policy, (void *)subchannel_list, reason);
}
return;
};
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "Shutting down subchannel_list %p",
(void *)subchannel_list);
} }
GPR_ASSERT(!subchannel_list->shutting_down); GPR_ASSERT(!subchannel_list->shutting_down);
subchannel_list->shutting_down = true; subchannel_list->shutting_down = true;
@ -212,10 +223,12 @@ static void rr_subchannel_list_shutdown(grpc_exec_ctx *exec_ctx,
subchannel_data *sd = &subchannel_list->subchannels[i]; subchannel_data *sd = &subchannel_list->subchannels[i];
if (sd->subchannel != NULL) { // if subchannel isn't shutdown, unsubscribe. if (sd->subchannel != NULL) { // if subchannel isn't shutdown, unsubscribe.
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, gpr_log(
"Unsubscribing from subchannel %p as part of shutting down " GPR_DEBUG,
"[RR %p] Unsubscribing from subchannel %p as part of shutting down "
"subchannel_list %p", "subchannel_list %p",
(void *)sd->subchannel, (void *)subchannel_list); (void *)subchannel_list->policy, (void *)sd->subchannel,
(void *)subchannel_list);
} }
grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL,
NULL, NULL,
@ -292,7 +305,8 @@ static void update_last_ready_subchannel_index_locked(round_robin_lb_policy *p,
static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol; round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "Destroying Round Robin policy at %p", (void *)pol); gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy at %p",
(void *)pol, (void *)pol);
} }
grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker); grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
gpr_free(p); gpr_free(p);
@ -301,7 +315,8 @@ static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void rr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { static void rr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol; round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "Shutting down Round Robin policy at %p", (void *)pol); gpr_log(GPR_DEBUG, "[RR %p] Shutting down Round Robin policy at %p",
(void *)pol, (void *)pol);
} }
p->shutdown = true; p->shutdown = true;
pending_pick *pp; pending_pick *pp;
@ -316,9 +331,18 @@ static void rr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
grpc_connectivity_state_set( grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN, exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "rr_shutdown"); GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "rr_shutdown");
rr_subchannel_list_shutdown(exec_ctx, p->subchannel_list, const bool latest_is_current =
p->subchannel_list == p->latest_pending_subchannel_list;
rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"sl_shutdown_rr_shutdown"); "sl_shutdown_rr_shutdown");
p->subchannel_list = NULL; p->subchannel_list = NULL;
if (!latest_is_current && p->latest_pending_subchannel_list != NULL &&
!p->latest_pending_subchannel_list->shutting_down) {
rr_subchannel_list_shutdown_and_unref(exec_ctx,
p->latest_pending_subchannel_list,
"sl_shutdown_pending_rr_shutdown");
p->latest_pending_subchannel_list = NULL;
}
} }
static void rr_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, static void rr_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
@ -374,8 +398,8 @@ static void start_picking_locked(grpc_exec_ctx *exec_ctx,
p->started_picking = true; p->started_picking = true;
for (size_t i = 0; i < p->subchannel_list->num_subchannels; i++) { for (size_t i = 0; i < p->subchannel_list->num_subchannels; i++) {
subchannel_data *sd = &p->subchannel_list->subchannels[i]; subchannel_data *sd = &p->subchannel_list->subchannels[i];
GRPC_LB_POLICY_WEAK_REF(&p->base, "rr_connectivity"); GRPC_LB_POLICY_WEAK_REF(&p->base, "start_picking_locked");
rr_subchannel_list_ref(sd->subchannel_list, "start_picking"); rr_subchannel_list_ref(sd->subchannel_list, "started_picking");
grpc_subchannel_notify_on_state_change( grpc_subchannel_notify_on_state_change(
exec_ctx, sd->subchannel, p->base.interested_parties, exec_ctx, sd->subchannel, p->base.interested_parties,
&sd->pending_connectivity_state_unsafe, &sd->pending_connectivity_state_unsafe,
@ -397,7 +421,7 @@ static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_closure *on_complete) { grpc_closure *on_complete) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol; round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_INFO, "Round Robin %p trying to pick", (void *)pol); gpr_log(GPR_INFO, "[RR %p] Trying to pick", (void *)pol);
} }
if (p->subchannel_list != NULL) { if (p->subchannel_list != NULL) {
const size_t next_ready_index = get_next_ready_subchannel_index_locked(p); const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
@ -413,8 +437,8 @@ static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log( gpr_log(
GPR_DEBUG, GPR_DEBUG,
"[RR %p] PICKED TARGET <-- SUBCHANNEL %p (CONNECTED %p) (SL %p, " "[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, "
"INDEX %lu)", "index %lu)",
(void *)p, (void *)sd->subchannel, (void *)*target, (void *)p, (void *)sd->subchannel, (void *)*target,
(void *)sd->subchannel_list, (unsigned long)next_ready_index); (void *)sd->subchannel_list, (unsigned long)next_ready_index);
} }
@ -543,22 +567,27 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
} }
// If the policy is shutting down, unref and return. // If the policy is shutting down, unref and return.
if (p->shutdown) { if (p->shutdown) {
rr_subchannel_list_unref(exec_ctx, sd->subchannel_list, "pol_shutdown"); rr_subchannel_list_unref(exec_ctx, sd->subchannel_list,
"pol_shutdown+started_picking");
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pol_shutdown"); GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pol_shutdown");
return; return;
} }
if (sd->subchannel_list->shutting_down && error == GRPC_ERROR_CANCELLED) { if (sd->subchannel_list->shutting_down && error == GRPC_ERROR_CANCELLED) {
// the subchannel list associated with sd has been discarded. This callback // the subchannel list associated with sd has been discarded. This callback
// corresponds to the unsubscription. // corresponds to the unsubscription. The unrefs correspond to the picking
rr_subchannel_list_unref(exec_ctx, sd->subchannel_list, "sl_shutdown"); // ref (start_picking_locked or update_started_picking).
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "sl_shutdown"); rr_subchannel_list_unref(exec_ctx, sd->subchannel_list,
"sl_shutdown+started_picking");
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "sl_shutdown+picking");
return; return;
} }
// Dispose of outdated subchannel lists. // Dispose of outdated subchannel lists.
if (sd->subchannel_list != p->subchannel_list && if (sd->subchannel_list != p->subchannel_list &&
sd->subchannel_list != p->latest_pending_subchannel_list) { sd->subchannel_list != p->latest_pending_subchannel_list) {
// sd belongs to an outdated subchannel_list: get rid of it. // sd belongs to an outdated subchannel_list: get rid of it.
rr_subchannel_list_shutdown(exec_ctx, sd->subchannel_list, "sl_oudated"); rr_subchannel_list_shutdown_and_unref(exec_ctx, sd->subchannel_list,
"sl_outdated");
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "sl_outdated");
return; return;
} }
// Now that we're inside the combiner, copy the pending connectivity // Now that we're inside the combiner, copy the pending connectivity
@ -578,9 +607,10 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
if (sd->user_data != NULL) { if (sd->user_data != NULL) {
GPR_ASSERT(sd->user_data_vtable != NULL); GPR_ASSERT(sd->user_data_vtable != NULL);
sd->user_data_vtable->destroy(exec_ctx, sd->user_data); sd->user_data_vtable->destroy(exec_ctx, sd->user_data);
sd->user_data = NULL;
} }
if (new_policy_connectivity_state == GRPC_CHANNEL_SHUTDOWN) { if (new_policy_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
/* the policy is shutting down. Flush all the pending picks... */ // the policy is shutting down. Flush all the pending picks...
pending_pick *pp; pending_pick *pp;
while ((pp = p->pending_picks)) { while ((pp = p->pending_picks)) {
p->pending_picks = pp->next; p->pending_picks = pp->next;
@ -589,8 +619,9 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(pp); gpr_free(pp);
} }
} }
/* unref the "rr_connectivity" weak ref from start_picking */ rr_subchannel_list_unref(exec_ctx, sd->subchannel_list,
rr_subchannel_list_unref(exec_ctx, sd->subchannel_list, "sd_shutdown"); "sd_shutdown+started_picking");
// unref the "rr_connectivity_update" weak ref from start_picking.
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base,
"rr_connectivity_sd_shutdown"); "rr_connectivity_sd_shutdown");
} else { // sd not in SHUTDOWN } else { // sd not in SHUTDOWN
@ -615,10 +646,10 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
} }
if (p->subchannel_list != NULL) { if (p->subchannel_list != NULL) {
// dispose of the current subchannel_list // dispose of the current subchannel_list
rr_subchannel_list_shutdown(exec_ctx, p->subchannel_list, rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"sl_shutdown_rr_update_connectivity"); "sl_phase_out_shutdown");
} }
p->subchannel_list = sd->subchannel_list; p->subchannel_list = p->latest_pending_subchannel_list;
p->latest_pending_subchannel_list = NULL; p->latest_pending_subchannel_list = NULL;
} }
/* at this point we know there's at least one suitable subchannel. Go /* at this point we know there's at least one suitable subchannel. Go
@ -629,8 +660,8 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
subchannel_data *selected = subchannel_data *selected =
&p->subchannel_list->subchannels[next_ready_index]; &p->subchannel_list->subchannels[next_ready_index];
if (p->pending_picks != NULL) { if (p->pending_picks != NULL) {
/* if the selected subchannel is going to be used for the pending // if the selected subchannel is going to be used for the pending
* picks, update the last picked pointer */ // picks, update the last picked pointer
update_last_ready_subchannel_index_locked(p, next_ready_index); update_last_ready_subchannel_index_locked(p, next_ready_index);
} }
pending_pick *pp; pending_pick *pp;
@ -644,16 +675,17 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
} }
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, gpr_log(GPR_DEBUG,
"[RR CONN CHANGED] TARGET <-- SUBCHANNEL %p (INDEX %lu)", "[RR %p] Fulfilling pending pick. Target <-- subchannel %p "
(void *)selected->subchannel, "(subchannel_list %p, index %lu)",
(unsigned long)next_ready_index); (void *)p, (void *)selected->subchannel,
(void *)p->subchannel_list, (unsigned long)next_ready_index);
} }
GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
gpr_free(pp); gpr_free(pp);
} }
} }
/* renew notification: reuses the "rr_connectivity" weak ref on the policy /* renew notification: reuses the "rr_connectivity_update" weak ref on the
* as well as the sd->subchannel_list ref. */ * policy as well as the sd->subchannel_list ref. */
grpc_subchannel_notify_on_state_change( grpc_subchannel_notify_on_state_change(
exec_ctx, sd->subchannel, p->base.interested_parties, exec_ctx, sd->subchannel, p->base.interested_parties,
&sd->pending_connectivity_state_unsafe, &sd->pending_connectivity_state_unsafe,
@ -711,8 +743,7 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
} else { } else {
// otherwise, keep using the current subchannel list (ignore this update). // otherwise, keep using the current subchannel list (ignore this update).
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"No valid LB addresses channel arg for Round Robin %p update, " "[RR %p] No valid LB addresses channel arg for update, ignoring.",
"ignoring.",
(void *)p); (void *)p);
} }
return; return;
@ -728,24 +759,27 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
"rr_update_empty"); "rr_update_empty");
if (p->subchannel_list != NULL) { if (p->subchannel_list != NULL) {
rr_subchannel_list_shutdown(exec_ctx, p->subchannel_list, rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"sl_shutdown_rr_update"); "sl_shutdown_empty_update");
p->subchannel_list = NULL; p->subchannel_list = NULL;
} }
return; return;
} }
size_t subchannel_index = 0; size_t subchannel_index = 0;
rr_subchannel_list *subchannel_list = gpr_zalloc(sizeof(*subchannel_list)); rr_subchannel_list *subchannel_list = rr_subchannel_list_create(p, num_addrs);
subchannel_list->policy = p; if (p->latest_pending_subchannel_list != NULL && p->started_picking) {
subchannel_list->subchannels =
gpr_zalloc(sizeof(subchannel_data) * num_addrs);
subchannel_list->num_subchannels = num_addrs;
gpr_ref_init(&subchannel_list->refcount, 1);
p->latest_pending_subchannel_list = subchannel_list;
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "Created subchannel list %p for %lu subchannels", gpr_log(GPR_DEBUG,
(void *)subchannel_list, (unsigned long)num_addrs); "[RR %p] Shutting down latest pending subchannel list %p, about "
"to be "
"replaced by newer latest %p",
(void *)p, (void *)p->latest_pending_subchannel_list,
(void *)subchannel_list);
}
rr_subchannel_list_shutdown_and_unref(
exec_ctx, p->latest_pending_subchannel_list, "sl_outdated_dont_smash");
} }
p->latest_pending_subchannel_list = subchannel_list;
grpc_subchannel_args sc_args; grpc_subchannel_args sc_args;
/* We need to remove the LB addresses in order to be able to compare the /* We need to remove the LB addresses in order to be able to compare the
* subchannel keys of subchannels from a different batch of addresses. */ * subchannel keys of subchannels from a different batch of addresses. */
@ -769,11 +803,12 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
char *address_uri = char *address_uri =
grpc_sockaddr_to_uri(&addresses->addresses[i].address); grpc_sockaddr_to_uri(&addresses->addresses[i].address);
gpr_log(GPR_DEBUG, gpr_log(
"index %lu: Created subchannel %p for address uri %s into " GPR_DEBUG,
"[RR %p] index %lu: Created subchannel %p for address uri %s into "
"subchannel_list %p", "subchannel_list %p",
(unsigned long)subchannel_index, (void *)subchannel, address_uri, (void *)p, (unsigned long)subchannel_index, (void *)subchannel,
(void *)subchannel_list); address_uri, (void *)subchannel_list);
gpr_free(address_uri); gpr_free(address_uri);
} }
grpc_channel_args_destroy(exec_ctx, new_args); grpc_channel_args_destroy(exec_ctx, new_args);
@ -812,10 +847,11 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
// The policy isn't picking yet. Save the update for later, disposing of // The policy isn't picking yet. Save the update for later, disposing of
// previous version if any. // previous version if any.
if (p->subchannel_list != NULL) { if (p->subchannel_list != NULL) {
rr_subchannel_list_shutdown(exec_ctx, p->subchannel_list, rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"rr_update_before_started_picking"); "rr_update_before_started_picking");
} }
p->subchannel_list = subchannel_list; p->subchannel_list = subchannel_list;
p->latest_pending_subchannel_list = NULL;
} }
} }
@ -845,7 +881,7 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE, grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
"round_robin"); "round_robin");
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "Created Round Robin %p with %lu subchannels", (void *)p, gpr_log(GPR_DEBUG, "[RR %p] Created with %lu subchannels", (void *)p,
(unsigned long)p->subchannel_list->num_subchannels); (unsigned long)p->subchannel_list->num_subchannels);
} }
return &p->base; return &p->base;
@ -866,7 +902,7 @@ static grpc_lb_policy_factory *round_robin_lb_factory_create() {
void grpc_lb_policy_round_robin_init() { void grpc_lb_policy_round_robin_init() {
grpc_register_lb_policy(round_robin_lb_factory_create()); grpc_register_lb_policy(round_robin_lb_factory_create());
grpc_register_tracer("round_robin", &grpc_lb_round_robin_trace); grpc_register_tracer(&grpc_lb_round_robin_trace);
} }
void grpc_lb_policy_round_robin_shutdown() {} void grpc_lb_policy_round_robin_shutdown() {}

@ -20,7 +20,8 @@
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_resolver_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_resolver_refcount =
GRPC_TRACER_INITIALIZER(false, "resolver_refcount");
#endif #endif
void grpc_resolver_init(grpc_resolver *resolver, void grpc_resolver_init(grpc_resolver *resolver,

@ -236,12 +236,12 @@ static void on_srv_query_done_cb(void *arg, int status, int timeouts,
srv_it = srv_it->next) { srv_it = srv_it->next) {
if (grpc_ipv6_loopback_available()) { if (grpc_ipv6_loopback_available()) {
grpc_ares_hostbyname_request *hr = create_hostbyname_request( grpc_ares_hostbyname_request *hr = create_hostbyname_request(
r, srv_it->host, srv_it->port, true /* is_balancer */); r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET6, ares_gethostbyname(*channel, hr->host, AF_INET6,
on_hostbyname_done_cb, hr); on_hostbyname_done_cb, hr);
} }
grpc_ares_hostbyname_request *hr = create_hostbyname_request( grpc_ares_hostbyname_request *hr = create_hostbyname_request(
r, srv_it->host, srv_it->port, true /* is_balancer */); r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb, ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb,
hr); hr);
grpc_ares_ev_driver_start(&exec_ctx, r->ev_driver); grpc_ares_ev_driver_start(&exec_ctx, r->ev_driver);

@ -188,6 +188,7 @@ static void subchannel_destroy(grpc_exec_ctx *exec_ctx, void *arg,
grpc_connector_unref(exec_ctx, c->connector); grpc_connector_unref(exec_ctx, c->connector);
grpc_pollset_set_destroy(exec_ctx, c->pollset_set); grpc_pollset_set_destroy(exec_ctx, c->pollset_set);
grpc_subchannel_key_destroy(exec_ctx, c->key); grpc_subchannel_key_destroy(exec_ctx, c->key);
gpr_mu_destroy(&c->mu);
gpr_free(c); gpr_free(c);
} }

@ -40,6 +40,8 @@ struct grpc_subchannel_key {
GPR_TLS_DECL(subchannel_index_exec_ctx); GPR_TLS_DECL(subchannel_index_exec_ctx);
static bool g_force_creation = false;
static void enter_ctx(grpc_exec_ctx *exec_ctx) { static void enter_ctx(grpc_exec_ctx *exec_ctx) {
GPR_ASSERT(gpr_tls_get(&subchannel_index_exec_ctx) == 0); GPR_ASSERT(gpr_tls_get(&subchannel_index_exec_ctx) == 0);
gpr_tls_set(&subchannel_index_exec_ctx, (intptr_t)exec_ctx); gpr_tls_set(&subchannel_index_exec_ctx, (intptr_t)exec_ctx);
@ -84,6 +86,7 @@ static grpc_subchannel_key *subchannel_key_copy(grpc_subchannel_key *k) {
int grpc_subchannel_key_compare(const grpc_subchannel_key *a, int grpc_subchannel_key_compare(const grpc_subchannel_key *a,
const grpc_subchannel_key *b) { const grpc_subchannel_key *b) {
if (g_force_creation) return false;
int c = GPR_ICMP(a->args.filter_count, b->args.filter_count); int c = GPR_ICMP(a->args.filter_count, b->args.filter_count);
if (c != 0) return c; if (c != 0) return c;
if (a->args.filter_count > 0) { if (a->args.filter_count > 0) {
@ -250,3 +253,7 @@ void grpc_subchannel_index_unregister(grpc_exec_ctx *exec_ctx,
leave_ctx(exec_ctx); leave_ctx(exec_ctx);
} }
void grpc_subchannel_index_test_only_set_force_creation(bool force_creation) {
g_force_creation = force_creation;
}

@ -59,4 +59,16 @@ void grpc_subchannel_index_init(void);
/** Shutdown the subchannel index (global) */ /** Shutdown the subchannel index (global) */
void grpc_subchannel_index_shutdown(void); void grpc_subchannel_index_shutdown(void);
/** \em TEST ONLY.
* If \a force_creation is true, all key comparisons will be false, resulting in
* new subchannels always being created. Otherwise, the keys will be compared as
* usual.
*
* This function is *not* threadsafe on purpose: it should *only* be used in
* test code.
*
* Tests using this function \em MUST run tests with and without \a
* force_creation set. */
void grpc_subchannel_index_test_only_set_force_creation(bool force_creation);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */ #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */

@ -65,7 +65,7 @@ static bool maybe_add_required_filter(grpc_exec_ctx *exec_ctx,
} }
void grpc_http_filters_init(void) { void grpc_http_filters_init(void) {
grpc_register_tracer("compression", &grpc_compression_trace); grpc_register_tracer(&grpc_compression_trace);
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_optional_filter, &compress_filter); maybe_add_optional_filter, &compress_filter);

@ -21,10 +21,10 @@
#include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/metadata.h"
void grpc_chttp2_plugin_init(void) { void grpc_chttp2_plugin_init(void) {
grpc_register_tracer("http", &grpc_http_trace); grpc_register_tracer(&grpc_http_trace);
grpc_register_tracer("flowctl", &grpc_flowctl_trace); grpc_register_tracer(&grpc_flowctl_trace);
#ifndef NDEBUG #ifndef NDEBUG
grpc_register_tracer("chttp2_refcount", &grpc_trace_chttp2_refcount); grpc_register_tracer(&grpc_trace_chttp2_refcount);
#endif #endif
} }

@ -33,6 +33,7 @@
#include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/varint.h" #include "src/core/ext/transport/chttp2/transport/varint.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/http/parser.h" #include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer.h"
@ -74,11 +75,12 @@ static bool g_default_keepalive_permit_without_calls =
DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS; DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS;
#define MAX_CLIENT_STREAM_ID 0x7fffffffu #define MAX_CLIENT_STREAM_ID 0x7fffffffu
grpc_tracer_flag grpc_http_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_http_trace = GRPC_TRACER_INITIALIZER(false, "http");
grpc_tracer_flag grpc_flowctl_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_flowctl_trace = GRPC_TRACER_INITIALIZER(false, "flowctl");
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_chttp2_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_chttp2_refcount =
GRPC_TRACER_INITIALIZER(false, "chttp2_refcount");
#endif #endif
static const grpc_transport_vtable vtable; static const grpc_transport_vtable vtable;
@ -1223,7 +1225,7 @@ static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id, static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id,
bool is_client, bool is_initial) { bool is_client, bool is_initial) {
for (grpc_linked_mdelem *md = md_batch->list.head; md != md_batch->list.tail; for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL;
md = md->next) { md = md->next) {
char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md)); char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md)); char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));

@ -33,6 +33,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" #include "src/core/ext/transport/chttp2/transport/incoming_metadata.h"
#include "src/core/ext/transport/chttp2/transport/stream_map.h" #include "src/core/ext/transport/chttp2/transport/stream_map.h"
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer.h"

@ -0,0 +1,29 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/ext/transport/inproc/inproc_transport.h"
#include "src/core/lib/debug/trace.h"
grpc_tracer_flag grpc_inproc_trace = GRPC_TRACER_INITIALIZER(false, "inproc");
void grpc_inproc_plugin_init(void) {
grpc_register_tracer(&grpc_inproc_trace);
grpc_inproc_transport_init();
}
void grpc_inproc_plugin_shutdown(void) { grpc_inproc_transport_shutdown(); }

File diff suppressed because it is too large Load Diff

@ -0,0 +1,41 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_EXT_TRANSPORT_INPROC_INPROC_TRANSPORT_H
#define GRPC_CORE_EXT_TRANSPORT_INPROC_INPROC_TRANSPORT_H
#include "src/core/lib/transport/transport_impl.h"
#ifdef __cplusplus
extern "C" {
#endif
grpc_channel *grpc_inproc_channel_create(grpc_server *server,
grpc_channel_args *args,
void *reserved);
extern grpc_tracer_flag grpc_inproc_trace;
void grpc_inproc_transport_init(void);
void grpc_inproc_transport_shutdown(void);
#ifdef __cplusplus
}
#endif
#endif /* GRPC_CORE_EXT_TRANSPORT_INPROC_INPROC_TRANSPORT_H */

@ -23,7 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
grpc_tracer_flag grpc_trace_channel = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_channel = GRPC_TRACER_INITIALIZER(false, "channel");
/* Memory layouts. /* Memory layouts.

@ -24,7 +24,7 @@
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
grpc_tracer_flag grpc_trace_channel_stack_builder = grpc_tracer_flag grpc_trace_channel_stack_builder =
GRPC_TRACER_INITIALIZER(false); GRPC_TRACER_INITIALIZER(false, "channel_stack_builder");
typedef struct filter_node { typedef struct filter_node {
struct filter_node *next; struct filter_node *next;

@ -0,0 +1,191 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
#define OUTPUT_BLOCK_SIZE (1024)
static bool gzip_flate(grpc_stream_compression_context *ctx,
grpc_slice_buffer *in, grpc_slice_buffer *out,
size_t *output_size, size_t max_output_size, int flush,
bool *end_of_context) {
GPR_ASSERT(flush == 0 || flush == Z_SYNC_FLUSH || flush == Z_FINISH);
/* Full flush is not allowed when inflating. */
GPR_ASSERT(!(ctx->flate == inflate && (flush == Z_FINISH)));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
int r;
bool eoc = false;
size_t original_max_output_size = max_output_size;
while (max_output_size > 0 && (in->length > 0 || flush) && !eoc) {
size_t slice_size = max_output_size < OUTPUT_BLOCK_SIZE ? max_output_size
: OUTPUT_BLOCK_SIZE;
grpc_slice slice_out = GRPC_SLICE_MALLOC(slice_size);
ctx->zs.avail_out = (uInt)slice_size;
ctx->zs.next_out = GRPC_SLICE_START_PTR(slice_out);
while (ctx->zs.avail_out > 0 && in->length > 0 && !eoc) {
grpc_slice slice = grpc_slice_buffer_take_first(in);
ctx->zs.avail_in = (uInt)GRPC_SLICE_LENGTH(slice);
ctx->zs.next_in = GRPC_SLICE_START_PTR(slice);
r = ctx->flate(&ctx->zs, Z_NO_FLUSH);
if (r < 0 && r != Z_BUF_ERROR) {
gpr_log(GPR_ERROR, "zlib error (%d)", r);
grpc_slice_unref_internal(&exec_ctx, slice_out);
grpc_exec_ctx_finish(&exec_ctx);
return false;
} else if (r == Z_STREAM_END && ctx->flate == inflate) {
eoc = true;
}
if (ctx->zs.avail_in > 0) {
grpc_slice_buffer_undo_take_first(
in,
grpc_slice_sub(slice, GRPC_SLICE_LENGTH(slice) - ctx->zs.avail_in,
GRPC_SLICE_LENGTH(slice)));
}
grpc_slice_unref_internal(&exec_ctx, slice);
}
if (flush != 0 && ctx->zs.avail_out > 0 && !eoc) {
GPR_ASSERT(in->length == 0);
r = ctx->flate(&ctx->zs, flush);
if (flush == Z_SYNC_FLUSH) {
switch (r) {
case Z_OK:
/* Maybe flush is not complete; just made some partial progress. */
if (ctx->zs.avail_out > 0) {
flush = 0;
}
break;
case Z_BUF_ERROR:
case Z_STREAM_END:
flush = 0;
break;
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
grpc_slice_unref_internal(&exec_ctx, slice_out);
grpc_exec_ctx_finish(&exec_ctx);
return false;
}
} else if (flush == Z_FINISH) {
switch (r) {
case Z_OK:
case Z_BUF_ERROR:
/* Wait for the next loop to assign additional output space. */
GPR_ASSERT(ctx->zs.avail_out == 0);
break;
case Z_STREAM_END:
flush = 0;
break;
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
grpc_slice_unref_internal(&exec_ctx, slice_out);
grpc_exec_ctx_finish(&exec_ctx);
return false;
}
}
}
if (ctx->zs.avail_out == 0) {
grpc_slice_buffer_add(out, slice_out);
} else if (ctx->zs.avail_out < slice_size) {
slice_out.data.refcounted.length -= ctx->zs.avail_out;
grpc_slice_buffer_add(out, slice_out);
} else {
grpc_slice_unref_internal(&exec_ctx, slice_out);
}
max_output_size -= (slice_size - ctx->zs.avail_out);
}
grpc_exec_ctx_finish(&exec_ctx);
if (end_of_context) {
*end_of_context = eoc;
}
if (output_size) {
*output_size = original_max_output_size - max_output_size;
}
return true;
}
bool grpc_stream_compress(grpc_stream_compression_context *ctx,
grpc_slice_buffer *in, grpc_slice_buffer *out,
size_t *output_size, size_t max_output_size,
grpc_stream_compression_flush flush) {
GPR_ASSERT(ctx->flate == deflate);
int gzip_flush;
switch (flush) {
case GRPC_STREAM_COMPRESSION_FLUSH_NONE:
gzip_flush = 0;
break;
case GRPC_STREAM_COMPRESSION_FLUSH_SYNC:
gzip_flush = Z_SYNC_FLUSH;
break;
case GRPC_STREAM_COMPRESSION_FLUSH_FINISH:
gzip_flush = Z_FINISH;
break;
default:
gzip_flush = 0;
}
return gzip_flate(ctx, in, out, output_size, max_output_size, gzip_flush,
NULL);
}
bool grpc_stream_decompress(grpc_stream_compression_context *ctx,
grpc_slice_buffer *in, grpc_slice_buffer *out,
size_t *output_size, size_t max_output_size,
bool *end_of_context) {
GPR_ASSERT(ctx->flate == inflate);
return gzip_flate(ctx, in, out, output_size, max_output_size, Z_SYNC_FLUSH,
end_of_context);
}
grpc_stream_compression_context *grpc_stream_compression_context_create(
grpc_stream_compression_method method) {
grpc_stream_compression_context *ctx =
gpr_zalloc(sizeof(grpc_stream_compression_context));
int r;
if (ctx == NULL) {
return NULL;
}
if (method == GRPC_STREAM_COMPRESSION_DECOMPRESS) {
r = inflateInit2(&ctx->zs, 0x1F);
ctx->flate = inflate;
} else {
r = deflateInit2(&ctx->zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 0x1F, 8,
Z_DEFAULT_STRATEGY);
ctx->flate = deflate;
}
if (r != Z_OK) {
gpr_free(ctx);
return NULL;
}
return ctx;
}
void grpc_stream_compression_context_destroy(
grpc_stream_compression_context *ctx) {
if (ctx->flate == inflate) {
inflateEnd(&ctx->zs);
} else {
deflateEnd(&ctx->zs);
}
gpr_free(ctx);
}

@ -0,0 +1,90 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_COMPRESSION_STREAM_COMPRESSION_H
#define GRPC_CORE_LIB_COMPRESSION_STREAM_COMPRESSION_H
#include <stdbool.h>
#include <grpc/slice_buffer.h>
#include <zlib.h>
/* Stream compression/decompression context */
typedef struct grpc_stream_compression_context {
z_stream zs;
int (*flate)(z_stream *zs, int flush);
} grpc_stream_compression_context;
typedef enum grpc_stream_compression_method {
GRPC_STREAM_COMPRESSION_COMPRESS = 0,
GRPC_STREAM_COMPRESSION_DECOMPRESS,
GRPC_STREAM_COMPRESSION_METHOD_COUNT
} grpc_stream_compression_method;
typedef enum grpc_stream_compression_flush {
GRPC_STREAM_COMPRESSION_FLUSH_NONE = 0,
GRPC_STREAM_COMPRESSION_FLUSH_SYNC,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH,
GRPC_STREAM_COMPRESSION_FLUSH_COUNT
} grpc_stream_compression_flush;
/**
* Compress bytes provided in \a in with a given context, with an optional flush
* at the end of compression. Emits at most \a max_output_size compressed bytes
* into \a out. If all the bytes in input buffer \a in are depleted and \a flush
* is not GRPC_STREAM_COMPRESSION_FLUSH_NONE, the corresponding flush method is
* executed. The total number of bytes emitted is outputed in \a output_size.
*
* A SYNC flush indicates that the entire messages in \a in can be decompressed
* from \a out. A FINISH flush implies a SYNC flush, and that any further
* compression will not be dependent on the state of the current context and any
* previous compressed bytes. It allows corresponding decompression context to
* be dropped when reaching this boundary.
*/
bool grpc_stream_compress(grpc_stream_compression_context *ctx,
grpc_slice_buffer *in, grpc_slice_buffer *out,
size_t *output_size, size_t max_output_size,
grpc_stream_compression_flush flush);
/**
* Decompress bytes provided in \a in with a given context. Emits at most \a
* max_output_size decompressed bytes into \a out. If decompression process
* reached the end of a gzip stream, \a end_of_context is set to true; otherwise
* it is set to false. The total number of bytes emitted is outputed in \a
* output_size.
*/
bool grpc_stream_decompress(grpc_stream_compression_context *ctx,
grpc_slice_buffer *in, grpc_slice_buffer *out,
size_t *output_size, size_t max_output_size,
bool *end_of_context);
/**
* Creates a stream compression context. \a pending_bytes_buffer is the input
* buffer for compression/decompression operations. \a method specifies whether
* the context is for compression or decompression.
*/
grpc_stream_compression_context *grpc_stream_compression_context_create(
grpc_stream_compression_method method);
/**
* Destroys a stream compression context.
*/
void grpc_stream_compression_context_destroy(
grpc_stream_compression_context *ctx);
#endif

@ -27,7 +27,6 @@
int grpc_tracer_set_enabled(const char *name, int enabled); int grpc_tracer_set_enabled(const char *name, int enabled);
typedef struct tracer { typedef struct tracer {
const char *name;
grpc_tracer_flag *flag; grpc_tracer_flag *flag;
struct tracer *next; struct tracer *next;
} tracer; } tracer;
@ -39,9 +38,8 @@ static tracer *tracers;
#define TRACER_SET(flag, on) (flag).value = (on) #define TRACER_SET(flag, on) (flag).value = (on)
#endif #endif
void grpc_register_tracer(const char *name, grpc_tracer_flag *flag) { void grpc_register_tracer(grpc_tracer_flag *flag) {
tracer *t = gpr_malloc(sizeof(*t)); tracer *t = gpr_malloc(sizeof(*t));
t->name = name;
t->flag = flag; t->flag = flag;
t->next = tracers; t->next = tracers;
TRACER_SET(*flag, false); TRACER_SET(*flag, false);
@ -93,6 +91,14 @@ static void parse(const char *s) {
gpr_free(strings); gpr_free(strings);
} }
static void list_tracers() {
gpr_log(GPR_DEBUG, "available tracers:");
tracer *t;
for (t = tracers; t; t = t->next) {
gpr_log(GPR_DEBUG, "\t%s", t->flag->name);
}
}
void grpc_tracer_init(const char *env_var) { void grpc_tracer_init(const char *env_var) {
char *e = gpr_getenv(env_var); char *e = gpr_getenv(env_var);
if (e != NULL) { if (e != NULL) {
@ -115,10 +121,18 @@ int grpc_tracer_set_enabled(const char *name, int enabled) {
for (t = tracers; t; t = t->next) { for (t = tracers; t; t = t->next) {
TRACER_SET(*t->flag, enabled); TRACER_SET(*t->flag, enabled);
} }
} else if (0 == strcmp(name, "list_tracers")) {
list_tracers();
} else if (0 == strcmp(name, "refcount")) {
for (t = tracers; t; t = t->next) {
if (strstr(t->flag->name, "refcount") != NULL) {
TRACER_SET(*t->flag, enabled);
}
}
} else { } else {
int found = 0; int found = 0;
for (t = tracers; t; t = t->next) { for (t = tracers; t; t = t->next) {
if (0 == strcmp(name, t->name)) { if (0 == strcmp(name, t->flag->name)) {
TRACER_SET(*t->flag, enabled); TRACER_SET(*t->flag, enabled);
found = 1; found = 1;
} }

@ -35,19 +35,20 @@ typedef struct {
#else #else
bool value; bool value;
#endif #endif
char *name;
} grpc_tracer_flag; } grpc_tracer_flag;
#ifdef GRPC_THREADSAFE_TRACER #ifdef GRPC_THREADSAFE_TRACER
#define GRPC_TRACER_ON(flag) (gpr_atm_no_barrier_load(&(flag).value) != 0) #define GRPC_TRACER_ON(flag) (gpr_atm_no_barrier_load(&(flag).value) != 0)
#define GRPC_TRACER_INITIALIZER(on) \ #define GRPC_TRACER_INITIALIZER(on, name) \
{ (gpr_atm)(on) } { (gpr_atm)(on), (name) }
#else #else
#define GRPC_TRACER_ON(flag) ((flag).value) #define GRPC_TRACER_ON(flag) ((flag).value)
#define GRPC_TRACER_INITIALIZER(on) \ #define GRPC_TRACER_INITIALIZER(on, name) \
{ (on) } { (on), (name) }
#endif #endif
void grpc_register_tracer(const char *name, grpc_tracer_flag *flag); void grpc_register_tracer(grpc_tracer_flag *flag);
void grpc_tracer_init(const char *env_var_name); void grpc_tracer_init(const char *env_var_name);
void grpc_tracer_shutdown(void); void grpc_tracer_shutdown(void);

@ -25,7 +25,7 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false, "http1");
static char *buf2str(void *buffer, size_t length) { static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1); char *out = gpr_malloc(length + 1);

@ -25,7 +25,7 @@
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_closure = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_closure = GRPC_TRACER_INITIALIZER(false, "closure");
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG

@ -27,7 +27,8 @@
#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
grpc_tracer_flag grpc_combiner_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_combiner_trace =
GRPC_TRACER_INITIALIZER(false, "combiner");
#define GRPC_COMBINER_TRACE(fn) \ #define GRPC_COMBINER_TRACE(fn) \
do { \ do { \

@ -36,7 +36,8 @@
#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_internal.h"
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_error_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_error_refcount =
GRPC_TRACER_INITIALIZER(false, "error_refcount");
#endif #endif
static const char *error_int_name(grpc_error_ints key) { static const char *error_int_name(grpc_error_ints key) {

@ -932,24 +932,12 @@ static int fd_wrapped_fd(grpc_fd *fd) {
static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
grpc_closure *on_done, int *release_fd, grpc_closure *on_done, int *release_fd,
const char *reason) { const char *reason) {
bool is_fd_closed = false;
grpc_error *error = GRPC_ERROR_NONE; grpc_error *error = GRPC_ERROR_NONE;
polling_island *unref_pi = NULL; polling_island *unref_pi = NULL;
gpr_mu_lock(&fd->po.mu); gpr_mu_lock(&fd->po.mu);
fd->on_done_closure = on_done; fd->on_done_closure = on_done;
/* If release_fd is not NULL, we should be relinquishing control of the file
descriptor fd->fd (but we still own the grpc_fd structure). */
if (release_fd != NULL) {
*release_fd = fd->fd;
} else {
close(fd->fd);
is_fd_closed = true;
}
fd->orphaned = true;
/* Remove the active status but keep referenced. We want this grpc_fd struct /* Remove the active status but keep referenced. We want this grpc_fd struct
to be alive (and not added to freelist) until the end of this function */ to be alive (and not added to freelist) until the end of this function */
REF_BY(fd, 1, reason); REF_BY(fd, 1, reason);
@ -964,13 +952,24 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
before doing this.) */ before doing this.) */
if (fd->po.pi != NULL) { if (fd->po.pi != NULL) {
polling_island *pi_latest = polling_island_lock(fd->po.pi); polling_island *pi_latest = polling_island_lock(fd->po.pi);
polling_island_remove_fd_locked(pi_latest, fd, is_fd_closed, &error); polling_island_remove_fd_locked(pi_latest, fd, false /* is_fd_closed */,
&error);
gpr_mu_unlock(&pi_latest->mu); gpr_mu_unlock(&pi_latest->mu);
unref_pi = fd->po.pi; unref_pi = fd->po.pi;
fd->po.pi = NULL; fd->po.pi = NULL;
} }
/* If release_fd is not NULL, we should be relinquishing control of the file
descriptor fd->fd (but we still own the grpc_fd structure). */
if (release_fd != NULL) {
*release_fd = fd->fd;
} else {
close(fd->fd);
}
fd->orphaned = true;
GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error)); GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error));
gpr_mu_unlock(&fd->po.mu); gpr_mu_unlock(&fd->po.mu);

@ -103,6 +103,32 @@ typedef struct pollable {
grpc_pollset_worker *root_worker; grpc_pollset_worker *root_worker;
} pollable; } pollable;
static const char *polling_obj_type_string(polling_obj_type t) {
switch (t) {
case PO_POLLING_GROUP:
return "polling_group";
case PO_POLLSET_SET:
return "pollset_set";
case PO_POLLSET:
return "pollset";
case PO_FD:
return "fd";
case PO_EMPTY_POLLABLE:
return "empty_pollable";
case PO_COUNT:
return "<invalid:count>";
}
return "<invalid>";
}
static char *pollable_desc(pollable *p) {
char *out;
gpr_asprintf(&out, "type=%s group=%p epfd=%d wakeup=%d",
polling_obj_type_string(p->po.type), p->po.group, p->epfd,
p->wakeup.read_fd);
return out;
}
static pollable g_empty_pollable; static pollable g_empty_pollable;
static void pollable_init(pollable *p, polling_obj_type type); static void pollable_init(pollable *p, polling_obj_type type);
@ -472,7 +498,7 @@ static grpc_error *pollable_add_fd(pollable *p, grpc_fd *fd) {
GPR_ASSERT(epfd != -1); GPR_ASSERT(epfd != -1);
if (GRPC_TRACER_ON(grpc_polling_trace)) { if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "add fd %p to pollable %p", fd, p); gpr_log(GPR_DEBUG, "add fd %p (%d) to pollable %p", fd, fd->fd, p);
} }
gpr_mu_lock(&fd->orphaned_mu); gpr_mu_lock(&fd->orphaned_mu);
@ -537,10 +563,18 @@ static void do_kick_all(grpc_exec_ctx *exec_ctx, void *arg,
if (worker->pollable != &pollset->pollable) { if (worker->pollable != &pollset->pollable) {
gpr_mu_lock(&worker->pollable->po.mu); gpr_mu_lock(&worker->pollable->po.mu);
} }
if (worker->initialized_cv) { if (worker->initialized_cv && worker != pollset->root_worker) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kickall_via_cv %p (pollable %p vs %p)",
pollset, worker, &pollset->pollable, worker->pollable);
}
worker->kicked = true; worker->kicked = true;
gpr_cv_signal(&worker->cv); gpr_cv_signal(&worker->cv);
} else { } else {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kickall_via_wakeup %p (pollable %p vs %p)",
pollset, worker, &pollset->pollable, worker->pollable);
}
append_error(&error, grpc_wakeup_fd_wakeup(&worker->pollable->wakeup), append_error(&error, grpc_wakeup_fd_wakeup(&worker->pollable->wakeup),
"pollset_shutdown"); "pollset_shutdown");
} }
@ -770,7 +804,9 @@ static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
int timeout = poll_deadline_to_millis_timeout(deadline, now); int timeout = poll_deadline_to_millis_timeout(deadline, now);
if (GRPC_TRACER_ON(grpc_polling_trace)) { if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p poll %p for %dms", pollset, p, timeout); char *desc = pollable_desc(p);
gpr_log(GPR_DEBUG, "PS:%p poll %p[%s] for %dms", pollset, p, desc, timeout);
gpr_free(desc);
} }
if (timeout != 0) { if (timeout != 0) {
@ -985,10 +1021,11 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
static const char *err_desc = "pollset_add_fd"; static const char *err_desc = "pollset_add_fd";
grpc_error *error = GRPC_ERROR_NONE; grpc_error *error = GRPC_ERROR_NONE;
if (pollset->current_pollable == &g_empty_pollable) { if (pollset->current_pollable == &g_empty_pollable) {
if (GRPC_TRACER_ON(grpc_polling_trace)) if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, gpr_log(GPR_DEBUG,
"PS:%p add fd %p; transition pollable from empty to fd", pollset, "PS:%p add fd %p; transition pollable from empty to fd", pollset,
fd); fd);
}
/* empty pollable --> single fd pollable */ /* empty pollable --> single fd pollable */
pollset_kick_all(exec_ctx, pollset); pollset_kick_all(exec_ctx, pollset);
pollset->current_pollable = &fd->pollable; pollset->current_pollable = &fd->pollable;
@ -997,16 +1034,23 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
if (!fd_locked) gpr_mu_unlock(&fd->pollable.po.mu); if (!fd_locked) gpr_mu_unlock(&fd->pollable.po.mu);
REF_BY(fd, 2, "pollset_pollable"); REF_BY(fd, 2, "pollset_pollable");
} else if (pollset->current_pollable == &pollset->pollable) { } else if (pollset->current_pollable == &pollset->pollable) {
if (GRPC_TRACER_ON(grpc_polling_trace)) if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p add fd %p; already multipolling", pollset, fd); gpr_log(GPR_DEBUG, "PS:%p add fd %p; already multipolling", pollset, fd);
}
append_error(&error, pollable_add_fd(pollset->current_pollable, fd), append_error(&error, pollable_add_fd(pollset->current_pollable, fd),
err_desc); err_desc);
} else if (pollset->current_pollable != &fd->pollable) { } else if (pollset->current_pollable != &fd->pollable) {
grpc_fd *had_fd = (grpc_fd *)pollset->current_pollable; grpc_fd *had_fd = (grpc_fd *)pollset->current_pollable;
if (GRPC_TRACER_ON(grpc_polling_trace)) if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, gpr_log(GPR_DEBUG,
"PS:%p add fd %p; transition pollable from fd %p to multipoller", "PS:%p add fd %p; transition pollable from fd %p to multipoller",
pollset, fd, had_fd); pollset, fd, had_fd);
}
/* Introduce a spurious completion.
If we do not, then it may be that the fd-specific epoll set consumed
a completion without being polled, leading to a missed edge going up. */
grpc_lfev_set_ready(exec_ctx, &had_fd->read_closure);
grpc_lfev_set_ready(exec_ctx, &had_fd->write_closure);
pollset_kick_all(exec_ctx, pollset); pollset_kick_all(exec_ctx, pollset);
pollset->current_pollable = &pollset->pollable; pollset->current_pollable = &pollset->pollable;
if (append_error(&error, pollable_materialize(&pollset->pollable), if (append_error(&error, pollable_materialize(&pollset->pollable),

@ -855,24 +855,12 @@ static int fd_wrapped_fd(grpc_fd *fd) {
static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
grpc_closure *on_done, int *release_fd, grpc_closure *on_done, int *release_fd,
const char *reason) { const char *reason) {
bool is_fd_closed = false;
grpc_error *error = GRPC_ERROR_NONE; grpc_error *error = GRPC_ERROR_NONE;
polling_island *unref_pi = NULL; polling_island *unref_pi = NULL;
gpr_mu_lock(&fd->po.mu); gpr_mu_lock(&fd->po.mu);
fd->on_done_closure = on_done; fd->on_done_closure = on_done;
/* If release_fd is not NULL, we should be relinquishing control of the file
descriptor fd->fd (but we still own the grpc_fd structure). */
if (release_fd != NULL) {
*release_fd = fd->fd;
} else {
close(fd->fd);
is_fd_closed = true;
}
fd->orphaned = true;
/* Remove the active status but keep referenced. We want this grpc_fd struct /* Remove the active status but keep referenced. We want this grpc_fd struct
to be alive (and not added to freelist) until the end of this function */ to be alive (and not added to freelist) until the end of this function */
REF_BY(fd, 1, reason); REF_BY(fd, 1, reason);
@ -887,13 +875,24 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
before doing this.) */ before doing this.) */
if (fd->po.pi != NULL) { if (fd->po.pi != NULL) {
polling_island *pi_latest = polling_island_lock(fd->po.pi); polling_island *pi_latest = polling_island_lock(fd->po.pi);
polling_island_remove_fd_locked(pi_latest, fd, is_fd_closed, &error); polling_island_remove_fd_locked(pi_latest, fd, false /* is_fd_closed */,
&error);
gpr_mu_unlock(&pi_latest->mu); gpr_mu_unlock(&pi_latest->mu);
unref_pi = fd->po.pi; unref_pi = fd->po.pi;
fd->po.pi = NULL; fd->po.pi = NULL;
} }
/* If release_fd is not NULL, we should be relinquishing control of the file
descriptor fd->fd (but we still own the grpc_fd structure). */
if (release_fd != NULL) {
*release_fd = fd->fd;
} else {
close(fd->fd);
}
fd->orphaned = true;
GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error)); GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error));
gpr_mu_unlock(&fd->po.mu); gpr_mu_unlock(&fd->po.mu);

@ -39,10 +39,11 @@
#include "src/core/lib/support/env.h" #include "src/core/lib/support/env.h"
grpc_tracer_flag grpc_polling_trace = grpc_tracer_flag grpc_polling_trace =
GRPC_TRACER_INITIALIZER(false); /* Disabled by default */ GRPC_TRACER_INITIALIZER(false, "polling"); /* Disabled by default */
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_fd_refcount =
GRPC_TRACER_INITIALIZER(false, "fd_refcount");
#endif #endif
/** Default poll() function - a pointer so that it can be overridden by some /** Default poll() function - a pointer so that it can be overridden by some
@ -120,11 +121,15 @@ void grpc_set_event_engine_test_only(
g_event_engine = ev_engine; g_event_engine = ev_engine;
} }
const grpc_event_engine_vtable *grpc_get_event_engine_test_only() {
return g_event_engine;
}
/* Call this only after calling grpc_event_engine_init() */ /* Call this only after calling grpc_event_engine_init() */
const char *grpc_get_poll_strategy_name() { return g_poll_strategy_name; } const char *grpc_get_poll_strategy_name() { return g_poll_strategy_name; }
void grpc_event_engine_init(void) { void grpc_event_engine_init(void) {
grpc_register_tracer("polling", &grpc_polling_trace); grpc_register_tracer(&grpc_polling_trace);
char *s = gpr_getenv("GRPC_POLL_STRATEGY"); char *s = gpr_getenv("GRPC_POLL_STRATEGY");
if (s == NULL) { if (s == NULL) {

@ -153,7 +153,9 @@ void grpc_pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
typedef int (*grpc_poll_function_type)(struct pollfd *, nfds_t, int); typedef int (*grpc_poll_function_type)(struct pollfd *, nfds_t, int);
extern grpc_poll_function_type grpc_poll_function; extern grpc_poll_function_type grpc_poll_function;
/* This should be used for testing purposes ONLY */ /* WARNING: The following two functions should be used for testing purposes
* ONLY */
void grpc_set_event_engine_test_only(const grpc_event_engine_vtable *); void grpc_set_event_engine_test_only(const grpc_event_engine_vtable *);
const grpc_event_engine_vtable *grpc_get_event_engine_test_only();
#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ #endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */

@ -23,6 +23,6 @@
#include "src/core/lib/debug/trace.h" #include "src/core/lib/debug/trace.h"
grpc_tracer_flag grpc_polling_trace = grpc_tracer_flag grpc_polling_trace =
GRPC_TRACER_INITIALIZER(false); /* Disabled by default */ GRPC_TRACER_INITIALIZER(false, "polling"); /* Disabled by default */
#endif // GRPC_WINSOCK_SOCKET #endif // GRPC_WINSOCK_SOCKET

@ -28,7 +28,7 @@
void grpc_iomgr_platform_init(void) { void grpc_iomgr_platform_init(void) {
grpc_wakeup_fd_global_init(); grpc_wakeup_fd_global_init();
grpc_event_engine_init(); grpc_event_engine_init();
grpc_register_tracer("tcp", &grpc_tcp_trace); grpc_register_tracer(&grpc_tcp_trace);
} }
void grpc_iomgr_platform_flush(void) {} void grpc_iomgr_platform_flush(void) {}

@ -31,7 +31,7 @@ gpr_thd_id grpc_init_thread;
void grpc_iomgr_platform_init(void) { void grpc_iomgr_platform_init(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_global_init(); grpc_pollset_global_init();
grpc_register_tracer("tcp", &grpc_tcp_trace); grpc_register_tracer(&grpc_tcp_trace);
grpc_executor_set_threading(&exec_ctx, false); grpc_executor_set_threading(&exec_ctx, false);
grpc_init_thread = gpr_thd_currentid(); grpc_init_thread = gpr_thd_currentid();
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);

@ -35,7 +35,8 @@
#include "src/core/lib/debug/trace.h" #include "src/core/lib/debug/trace.h"
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_fd_refcount =
GRPC_TRACER_INITIALIZER(false, "fd_refcount");
#endif #endif
struct grpc_pollset { struct grpc_pollset {

@ -31,7 +31,8 @@
#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_fd_refcount =
GRPC_TRACER_INITIALIZER(false, "fd_refcount");
#endif #endif
gpr_mu grpc_polling_mu; gpr_mu grpc_polling_mu;

@ -29,7 +29,8 @@
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
grpc_tracer_flag grpc_resource_quota_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_resource_quota_trace =
GRPC_TRACER_INITIALIZER(false, "resource_quota");
#define MEMORY_USAGE_ESTIMATION_MAX 65536 #define MEMORY_USAGE_ESTIMATION_MAX 65536

@ -59,7 +59,7 @@ typedef GRPC_MSG_IOVLEN_TYPE msg_iovlen_type;
typedef size_t msg_iovlen_type; typedef size_t msg_iovlen_type;
#endif #endif
grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false, "tcp");
typedef struct { typedef struct {
grpc_endpoint base; grpc_endpoint base;

@ -38,7 +38,7 @@
#include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false, "tcp");
typedef struct { typedef struct {
grpc_endpoint base; grpc_endpoint base;

@ -48,7 +48,7 @@
#define GRPC_FIONBIO FIONBIO #define GRPC_FIONBIO FIONBIO
#endif #endif
grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false, "tcp");
static grpc_error *set_non_block(SOCKET sock) { static grpc_error *set_non_block(SOCKET sock) {
int status; int status;

@ -41,44 +41,67 @@
#define MIN_QUEUE_WINDOW_DURATION 0.01 #define MIN_QUEUE_WINDOW_DURATION 0.01
#define MAX_QUEUE_WINDOW_DURATION 1 #define MAX_QUEUE_WINDOW_DURATION 1
grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false, "timer");
grpc_tracer_flag grpc_timer_check_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_timer_check_trace =
GRPC_TRACER_INITIALIZER(false, "timer_check");
/* A "timer shard". Contains a 'heap' and a 'list' of timers. All timers with
* deadlines earlier than 'queue_deadline" cap are maintained in the heap and
* others are maintained in the list (unordered). This helps to keep the number
* of elements in the heap low.
*
* The 'queue_deadline_cap' gets recomputed periodically based on the timer
* stats maintained in 'stats' and the relevant timers are then moved from the
* 'list' to 'heap'
*/
typedef struct { typedef struct {
gpr_mu mu; gpr_mu mu;
grpc_time_averaged_stats stats; grpc_time_averaged_stats stats;
/* All and only timers with deadlines <= this will be in the heap. */ /* All and only timers with deadlines <= this will be in the heap. */
gpr_atm queue_deadline_cap; gpr_atm queue_deadline_cap;
/* The deadline of the next timer due in this shard */
gpr_atm min_deadline; gpr_atm min_deadline;
/* Index in the g_shard_queue */ /* Index of this timer_shard in the g_shard_queue */
uint32_t shard_queue_index; uint32_t shard_queue_index;
/* This holds all timers with deadlines < queue_deadline_cap. Timers in this /* This holds all timers with deadlines < queue_deadline_cap. Timers in this
list have the top bit of their deadline set to 0. */ list have the top bit of their deadline set to 0. */
grpc_timer_heap heap; grpc_timer_heap heap;
/* This holds timers whose deadline is >= queue_deadline_cap. */ /* This holds timers whose deadline is >= queue_deadline_cap. */
grpc_timer list; grpc_timer list;
} shard_type; } timer_shard;
/* Array of timer shards. Whenever a timer (grpc_timer *) is added, its address
* is hashed to select the timer shard to add the timer to */
static timer_shard g_shards[NUM_SHARDS];
/* Maintains a sorted list of timer shards (sorted by their min_deadline, i.e
* the deadline of the next timer in each shard).
* Access to this is protected by g_shared_mutables.mu */
static timer_shard *g_shard_queue[NUM_SHARDS];
/* Thread local variable that stores the deadline of the next timer the thread
* has last-seen. This is an optimization to prevent the thread from checking
* shared_mutables.min_timer (which requires acquiring shared_mutables.mu lock,
* an expensive operation) */
GPR_TLS_DECL(g_last_seen_min_timer);
struct shared_mutables { struct shared_mutables {
/* The deadline of the next timer due across all timer shards */
gpr_atm min_timer; gpr_atm min_timer;
/* Allow only one run_some_expired_timers at once */ /* Allow only one run_some_expired_timers at once */
gpr_spinlock checker_mu; gpr_spinlock checker_mu;
bool initialized; bool initialized;
/* Protects g_shard_queue */ /* Protects g_shard_queue (and the shared_mutables struct itself) */
gpr_mu mu; gpr_mu mu;
} GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE); } GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE);
static struct shared_mutables g_shared_mutables = { static struct shared_mutables g_shared_mutables = {
.checker_mu = GPR_SPINLOCK_STATIC_INITIALIZER, .initialized = false, .checker_mu = GPR_SPINLOCK_STATIC_INITIALIZER, .initialized = false,
}; };
static gpr_clock_type g_clock_type; static gpr_clock_type g_clock_type;
static shard_type g_shards[NUM_SHARDS];
/* Protected by g_shared_mutables.mu */
static shard_type *g_shard_queue[NUM_SHARDS];
static gpr_timespec g_start_time; static gpr_timespec g_start_time;
GPR_TLS_DECL(g_last_seen_min_timer);
static gpr_atm saturating_add(gpr_atm a, gpr_atm b) { static gpr_atm saturating_add(gpr_atm a, gpr_atm b) {
if (a > GPR_ATM_MAX - b) { if (a > GPR_ATM_MAX - b) {
return GPR_ATM_MAX; return GPR_ATM_MAX;
@ -122,7 +145,7 @@ static gpr_timespec atm_to_timespec(gpr_atm x) {
return gpr_time_add(g_start_time, dbl_to_ts((double)x / 1000.0)); return gpr_time_add(g_start_time, dbl_to_ts((double)x / 1000.0));
} }
static gpr_atm compute_min_deadline(shard_type *shard) { static gpr_atm compute_min_deadline(timer_shard *shard) {
return grpc_timer_heap_is_empty(&shard->heap) return grpc_timer_heap_is_empty(&shard->heap)
? saturating_add(shard->queue_deadline_cap, 1) ? saturating_add(shard->queue_deadline_cap, 1)
: grpc_timer_heap_top(&shard->heap)->deadline; : grpc_timer_heap_top(&shard->heap)->deadline;
@ -138,11 +161,11 @@ void grpc_timer_list_init(gpr_timespec now) {
g_shared_mutables.min_timer = timespec_to_atm_round_down(now); g_shared_mutables.min_timer = timespec_to_atm_round_down(now);
gpr_tls_init(&g_last_seen_min_timer); gpr_tls_init(&g_last_seen_min_timer);
gpr_tls_set(&g_last_seen_min_timer, 0); gpr_tls_set(&g_last_seen_min_timer, 0);
grpc_register_tracer("timer", &grpc_timer_trace); grpc_register_tracer(&grpc_timer_trace);
grpc_register_tracer("timer_check", &grpc_timer_check_trace); grpc_register_tracer(&grpc_timer_check_trace);
for (i = 0; i < NUM_SHARDS; i++) { for (i = 0; i < NUM_SHARDS; i++) {
shard_type *shard = &g_shards[i]; timer_shard *shard = &g_shards[i];
gpr_mu_init(&shard->mu); gpr_mu_init(&shard->mu);
grpc_time_averaged_stats_init(&shard->stats, 1.0 / ADD_DEADLINE_SCALE, 0.1, grpc_time_averaged_stats_init(&shard->stats, 1.0 / ADD_DEADLINE_SCALE, 0.1,
0.5); 0.5);
@ -161,7 +184,7 @@ void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {
exec_ctx, GPR_ATM_MAX, NULL, exec_ctx, GPR_ATM_MAX, NULL,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Timer list shutdown")); GRPC_ERROR_CREATE_FROM_STATIC_STRING("Timer list shutdown"));
for (i = 0; i < NUM_SHARDS; i++) { for (i = 0; i < NUM_SHARDS; i++) {
shard_type *shard = &g_shards[i]; timer_shard *shard = &g_shards[i];
gpr_mu_destroy(&shard->mu); gpr_mu_destroy(&shard->mu);
grpc_timer_heap_destroy(&shard->heap); grpc_timer_heap_destroy(&shard->heap);
} }
@ -187,7 +210,7 @@ static void list_remove(grpc_timer *timer) {
} }
static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) { static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) {
shard_type *temp; timer_shard *temp;
temp = g_shard_queue[first_shard_queue_index]; temp = g_shard_queue[first_shard_queue_index];
g_shard_queue[first_shard_queue_index] = g_shard_queue[first_shard_queue_index] =
g_shard_queue[first_shard_queue_index + 1]; g_shard_queue[first_shard_queue_index + 1];
@ -198,7 +221,7 @@ static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) {
first_shard_queue_index + 1; first_shard_queue_index + 1;
} }
static void note_deadline_change(shard_type *shard) { static void note_deadline_change(timer_shard *shard) {
while (shard->shard_queue_index > 0 && while (shard->shard_queue_index > 0 &&
shard->min_deadline < shard->min_deadline <
g_shard_queue[shard->shard_queue_index - 1]->min_deadline) { g_shard_queue[shard->shard_queue_index - 1]->min_deadline) {
@ -215,7 +238,7 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
gpr_timespec deadline, grpc_closure *closure, gpr_timespec deadline, grpc_closure *closure,
gpr_timespec now) { gpr_timespec now) {
int is_first_timer = 0; int is_first_timer = 0;
shard_type *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)]; timer_shard *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)];
GPR_ASSERT(deadline.clock_type == g_clock_type); GPR_ASSERT(deadline.clock_type == g_clock_type);
GPR_ASSERT(now.clock_type == g_clock_type); GPR_ASSERT(now.clock_type == g_clock_type);
timer->closure = closure; timer->closure = closure;
@ -303,7 +326,7 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
return; return;
} }
shard_type *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)]; timer_shard *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)];
gpr_mu_lock(&shard->mu); gpr_mu_lock(&shard->mu);
if (GRPC_TRACER_ON(grpc_timer_trace)) { if (GRPC_TRACER_ON(grpc_timer_trace)) {
gpr_log(GPR_DEBUG, "TIMER %p: CANCEL pending=%s", timer, gpr_log(GPR_DEBUG, "TIMER %p: CANCEL pending=%s", timer,
@ -321,12 +344,12 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
gpr_mu_unlock(&shard->mu); gpr_mu_unlock(&shard->mu);
} }
/* This is called when the queue is empty and "now" has reached the /* Rebalances the timer shard by computing a new 'queue_deadline_cap' and moving
queue_deadline_cap. We compute a new queue deadline and then scan the map all relevant timers in shard->list (i.e timers with deadlines earlier than
for timers that fall at or under it. Returns true if the queue is no 'queue_deadline_cap') into into shard->heap.
longer empty. Returns 'true' if shard->heap has atleast ONE element
REQUIRES: shard->mu locked */ REQUIRES: shard->mu locked */
static int refill_queue(shard_type *shard, gpr_atm now) { static int refill_heap(timer_shard *shard, gpr_atm now) {
/* Compute the new queue window width and bound by the limits: */ /* Compute the new queue window width and bound by the limits: */
double computed_deadline_delta = double computed_deadline_delta =
grpc_time_averaged_stats_update_average(&shard->stats) * grpc_time_averaged_stats_update_average(&shard->stats) *
@ -363,7 +386,7 @@ static int refill_queue(shard_type *shard, gpr_atm now) {
/* This pops the next non-cancelled timer with deadline <= now from the /* This pops the next non-cancelled timer with deadline <= now from the
queue, or returns NULL if there isn't one. queue, or returns NULL if there isn't one.
REQUIRES: shard->mu locked */ REQUIRES: shard->mu locked */
static grpc_timer *pop_one(shard_type *shard, gpr_atm now) { static grpc_timer *pop_one(timer_shard *shard, gpr_atm now) {
grpc_timer *timer; grpc_timer *timer;
for (;;) { for (;;) {
if (GRPC_TRACER_ON(grpc_timer_check_trace)) { if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
@ -373,7 +396,7 @@ static grpc_timer *pop_one(shard_type *shard, gpr_atm now) {
} }
if (grpc_timer_heap_is_empty(&shard->heap)) { if (grpc_timer_heap_is_empty(&shard->heap)) {
if (now < shard->queue_deadline_cap) return NULL; if (now < shard->queue_deadline_cap) return NULL;
if (!refill_queue(shard, now)) return NULL; if (!refill_heap(shard, now)) return NULL;
} }
timer = grpc_timer_heap_top(&shard->heap); timer = grpc_timer_heap_top(&shard->heap);
if (GRPC_TRACER_ON(grpc_timer_check_trace)) { if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
@ -393,7 +416,7 @@ static grpc_timer *pop_one(shard_type *shard, gpr_atm now) {
} }
/* REQUIRES: shard->mu unlocked */ /* REQUIRES: shard->mu unlocked */
static size_t pop_timers(grpc_exec_ctx *exec_ctx, shard_type *shard, static size_t pop_timers(grpc_exec_ctx *exec_ctx, timer_shard *shard,
gpr_atm now, gpr_atm *new_min_deadline, gpr_atm now, gpr_atm *new_min_deadline,
grpc_error *error) { grpc_error *error) {
size_t n = 0; size_t n = 0;

@ -56,7 +56,7 @@ static gpr_timespec g_timed_waiter_deadline;
// generation counter to track which thread is waiting for the next timer // generation counter to track which thread is waiting for the next timer
static uint64_t g_timed_waiter_generation; static uint64_t g_timed_waiter_generation;
static void timer_thread(void *unused); static void timer_thread(void *completed_thread_ptr);
static void gc_completed_threads(void) { static void gc_completed_threads(void) {
if (g_completed_threads != NULL) { if (g_completed_threads != NULL) {
@ -81,10 +81,17 @@ static void start_timer_thread_and_unlock(void) {
if (GRPC_TRACER_ON(grpc_timer_check_trace)) { if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
gpr_log(GPR_DEBUG, "Spawn timer thread"); gpr_log(GPR_DEBUG, "Spawn timer thread");
} }
gpr_thd_id thd;
gpr_thd_options opt = gpr_thd_options_default(); gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt); gpr_thd_options_set_joinable(&opt);
gpr_thd_new(&thd, timer_thread, NULL, &opt); completed_thread *ct = gpr_malloc(sizeof(*ct));
// The call to gpr_thd_new() has to be under the same lock used by
// gc_completed_threads(), particularly due to ct->t, which is written here
// (internally by gpr_thd_new) and read there. Otherwise it's possible for ct
// to leak through g_completed_threads and be freed in gc_completed_threads()
// before "&ct->t" is written to, causing a use-after-free.
gpr_mu_lock(&g_mu);
gpr_thd_new(&ct->t, timer_thread, ct, &opt);
gpr_mu_unlock(&g_mu);
} }
void grpc_timer_manager_tick() { void grpc_timer_manager_tick() {
@ -245,7 +252,7 @@ static void timer_main_loop(grpc_exec_ctx *exec_ctx) {
} }
} }
static void timer_thread_cleanup(void) { static void timer_thread_cleanup(completed_thread *ct) {
gpr_mu_lock(&g_mu); gpr_mu_lock(&g_mu);
// terminate the thread: drop the waiter count, thread count, and let whomever // terminate the thread: drop the waiter count, thread count, and let whomever
// stopped the threading stuff know that we're done // stopped the threading stuff know that we're done
@ -254,8 +261,6 @@ static void timer_thread_cleanup(void) {
if (0 == g_thread_count) { if (0 == g_thread_count) {
gpr_cv_signal(&g_cv_shutdown); gpr_cv_signal(&g_cv_shutdown);
} }
completed_thread *ct = gpr_malloc(sizeof(*ct));
ct->t = gpr_thd_currentid();
ct->next = g_completed_threads; ct->next = g_completed_threads;
g_completed_threads = ct; g_completed_threads = ct;
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);
@ -264,14 +269,14 @@ static void timer_thread_cleanup(void) {
} }
} }
static void timer_thread(void *unused) { static void timer_thread(void *completed_thread_ptr) {
// this threads exec_ctx: we try to run things through to completion here // this threads exec_ctx: we try to run things through to completion here
// since it's easy to spin up new threads // since it's easy to spin up new threads
grpc_exec_ctx exec_ctx = grpc_exec_ctx exec_ctx =
GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL); GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
timer_main_loop(&exec_ctx); timer_main_loop(&exec_ctx);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
timer_thread_cleanup(); timer_thread_cleanup(completed_thread_ptr);
} }
static void start_threads(void) { static void start_threads(void) {

@ -29,8 +29,9 @@
#include <uv.h> #include <uv.h>
grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false, "timer");
grpc_tracer_flag grpc_timer_check_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_timer_check_trace =
GRPC_TRACER_INITIALIZER(false, "timer_check");
static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); } static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); }

@ -31,7 +31,7 @@
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_auth_context_refcount = grpc_tracer_flag grpc_trace_auth_context_refcount =
GRPC_TRACER_INITIALIZER(false); GRPC_TRACER_INITIALIZER(false, "auth_context_refcount");
#endif #endif
/* --- grpc_call --- */ /* --- grpc_call --- */

@ -125,6 +125,13 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &jwt_vtable; c->base.vtable = &jwt_vtable;
c->key = key; c->key = key;
gpr_timespec max_token_lifetime = grpc_max_auth_token_lifetime();
if (gpr_time_cmp(token_lifetime, max_token_lifetime) > 0) {
gpr_log(GPR_INFO,
"Cropping token lifetime to maximum allowed value (%d secs).",
(int)max_token_lifetime.tv_sec);
token_lifetime = grpc_max_auth_token_lifetime();
}
c->jwt_lifetime = token_lifetime; c->jwt_lifetime = token_lifetime;
gpr_mu_init(&c->cache_mu); gpr_mu_init(&c->cache_mu);
jwt_reset_cache(exec_ctx, c); jwt_reset_cache(exec_ctx, c);

@ -60,7 +60,8 @@ typedef struct {
gpr_refcount ref; gpr_refcount ref;
} secure_endpoint; } secure_endpoint;
grpc_tracer_flag grpc_trace_secure_endpoint = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_secure_endpoint =
GRPC_TRACER_INITIALIZER(false, "secure_endpoint");
static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) { static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) {
secure_endpoint *ep = secure_ep; secure_endpoint *ep = secure_ep;

@ -45,7 +45,7 @@
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_security_connector_refcount = grpc_tracer_flag grpc_trace_security_connector_refcount =
GRPC_TRACER_INITIALIZER(false); GRPC_TRACER_INITIALIZER(false, "security_connector_refcount");
#endif #endif
/* -- Constants. -- */ /* -- Constants. -- */
@ -383,8 +383,7 @@ static void fake_channel_add_handshakers(
grpc_handshake_manager_add( grpc_handshake_manager_add(
handshake_mgr, handshake_mgr,
grpc_security_handshaker_create( grpc_security_handshaker_create(
exec_ctx, tsi_create_adapter_handshaker( exec_ctx, tsi_create_fake_handshaker(true /* is_client */),
tsi_create_fake_handshaker(true /* is_client */)),
&sc->base)); &sc->base));
} }
@ -394,8 +393,7 @@ static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx,
grpc_handshake_manager_add( grpc_handshake_manager_add(
handshake_mgr, handshake_mgr,
grpc_security_handshaker_create( grpc_security_handshaker_create(
exec_ctx, tsi_create_adapter_handshaker( exec_ctx, tsi_create_fake_handshaker(false /* is_client */),
tsi_create_fake_handshaker(false /* is_client */)),
&sc->base)); &sc->base));
} }

@ -64,6 +64,8 @@ void gpr_default_log(gpr_log_func_args *args) {
time_t timer; time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
struct tm tm; struct tm tm;
static __thread long tid = 0;
if (tid == 0) tid = gettid();
timer = (time_t)now.tv_sec; timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '/'); final_slash = strrchr(args->file, '/');
@ -81,7 +83,7 @@ void gpr_default_log(gpr_log_func_args *args) {
gpr_asprintf(&prefix, "%s%s.%09" PRId32 " %7ld %s:%d]", gpr_asprintf(&prefix, "%s%s.%09" PRId32 " %7ld %s:%d]",
gpr_log_severity_string(args->severity), time_buffer, gpr_log_severity_string(args->severity), time_buffer,
now.tv_nsec, gettid(), display_file, args->line); now.tv_nsec, tid, display_file, args->line);
fprintf(stderr, "%-60s %s\n", prefix, args->message); fprintf(stderr, "%-60s %s\n", prefix, args->message);
gpr_free(prefix); gpr_free(prefix);

@ -19,4 +19,4 @@
#include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/debug/trace.h" #include "src/core/lib/debug/trace.h"
grpc_tracer_flag grpc_api_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_api_trace = GRPC_TRACER_INITIALIZER(false, "api");

@ -229,8 +229,10 @@ struct grpc_call {
void *saved_receiving_stream_ready_bctlp; void *saved_receiving_stream_ready_bctlp;
}; };
grpc_tracer_flag grpc_call_error_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_call_error_trace =
grpc_tracer_flag grpc_compression_trace = GRPC_TRACER_INITIALIZER(false); GRPC_TRACER_INITIALIZER(false, "call_error");
grpc_tracer_flag grpc_compression_trace =
GRPC_TRACER_INITIALIZER(false, "compression");
#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1))
#define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1) #define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1)

File diff suppressed because it is too large Load Diff

@ -84,10 +84,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
void *done_arg, grpc_cq_completion *storage); void *done_arg, grpc_cq_completion *storage);
grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cc); grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cc);
grpc_completion_queue *grpc_cq_from_pollset(grpc_pollset *ps);
void grpc_cq_mark_server_cq(grpc_completion_queue *cc);
bool grpc_cq_is_server_cq(grpc_completion_queue *cc);
bool grpc_cq_can_listen(grpc_completion_queue *cc); bool grpc_cq_can_listen(grpc_completion_queue *cc);
grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc); grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc);

@ -120,29 +120,27 @@ void grpc_init(void) {
grpc_slice_intern_init(); grpc_slice_intern_init();
grpc_mdctx_global_init(); grpc_mdctx_global_init();
grpc_channel_init_init(); grpc_channel_init_init();
grpc_register_tracer("api", &grpc_api_trace); grpc_register_tracer(&grpc_api_trace);
grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer(&grpc_trace_channel);
grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace); grpc_register_tracer(&grpc_connectivity_state_trace);
grpc_register_tracer("channel_stack_builder", grpc_register_tracer(&grpc_trace_channel_stack_builder);
&grpc_trace_channel_stack_builder); grpc_register_tracer(&grpc_http1_trace);
grpc_register_tracer("http1", &grpc_http1_trace); grpc_register_tracer(&grpc_cq_pluck_trace); // default on
grpc_register_tracer("queue_pluck", &grpc_cq_pluck_trace); // default on grpc_register_tracer(&grpc_combiner_trace);
grpc_register_tracer("combiner", &grpc_combiner_trace); grpc_register_tracer(&grpc_server_channel_trace);
grpc_register_tracer("server_channel", &grpc_server_channel_trace); grpc_register_tracer(&grpc_bdp_estimator_trace);
grpc_register_tracer("bdp_estimator", &grpc_bdp_estimator_trace); grpc_register_tracer(&grpc_cq_event_timeout_trace); // default on
grpc_register_tracer("queue_timeout", grpc_register_tracer(&grpc_trace_operation_failures);
&grpc_cq_event_timeout_trace); // default on grpc_register_tracer(&grpc_resource_quota_trace);
grpc_register_tracer("op_failure", &grpc_trace_operation_failures); grpc_register_tracer(&grpc_call_error_trace);
grpc_register_tracer("resource_quota", &grpc_resource_quota_trace);
grpc_register_tracer("call_error", &grpc_call_error_trace);
#ifndef NDEBUG #ifndef NDEBUG
grpc_register_tracer("pending_tags", &grpc_trace_pending_tags); grpc_register_tracer(&grpc_trace_pending_tags);
grpc_register_tracer("queue_refcount", &grpc_trace_cq_refcount); grpc_register_tracer(&grpc_trace_cq_refcount);
grpc_register_tracer("closure", &grpc_trace_closure); grpc_register_tracer(&grpc_trace_closure);
grpc_register_tracer("error_refcount", &grpc_trace_error_refcount); grpc_register_tracer(&grpc_trace_error_refcount);
grpc_register_tracer("stream_refcount", &grpc_trace_stream_refcount); grpc_register_tracer(&grpc_trace_stream_refcount);
grpc_register_tracer("fd_refcount", &grpc_trace_fd_refcount); grpc_register_tracer(&grpc_trace_fd_refcount);
grpc_register_tracer("metadata", &grpc_trace_metadata); grpc_register_tracer(&grpc_trace_metadata);
#endif #endif
grpc_security_pre_init(); grpc_security_pre_init();
grpc_iomgr_init(&exec_ctx); grpc_iomgr_init(&exec_ctx);

@ -37,13 +37,11 @@
#endif #endif
void grpc_security_pre_init(void) { void grpc_security_pre_init(void) {
grpc_register_tracer("secure_endpoint", &grpc_trace_secure_endpoint); grpc_register_tracer(&grpc_trace_secure_endpoint);
grpc_register_tracer("transport_security", &tsi_tracing_enabled); grpc_register_tracer(&tsi_tracing_enabled);
#ifndef NDEBUG #ifndef NDEBUG
grpc_register_tracer("auth_context_refcount", grpc_register_tracer(&grpc_trace_auth_context_refcount);
&grpc_trace_auth_context_refcount); grpc_register_tracer(&grpc_trace_security_connector_refcount);
grpc_register_tracer("security_connector_refcount",
&grpc_trace_security_connector_refcount);
#endif #endif
} }

@ -58,7 +58,8 @@ typedef struct registered_method registered_method;
typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type; typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type;
grpc_tracer_flag grpc_server_channel_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_server_channel_trace =
GRPC_TRACER_INITIALIZER(false, "server_channel");
typedef struct requested_call { typedef struct requested_call {
requested_call_type type; requested_call_type type;
@ -975,8 +976,6 @@ static void register_completion_queue(grpc_server *server,
if (server->cqs[i] == cq) return; if (server->cqs[i] == cq) return;
} }
grpc_cq_mark_server_cq(cq);
GRPC_CQ_INTERNAL_REF(cq, "server"); GRPC_CQ_INTERNAL_REF(cq, "server");
n = server->cq_count++; n = server->cq_count++;
server->cqs = gpr_realloc(server->cqs, server->cqs = gpr_realloc(server->cqs,
@ -1156,9 +1155,8 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
chand->channel = channel; chand->channel = channel;
size_t cq_idx; size_t cq_idx;
grpc_completion_queue *accepting_cq = grpc_cq_from_pollset(accepting_pollset);
for (cq_idx = 0; cq_idx < s->cq_count; cq_idx++) { for (cq_idx = 0; cq_idx < s->cq_count; cq_idx++) {
if (s->cqs[cq_idx] == accepting_cq) break; if (grpc_cq_pollset(s->cqs[cq_idx]) == accepting_pollset) break;
} }
if (cq_idx == s->cq_count) { if (cq_idx == s->cq_count) {
/* completion queue not found: pick a random one to publish new calls to */ /* completion queue not found: pick a random one to publish new calls to */

@ -23,7 +23,8 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
grpc_tracer_flag grpc_bdp_estimator_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_bdp_estimator_trace =
GRPC_TRACER_INITIALIZER(false, "bdp_estimator");
void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) { void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) {
estimator->estimate = 65536; estimator->estimate = 65536;

@ -24,7 +24,8 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
grpc_tracer_flag grpc_connectivity_state_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_connectivity_state_trace =
GRPC_TRACER_INITIALIZER(false, "connectivity_state");
const char *grpc_connectivity_state_name(grpc_connectivity_state state) { const char *grpc_connectivity_state_name(grpc_connectivity_state state) {
switch (state) { switch (state) {

@ -48,7 +48,8 @@
*/ */
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_metadata = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_metadata =
GRPC_TRACER_INITIALIZER(false, "metadata");
#define DEBUG_ARGS , const char *file, int line #define DEBUG_ARGS , const char *file, int line
#define FWD_DEBUG_ARGS , file, line #define FWD_DEBUG_ARGS , file, line
#define REF_MD_LOCKED(shard, s) ref_md_locked((shard), (s), __FILE__, __LINE__) #define REF_MD_LOCKED(shard, s) ref_md_locked((shard), (s), __FILE__, __LINE__)

@ -32,7 +32,8 @@
#include "src/core/lib/transport/transport_impl.h" #include "src/core/lib/transport/transport_impl.h"
#ifndef NDEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_stream_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_stream_refcount =
GRPC_TRACER_INITIALIZER(false, "stream_refcount");
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG

@ -26,6 +26,8 @@ extern void grpc_deadline_filter_init(void);
extern void grpc_deadline_filter_shutdown(void); extern void grpc_deadline_filter_shutdown(void);
extern void grpc_client_channel_init(void); extern void grpc_client_channel_init(void);
extern void grpc_client_channel_shutdown(void); extern void grpc_client_channel_shutdown(void);
extern void grpc_tsi_gts_init(void);
extern void grpc_tsi_gts_shutdown(void);
extern void grpc_load_reporting_plugin_init(void); extern void grpc_load_reporting_plugin_init(void);
extern void grpc_load_reporting_plugin_shutdown(void); extern void grpc_load_reporting_plugin_shutdown(void);
@ -38,6 +40,8 @@ void grpc_register_built_in_plugins(void) {
grpc_deadline_filter_shutdown); grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init, grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown); grpc_client_channel_shutdown);
grpc_register_plugin(grpc_tsi_gts_init,
grpc_tsi_gts_shutdown);
grpc_register_plugin(grpc_load_reporting_plugin_init, grpc_register_plugin(grpc_load_reporting_plugin_init,
grpc_load_reporting_plugin_shutdown); grpc_load_reporting_plugin_shutdown);
} }

@ -22,10 +22,14 @@ extern void grpc_http_filters_init(void);
extern void grpc_http_filters_shutdown(void); extern void grpc_http_filters_shutdown(void);
extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_init(void);
extern void grpc_chttp2_plugin_shutdown(void); extern void grpc_chttp2_plugin_shutdown(void);
extern void grpc_tsi_gts_init(void);
extern void grpc_tsi_gts_shutdown(void);
extern void grpc_deadline_filter_init(void); extern void grpc_deadline_filter_init(void);
extern void grpc_deadline_filter_shutdown(void); extern void grpc_deadline_filter_shutdown(void);
extern void grpc_client_channel_init(void); extern void grpc_client_channel_init(void);
extern void grpc_client_channel_shutdown(void); extern void grpc_client_channel_shutdown(void);
extern void grpc_inproc_plugin_init(void);
extern void grpc_inproc_plugin_shutdown(void);
extern void grpc_resolver_fake_init(void); extern void grpc_resolver_fake_init(void);
extern void grpc_resolver_fake_shutdown(void); extern void grpc_resolver_fake_shutdown(void);
extern void grpc_lb_policy_grpclb_init(void); extern void grpc_lb_policy_grpclb_init(void);
@ -56,10 +60,14 @@ void grpc_register_built_in_plugins(void) {
grpc_http_filters_shutdown); grpc_http_filters_shutdown);
grpc_register_plugin(grpc_chttp2_plugin_init, grpc_register_plugin(grpc_chttp2_plugin_init,
grpc_chttp2_plugin_shutdown); grpc_chttp2_plugin_shutdown);
grpc_register_plugin(grpc_tsi_gts_init,
grpc_tsi_gts_shutdown);
grpc_register_plugin(grpc_deadline_filter_init, grpc_register_plugin(grpc_deadline_filter_init,
grpc_deadline_filter_shutdown); grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init, grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown); grpc_client_channel_shutdown);
grpc_register_plugin(grpc_inproc_plugin_init,
grpc_inproc_plugin_shutdown);
grpc_register_plugin(grpc_resolver_fake_init, grpc_register_plugin(grpc_resolver_fake_init,
grpc_resolver_fake_shutdown); grpc_resolver_fake_shutdown);
grpc_register_plugin(grpc_lb_policy_grpclb_init, grpc_register_plugin(grpc_lb_policy_grpclb_init,

@ -26,6 +26,8 @@ extern void grpc_deadline_filter_init(void);
extern void grpc_deadline_filter_shutdown(void); extern void grpc_deadline_filter_shutdown(void);
extern void grpc_client_channel_init(void); extern void grpc_client_channel_init(void);
extern void grpc_client_channel_shutdown(void); extern void grpc_client_channel_shutdown(void);
extern void grpc_inproc_plugin_init(void);
extern void grpc_inproc_plugin_shutdown(void);
extern void grpc_resolver_dns_ares_init(void); extern void grpc_resolver_dns_ares_init(void);
extern void grpc_resolver_dns_ares_shutdown(void); extern void grpc_resolver_dns_ares_shutdown(void);
extern void grpc_resolver_dns_native_init(void); extern void grpc_resolver_dns_native_init(void);
@ -60,6 +62,8 @@ void grpc_register_built_in_plugins(void) {
grpc_deadline_filter_shutdown); grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init, grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown); grpc_client_channel_shutdown);
grpc_register_plugin(grpc_inproc_plugin_init,
grpc_inproc_plugin_shutdown);
grpc_register_plugin(grpc_resolver_dns_ares_init, grpc_register_plugin(grpc_resolver_dns_ares_init,
grpc_resolver_dns_ares_shutdown); grpc_resolver_dns_ares_shutdown);
grpc_register_plugin(grpc_resolver_dns_native_init, grpc_register_plugin(grpc_resolver_dns_native_init,

@ -31,6 +31,7 @@
#define TSI_FAKE_FRAME_HEADER_SIZE 4 #define TSI_FAKE_FRAME_HEADER_SIZE 4
#define TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE 64 #define TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE 64
#define TSI_FAKE_DEFAULT_FRAME_SIZE 16384 #define TSI_FAKE_DEFAULT_FRAME_SIZE 16384
#define TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE 256
/* --- Structure definitions. ---*/ /* --- Structure definitions. ---*/
@ -59,8 +60,10 @@ typedef struct {
int is_client; int is_client;
tsi_fake_handshake_message next_message_to_send; tsi_fake_handshake_message next_message_to_send;
int needs_incoming_message; int needs_incoming_message;
tsi_fake_frame incoming; tsi_fake_frame incoming_frame;
tsi_fake_frame outgoing; tsi_fake_frame outgoing_frame;
unsigned char *outgoing_bytes_buffer;
size_t outgoing_bytes_buffer_size;
tsi_result result; tsi_result result;
} tsi_fake_handshaker; } tsi_fake_handshaker;
@ -116,27 +119,23 @@ static void tsi_fake_frame_reset(tsi_fake_frame *frame, int needs_draining) {
if (!needs_draining) frame->size = 0; if (!needs_draining) frame->size = 0;
} }
/* Returns 1 if successful, 0 otherwise. */ /* Checks if the frame's allocated size is at least frame->size, and reallocs
static int tsi_fake_frame_ensure_size(tsi_fake_frame *frame) { * more memory if necessary. */
static void tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
if (frame->data == NULL) { if (frame->data == NULL) {
frame->allocated_size = frame->size; frame->allocated_size = frame->size;
frame->data = gpr_malloc(frame->allocated_size); frame->data = gpr_malloc(frame->allocated_size);
if (frame->data == NULL) return 0;
} else if (frame->size > frame->allocated_size) { } else if (frame->size > frame->allocated_size) {
unsigned char *new_data = gpr_realloc(frame->data, frame->size); unsigned char *new_data = gpr_realloc(frame->data, frame->size);
if (new_data == NULL) {
gpr_free(frame->data);
frame->data = NULL;
return 0;
}
frame->data = new_data; frame->data = new_data;
frame->allocated_size = frame->size; frame->allocated_size = frame->size;
} }
return 1;
} }
/* This method should not be called if frame->needs_framing is not 0. */ /* Decodes the serialized fake frame contained in incoming_bytes, and fills
static tsi_result fill_frame_from_bytes(const unsigned char *incoming_bytes, * frame with the contents of the decoded frame.
* This method should not be called if frame->needs_framing is not 0. */
static tsi_result tsi_fake_frame_decode(const unsigned char *incoming_bytes,
size_t *incoming_bytes_size, size_t *incoming_bytes_size,
tsi_fake_frame *frame) { tsi_fake_frame *frame) {
size_t available_size = *incoming_bytes_size; size_t available_size = *incoming_bytes_size;
@ -147,7 +146,6 @@ static tsi_result fill_frame_from_bytes(const unsigned char *incoming_bytes,
if (frame->data == NULL) { if (frame->data == NULL) {
frame->allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE; frame->allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE;
frame->data = gpr_malloc(frame->allocated_size); frame->data = gpr_malloc(frame->allocated_size);
if (frame->data == NULL) return TSI_OUT_OF_RESOURCES;
} }
if (frame->offset < TSI_FAKE_FRAME_HEADER_SIZE) { if (frame->offset < TSI_FAKE_FRAME_HEADER_SIZE) {
@ -165,7 +163,7 @@ static tsi_result fill_frame_from_bytes(const unsigned char *incoming_bytes,
frame->offset += to_read_size; frame->offset += to_read_size;
available_size -= to_read_size; available_size -= to_read_size;
frame->size = load32_little_endian(frame->data); frame->size = load32_little_endian(frame->data);
if (!tsi_fake_frame_ensure_size(frame)) return TSI_OUT_OF_RESOURCES; tsi_fake_frame_ensure_size(frame);
} }
to_read_size = frame->size - frame->offset; to_read_size = frame->size - frame->offset;
@ -183,8 +181,10 @@ static tsi_result fill_frame_from_bytes(const unsigned char *incoming_bytes,
return TSI_OK; return TSI_OK;
} }
/* This method should not be called if frame->needs_framing is 0. */ /* Encodes a fake frame into its wire format and places the result in
static tsi_result drain_frame_to_bytes(unsigned char *outgoing_bytes, * outgoing_bytes. outgoing_bytes_size indicates the size of the encoded frame.
* This method should not be called if frame->needs_framing is 0. */
static tsi_result tsi_fake_frame_encode(unsigned char *outgoing_bytes,
size_t *outgoing_bytes_size, size_t *outgoing_bytes_size,
tsi_fake_frame *frame) { tsi_fake_frame *frame) {
size_t to_write_size = frame->size - frame->offset; size_t to_write_size = frame->size - frame->offset;
@ -200,17 +200,20 @@ static tsi_result drain_frame_to_bytes(unsigned char *outgoing_bytes,
return TSI_OK; return TSI_OK;
} }
static tsi_result bytes_to_frame(unsigned char *bytes, size_t bytes_size, /* Sets the payload of a fake frame to contain the given data blob, where
* data_size indicates the size of data. */
static tsi_result tsi_fake_frame_set_data(unsigned char *data, size_t data_size,
tsi_fake_frame *frame) { tsi_fake_frame *frame) {
frame->offset = 0; frame->offset = 0;
frame->size = bytes_size + TSI_FAKE_FRAME_HEADER_SIZE; frame->size = data_size + TSI_FAKE_FRAME_HEADER_SIZE;
if (!tsi_fake_frame_ensure_size(frame)) return TSI_OUT_OF_RESOURCES; tsi_fake_frame_ensure_size(frame);
store32_little_endian((uint32_t)frame->size, frame->data); store32_little_endian((uint32_t)frame->size, frame->data);
memcpy(frame->data + TSI_FAKE_FRAME_HEADER_SIZE, bytes, bytes_size); memcpy(frame->data + TSI_FAKE_FRAME_HEADER_SIZE, data, data_size);
tsi_fake_frame_reset(frame, 1 /* needs draining */); tsi_fake_frame_reset(frame, 1 /* needs draining */);
return TSI_OK; return TSI_OK;
} }
/* Destroys the contents of a fake frame. */
static void tsi_fake_frame_destruct(tsi_fake_frame *frame) { static void tsi_fake_frame_destruct(tsi_fake_frame *frame) {
if (frame->data != NULL) gpr_free(frame->data); if (frame->data != NULL) gpr_free(frame->data);
} }
@ -235,7 +238,7 @@ static tsi_result fake_protector_protect(tsi_frame_protector *self,
if (frame->needs_draining) { if (frame->needs_draining) {
drained_size = saved_output_size - *num_bytes_written; drained_size = saved_output_size - *num_bytes_written;
result = result =
drain_frame_to_bytes(protected_output_frames, &drained_size, frame); tsi_fake_frame_encode(protected_output_frames, &drained_size, frame);
*num_bytes_written += drained_size; *num_bytes_written += drained_size;
protected_output_frames += drained_size; protected_output_frames += drained_size;
if (result != TSI_OK) { if (result != TSI_OK) {
@ -254,15 +257,15 @@ static tsi_result fake_protector_protect(tsi_frame_protector *self,
size_t written_in_frame_size = 0; size_t written_in_frame_size = 0;
store32_little_endian((uint32_t)impl->max_frame_size, frame_header); store32_little_endian((uint32_t)impl->max_frame_size, frame_header);
written_in_frame_size = TSI_FAKE_FRAME_HEADER_SIZE; written_in_frame_size = TSI_FAKE_FRAME_HEADER_SIZE;
result = fill_frame_from_bytes(frame_header, &written_in_frame_size, frame); result = tsi_fake_frame_decode(frame_header, &written_in_frame_size, frame);
if (result != TSI_INCOMPLETE_DATA) { if (result != TSI_INCOMPLETE_DATA) {
gpr_log(GPR_ERROR, "fill_frame_from_bytes returned %s", gpr_log(GPR_ERROR, "tsi_fake_frame_decode returned %s",
tsi_result_to_string(result)); tsi_result_to_string(result));
return result; return result;
} }
} }
result = result =
fill_frame_from_bytes(unprotected_bytes, unprotected_bytes_size, frame); tsi_fake_frame_decode(unprotected_bytes, unprotected_bytes_size, frame);
if (result != TSI_OK) { if (result != TSI_OK) {
if (result == TSI_INCOMPLETE_DATA) result = TSI_OK; if (result == TSI_INCOMPLETE_DATA) result = TSI_OK;
return result; return result;
@ -272,7 +275,7 @@ static tsi_result fake_protector_protect(tsi_frame_protector *self,
if (!frame->needs_draining) return TSI_INTERNAL_ERROR; if (!frame->needs_draining) return TSI_INTERNAL_ERROR;
if (frame->offset != 0) return TSI_INTERNAL_ERROR; if (frame->offset != 0) return TSI_INTERNAL_ERROR;
drained_size = saved_output_size - *num_bytes_written; drained_size = saved_output_size - *num_bytes_written;
result = drain_frame_to_bytes(protected_output_frames, &drained_size, frame); result = tsi_fake_frame_encode(protected_output_frames, &drained_size, frame);
*num_bytes_written += drained_size; *num_bytes_written += drained_size;
if (result == TSI_INCOMPLETE_DATA) result = TSI_OK; if (result == TSI_INCOMPLETE_DATA) result = TSI_OK;
return result; return result;
@ -292,7 +295,7 @@ static tsi_result fake_protector_protect_flush(
store32_little_endian((uint32_t)frame->size, store32_little_endian((uint32_t)frame->size,
frame->data); /* Overwrite header. */ frame->data); /* Overwrite header. */
} }
result = drain_frame_to_bytes(protected_output_frames, result = tsi_fake_frame_encode(protected_output_frames,
protected_output_frames_size, frame); protected_output_frames_size, frame);
if (result == TSI_INCOMPLETE_DATA) result = TSI_OK; if (result == TSI_INCOMPLETE_DATA) result = TSI_OK;
*still_pending_size = frame->size - frame->offset; *still_pending_size = frame->size - frame->offset;
@ -316,7 +319,7 @@ static tsi_result fake_protector_unprotect(
/* Go past the header if needed. */ /* Go past the header if needed. */
if (frame->offset == 0) frame->offset = TSI_FAKE_FRAME_HEADER_SIZE; if (frame->offset == 0) frame->offset = TSI_FAKE_FRAME_HEADER_SIZE;
drained_size = saved_output_size - *num_bytes_written; drained_size = saved_output_size - *num_bytes_written;
result = drain_frame_to_bytes(unprotected_bytes, &drained_size, frame); result = tsi_fake_frame_encode(unprotected_bytes, &drained_size, frame);
unprotected_bytes += drained_size; unprotected_bytes += drained_size;
*num_bytes_written += drained_size; *num_bytes_written += drained_size;
if (result != TSI_OK) { if (result != TSI_OK) {
@ -330,7 +333,7 @@ static tsi_result fake_protector_unprotect(
/* Now process the protected_bytes. */ /* Now process the protected_bytes. */
if (frame->needs_draining) return TSI_INTERNAL_ERROR; if (frame->needs_draining) return TSI_INTERNAL_ERROR;
result = fill_frame_from_bytes(protected_frames_bytes, result = tsi_fake_frame_decode(protected_frames_bytes,
protected_frames_bytes_size, frame); protected_frames_bytes_size, frame);
if (result != TSI_OK) { if (result != TSI_OK) {
if (result == TSI_INCOMPLETE_DATA) result = TSI_OK; if (result == TSI_INCOMPLETE_DATA) result = TSI_OK;
@ -342,7 +345,7 @@ static tsi_result fake_protector_unprotect(
if (frame->offset != 0) return TSI_INTERNAL_ERROR; if (frame->offset != 0) return TSI_INTERNAL_ERROR;
frame->offset = TSI_FAKE_FRAME_HEADER_SIZE; /* Go past the header. */ frame->offset = TSI_FAKE_FRAME_HEADER_SIZE; /* Go past the header. */
drained_size = saved_output_size - *num_bytes_written; drained_size = saved_output_size - *num_bytes_written;
result = drain_frame_to_bytes(unprotected_bytes, &drained_size, frame); result = tsi_fake_frame_encode(unprotected_bytes, &drained_size, frame);
*num_bytes_written += drained_size; *num_bytes_written += drained_size;
if (result == TSI_INCOMPLETE_DATA) result = TSI_OK; if (result == TSI_INCOMPLETE_DATA) result = TSI_OK;
return result; return result;
@ -360,6 +363,72 @@ static const tsi_frame_protector_vtable frame_protector_vtable = {
fake_protector_unprotect, fake_protector_destroy, fake_protector_unprotect, fake_protector_destroy,
}; };
/* --- tsi_handshaker_result methods implementation. ---*/
typedef struct {
tsi_handshaker_result base;
unsigned char *unused_bytes;
size_t unused_bytes_size;
} fake_handshaker_result;
static tsi_result fake_handshaker_result_extract_peer(
const tsi_handshaker_result *self, tsi_peer *peer) {
/* Construct a tsi_peer with 1 property: certificate type. */
tsi_result result = tsi_construct_peer(1, peer);
if (result != TSI_OK) return result;
result = tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_FAKE_CERTIFICATE_TYPE,
&peer->properties[0]);
if (result != TSI_OK) tsi_peer_destruct(peer);
return result;
}
static tsi_result fake_handshaker_result_create_frame_protector(
const tsi_handshaker_result *self, size_t *max_output_protected_frame_size,
tsi_frame_protector **protector) {
*protector = tsi_create_fake_frame_protector(max_output_protected_frame_size);
return TSI_OK;
}
static tsi_result fake_handshaker_result_get_unused_bytes(
const tsi_handshaker_result *self, unsigned char **bytes,
size_t *bytes_size) {
fake_handshaker_result *result = (fake_handshaker_result *)self;
*bytes_size = result->unused_bytes_size;
*bytes = result->unused_bytes;
return TSI_OK;
}
static void fake_handshaker_result_destroy(tsi_handshaker_result *self) {
fake_handshaker_result *result = (fake_handshaker_result *)self;
gpr_free(result->unused_bytes);
gpr_free(self);
}
static const tsi_handshaker_result_vtable handshaker_result_vtable = {
fake_handshaker_result_extract_peer,
fake_handshaker_result_create_frame_protector,
fake_handshaker_result_get_unused_bytes, fake_handshaker_result_destroy,
};
static tsi_result fake_handshaker_result_create(
const unsigned char *unused_bytes, size_t unused_bytes_size,
tsi_handshaker_result **handshaker_result) {
if ((unused_bytes_size > 0 && unused_bytes == NULL) ||
handshaker_result == NULL) {
return TSI_INVALID_ARGUMENT;
}
fake_handshaker_result *result = gpr_zalloc(sizeof(*result));
result->base.vtable = &handshaker_result_vtable;
if (unused_bytes_size > 0) {
result->unused_bytes = gpr_malloc(unused_bytes_size);
memcpy(result->unused_bytes, unused_bytes, unused_bytes_size);
}
result->unused_bytes_size = unused_bytes_size;
*handshaker_result = &result->base;
return TSI_OK;
}
/* --- tsi_handshaker methods implementation. ---*/ /* --- tsi_handshaker methods implementation. ---*/
static tsi_result fake_handshaker_get_bytes_to_send_to_peer( static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
@ -370,13 +439,13 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
*bytes_size = 0; *bytes_size = 0;
return TSI_OK; return TSI_OK;
} }
if (!impl->outgoing.needs_draining) { if (!impl->outgoing_frame.needs_draining) {
tsi_fake_handshake_message next_message_to_send = tsi_fake_handshake_message next_message_to_send =
impl->next_message_to_send + 2; impl->next_message_to_send + 2;
const char *msg_string = const char *msg_string =
tsi_fake_handshake_message_to_string(impl->next_message_to_send); tsi_fake_handshake_message_to_string(impl->next_message_to_send);
result = bytes_to_frame((unsigned char *)msg_string, strlen(msg_string), result = tsi_fake_frame_set_data((unsigned char *)msg_string,
&impl->outgoing); strlen(msg_string), &impl->outgoing_frame);
if (result != TSI_OK) return result; if (result != TSI_OK) return result;
if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX; next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX;
@ -388,7 +457,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
} }
impl->next_message_to_send = next_message_to_send; impl->next_message_to_send = next_message_to_send;
} }
result = drain_frame_to_bytes(bytes, bytes_size, &impl->outgoing); result = tsi_fake_frame_encode(bytes, bytes_size, &impl->outgoing_frame);
if (result != TSI_OK) return result; if (result != TSI_OK) return result;
if (!impl->is_client && if (!impl->is_client &&
impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
@ -414,12 +483,12 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
*bytes_size = 0; *bytes_size = 0;
return TSI_OK; return TSI_OK;
} }
result = fill_frame_from_bytes(bytes, bytes_size, &impl->incoming); result = tsi_fake_frame_decode(bytes, bytes_size, &impl->incoming_frame);
if (result != TSI_OK) return result; if (result != TSI_OK) return result;
/* We now have a complete frame. */ /* We now have a complete frame. */
result = tsi_fake_handshake_message_from_string( result = tsi_fake_handshake_message_from_string(
(const char *)impl->incoming.data + TSI_FAKE_FRAME_HEADER_SIZE, (const char *)impl->incoming_frame.data + TSI_FAKE_FRAME_HEADER_SIZE,
&received_msg); &received_msg);
if (result != TSI_OK) { if (result != TSI_OK) {
impl->result = result; impl->result = result;
@ -434,7 +503,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server", gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server",
tsi_fake_handshake_message_to_string(received_msg)); tsi_fake_handshake_message_to_string(received_msg));
} }
tsi_fake_frame_reset(&impl->incoming, 0 /* needs_draining */); tsi_fake_frame_reset(&impl->incoming_frame, 0 /* needs_draining */);
impl->needs_incoming_message = 0; impl->needs_incoming_message = 0;
if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
/* We're done. */ /* We're done. */
@ -451,40 +520,86 @@ static tsi_result fake_handshaker_get_result(tsi_handshaker *self) {
return impl->result; return impl->result;
} }
static tsi_result fake_handshaker_extract_peer(tsi_handshaker *self,
tsi_peer *peer) {
tsi_result result = tsi_construct_peer(1, peer);
if (result != TSI_OK) return result;
result = tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_FAKE_CERTIFICATE_TYPE,
&peer->properties[0]);
if (result != TSI_OK) tsi_peer_destruct(peer);
return result;
}
static tsi_result fake_handshaker_create_frame_protector(
tsi_handshaker *self, size_t *max_protected_frame_size,
tsi_frame_protector **protector) {
*protector = tsi_create_fake_protector(max_protected_frame_size);
if (*protector == NULL) return TSI_OUT_OF_RESOURCES;
return TSI_OK;
}
static void fake_handshaker_destroy(tsi_handshaker *self) { static void fake_handshaker_destroy(tsi_handshaker *self) {
tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self; tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
tsi_fake_frame_destruct(&impl->incoming); tsi_fake_frame_destruct(&impl->incoming_frame);
tsi_fake_frame_destruct(&impl->outgoing); tsi_fake_frame_destruct(&impl->outgoing_frame);
gpr_free(impl->outgoing_bytes_buffer);
gpr_free(self); gpr_free(self);
} }
static tsi_result fake_handshaker_next(
tsi_handshaker *self, const unsigned char *received_bytes,
size_t received_bytes_size, unsigned char **bytes_to_send,
size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
tsi_handshaker_on_next_done_cb cb, void *user_data) {
/* Sanity check the arguments. */
if ((received_bytes_size > 0 && received_bytes == NULL) ||
bytes_to_send == NULL || bytes_to_send_size == NULL ||
handshaker_result == NULL) {
return TSI_INVALID_ARGUMENT;
}
tsi_fake_handshaker *handshaker = (tsi_fake_handshaker *)self;
tsi_result result = TSI_OK;
/* Decode and process a handshake frame from the peer. */
size_t consumed_bytes_size = received_bytes_size;
if (received_bytes_size > 0) {
result = fake_handshaker_process_bytes_from_peer(self, received_bytes,
&consumed_bytes_size);
if (result != TSI_OK) return result;
}
/* Create a handshake message to send to the peer and encode it as a fake
* frame. */
size_t offset = 0;
do {
size_t sent_bytes_size = handshaker->outgoing_bytes_buffer_size - offset;
result = fake_handshaker_get_bytes_to_send_to_peer(
self, handshaker->outgoing_bytes_buffer + offset, &sent_bytes_size);
offset += sent_bytes_size;
if (result == TSI_INCOMPLETE_DATA) {
handshaker->outgoing_bytes_buffer_size *= 2;
handshaker->outgoing_bytes_buffer =
gpr_realloc(handshaker->outgoing_bytes_buffer,
handshaker->outgoing_bytes_buffer_size);
}
} while (result == TSI_INCOMPLETE_DATA);
if (result != TSI_OK) return result;
*bytes_to_send = handshaker->outgoing_bytes_buffer;
*bytes_to_send_size = offset;
/* Check if the handshake was completed. */
if (fake_handshaker_get_result(self) == TSI_HANDSHAKE_IN_PROGRESS) {
*handshaker_result = NULL;
} else {
/* Calculate the unused bytes. */
const unsigned char *unused_bytes = NULL;
size_t unused_bytes_size = received_bytes_size - consumed_bytes_size;
if (unused_bytes_size > 0) {
unused_bytes = received_bytes + consumed_bytes_size;
}
/* Create a handshaker_result containing the unused bytes. */
result = fake_handshaker_result_create(unused_bytes, unused_bytes_size,
handshaker_result);
if (result == TSI_OK) {
/* Indicate that the handshake has completed and that a handshaker_result
* has been created. */
self->handshaker_result_created = true;
}
}
return result;
}
static const tsi_handshaker_vtable handshaker_vtable = { static const tsi_handshaker_vtable handshaker_vtable = {
fake_handshaker_get_bytes_to_send_to_peer, NULL, /* get_bytes_to_send_to_peer -- deprecated */
fake_handshaker_process_bytes_from_peer, NULL, /* process_bytes_from_peer -- deprecated */
fake_handshaker_get_result, NULL, /* get_result -- deprecated */
fake_handshaker_extract_peer, NULL, /* extract_peer -- deprecated */
fake_handshaker_create_frame_protector, NULL, /* create_frame_protector -- deprecated */
fake_handshaker_destroy, fake_handshaker_destroy,
NULL, fake_handshaker_next,
}; };
tsi_handshaker *tsi_create_fake_handshaker(int is_client) { tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
@ -492,6 +607,9 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
impl->base.vtable = &handshaker_vtable; impl->base.vtable = &handshaker_vtable;
impl->is_client = is_client; impl->is_client = is_client;
impl->result = TSI_HANDSHAKE_IN_PROGRESS; impl->result = TSI_HANDSHAKE_IN_PROGRESS;
impl->outgoing_bytes_buffer_size =
TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE;
impl->outgoing_bytes_buffer = gpr_malloc(impl->outgoing_bytes_buffer_size);
if (is_client) { if (is_client) {
impl->needs_incoming_message = 0; impl->needs_incoming_message = 0;
impl->next_message_to_send = TSI_FAKE_CLIENT_INIT; impl->next_message_to_send = TSI_FAKE_CLIENT_INIT;
@ -502,7 +620,7 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
return &impl->base; return &impl->base;
} }
tsi_frame_protector *tsi_create_fake_protector( tsi_frame_protector *tsi_create_fake_frame_protector(
size_t *max_protected_frame_size) { size_t *max_protected_frame_size) {
tsi_fake_frame_protector *impl = gpr_zalloc(sizeof(*impl)); tsi_fake_frame_protector *impl = gpr_zalloc(sizeof(*impl));
impl->max_frame_size = (max_protected_frame_size == NULL) impl->max_frame_size = (max_protected_frame_size == NULL)

@ -36,7 +36,7 @@ extern "C" {
tsi_handshaker *tsi_create_fake_handshaker(int is_client); tsi_handshaker *tsi_create_fake_handshaker(int is_client);
/* Creates a protector directly without going through the handshake phase. */ /* Creates a protector directly without going through the handshake phase. */
tsi_frame_protector *tsi_create_fake_protector( tsi_frame_protector *tsi_create_fake_frame_protector(
size_t *max_protected_frame_size); size_t *max_protected_frame_size);
#ifdef __cplusplus #ifdef __cplusplus

@ -0,0 +1,40 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/tsi/gts_transport_security.h"
#include <string.h>
static gts_shared_resource g_gts_resource;
gts_shared_resource *gts_get_shared_resource(void) { return &g_gts_resource; }
void grpc_tsi_gts_init() {
memset(&g_gts_resource, 0, sizeof(gts_shared_resource));
gpr_mu_init(&g_gts_resource.mu);
}
void grpc_tsi_gts_shutdown() {
gpr_mu_destroy(&g_gts_resource.mu);
if (g_gts_resource.cq == NULL) {
return;
}
grpc_completion_queue_destroy(g_gts_resource.cq);
grpc_channel_destroy(g_gts_resource.channel);
gpr_thd_join(g_gts_resource.thread_id);
}

@ -0,0 +1,37 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H
#define GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H
#include <grpc/grpc.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
typedef struct gts_shared_resource {
gpr_thd_id thread_id;
grpc_channel *channel;
grpc_completion_queue *cq;
gpr_mu mu;
} gts_shared_resource;
/* This method returns the address of gts_shared_resource object shared by all
* TSI handshakes. */
gts_shared_resource *gts_get_shared_resource(void);
#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */

@ -26,7 +26,7 @@
/* --- Tracing. --- */ /* --- Tracing. --- */
grpc_tracer_flag tsi_tracing_enabled = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag tsi_tracing_enabled = GRPC_TRACER_INITIALIZER(false, "tsi");
/* --- tsi_result common implementation. --- */ /* --- tsi_result common implementation. --- */

@ -93,6 +93,11 @@ void CoreCodegen::grpc_byte_buffer_destroy(grpc_byte_buffer* bb) {
::grpc_byte_buffer_destroy(bb); ::grpc_byte_buffer_destroy(bb);
} }
grpc_call_error CoreCodegen::grpc_call_cancel_with_status(
grpc_call* call, grpc_status_code status, const char* description,
void* reserved) {
return ::grpc_call_cancel_with_status(call, status, description, reserved);
}
void CoreCodegen::grpc_call_ref(grpc_call* call) { ::grpc_call_ref(call); } void CoreCodegen::grpc_call_ref(grpc_call* call) { ::grpc_call_ref(call); }
void CoreCodegen::grpc_call_unref(grpc_call* call) { ::grpc_call_unref(call); } void CoreCodegen::grpc_call_unref(grpc_call* call) { ::grpc_call_unref(call); }
void* CoreCodegen::grpc_call_arena_alloc(grpc_call* call, size_t length) { void* CoreCodegen::grpc_call_arena_alloc(grpc_call* call, size_t length) {

@ -36,7 +36,9 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/ext/transport/inproc/inproc_transport.h"
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#include "src/cpp/client/create_channel_internal.h"
#include "src/cpp/server/health/default_health_check_service.h" #include "src/cpp/server/health/default_health_check_service.h"
#include "src/cpp/thread_manager/thread_manager.h" #include "src/cpp/thread_manager/thread_manager.h"
@ -422,6 +424,13 @@ void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) {
grpc_server* Server::c_server() { return server_; } grpc_server* Server::c_server() { return server_; }
std::shared_ptr<Channel> Server::InProcessChannel(
const ChannelArguments& args) {
grpc_channel_args channel_args = args.c_channel_args();
return CreateChannelInternal(
"inproc", grpc_inproc_channel_create(server_, &channel_args, nullptr));
}
static grpc_server_register_method_payload_handling PayloadHandlingForMethod( static grpc_server_register_method_payload_handling PayloadHandlingForMethod(
internal::RpcServiceMethod* method) { internal::RpcServiceMethod* method) {
switch (method->method_type()) { switch (method->method_type()) {

@ -27,14 +27,23 @@
namespace grpc { namespace grpc {
ThreadManager::WorkerThread::WorkerThread(ThreadManager* thd_mgr) ThreadManager::WorkerThread::WorkerThread(ThreadManager* thd_mgr)
: thd_mgr_(thd_mgr), thd_(&ThreadManager::WorkerThread::Run, this) {} : thd_mgr_(thd_mgr) {
// Make thread creation exclusive with respect to its join happening in
// ~WorkerThread().
std::lock_guard<std::mutex> lock(wt_mu_);
thd_ = std::thread(&ThreadManager::WorkerThread::Run, this);
}
void ThreadManager::WorkerThread::Run() { void ThreadManager::WorkerThread::Run() {
thd_mgr_->MainWorkLoop(); thd_mgr_->MainWorkLoop();
thd_mgr_->MarkAsCompleted(this); thd_mgr_->MarkAsCompleted(this);
} }
ThreadManager::WorkerThread::~WorkerThread() { thd_.join(); } ThreadManager::WorkerThread::~WorkerThread() {
// Don't join until the thread is fully constructed.
std::lock_guard<std::mutex> lock(wt_mu_);
thd_.join();
}
ThreadManager::ThreadManager(int min_pollers, int max_pollers) ThreadManager::ThreadManager(int min_pollers, int max_pollers)
: shutdown_(false), : shutdown_(false),
@ -45,7 +54,7 @@ ThreadManager::ThreadManager(int min_pollers, int max_pollers)
ThreadManager::~ThreadManager() { ThreadManager::~ThreadManager() {
{ {
std::unique_lock<std::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
GPR_ASSERT(num_threads_ == 0); GPR_ASSERT(num_threads_ == 0);
} }
@ -60,22 +69,22 @@ void ThreadManager::Wait() {
} }
void ThreadManager::Shutdown() { void ThreadManager::Shutdown() {
std::unique_lock<std::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
shutdown_ = true; shutdown_ = true;
} }
bool ThreadManager::IsShutdown() { bool ThreadManager::IsShutdown() {
std::unique_lock<std::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
return shutdown_; return shutdown_;
} }
void ThreadManager::MarkAsCompleted(WorkerThread* thd) { void ThreadManager::MarkAsCompleted(WorkerThread* thd) {
{ {
std::unique_lock<std::mutex> list_lock(list_mu_); std::lock_guard<std::mutex> list_lock(list_mu_);
completed_threads_.push_back(thd); completed_threads_.push_back(thd);
} }
std::unique_lock<std::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
num_threads_--; num_threads_--;
if (num_threads_ == 0) { if (num_threads_ == 0) {
shutdown_cv_.notify_one(); shutdown_cv_.notify_one();

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

Loading…
Cancel
Save