Merge remote-tracking branch 'upstream/master' into core-end2end-tests-cronet-update

pull/8241/head
Muxi Yan 8 years ago
commit 4be8afc7ed
  1. 3
      .gitmodules
  2. 90
      BUILD
  3. 85
      CMakeLists.txt
  4. 452
      Makefile
  5. 1
      binding.gyp
  6. 89
      build.yaml
  7. 1
      config.m4
  8. 88
      doc/cpp-style-guide.md
  9. 3
      gRPC-Core.podspec
  10. 2
      grpc.gemspec
  11. 2
      include/grpc++/alarm.h
  12. 14
      include/grpc++/channel.h
  13. 12
      include/grpc++/ext/proto_server_reflection_plugin.h
  14. 188
      include/grpc++/ext/reflection.grpc.pb.h
  15. 2125
      include/grpc++/ext/reflection.pb.h
  16. 4
      include/grpc++/generic/async_generic_service.h
  17. 2
      include/grpc++/generic/generic_stub.h
  18. 64
      include/grpc++/impl/codegen/async_stream.h
  19. 9
      include/grpc++/impl/codegen/async_unary_call.h
  20. 14
      include/grpc++/impl/codegen/call.h
  21. 6
      include/grpc++/impl/codegen/client_context.h
  22. 83
      include/grpc++/impl/codegen/config.h
  23. 67
      include/grpc++/impl/codegen/core_codegen.h
  24. 10
      include/grpc++/impl/codegen/method_handler_impl.h
  25. 22
      include/grpc++/impl/codegen/proto_utils.h
  26. 2
      include/grpc++/impl/codegen/server_context.h
  27. 10
      include/grpc++/impl/codegen/server_interface.h
  28. 45
      include/grpc++/impl/codegen/sync.h
  29. 111
      include/grpc++/impl/codegen/sync_no_cxx11.h
  30. 76
      include/grpc++/impl/codegen/sync_stream.h
  31. 4
      include/grpc++/impl/codegen/time.h
  32. 8
      include/grpc++/impl/grpc_library.h
  33. 39
      include/grpc++/impl/sync.h
  34. 117
      include/grpc++/impl/thd_no_cxx11.h
  35. 2
      include/grpc++/resource_quota.h
  36. 28
      include/grpc++/server.h
  37. 2
      include/grpc++/support/byte_buffer.h
  38. 5
      include/grpc++/support/channel_arguments.h
  39. 2
      include/grpc++/support/slice.h
  40. 2
      package.xml
  41. 2
      setup.py
  42. 57
      src/compiler/cpp_generator.cc
  43. 446
      src/compiler/python_generator.cc
  44. 4
      src/compiler/python_generator.h
  45. 6
      src/core/ext/client_channel/lb_policy.h
  46. 651
      src/core/ext/lb_policy/grpclb/grpclb.c
  47. 4
      src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
  48. 45
      src/core/ext/lb_policy/round_robin/round_robin.c
  49. 2
      src/core/ext/resolver/dns/native/dns_resolver.c
  50. 2
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  51. 26
      src/core/ext/transport/chttp2/transport/hpack_parser.c
  52. 3
      src/core/lib/iomgr/endpoint_pair_uv.c
  53. 2
      src/core/lib/iomgr/network_status_tracker.c
  54. 7
      src/core/lib/iomgr/resource_quota.c
  55. 5
      src/core/lib/iomgr/resource_quota.h
  56. 36
      src/core/lib/iomgr/tcp_client_uv.c
  57. 45
      src/core/lib/iomgr/tcp_server_posix.c
  58. 24
      src/core/lib/iomgr/tcp_server_uv.c
  59. 71
      src/core/lib/iomgr/tcp_uv.c
  60. 4
      src/core/lib/iomgr/tcp_uv.h
  61. 4
      src/core/lib/security/transport/security_connector.c
  62. 36
      src/core/lib/transport/pid_controller.c
  63. 39
      src/core/lib/transport/pid_controller.h
  64. 14
      src/core/lib/tsi/ssl_transport_security.c
  65. 6
      src/cpp/client/channel_cc.cc
  66. 12
      src/cpp/client/client_context.cc
  67. 8
      src/cpp/client/cronet_credentials.cc
  68. 8
      src/cpp/client/insecure_credentials.cc
  69. 14
      src/cpp/client/secure_credentials.h
  70. 5
      src/cpp/common/channel_arguments.cc
  71. 2
      src/cpp/common/channel_filter.h
  72. 21
      src/cpp/common/secure_auth_context.h
  73. 23
      src/cpp/ext/proto_server_reflection.h
  74. 97
      src/cpp/ext/reflection.grpc.pb.cc
  75. 4045
      src/cpp/ext/reflection.pb.cc
  76. 16
      src/cpp/server/dynamic_thread_pool.cc
  77. 17
      src/cpp/server/dynamic_thread_pool.h
  78. 7
      src/cpp/server/insecure_server_credentials.cc
  79. 11
      src/cpp/server/secure_server_credentials.h
  80. 32
      src/cpp/server/server_cc.cc
  81. 17
      src/cpp/server/server_context.cc
  82. 29
      src/cpp/thread_manager/thread_manager.cc
  83. 13
      src/cpp/thread_manager/thread_manager.h
  84. 5
      src/cpp/util/time_cc.cc
  85. 37
      src/google_benchmark/gen_build_yaml.py
  86. 13
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
  87. 12
      src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h
  88. 14
      src/objective-c/GRPCClient/GRPCCall+OAuth2.h
  89. 25
      src/objective-c/GRPCClient/GRPCCall+Tests.h
  90. 185
      src/objective-c/GRPCClient/GRPCCall.h
  91. 142
      src/objective-c/GRPCClient/GRPCCall.m
  92. 15
      src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
  93. 17
      src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
  94. 53
      src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
  95. 65
      src/objective-c/GRPCClient/private/GRPCHost.m
  96. 31
      src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
  97. 40
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  98. 7
      src/objective-c/GRPCClient/private/NSError+GRPC.h
  99. 3
      src/proto/grpc/lb/v1/load_balancer.options
  100. 8
      src/proto/grpc/lb/v1/load_balancer.proto
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitmodules vendored

@ -17,3 +17,6 @@
[submodule "third_party/thrift"] [submodule "third_party/thrift"]
path = third_party/thrift path = third_party/thrift
url = https://github.com/apache/thrift.git url = https://github.com/apache/thrift.git
[submodule "third_party/google_benchmark"]
path = third_party/google_benchmark
url = https://github.com/google/benchmark

90
BUILD

@ -252,6 +252,7 @@ cc_library(
"src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata.h",
"src/core/lib/transport/metadata_batch.h", "src/core/lib/transport/metadata_batch.h",
"src/core/lib/transport/method_config.h", "src/core/lib/transport/method_config.h",
"src/core/lib/transport/pid_controller.h",
"src/core/lib/transport/static_metadata.h", "src/core/lib/transport/static_metadata.h",
"src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/timeout_encoding.h",
"src/core/lib/transport/transport.h", "src/core/lib/transport/transport.h",
@ -436,6 +437,7 @@ cc_library(
"src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata.c",
"src/core/lib/transport/metadata_batch.c", "src/core/lib/transport/metadata_batch.c",
"src/core/lib/transport/method_config.c", "src/core/lib/transport/method_config.c",
"src/core/lib/transport/pid_controller.c",
"src/core/lib/transport/static_metadata.c", "src/core/lib/transport/static_metadata.c",
"src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/timeout_encoding.c",
"src/core/lib/transport/transport.c", "src/core/lib/transport/transport.c",
@ -676,6 +678,7 @@ cc_library(
"src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata.h",
"src/core/lib/transport/metadata_batch.h", "src/core/lib/transport/metadata_batch.h",
"src/core/lib/transport/method_config.h", "src/core/lib/transport/method_config.h",
"src/core/lib/transport/pid_controller.h",
"src/core/lib/transport/static_metadata.h", "src/core/lib/transport/static_metadata.h",
"src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/timeout_encoding.h",
"src/core/lib/transport/transport.h", "src/core/lib/transport/transport.h",
@ -845,6 +848,7 @@ cc_library(
"src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata.c",
"src/core/lib/transport/metadata_batch.c", "src/core/lib/transport/metadata_batch.c",
"src/core/lib/transport/method_config.c", "src/core/lib/transport/method_config.c",
"src/core/lib/transport/pid_controller.c",
"src/core/lib/transport/static_metadata.c", "src/core/lib/transport/static_metadata.c",
"src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/timeout_encoding.c",
"src/core/lib/transport/transport.c", "src/core/lib/transport/transport.c",
@ -1055,6 +1059,7 @@ cc_library(
"src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata.h",
"src/core/lib/transport/metadata_batch.h", "src/core/lib/transport/metadata_batch.h",
"src/core/lib/transport/method_config.h", "src/core/lib/transport/method_config.h",
"src/core/lib/transport/pid_controller.h",
"src/core/lib/transport/static_metadata.h", "src/core/lib/transport/static_metadata.h",
"src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/timeout_encoding.h",
"src/core/lib/transport/transport.h", "src/core/lib/transport/transport.h",
@ -1216,6 +1221,7 @@ cc_library(
"src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata.c",
"src/core/lib/transport/metadata_batch.c", "src/core/lib/transport/metadata_batch.c",
"src/core/lib/transport/method_config.c", "src/core/lib/transport/method_config.c",
"src/core/lib/transport/pid_controller.c",
"src/core/lib/transport/static_metadata.c", "src/core/lib/transport/static_metadata.c",
"src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/timeout_encoding.c",
"src/core/lib/transport/transport.c", "src/core/lib/transport/transport.c",
@ -1402,12 +1408,6 @@ cc_library(
"include/grpc++/impl/server_builder_plugin.h", "include/grpc++/impl/server_builder_plugin.h",
"include/grpc++/impl/server_initializer.h", "include/grpc++/impl/server_initializer.h",
"include/grpc++/impl/service_type.h", "include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync.h",
"include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/impl/thd.h",
"include/grpc++/impl/thd_cxx11.h",
"include/grpc++/impl/thd_no_cxx11.h",
"include/grpc++/resource_quota.h", "include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h", "include/grpc++/security/auth_context.h",
"include/grpc++/security/auth_metadata_processor.h", "include/grpc++/security/auth_metadata_processor.h",
@ -1455,9 +1455,6 @@ cc_library(
"include/grpc++/impl/codegen/status_helper.h", "include/grpc++/impl/codegen/status_helper.h",
"include/grpc++/impl/codegen/string_ref.h", "include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h", "include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
"include/grpc++/impl/codegen/sync_stream.h", "include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h", "include/grpc++/impl/codegen/time.h",
"include/grpc/impl/codegen/byte_buffer_reader.h", "include/grpc/impl/codegen/byte_buffer_reader.h",
@ -1554,12 +1551,6 @@ cc_library(
"include/grpc++/impl/server_builder_plugin.h", "include/grpc++/impl/server_builder_plugin.h",
"include/grpc++/impl/server_initializer.h", "include/grpc++/impl/server_initializer.h",
"include/grpc++/impl/service_type.h", "include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync.h",
"include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/impl/thd.h",
"include/grpc++/impl/thd_cxx11.h",
"include/grpc++/impl/thd_no_cxx11.h",
"include/grpc++/resource_quota.h", "include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h", "include/grpc++/security/auth_context.h",
"include/grpc++/security/auth_metadata_processor.h", "include/grpc++/security/auth_metadata_processor.h",
@ -1607,9 +1598,6 @@ cc_library(
"include/grpc++/impl/codegen/status_helper.h", "include/grpc++/impl/codegen/status_helper.h",
"include/grpc++/impl/codegen/string_ref.h", "include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h", "include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
"include/grpc++/impl/codegen/sync_stream.h", "include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h", "include/grpc++/impl/codegen/time.h",
"include/grpc/impl/codegen/byte_buffer_reader.h", "include/grpc/impl/codegen/byte_buffer_reader.h",
@ -1649,63 +1637,10 @@ cc_library(
"src/cpp/ext/proto_server_reflection.h", "src/cpp/ext/proto_server_reflection.h",
"src/cpp/ext/proto_server_reflection.cc", "src/cpp/ext/proto_server_reflection.cc",
"src/cpp/ext/proto_server_reflection_plugin.cc", "src/cpp/ext/proto_server_reflection_plugin.cc",
"src/cpp/ext/reflection.grpc.pb.cc", "src/proto/grpc/reflection/v1alpha/reflection.proto",
"src/cpp/ext/reflection.pb.cc",
], ],
hdrs = [ hdrs = [
"include/grpc++/ext/proto_server_reflection_plugin.h", "include/grpc++/ext/proto_server_reflection_plugin.h",
"include/grpc++/ext/reflection.grpc.pb.h",
"include/grpc++/ext/reflection.pb.h",
"include/grpc++/impl/codegen/proto_utils.h",
"include/grpc++/impl/codegen/async_stream.h",
"include/grpc++/impl/codegen/async_unary_call.h",
"include/grpc++/impl/codegen/call.h",
"include/grpc++/impl/codegen/call_hook.h",
"include/grpc++/impl/codegen/channel_interface.h",
"include/grpc++/impl/codegen/client_context.h",
"include/grpc++/impl/codegen/client_unary_call.h",
"include/grpc++/impl/codegen/completion_queue.h",
"include/grpc++/impl/codegen/completion_queue_tag.h",
"include/grpc++/impl/codegen/config.h",
"include/grpc++/impl/codegen/core_codegen_interface.h",
"include/grpc++/impl/codegen/create_auth_context.h",
"include/grpc++/impl/codegen/grpc_library.h",
"include/grpc++/impl/codegen/method_handler_impl.h",
"include/grpc++/impl/codegen/rpc_method.h",
"include/grpc++/impl/codegen/rpc_service_method.h",
"include/grpc++/impl/codegen/security/auth_context.h",
"include/grpc++/impl/codegen/serialization_traits.h",
"include/grpc++/impl/codegen/server_context.h",
"include/grpc++/impl/codegen/server_interface.h",
"include/grpc++/impl/codegen/service_type.h",
"include/grpc++/impl/codegen/status.h",
"include/grpc++/impl/codegen/status_code_enum.h",
"include/grpc++/impl/codegen/status_helper.h",
"include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
"include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h",
"include/grpc/impl/codegen/byte_buffer_reader.h",
"include/grpc/impl/codegen/compression_types.h",
"include/grpc/impl/codegen/connectivity_state.h",
"include/grpc/impl/codegen/grpc_types.h",
"include/grpc/impl/codegen/propagation_bits.h",
"include/grpc/impl/codegen/status.h",
"include/grpc/impl/codegen/atm.h",
"include/grpc/impl/codegen/atm_gcc_atomic.h",
"include/grpc/impl/codegen/atm_gcc_sync.h",
"include/grpc/impl/codegen/atm_windows.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/port_platform.h",
"include/grpc/impl/codegen/slice.h",
"include/grpc/impl/codegen/sync.h",
"include/grpc/impl/codegen/sync_generic.h",
"include/grpc/impl/codegen/sync_posix.h",
"include/grpc/impl/codegen/sync_windows.h",
"include/grpc++/impl/codegen/config_protobuf.h",
], ],
includes = [ includes = [
"include", "include",
@ -1780,12 +1715,6 @@ cc_library(
"include/grpc++/impl/server_builder_plugin.h", "include/grpc++/impl/server_builder_plugin.h",
"include/grpc++/impl/server_initializer.h", "include/grpc++/impl/server_initializer.h",
"include/grpc++/impl/service_type.h", "include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync.h",
"include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/impl/thd.h",
"include/grpc++/impl/thd_cxx11.h",
"include/grpc++/impl/thd_no_cxx11.h",
"include/grpc++/resource_quota.h", "include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h", "include/grpc++/security/auth_context.h",
"include/grpc++/security/auth_metadata_processor.h", "include/grpc++/security/auth_metadata_processor.h",
@ -1833,9 +1762,6 @@ cc_library(
"include/grpc++/impl/codegen/status_helper.h", "include/grpc++/impl/codegen/status_helper.h",
"include/grpc++/impl/codegen/string_ref.h", "include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h", "include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
"include/grpc++/impl/codegen/sync_stream.h", "include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h", "include/grpc++/impl/codegen/time.h",
"include/grpc/impl/codegen/byte_buffer_reader.h", "include/grpc/impl/codegen/byte_buffer_reader.h",
@ -2153,6 +2079,7 @@ objc_library(
"src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata.c",
"src/core/lib/transport/metadata_batch.c", "src/core/lib/transport/metadata_batch.c",
"src/core/lib/transport/method_config.c", "src/core/lib/transport/method_config.c",
"src/core/lib/transport/pid_controller.c",
"src/core/lib/transport/static_metadata.c", "src/core/lib/transport/static_metadata.c",
"src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/timeout_encoding.c",
"src/core/lib/transport/transport.c", "src/core/lib/transport/transport.c",
@ -2372,6 +2299,7 @@ objc_library(
"src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata.h",
"src/core/lib/transport/metadata_batch.h", "src/core/lib/transport/metadata_batch.h",
"src/core/lib/transport/method_config.h", "src/core/lib/transport/method_config.h",
"src/core/lib/transport/pid_controller.h",
"src/core/lib/transport/static_metadata.h", "src/core/lib/transport/static_metadata.h",
"src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/timeout_encoding.h",
"src/core/lib/transport/transport.h", "src/core/lib/transport/transport.h",

@ -393,6 +393,7 @@ add_library(grpc
src/core/lib/transport/metadata.c src/core/lib/transport/metadata.c
src/core/lib/transport/metadata_batch.c src/core/lib/transport/metadata_batch.c
src/core/lib/transport/method_config.c src/core/lib/transport/method_config.c
src/core/lib/transport/pid_controller.c
src/core/lib/transport/static_metadata.c src/core/lib/transport/static_metadata.c
src/core/lib/transport/timeout_encoding.c src/core/lib/transport/timeout_encoding.c
src/core/lib/transport/transport.c src/core/lib/transport/transport.c
@ -665,6 +666,7 @@ add_library(grpc_cronet
src/core/lib/transport/metadata.c src/core/lib/transport/metadata.c
src/core/lib/transport/metadata_batch.c src/core/lib/transport/metadata_batch.c
src/core/lib/transport/method_config.c src/core/lib/transport/method_config.c
src/core/lib/transport/pid_controller.c
src/core/lib/transport/static_metadata.c src/core/lib/transport/static_metadata.c
src/core/lib/transport/timeout_encoding.c src/core/lib/transport/timeout_encoding.c
src/core/lib/transport/transport.c src/core/lib/transport/transport.c
@ -909,6 +911,7 @@ add_library(grpc_unsecure
src/core/lib/transport/metadata.c src/core/lib/transport/metadata.c
src/core/lib/transport/metadata_batch.c src/core/lib/transport/metadata_batch.c
src/core/lib/transport/method_config.c src/core/lib/transport/method_config.c
src/core/lib/transport/pid_controller.c
src/core/lib/transport/static_metadata.c src/core/lib/transport/static_metadata.c
src/core/lib/transport/timeout_encoding.c src/core/lib/transport/timeout_encoding.c
src/core/lib/transport/transport.c src/core/lib/transport/transport.c
@ -1121,12 +1124,6 @@ foreach(_hdr
include/grpc++/impl/server_builder_plugin.h include/grpc++/impl/server_builder_plugin.h
include/grpc++/impl/server_initializer.h include/grpc++/impl/server_initializer.h
include/grpc++/impl/service_type.h include/grpc++/impl/service_type.h
include/grpc++/impl/sync.h
include/grpc++/impl/sync_cxx11.h
include/grpc++/impl/sync_no_cxx11.h
include/grpc++/impl/thd.h
include/grpc++/impl/thd_cxx11.h
include/grpc++/impl/thd_no_cxx11.h
include/grpc++/resource_quota.h include/grpc++/resource_quota.h
include/grpc++/security/auth_context.h include/grpc++/security/auth_context.h
include/grpc++/security/auth_metadata_processor.h include/grpc++/security/auth_metadata_processor.h
@ -1174,9 +1171,6 @@ foreach(_hdr
include/grpc++/impl/codegen/status_helper.h include/grpc++/impl/codegen/status_helper.h
include/grpc++/impl/codegen/string_ref.h include/grpc++/impl/codegen/string_ref.h
include/grpc++/impl/codegen/stub_options.h include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync.h
include/grpc++/impl/codegen/sync_cxx11.h
include/grpc++/impl/codegen/sync_no_cxx11.h
include/grpc++/impl/codegen/sync_stream.h include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h include/grpc++/impl/codegen/time.h
include/grpc/impl/codegen/byte_buffer_reader.h include/grpc/impl/codegen/byte_buffer_reader.h
@ -1287,12 +1281,6 @@ foreach(_hdr
include/grpc++/impl/server_builder_plugin.h include/grpc++/impl/server_builder_plugin.h
include/grpc++/impl/server_initializer.h include/grpc++/impl/server_initializer.h
include/grpc++/impl/service_type.h include/grpc++/impl/service_type.h
include/grpc++/impl/sync.h
include/grpc++/impl/sync_cxx11.h
include/grpc++/impl/sync_no_cxx11.h
include/grpc++/impl/thd.h
include/grpc++/impl/thd_cxx11.h
include/grpc++/impl/thd_no_cxx11.h
include/grpc++/resource_quota.h include/grpc++/resource_quota.h
include/grpc++/security/auth_context.h include/grpc++/security/auth_context.h
include/grpc++/security/auth_metadata_processor.h include/grpc++/security/auth_metadata_processor.h
@ -1340,9 +1328,6 @@ foreach(_hdr
include/grpc++/impl/codegen/status_helper.h include/grpc++/impl/codegen/status_helper.h
include/grpc++/impl/codegen/string_ref.h include/grpc++/impl/codegen/string_ref.h
include/grpc++/impl/codegen/stub_options.h include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync.h
include/grpc++/impl/codegen/sync_cxx11.h
include/grpc++/impl/codegen/sync_no_cxx11.h
include/grpc++/impl/codegen/sync_stream.h include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h include/grpc++/impl/codegen/time.h
include/grpc/impl/codegen/byte_buffer_reader.h include/grpc/impl/codegen/byte_buffer_reader.h
@ -1383,8 +1368,7 @@ endif()
add_library(grpc++_reflection add_library(grpc++_reflection
src/cpp/ext/proto_server_reflection.cc src/cpp/ext/proto_server_reflection.cc
src/cpp/ext/proto_server_reflection_plugin.cc src/cpp/ext/proto_server_reflection_plugin.cc
src/cpp/ext/reflection.grpc.pb.cc src/proto/grpc/reflection/v1alpha/reflection.proto
src/cpp/ext/reflection.pb.cc
) )
target_include_directories(grpc++_reflection target_include_directories(grpc++_reflection
@ -1402,58 +1386,6 @@ target_link_libraries(grpc++_reflection
foreach(_hdr foreach(_hdr
include/grpc++/ext/proto_server_reflection_plugin.h include/grpc++/ext/proto_server_reflection_plugin.h
include/grpc++/ext/reflection.grpc.pb.h
include/grpc++/ext/reflection.pb.h
include/grpc++/impl/codegen/proto_utils.h
include/grpc++/impl/codegen/async_stream.h
include/grpc++/impl/codegen/async_unary_call.h
include/grpc++/impl/codegen/call.h
include/grpc++/impl/codegen/call_hook.h
include/grpc++/impl/codegen/channel_interface.h
include/grpc++/impl/codegen/client_context.h
include/grpc++/impl/codegen/client_unary_call.h
include/grpc++/impl/codegen/completion_queue.h
include/grpc++/impl/codegen/completion_queue_tag.h
include/grpc++/impl/codegen/config.h
include/grpc++/impl/codegen/core_codegen_interface.h
include/grpc++/impl/codegen/create_auth_context.h
include/grpc++/impl/codegen/grpc_library.h
include/grpc++/impl/codegen/method_handler_impl.h
include/grpc++/impl/codegen/rpc_method.h
include/grpc++/impl/codegen/rpc_service_method.h
include/grpc++/impl/codegen/security/auth_context.h
include/grpc++/impl/codegen/serialization_traits.h
include/grpc++/impl/codegen/server_context.h
include/grpc++/impl/codegen/server_interface.h
include/grpc++/impl/codegen/service_type.h
include/grpc++/impl/codegen/status.h
include/grpc++/impl/codegen/status_code_enum.h
include/grpc++/impl/codegen/status_helper.h
include/grpc++/impl/codegen/string_ref.h
include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync.h
include/grpc++/impl/codegen/sync_cxx11.h
include/grpc++/impl/codegen/sync_no_cxx11.h
include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/status.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/slice.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_generic.h
include/grpc/impl/codegen/sync_posix.h
include/grpc/impl/codegen/sync_windows.h
include/grpc++/impl/codegen/config_protobuf.h
) )
string(REPLACE "include/" "" _path ${_hdr}) string(REPLACE "include/" "" _path ${_hdr})
get_filename_component(_path ${_path} PATH) get_filename_component(_path ${_path} PATH)
@ -1544,12 +1476,6 @@ foreach(_hdr
include/grpc++/impl/server_builder_plugin.h include/grpc++/impl/server_builder_plugin.h
include/grpc++/impl/server_initializer.h include/grpc++/impl/server_initializer.h
include/grpc++/impl/service_type.h include/grpc++/impl/service_type.h
include/grpc++/impl/sync.h
include/grpc++/impl/sync_cxx11.h
include/grpc++/impl/sync_no_cxx11.h
include/grpc++/impl/thd.h
include/grpc++/impl/thd_cxx11.h
include/grpc++/impl/thd_no_cxx11.h
include/grpc++/resource_quota.h include/grpc++/resource_quota.h
include/grpc++/security/auth_context.h include/grpc++/security/auth_context.h
include/grpc++/security/auth_metadata_processor.h include/grpc++/security/auth_metadata_processor.h
@ -1597,9 +1523,6 @@ foreach(_hdr
include/grpc++/impl/codegen/status_helper.h include/grpc++/impl/codegen/status_helper.h
include/grpc++/impl/codegen/string_ref.h include/grpc++/impl/codegen/string_ref.h
include/grpc++/impl/codegen/stub_options.h include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync.h
include/grpc++/impl/codegen/sync_cxx11.h
include/grpc++/impl/codegen/sync_no_cxx11.h
include/grpc++/impl/codegen/sync_stream.h include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h include/grpc++/impl/codegen/time.h
include/grpc/impl/codegen/byte_buffer_reader.h include/grpc/impl/codegen/byte_buffer_reader.h

@ -1028,6 +1028,7 @@ timer_heap_test: $(BINDIR)/$(CONFIG)/timer_heap_test
timer_list_test: $(BINDIR)/$(CONFIG)/timer_list_test timer_list_test: $(BINDIR)/$(CONFIG)/timer_list_test
transport_connectivity_state_test: $(BINDIR)/$(CONFIG)/transport_connectivity_state_test transport_connectivity_state_test: $(BINDIR)/$(CONFIG)/transport_connectivity_state_test
transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test
transport_pid_controller_test: $(BINDIR)/$(CONFIG)/transport_pid_controller_test
transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test
udp_server_test: $(BINDIR)/$(CONFIG)/udp_server_test udp_server_test: $(BINDIR)/$(CONFIG)/udp_server_test
uri_fuzzer_test: $(BINDIR)/$(CONFIG)/uri_fuzzer_test uri_fuzzer_test: $(BINDIR)/$(CONFIG)/uri_fuzzer_test
@ -1069,6 +1070,7 @@ interop_test: $(BINDIR)/$(CONFIG)/interop_test
json_run_localhost: $(BINDIR)/$(CONFIG)/json_run_localhost json_run_localhost: $(BINDIR)/$(CONFIG)/json_run_localhost
metrics_client: $(BINDIR)/$(CONFIG)/metrics_client metrics_client: $(BINDIR)/$(CONFIG)/metrics_client
mock_test: $(BINDIR)/$(CONFIG)/mock_test mock_test: $(BINDIR)/$(CONFIG)/mock_test
noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark
proto_server_reflection_test: $(BINDIR)/$(CONFIG)/proto_server_reflection_test proto_server_reflection_test: $(BINDIR)/$(CONFIG)/proto_server_reflection_test
qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test
qps_json_driver: $(BINDIR)/$(CONFIG)/qps_json_driver qps_json_driver: $(BINDIR)/$(CONFIG)/qps_json_driver
@ -1076,6 +1078,7 @@ qps_openloop_test: $(BINDIR)/$(CONFIG)/qps_openloop_test
qps_worker: $(BINDIR)/$(CONFIG)/qps_worker qps_worker: $(BINDIR)/$(CONFIG)/qps_worker
reconnect_interop_client: $(BINDIR)/$(CONFIG)/reconnect_interop_client reconnect_interop_client: $(BINDIR)/$(CONFIG)/reconnect_interop_client
reconnect_interop_server: $(BINDIR)/$(CONFIG)/reconnect_interop_server reconnect_interop_server: $(BINDIR)/$(CONFIG)/reconnect_interop_server
round_robin_end2end_test: $(BINDIR)/$(CONFIG)/round_robin_end2end_test
secure_auth_context_test: $(BINDIR)/$(CONFIG)/secure_auth_context_test secure_auth_context_test: $(BINDIR)/$(CONFIG)/secure_auth_context_test
secure_sync_unary_ping_pong_test: $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test secure_sync_unary_ping_pong_test: $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test
server_builder_plugin_test: $(BINDIR)/$(CONFIG)/server_builder_plugin_test server_builder_plugin_test: $(BINDIR)/$(CONFIG)/server_builder_plugin_test
@ -1141,7 +1144,6 @@ bad_ssl_cert_server: $(BINDIR)/$(CONFIG)/bad_ssl_cert_server
bad_ssl_cert_test: $(BINDIR)/$(CONFIG)/bad_ssl_cert_test bad_ssl_cert_test: $(BINDIR)/$(CONFIG)/bad_ssl_cert_test
h2_census_test: $(BINDIR)/$(CONFIG)/h2_census_test h2_census_test: $(BINDIR)/$(CONFIG)/h2_census_test
h2_compress_test: $(BINDIR)/$(CONFIG)/h2_compress_test h2_compress_test: $(BINDIR)/$(CONFIG)/h2_compress_test
h2_fake_resolver_test: $(BINDIR)/$(CONFIG)/h2_fake_resolver_test
h2_fakesec_test: $(BINDIR)/$(CONFIG)/h2_fakesec_test h2_fakesec_test: $(BINDIR)/$(CONFIG)/h2_fakesec_test
h2_fd_test: $(BINDIR)/$(CONFIG)/h2_fd_test h2_fd_test: $(BINDIR)/$(CONFIG)/h2_fd_test
h2_full_test: $(BINDIR)/$(CONFIG)/h2_full_test h2_full_test: $(BINDIR)/$(CONFIG)/h2_full_test
@ -1160,7 +1162,6 @@ 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
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_fake_resolver_nosec_test: $(BINDIR)/$(CONFIG)/h2_fake_resolver_nosec_test
h2_fd_nosec_test: $(BINDIR)/$(CONFIG)/h2_fd_nosec_test h2_fd_nosec_test: $(BINDIR)/$(CONFIG)/h2_fd_nosec_test
h2_full_nosec_test: $(BINDIR)/$(CONFIG)/h2_full_nosec_test h2_full_nosec_test: $(BINDIR)/$(CONFIG)/h2_full_nosec_test
h2_full+pipe_nosec_test: $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test h2_full+pipe_nosec_test: $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test
@ -1236,9 +1237,9 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
ifeq ($(EMBED_OPENSSL),true) ifeq ($(EMBED_OPENSSL),true)
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(LIBDIR)/$(CONFIG)/libgrpc++_test.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a
else else
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(LIBDIR)/$(CONFIG)/libgrpc++_test.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a
endif endif
@ -1352,6 +1353,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/timer_list_test \ $(BINDIR)/$(CONFIG)/timer_list_test \
$(BINDIR)/$(CONFIG)/transport_connectivity_state_test \ $(BINDIR)/$(CONFIG)/transport_connectivity_state_test \
$(BINDIR)/$(CONFIG)/transport_metadata_test \ $(BINDIR)/$(CONFIG)/transport_metadata_test \
$(BINDIR)/$(CONFIG)/transport_pid_controller_test \
$(BINDIR)/$(CONFIG)/transport_security_test \ $(BINDIR)/$(CONFIG)/transport_security_test \
$(BINDIR)/$(CONFIG)/udp_server_test \ $(BINDIR)/$(CONFIG)/udp_server_test \
$(BINDIR)/$(CONFIG)/uri_parser_test \ $(BINDIR)/$(CONFIG)/uri_parser_test \
@ -1371,7 +1373,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/bad_ssl_cert_test \ $(BINDIR)/$(CONFIG)/bad_ssl_cert_test \
$(BINDIR)/$(CONFIG)/h2_census_test \ $(BINDIR)/$(CONFIG)/h2_census_test \
$(BINDIR)/$(CONFIG)/h2_compress_test \ $(BINDIR)/$(CONFIG)/h2_compress_test \
$(BINDIR)/$(CONFIG)/h2_fake_resolver_test \
$(BINDIR)/$(CONFIG)/h2_fakesec_test \ $(BINDIR)/$(CONFIG)/h2_fakesec_test \
$(BINDIR)/$(CONFIG)/h2_fd_test \ $(BINDIR)/$(CONFIG)/h2_fd_test \
$(BINDIR)/$(CONFIG)/h2_full_test \ $(BINDIR)/$(CONFIG)/h2_full_test \
@ -1390,7 +1391,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_uds_test \ $(BINDIR)/$(CONFIG)/h2_uds_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_fake_resolver_nosec_test \
$(BINDIR)/$(CONFIG)/h2_fd_nosec_test \ $(BINDIR)/$(CONFIG)/h2_fd_nosec_test \
$(BINDIR)/$(CONFIG)/h2_full_nosec_test \ $(BINDIR)/$(CONFIG)/h2_full_nosec_test \
$(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test \ $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test \
@ -1447,6 +1447,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/json_run_localhost \ $(BINDIR)/$(CONFIG)/json_run_localhost \
$(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \ $(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \ $(BINDIR)/$(CONFIG)/proto_server_reflection_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \ $(BINDIR)/$(CONFIG)/qps_interarrival_test \
$(BINDIR)/$(CONFIG)/qps_json_driver \ $(BINDIR)/$(CONFIG)/qps_json_driver \
@ -1454,6 +1455,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_worker \ $(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \ $(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \ $(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/round_robin_end2end_test \
$(BINDIR)/$(CONFIG)/secure_auth_context_test \ $(BINDIR)/$(CONFIG)/secure_auth_context_test \
$(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \ $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/server_builder_plugin_test \ $(BINDIR)/$(CONFIG)/server_builder_plugin_test \
@ -1536,6 +1538,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/json_run_localhost \ $(BINDIR)/$(CONFIG)/json_run_localhost \
$(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \ $(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \ $(BINDIR)/$(CONFIG)/proto_server_reflection_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \ $(BINDIR)/$(CONFIG)/qps_interarrival_test \
$(BINDIR)/$(CONFIG)/qps_json_driver \ $(BINDIR)/$(CONFIG)/qps_json_driver \
@ -1543,6 +1546,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_worker \ $(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \ $(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \ $(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/round_robin_end2end_test \
$(BINDIR)/$(CONFIG)/secure_auth_context_test \ $(BINDIR)/$(CONFIG)/secure_auth_context_test \
$(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \ $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/server_builder_plugin_test \ $(BINDIR)/$(CONFIG)/server_builder_plugin_test \
@ -1760,6 +1764,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/transport_connectivity_state_test || ( echo test transport_connectivity_state_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/transport_connectivity_state_test || ( echo test transport_connectivity_state_test failed ; exit 1 )
$(E) "[RUN] Testing transport_metadata_test" $(E) "[RUN] Testing transport_metadata_test"
$(Q) $(BINDIR)/$(CONFIG)/transport_metadata_test || ( echo test transport_metadata_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/transport_metadata_test || ( echo test transport_metadata_test failed ; exit 1 )
$(E) "[RUN] Testing transport_pid_controller_test"
$(Q) $(BINDIR)/$(CONFIG)/transport_pid_controller_test || ( echo test transport_pid_controller_test failed ; exit 1 )
$(E) "[RUN] Testing transport_security_test" $(E) "[RUN] Testing transport_security_test"
$(Q) $(BINDIR)/$(CONFIG)/transport_security_test || ( echo test transport_security_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/transport_security_test || ( echo test transport_security_test failed ; exit 1 )
$(E) "[RUN] Testing udp_server_test" $(E) "[RUN] Testing udp_server_test"
@ -1848,10 +1854,14 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 )
$(E) "[RUN] Testing mock_test" $(E) "[RUN] Testing mock_test"
$(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 )
$(E) "[RUN] Testing noop-benchmark"
$(Q) $(BINDIR)/$(CONFIG)/noop-benchmark || ( echo test noop-benchmark failed ; exit 1 )
$(E) "[RUN] Testing proto_server_reflection_test" $(E) "[RUN] Testing proto_server_reflection_test"
$(Q) $(BINDIR)/$(CONFIG)/proto_server_reflection_test || ( echo test proto_server_reflection_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/proto_server_reflection_test || ( echo test proto_server_reflection_test failed ; exit 1 )
$(E) "[RUN] Testing qps_openloop_test" $(E) "[RUN] Testing qps_openloop_test"
$(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 )
$(E) "[RUN] Testing round_robin_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/round_robin_end2end_test || ( echo test round_robin_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing secure_auth_context_test" $(E) "[RUN] Testing secure_auth_context_test"
$(Q) $(BINDIR)/$(CONFIG)/secure_auth_context_test || ( echo test secure_auth_context_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/secure_auth_context_test || ( echo test secure_auth_context_test failed ; exit 1 )
$(E) "[RUN] Testing secure_sync_unary_ping_pong_test" $(E) "[RUN] Testing secure_sync_unary_ping_pong_test"
@ -2687,6 +2697,7 @@ LIBGRPC_SRC = \
src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata.c \
src/core/lib/transport/metadata_batch.c \ src/core/lib/transport/metadata_batch.c \
src/core/lib/transport/method_config.c \ src/core/lib/transport/method_config.c \
src/core/lib/transport/pid_controller.c \
src/core/lib/transport/static_metadata.c \ src/core/lib/transport/static_metadata.c \
src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/timeout_encoding.c \
src/core/lib/transport/transport.c \ src/core/lib/transport/transport.c \
@ -2977,6 +2988,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata.c \
src/core/lib/transport/metadata_batch.c \ src/core/lib/transport/metadata_batch.c \
src/core/lib/transport/method_config.c \ src/core/lib/transport/method_config.c \
src/core/lib/transport/pid_controller.c \
src/core/lib/transport/static_metadata.c \ src/core/lib/transport/static_metadata.c \
src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/timeout_encoding.c \
src/core/lib/transport/transport.c \ src/core/lib/transport/transport.c \
@ -3258,6 +3270,7 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata.c \
src/core/lib/transport/metadata_batch.c \ src/core/lib/transport/metadata_batch.c \
src/core/lib/transport/method_config.c \ src/core/lib/transport/method_config.c \
src/core/lib/transport/pid_controller.c \
src/core/lib/transport/static_metadata.c \ src/core/lib/transport/static_metadata.c \
src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/timeout_encoding.c \
src/core/lib/transport/transport.c \ src/core/lib/transport/transport.c \
@ -3468,6 +3481,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata.c \
src/core/lib/transport/metadata_batch.c \ src/core/lib/transport/metadata_batch.c \
src/core/lib/transport/method_config.c \ src/core/lib/transport/method_config.c \
src/core/lib/transport/pid_controller.c \
src/core/lib/transport/static_metadata.c \ src/core/lib/transport/static_metadata.c \
src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/timeout_encoding.c \
src/core/lib/transport/transport.c \ src/core/lib/transport/transport.c \
@ -3746,12 +3760,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/server_builder_plugin.h \ include/grpc++/impl/server_builder_plugin.h \
include/grpc++/impl/server_initializer.h \ include/grpc++/impl/server_initializer.h \
include/grpc++/impl/service_type.h \ include/grpc++/impl/service_type.h \
include/grpc++/impl/sync.h \
include/grpc++/impl/sync_cxx11.h \
include/grpc++/impl/sync_no_cxx11.h \
include/grpc++/impl/thd.h \
include/grpc++/impl/thd_cxx11.h \
include/grpc++/impl/thd_no_cxx11.h \
include/grpc++/resource_quota.h \ include/grpc++/resource_quota.h \
include/grpc++/security/auth_context.h \ include/grpc++/security/auth_context.h \
include/grpc++/security/auth_metadata_processor.h \ include/grpc++/security/auth_metadata_processor.h \
@ -3799,9 +3807,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status_helper.h \ include/grpc++/impl/codegen/status_helper.h \
include/grpc++/impl/codegen/string_ref.h \ include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \ include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
include/grpc++/impl/codegen/sync_stream.h \ include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \ include/grpc++/impl/codegen/time.h \
include/grpc/impl/codegen/byte_buffer_reader.h \ include/grpc/impl/codegen/byte_buffer_reader.h \
@ -3941,12 +3946,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/server_builder_plugin.h \ include/grpc++/impl/server_builder_plugin.h \
include/grpc++/impl/server_initializer.h \ include/grpc++/impl/server_initializer.h \
include/grpc++/impl/service_type.h \ include/grpc++/impl/service_type.h \
include/grpc++/impl/sync.h \
include/grpc++/impl/sync_cxx11.h \
include/grpc++/impl/sync_no_cxx11.h \
include/grpc++/impl/thd.h \
include/grpc++/impl/thd_cxx11.h \
include/grpc++/impl/thd_no_cxx11.h \
include/grpc++/resource_quota.h \ include/grpc++/resource_quota.h \
include/grpc++/security/auth_context.h \ include/grpc++/security/auth_context.h \
include/grpc++/security/auth_metadata_processor.h \ include/grpc++/security/auth_metadata_processor.h \
@ -3994,9 +3993,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status_helper.h \ include/grpc++/impl/codegen/status_helper.h \
include/grpc++/impl/codegen/string_ref.h \ include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \ include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
include/grpc++/impl/codegen/sync_stream.h \ include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \ include/grpc++/impl/codegen/time.h \
include/grpc/impl/codegen/byte_buffer_reader.h \ include/grpc/impl/codegen/byte_buffer_reader.h \
@ -4080,77 +4076,22 @@ endif
endif endif
LIBGRPC++_REFLECTION_SRC = \ LIBGRPC++_PROTO_REFLECTION_DESC_DB_SRC = \
src/cpp/ext/proto_server_reflection.cc \ test/cpp/util/proto_reflection_descriptor_database.cc \
src/cpp/ext/proto_server_reflection_plugin.cc \ $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc \
src/cpp/ext/reflection.grpc.pb.cc \
src/cpp/ext/reflection.pb.cc \
PUBLIC_HEADERS_CXX += \ PUBLIC_HEADERS_CXX += \
include/grpc++/ext/proto_server_reflection_plugin.h \
include/grpc++/ext/reflection.grpc.pb.h \
include/grpc++/ext/reflection.pb.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/async_stream.h \
include/grpc++/impl/codegen/async_unary_call.h \
include/grpc++/impl/codegen/call.h \
include/grpc++/impl/codegen/call_hook.h \
include/grpc++/impl/codegen/channel_interface.h \
include/grpc++/impl/codegen/client_context.h \
include/grpc++/impl/codegen/client_unary_call.h \
include/grpc++/impl/codegen/completion_queue.h \
include/grpc++/impl/codegen/completion_queue_tag.h \
include/grpc++/impl/codegen/config.h \
include/grpc++/impl/codegen/core_codegen_interface.h \
include/grpc++/impl/codegen/create_auth_context.h \
include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/method_handler_impl.h \
include/grpc++/impl/codegen/rpc_method.h \
include/grpc++/impl/codegen/rpc_service_method.h \
include/grpc++/impl/codegen/security/auth_context.h \
include/grpc++/impl/codegen/serialization_traits.h \
include/grpc++/impl/codegen/server_context.h \
include/grpc++/impl/codegen/server_interface.h \
include/grpc++/impl/codegen/service_type.h \
include/grpc++/impl/codegen/status.h \
include/grpc++/impl/codegen/status_code_enum.h \
include/grpc++/impl/codegen/status_helper.h \
include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/status.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/slice.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_generic.h \
include/grpc/impl/codegen/sync_posix.h \
include/grpc/impl/codegen/sync_windows.h \
include/grpc++/impl/codegen/config_protobuf.h \ include/grpc++/impl/codegen/config_protobuf.h \
LIBGRPC++_REFLECTION_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_SRC)))) LIBGRPC++_PROTO_REFLECTION_DESC_DB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_PROTO_REFLECTION_DESC_DB_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
# You can't build secure libraries if you don't have OpenSSL. # You can't build secure libraries if you don't have OpenSSL.
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: openssl_dep_error $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a: openssl_dep_error
$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error
else else
@ -4158,40 +4099,22 @@ ifeq ($(NO_PROTOBUF),true)
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: protobuf_dep_error $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a: protobuf_dep_error
$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
else else
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_REFLECTION_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_PROTO_REFLECTION_DESC_DB_OBJS)
$(E) "[AR] Creating $@" $(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a
$(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBGRPC++_REFLECTION_OBJS) $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBGRPC++_PROTO_REFLECTION_DESC_DB_OBJS)
ifeq ($(SYSTEM),Darwin) ifeq ($(SYSTEM),Darwin)
$(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a
endif endif
ifeq ($(SYSTEM),MINGW32)
$(LIBDIR)/$(CONFIG)/grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_DEP) $(PROTOBUF_DEP) $(LIBDIR)/$(CONFIG)/grpc++.$(SHARED_EXT) $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared grpc++_reflection.def -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc++_reflection$(SHARED_VERSION).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_REFLECTION_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) -lgrpc++-imp
else
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_DEP) $(PROTOBUF_DEP) $(LIBDIR)/$(CONFIG)/libgrpc++.$(SHARED_EXT) $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_REFLECTION_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) -lgrpc++
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_reflection.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_REFLECTION_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) -lgrpc++
$(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).so.1
$(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).so
endif
endif
endif endif
@ -4199,25 +4122,30 @@ endif
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true) ifneq ($(NO_DEPS),true)
-include $(LIBGRPC++_REFLECTION_OBJS:.o=.dep) -include $(LIBGRPC++_PROTO_REFLECTION_DESC_DB_OBJS:.o=.dep)
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/util/proto_reflection_descriptor_database.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
LIBGRPC++_REFLECTION_CODEGEN_SRC = \ LIBGRPC++_REFLECTION_SRC = \
src/cpp/ext/proto_server_reflection.cc \
src/cpp/ext/proto_server_reflection_plugin.cc \
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc \
PUBLIC_HEADERS_CXX += \ PUBLIC_HEADERS_CXX += \
include/grpc++/ext/proto_server_reflection_plugin.h \
LIBGRPC++_REFLECTION_CODEGEN_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_CODEGEN_SRC)))) LIBGRPC++_REFLECTION_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
# You can't build secure libraries if you don't have OpenSSL. # You can't build secure libraries if you don't have OpenSSL.
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a: openssl_dep_error $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: openssl_dep_error
$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error
else else
@ -4225,22 +4153,40 @@ ifeq ($(NO_PROTOBUF),true)
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a: protobuf_dep_error $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: protobuf_dep_error
$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
else else
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_REFLECTION_CODEGEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_REFLECTION_OBJS)
$(E) "[AR] Creating $@" $(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a
$(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(LIBGRPC++_REFLECTION_CODEGEN_OBJS) $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBGRPC++_REFLECTION_OBJS)
ifeq ($(SYSTEM),Darwin) ifeq ($(SYSTEM),Darwin)
$(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a
endif endif
ifeq ($(SYSTEM),MINGW32)
$(LIBDIR)/$(CONFIG)/grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_DEP) $(PROTOBUF_DEP) $(LIBDIR)/$(CONFIG)/grpc++.$(SHARED_EXT) $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared grpc++_reflection.def -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc++_reflection$(SHARED_VERSION).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_REFLECTION_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) -lgrpc++-imp
else
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_DEP) $(PROTOBUF_DEP) $(LIBDIR)/$(CONFIG)/libgrpc++.$(SHARED_EXT) $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_REFLECTION_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) -lgrpc++
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_reflection.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_REFLECTION_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) -lgrpc++
$(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).so.1
$(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).so
endif
endif
endif endif
@ -4248,9 +4194,11 @@ endif
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true) ifneq ($(NO_DEPS),true)
-include $(LIBGRPC++_REFLECTION_CODEGEN_OBJS:.o=.dep) -include $(LIBGRPC++_REFLECTION_OBJS:.o=.dep)
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/src/cpp/ext/proto_server_reflection.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/src/cpp/ext/proto_server_reflection_plugin.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
LIBGRPC++_TEST_SRC = \ LIBGRPC++_TEST_SRC = \
@ -4390,9 +4338,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status_helper.h \ include/grpc++/impl/codegen/status_helper.h \
include/grpc++/impl/codegen/string_ref.h \ include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \ include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
include/grpc++/impl/codegen/sync_stream.h \ include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \ include/grpc++/impl/codegen/time.h \
include/grpc/impl/codegen/byte_buffer_reader.h \ include/grpc/impl/codegen/byte_buffer_reader.h \
@ -4523,12 +4468,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/server_builder_plugin.h \ include/grpc++/impl/server_builder_plugin.h \
include/grpc++/impl/server_initializer.h \ include/grpc++/impl/server_initializer.h \
include/grpc++/impl/service_type.h \ include/grpc++/impl/service_type.h \
include/grpc++/impl/sync.h \
include/grpc++/impl/sync_cxx11.h \
include/grpc++/impl/sync_no_cxx11.h \
include/grpc++/impl/thd.h \
include/grpc++/impl/thd_cxx11.h \
include/grpc++/impl/thd_no_cxx11.h \
include/grpc++/resource_quota.h \ include/grpc++/resource_quota.h \
include/grpc++/security/auth_context.h \ include/grpc++/security/auth_context.h \
include/grpc++/security/auth_metadata_processor.h \ include/grpc++/security/auth_metadata_processor.h \
@ -4576,9 +4515,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status_helper.h \ include/grpc++/impl/codegen/status_helper.h \
include/grpc++/impl/codegen/string_ref.h \ include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \ include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
include/grpc++/impl/codegen/sync_stream.h \ include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \ include/grpc++/impl/codegen/time.h \
include/grpc/impl/codegen/byte_buffer_reader.h \ include/grpc/impl/codegen/byte_buffer_reader.h \
@ -4653,10 +4589,11 @@ LIBGRPC_CLI_LIBS_SRC = \
test/cpp/util/cli_credentials.cc \ test/cpp/util/cli_credentials.cc \
test/cpp/util/grpc_tool.cc \ test/cpp/util/grpc_tool.cc \
test/cpp/util/proto_file_parser.cc \ test/cpp/util/proto_file_parser.cc \
test/cpp/util/proto_reflection_descriptor_database.cc \
test/cpp/util/service_describer.cc \ test/cpp/util/service_describer.cc \
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc \
PUBLIC_HEADERS_CXX += \ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/config_protobuf.h \
LIBGRPC_CLI_LIBS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_CLI_LIBS_SRC)))) LIBGRPC_CLI_LIBS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_CLI_LIBS_SRC))))
@ -4700,6 +4637,11 @@ ifneq ($(NO_DEPS),true)
-include $(LIBGRPC_CLI_LIBS_OBJS:.o=.dep) -include $(LIBGRPC_CLI_LIBS_OBJS:.o=.dep)
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/cli_credentials.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_tool.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/proto_file_parser.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/service_describer.o: $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc
LIBGRPC_PLUGIN_SUPPORT_SRC = \ LIBGRPC_PLUGIN_SUPPORT_SRC = \
@ -6809,6 +6751,55 @@ ifneq ($(NO_DEPS),true)
endif endif
LIBGOOGLE_BENCHMARK_SRC = \
third_party/google_benchmark/src/benchmark.cc \
third_party/google_benchmark/src/benchmark_register.cc \
third_party/google_benchmark/src/colorprint.cc \
third_party/google_benchmark/src/commandlineflags.cc \
third_party/google_benchmark/src/complexity.cc \
third_party/google_benchmark/src/console_reporter.cc \
third_party/google_benchmark/src/csv_reporter.cc \
third_party/google_benchmark/src/json_reporter.cc \
third_party/google_benchmark/src/reporter.cc \
third_party/google_benchmark/src/sleep.cc \
third_party/google_benchmark/src/string_util.cc \
third_party/google_benchmark/src/sysinfo.cc \
third_party/google_benchmark/src/timers.cc \
PUBLIC_HEADERS_CXX += \
LIBGOOGLE_BENCHMARK_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGOOGLE_BENCHMARK_SRC))))
$(LIBGOOGLE_BENCHMARK_OBJS): CPPFLAGS += -Ithird_party/google_benchmark/include -DHAVE_POSIX_REGEX
ifeq ($(NO_PROTOBUF),true)
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a: protobuf_dep_error
else
$(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a: $(ZLIB_DEP) $(PROTOBUF_DEP) $(LIBGOOGLE_BENCHMARK_OBJS)
$(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@`
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a
$(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a $(LIBGOOGLE_BENCHMARK_OBJS)
ifeq ($(SYSTEM),Darwin)
$(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a
endif
endif
ifneq ($(NO_DEPS),true)
-include $(LIBGOOGLE_BENCHMARK_OBJS:.o=.dep)
endif
LIBZ_SRC = \ LIBZ_SRC = \
third_party/zlib/adler32.c \ third_party/zlib/adler32.c \
third_party/zlib/compress.c \ third_party/zlib/compress.c \
@ -11084,6 +11075,38 @@ endif
endif endif
TRANSPORT_PID_CONTROLLER_TEST_SRC = \
test/core/transport/pid_controller_test.c \
TRANSPORT_PID_CONTROLLER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TRANSPORT_PID_CONTROLLER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/transport_pid_controller_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/transport_pid_controller_test: $(TRANSPORT_PID_CONTROLLER_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) $(TRANSPORT_PID_CONTROLLER_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)/transport_pid_controller_test
endif
$(OBJDIR)/$(CONFIG)/test/core/transport/pid_controller_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_transport_pid_controller_test: $(TRANSPORT_PID_CONTROLLER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(TRANSPORT_PID_CONTROLLER_TEST_OBJS:.o=.dep)
endif
endif
TRANSPORT_SECURITY_TEST_SRC = \ TRANSPORT_SECURITY_TEST_SRC = \
test/core/tsi/transport_security_test.c \ test/core/tsi/transport_security_test.c \
@ -12081,16 +12104,16 @@ $(BINDIR)/$(CONFIG)/grpc_cli: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/grpc_cli: $(PROTOBUF_DEP) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(BINDIR)/$(CONFIG)/grpc_cli: $(PROTOBUF_DEP) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.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) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_cli $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_cli
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_cli.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_cli.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
deps_grpc_cli: $(GRPC_CLI_OBJS:.o=.dep) deps_grpc_cli: $(GRPC_CLI_OBJS:.o=.dep)
@ -12322,7 +12345,6 @@ GRPC_TOOL_TEST_SRC = \
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \
$(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_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \
test/cpp/util/grpc_tool_test.cc \ test/cpp/util/grpc_tool_test.cc \
test/cpp/util/string_ref_helper.cc \
GRPC_TOOL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_TOOL_TEST_SRC)))) GRPC_TOOL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_TOOL_TEST_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
@ -12344,22 +12366,20 @@ $(BINDIR)/$(CONFIG)/grpc_tool_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/grpc_tool_test: $(PROTOBUF_DEP) $(GRPC_TOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/grpc_tool_test: $(PROTOBUF_DEP) $(GRPC_TOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(GRPC_TOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/grpc_tool_test $(Q) $(LDXX) $(LDFLAGS) $(GRPC_TOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/grpc_tool_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/echo.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/src/proto/grpc/testing/echo.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/src/proto/grpc/testing/echo_messages.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/src/proto/grpc/testing/echo_messages.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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/util/grpc_tool_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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/util/grpc_tool_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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/util/string_ref_helper.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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
deps_grpc_tool_test: $(GRPC_TOOL_TEST_OBJS:.o=.dep) deps_grpc_tool_test: $(GRPC_TOOL_TEST_OBJS:.o=.dep)
@ -12369,7 +12389,6 @@ ifneq ($(NO_DEPS),true)
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_tool_test.o: $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_tool_test.o: $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc
GRPCLB_API_TEST_SRC = \ GRPCLB_API_TEST_SRC = \
@ -12747,9 +12766,51 @@ endif
endif endif
NOOP-BENCHMARK_SRC = \
test/cpp/microbenchmarks/noop-benchmark.cc \
NOOP-BENCHMARK_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NOOP-BENCHMARK_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/noop-benchmark: 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)/noop-benchmark: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/noop-benchmark: $(PROTOBUF_DEP) $(NOOP-BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(NOOP-BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/noop-benchmark
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/noop-benchmark.o: $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a
deps_noop-benchmark: $(NOOP-BENCHMARK_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(NOOP-BENCHMARK_OBJS:.o=.dep)
endif
endif
PROTO_SERVER_REFLECTION_TEST_SRC = \ PROTO_SERVER_REFLECTION_TEST_SRC = \
test/cpp/end2end/proto_server_reflection_test.cc \ test/cpp/end2end/proto_server_reflection_test.cc \
test/cpp/util/proto_reflection_descriptor_database.cc \
PROTO_SERVER_REFLECTION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PROTO_SERVER_REFLECTION_TEST_SRC)))) PROTO_SERVER_REFLECTION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PROTO_SERVER_REFLECTION_TEST_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
@ -12771,18 +12832,16 @@ $(BINDIR)/$(CONFIG)/proto_server_reflection_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/proto_server_reflection_test: $(PROTOBUF_DEP) $(PROTO_SERVER_REFLECTION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/proto_server_reflection_test: $(PROTOBUF_DEP) $(PROTO_SERVER_REFLECTION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(PROTO_SERVER_REFLECTION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/proto_server_reflection_test $(Q) $(LDXX) $(LDFLAGS) $(PROTO_SERVER_REFLECTION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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)/proto_server_reflection_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/proto_server_reflection_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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/end2end/proto_server_reflection_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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/util/proto_reflection_descriptor_database.o: $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.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
deps_proto_server_reflection_test: $(PROTO_SERVER_REFLECTION_TEST_OBJS:.o=.dep) deps_proto_server_reflection_test: $(PROTO_SERVER_REFLECTION_TEST_OBJS:.o=.dep)
@ -13071,6 +13130,49 @@ endif
$(OBJDIR)/$(CONFIG)/test/cpp/interop/reconnect_interop_server.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/interop/reconnect_interop_server.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc
ROUND_ROBIN_END2END_TEST_SRC = \
test/cpp/end2end/round_robin_end2end_test.cc \
ROUND_ROBIN_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ROUND_ROBIN_END2END_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/round_robin_end2end_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)/round_robin_end2end_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/round_robin_end2end_test: $(PROTOBUF_DEP) $(ROUND_ROBIN_END2END_TEST_OBJS) $(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
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(ROUND_ROBIN_END2END_TEST_OBJS) $(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)/round_robin_end2end_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/round_robin_end2end_test.o: $(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
deps_round_robin_end2end_test: $(ROUND_ROBIN_END2END_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(ROUND_ROBIN_END2END_TEST_OBJS:.o=.dep)
endif
endif
SECURE_AUTH_CONTEXT_TEST_SRC = \ SECURE_AUTH_CONTEXT_TEST_SRC = \
test/cpp/common/secure_auth_context_test.cc \ test/cpp/common/secure_auth_context_test.cc \
@ -15006,38 +15108,6 @@ endif
endif endif
H2_FAKE_RESOLVER_TEST_SRC = \
test/core/end2end/fixtures/h2_fake_resolver.c \
H2_FAKE_RESOLVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FAKE_RESOLVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/h2_fake_resolver_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/h2_fake_resolver_test: $(H2_FAKE_RESOLVER_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) $(H2_FAKE_RESOLVER_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)/h2_fake_resolver_test
endif
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_fake_resolver.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_h2_fake_resolver_test: $(H2_FAKE_RESOLVER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(H2_FAKE_RESOLVER_TEST_OBJS:.o=.dep)
endif
endif
H2_FAKESEC_TEST_SRC = \ H2_FAKESEC_TEST_SRC = \
test/core/end2end/fixtures/h2_fakesec.c \ test/core/end2end/fixtures/h2_fakesec.c \
@ -15590,26 +15660,6 @@ ifneq ($(NO_DEPS),true)
endif endif
H2_FAKE_RESOLVER_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_fake_resolver.c \
H2_FAKE_RESOLVER_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FAKE_RESOLVER_NOSEC_TEST_SRC))))
$(BINDIR)/$(CONFIG)/h2_fake_resolver_nosec_test: $(H2_FAKE_RESOLVER_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) $(H2_FAKE_RESOLVER_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)/h2_fake_resolver_nosec_test
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_fake_resolver.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_h2_fake_resolver_nosec_test: $(H2_FAKE_RESOLVER_NOSEC_TEST_OBJS:.o=.dep)
ifneq ($(NO_DEPS),true)
-include $(H2_FAKE_RESOLVER_NOSEC_TEST_OBJS:.o=.dep)
endif
H2_FD_NOSEC_TEST_SRC = \ H2_FD_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_fd.c \ test/core/end2end/fixtures/h2_fd.c \
@ -16300,8 +16350,6 @@ src/cpp/common/secure_channel_arguments.cc: $(OPENSSL_DEP)
src/cpp/common/secure_create_auth_context.cc: $(OPENSSL_DEP) src/cpp/common/secure_create_auth_context.cc: $(OPENSSL_DEP)
src/cpp/ext/proto_server_reflection.cc: $(OPENSSL_DEP) src/cpp/ext/proto_server_reflection.cc: $(OPENSSL_DEP)
src/cpp/ext/proto_server_reflection_plugin.cc: $(OPENSSL_DEP) src/cpp/ext/proto_server_reflection_plugin.cc: $(OPENSSL_DEP)
src/cpp/ext/reflection.grpc.pb.cc: $(OPENSSL_DEP)
src/cpp/ext/reflection.pb.cc: $(OPENSSL_DEP)
src/cpp/server/secure_server_credentials.cc: $(OPENSSL_DEP) src/cpp/server/secure_server_credentials.cc: $(OPENSSL_DEP)
src/cpp/test/server_context_test_spouse.cc: $(OPENSSL_DEP) src/cpp/test/server_context_test_spouse.cc: $(OPENSSL_DEP)
src/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP) src/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP)

@ -671,6 +671,7 @@
'src/core/lib/transport/metadata.c', 'src/core/lib/transport/metadata.c',
'src/core/lib/transport/metadata_batch.c', 'src/core/lib/transport/metadata_batch.c',
'src/core/lib/transport/method_config.c', 'src/core/lib/transport/method_config.c',
'src/core/lib/transport/pid_controller.c',
'src/core/lib/transport/static_metadata.c', 'src/core/lib/transport/static_metadata.c',
'src/core/lib/transport/timeout_encoding.c', 'src/core/lib/transport/timeout_encoding.c',
'src/core/lib/transport/transport.c', 'src/core/lib/transport/transport.c',

@ -256,6 +256,7 @@ filegroups:
- src/core/lib/transport/metadata.h - src/core/lib/transport/metadata.h
- src/core/lib/transport/metadata_batch.h - src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/method_config.h - src/core/lib/transport/method_config.h
- src/core/lib/transport/pid_controller.h
- src/core/lib/transport/static_metadata.h - src/core/lib/transport/static_metadata.h
- src/core/lib/transport/timeout_encoding.h - src/core/lib/transport/timeout_encoding.h
- src/core/lib/transport/transport.h - src/core/lib/transport/transport.h
@ -364,6 +365,7 @@ filegroups:
- src/core/lib/transport/metadata.c - src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c - src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/method_config.c - src/core/lib/transport/method_config.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/static_metadata.c - src/core/lib/transport/static_metadata.c
- src/core/lib/transport/timeout_encoding.c - src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c - src/core/lib/transport/transport.c
@ -684,8 +686,6 @@ filegroups:
deps: deps:
- gpr - gpr
secure: true secure: true
uses:
- grpc_base
- name: grpc++_base - name: grpc++_base
language: c++ language: c++
public_headers: public_headers:
@ -710,12 +710,6 @@ filegroups:
- include/grpc++/impl/server_builder_plugin.h - include/grpc++/impl/server_builder_plugin.h
- include/grpc++/impl/server_initializer.h - include/grpc++/impl/server_initializer.h
- include/grpc++/impl/service_type.h - include/grpc++/impl/service_type.h
- include/grpc++/impl/sync.h
- include/grpc++/impl/sync_cxx11.h
- include/grpc++/impl/sync_no_cxx11.h
- include/grpc++/impl/thd.h
- include/grpc++/impl/thd_cxx11.h
- include/grpc++/impl/thd_no_cxx11.h
- include/grpc++/resource_quota.h - include/grpc++/resource_quota.h
- include/grpc++/security/auth_context.h - include/grpc++/security/auth_context.h
- include/grpc++/security/auth_metadata_processor.h - include/grpc++/security/auth_metadata_processor.h
@ -802,9 +796,6 @@ filegroups:
- include/grpc++/impl/codegen/status_helper.h - include/grpc++/impl/codegen/status_helper.h
- include/grpc++/impl/codegen/string_ref.h - include/grpc++/impl/codegen/string_ref.h
- include/grpc++/impl/codegen/stub_options.h - include/grpc++/impl/codegen/stub_options.h
- include/grpc++/impl/codegen/sync.h
- include/grpc++/impl/codegen/sync_cxx11.h
- include/grpc++/impl/codegen/sync_no_cxx11.h
- include/grpc++/impl/codegen/sync_stream.h - include/grpc++/impl/codegen/sync_stream.h
- include/grpc++/impl/codegen/time.h - include/grpc++/impl/codegen/time.h
uses: uses:
@ -828,14 +819,8 @@ filegroups:
- include/grpc++/impl/codegen/config_protobuf.h - include/grpc++/impl/codegen/config_protobuf.h
- name: grpc++_reflection_proto - name: grpc++_reflection_proto
language: c++ language: c++
public_headers:
- include/grpc++/ext/reflection.grpc.pb.h
- include/grpc++/ext/reflection.pb.h
src: src:
- src/cpp/ext/reflection.grpc.pb.cc - src/proto/grpc/reflection/v1alpha/reflection.proto
- src/cpp/ext/reflection.pb.cc
uses:
- grpc++_codegen_proto
- name: thrift_util - name: thrift_util
language: c++ language: c++
public_headers: public_headers:
@ -1053,6 +1038,18 @@ libs:
platforms: platforms:
- linux - linux
secure: true secure: true
- name: grpc++_proto_reflection_desc_db
build: private
language: c++
headers:
- test/cpp/util/proto_reflection_descriptor_database.h
src:
- test/cpp/util/proto_reflection_descriptor_database.cc
deps:
- grpc++
filegroups:
- grpc++_reflection_proto
- grpc++_config_proto
- name: grpc++_reflection - name: grpc++_reflection
build: all build: all
language: c++ language: c++
@ -1067,11 +1064,6 @@ libs:
- grpc++ - grpc++
filegroups: filegroups:
- grpc++_reflection_proto - grpc++_reflection_proto
- name: grpc++_reflection_codegen
build: private
language: c++
src:
- src/proto/grpc/reflection/v1alpha/reflection.proto
- name: grpc++_test - name: grpc++_test
build: private build: private
language: c++ language: c++
@ -1144,18 +1136,19 @@ libs:
- test/cpp/util/config_grpc_cli.h - test/cpp/util/config_grpc_cli.h
- test/cpp/util/grpc_tool.h - test/cpp/util/grpc_tool.h
- test/cpp/util/proto_file_parser.h - test/cpp/util/proto_file_parser.h
- test/cpp/util/proto_reflection_descriptor_database.h
- test/cpp/util/service_describer.h - test/cpp/util/service_describer.h
src: src:
- test/cpp/util/cli_call.cc - test/cpp/util/cli_call.cc
- test/cpp/util/cli_credentials.cc - test/cpp/util/cli_credentials.cc
- test/cpp/util/grpc_tool.cc - test/cpp/util/grpc_tool.cc
- test/cpp/util/proto_file_parser.cc - test/cpp/util/proto_file_parser.cc
- test/cpp/util/proto_reflection_descriptor_database.cc
- test/cpp/util/service_describer.cc - test/cpp/util/service_describer.cc
deps: deps:
- grpc++_reflection - grpc++_proto_reflection_desc_db
- grpc++ - grpc++
filegroups:
- grpc++_reflection_proto
- grpc++_config_proto
- name: grpc_plugin_support - name: grpc_plugin_support
build: protoc build: protoc
language: c++ language: c++
@ -2677,6 +2670,16 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: transport_pid_controller_test
build: test
language: c
src:
- test/core/transport/pid_controller_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: transport_security_test - name: transport_security_test
build: test build: test
language: c language: c
@ -2984,7 +2987,7 @@ targets:
- test/cpp/util/grpc_cli.cc - test/cpp/util/grpc_cli.cc
deps: deps:
- grpc_cli_libs - grpc_cli_libs
- grpc++_reflection - grpc++_proto_reflection_desc_db
- grpc++ - grpc++
- grpc - grpc
- gpr - gpr
@ -3061,16 +3064,15 @@ targets:
gtest: true gtest: true
build: test build: test
language: c++ language: c++
headers:
- test/cpp/util/string_ref_helper.h
src: src:
- src/proto/grpc/testing/echo.proto - src/proto/grpc/testing/echo.proto
- src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/echo_messages.proto
- test/cpp/util/grpc_tool_test.cc - test/cpp/util/grpc_tool_test.cc
- test/cpp/util/string_ref_helper.cc
deps: deps:
- grpc_cli_libs - grpc_cli_libs
- grpc++_proto_reflection_desc_db
- grpc++_reflection - grpc++_reflection
- grpc++_test_util
- grpc_test_util - grpc_test_util
- grpc++ - grpc++
- grpc - grpc
@ -3078,7 +3080,6 @@ targets:
- gpr - gpr
filegroups: filegroups:
- grpc++_codegen_proto - grpc++_codegen_proto
- grpc++_config_proto
- name: grpclb_api_test - name: grpclb_api_test
gtest: true gtest: true
build: test build: test
@ -3214,16 +3215,21 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: noop-benchmark
build: test
language: c++
src:
- test/cpp/microbenchmarks/noop-benchmark.cc
deps:
- google_benchmark
- name: proto_server_reflection_test - name: proto_server_reflection_test
gtest: true gtest: true
build: test build: test
language: c++ language: c++
headers:
- test/cpp/util/proto_reflection_descriptor_database.h
src: src:
- test/cpp/end2end/proto_server_reflection_test.cc - test/cpp/end2end/proto_server_reflection_test.cc
- test/cpp/util/proto_reflection_descriptor_database.cc
deps: deps:
- grpc++_proto_reflection_desc_db
- grpc++_reflection - grpc++_reflection
- grpc++_test_util - grpc++_test_util
- grpc_test_util - grpc_test_util
@ -3337,6 +3343,19 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- grpc++_test_config - grpc++_test_config
- name: round_robin_end2end_test
gtest: true
build: test
language: c++
src:
- test/cpp/end2end/round_robin_end2end_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
- name: secure_auth_context_test - name: secure_auth_context_test
gtest: true gtest: true
build: test build: test
@ -3696,6 +3715,8 @@ defaults:
global: global:
CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
LDFLAGS: -g LDFLAGS: -g
google_benchmark:
CPPFLAGS: -Ithird_party/google_benchmark/include -DHAVE_POSIX_REGEX
zlib: zlib:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration
$(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden

@ -187,6 +187,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata.c \
src/core/lib/transport/metadata_batch.c \ src/core/lib/transport/metadata_batch.c \
src/core/lib/transport/method_config.c \ src/core/lib/transport/method_config.c \
src/core/lib/transport/pid_controller.c \
src/core/lib/transport/static_metadata.c \ src/core/lib/transport/static_metadata.c \
src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/timeout_encoding.c \
src/core/lib/transport/transport.c \ src/core/lib/transport/transport.c \

@ -1,91 +1,9 @@
GRPC C++ STYLE GUIDE GRPC C++ STYLE GUIDE
===================== =====================
Background The majority of gRPC's C++ requirements are drawn from the [Google C++ style
---------- guide] (https://google.github.io/styleguide/cppguide.html). Additionally,
as in C, layout rules are defined by clang-format, and all code
Here we document style rules for C++ usage in the gRPC C++ bindings
and tests.
General
-------
- The majority of gRPC's C++ requirements are drawn from the [Google C++ style
guide] (https://google.github.io/styleguide/cppguide.html)
- However, gRPC has some additional requirements to maintain
[portability] (#portability)
- As in C, layout rules are defined by clang-format, and all code
should be passed through clang-format. A (docker-based) script to do should be passed through clang-format. A (docker-based) script to do
so is included in [tools/distrib/clang\_format\_code.sh] so is included in [tools/distrib/clang\_format\_code.sh]
(../tools/distrib/clang_format_code.sh). (../tools/distrib/clang_format_code.sh).
<a name="portability"></a>
Portability Restrictions
-------------------
gRPC supports a large number of compilers, ranging from those that are
missing many key C++11 features to those that have quite detailed
analysis. As a result, gRPC compiles with a high level of warnings and
treat all warnings as errors. gRPC also forbids the use of some common
C++11 constructs. Here are some guidelines, to be extended as needed:
- Do not use range-based for. Expressions of the form
```c
for (auto& i: vec) {
// code
}
```
are not allowed and should be replaced with code such as
```c
for (auto it = vec.begin; it != vec.end(); it++) {
auto& i = *it;
// code
}
```
- Do not use lambda of any kind (no capture, explicit capture, or
default capture). Other C++ functional features such as
`std::function` or `std::bind` are allowed
- Do not use brace-list initializers.
- Do not compare a pointer to `nullptr` . This is because gcc 4.4
does not support `nullptr` directly and gRPC implements a subset of
its features in [include/grpc++/impl/codegen/config.h]
(../include/grpc++/impl/codegen/config.h). Instead, pointers should
be checked for validity using their implicit conversion to `bool`.
In other words, use `if (p)` rather than `if (p != nullptr)`
- Do not initialize global/static pointer variables to `nullptr`. Just let
the compiler implicitly initialize them to `nullptr` (which it will
definitely do). The reason is that `nullptr` is an actual object in
our implementation rather than just a constant pointer value, so
static/global constructors will be called in a potentially
undesirable sequence.
- Do not use `final` or `override` as these are not supported by some
compilers. Instead use `GRPC_FINAL` and `GRPC_OVERRIDE` . These
compile down to the traditional C++ forms for compilers that support
them but are just elided if the compiler does not support those features.
- In the [include] (../../../tree/master/include/grpc++) and [src]
(../../../tree/master/src/cpp) directory trees, you should also not
use certain STL objects like `std::mutex`, `std::lock_guard`,
`std::unique_lock`, `std::nullptr`, `std::thread` . Instead, use
`grpc::mutex`, `grpc::lock_guard`, etc., which are gRPC
implementations of the prominent features of these objects that are
not always available. You can use the `std` versions of those in [test]
(../../../tree/master/test/cpp)
- Similarly, in the same directories, do not use `std::chrono` unless
it is guarded by `#ifndef GRPC_CXX0X_NO_CHRONO` . For platforms that
lack`std::chrono,` there is a C-language timer called gpr_timespec that can
be used instead.
- `std::unique_ptr` must be used with extreme care in any kind of
collection. For example `vector<std::unique_ptr>` does not work in
gcc 4.4 if the vector is constructed to its full size at
initialization but does work if elements are added to the vector
using functions like `push_back`. `map` and other pair-based
collections do not work with `unique_ptr` under gcc 4.4. The issue
is that many of these collection implementations assume a copy
constructor
to be available.
- Don't use `std::this_thread` . Use `gpr_sleep_until` for sleeping a thread.
- [Some adjacent character combinations cause problems]
(https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C). If declaring a
template against some class relative to the global namespace,
`<::name` will be non-portable. Separate the `<` from the `:` and use `< ::name`.

@ -339,6 +339,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/metadata.h', 'src/core/lib/transport/metadata.h',
'src/core/lib/transport/metadata_batch.h', 'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/method_config.h', 'src/core/lib/transport/method_config.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/static_metadata.h', 'src/core/lib/transport/static_metadata.h',
'src/core/lib/transport/timeout_encoding.h', 'src/core/lib/transport/timeout_encoding.h',
'src/core/lib/transport/transport.h', 'src/core/lib/transport/transport.h',
@ -527,6 +528,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/metadata.c', 'src/core/lib/transport/metadata.c',
'src/core/lib/transport/metadata_batch.c', 'src/core/lib/transport/metadata_batch.c',
'src/core/lib/transport/method_config.c', 'src/core/lib/transport/method_config.c',
'src/core/lib/transport/pid_controller.c',
'src/core/lib/transport/static_metadata.c', 'src/core/lib/transport/static_metadata.c',
'src/core/lib/transport/timeout_encoding.c', 'src/core/lib/transport/timeout_encoding.c',
'src/core/lib/transport/transport.c', 'src/core/lib/transport/transport.c',
@ -735,6 +737,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/metadata.h', 'src/core/lib/transport/metadata.h',
'src/core/lib/transport/metadata_batch.h', 'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/method_config.h', 'src/core/lib/transport/method_config.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/static_metadata.h', 'src/core/lib/transport/static_metadata.h',
'src/core/lib/transport/timeout_encoding.h', 'src/core/lib/transport/timeout_encoding.h',
'src/core/lib/transport/transport.h', 'src/core/lib/transport/transport.h',

@ -259,6 +259,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/transport/metadata.h ) s.files += %w( src/core/lib/transport/metadata.h )
s.files += %w( src/core/lib/transport/metadata_batch.h ) s.files += %w( src/core/lib/transport/metadata_batch.h )
s.files += %w( src/core/lib/transport/method_config.h ) s.files += %w( src/core/lib/transport/method_config.h )
s.files += %w( src/core/lib/transport/pid_controller.h )
s.files += %w( src/core/lib/transport/static_metadata.h ) s.files += %w( src/core/lib/transport/static_metadata.h )
s.files += %w( src/core/lib/transport/timeout_encoding.h ) s.files += %w( src/core/lib/transport/timeout_encoding.h )
s.files += %w( src/core/lib/transport/transport.h ) s.files += %w( src/core/lib/transport/transport.h )
@ -447,6 +448,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/transport/metadata.c ) s.files += %w( src/core/lib/transport/metadata.c )
s.files += %w( src/core/lib/transport/metadata_batch.c ) s.files += %w( src/core/lib/transport/metadata_batch.c )
s.files += %w( src/core/lib/transport/method_config.c ) s.files += %w( src/core/lib/transport/method_config.c )
s.files += %w( src/core/lib/transport/pid_controller.c )
s.files += %w( src/core/lib/transport/static_metadata.c ) s.files += %w( src/core/lib/transport/static_metadata.c )
s.files += %w( src/core/lib/transport/timeout_encoding.c ) s.files += %w( src/core/lib/transport/timeout_encoding.c )
s.files += %w( src/core/lib/transport/transport.c ) s.files += %w( src/core/lib/transport/transport.c )

@ -78,7 +78,7 @@ class Alarm : private GrpcLibraryCodegen {
class AlarmEntry : public CompletionQueueTag { class AlarmEntry : public CompletionQueueTag {
public: public:
AlarmEntry(void* tag) : tag_(tag) {} AlarmEntry(void* tag) : tag_(tag) {}
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
*tag = tag_; *tag = tag_;
return true; return true;
} }

@ -46,7 +46,7 @@ struct grpc_channel;
namespace grpc { namespace grpc {
/// Channels represent a connection to an endpoint. Created by \a CreateChannel. /// Channels represent a connection to an endpoint. Created by \a CreateChannel.
class Channel GRPC_FINAL : public ChannelInterface, class Channel final : public ChannelInterface,
public CallHook, public CallHook,
public std::enable_shared_from_this<Channel>, public std::enable_shared_from_this<Channel>,
private GrpcLibraryCodegen { private GrpcLibraryCodegen {
@ -55,7 +55,7 @@ class Channel GRPC_FINAL : public ChannelInterface,
/// Get the current channel state. If the channel is in IDLE and /// Get the current channel state. If the channel is in IDLE and
/// \a try_to_connect is set to true, try to connect. /// \a try_to_connect is set to true, try to connect.
grpc_connectivity_state GetState(bool try_to_connect) GRPC_OVERRIDE; grpc_connectivity_state GetState(bool try_to_connect) override;
private: private:
template <class InputMessage, class OutputMessage> template <class InputMessage, class OutputMessage>
@ -69,15 +69,15 @@ class Channel GRPC_FINAL : public ChannelInterface,
Channel(const grpc::string& host, grpc_channel* c_channel); Channel(const grpc::string& host, grpc_channel* c_channel);
Call CreateCall(const RpcMethod& method, ClientContext* context, Call CreateCall(const RpcMethod& method, ClientContext* context,
CompletionQueue* cq) GRPC_OVERRIDE; CompletionQueue* cq) override;
void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE; void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override;
void* RegisterMethod(const char* method) GRPC_OVERRIDE; void* RegisterMethod(const char* method) override;
void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline, CompletionQueue* cq, gpr_timespec deadline, CompletionQueue* cq,
void* tag) GRPC_OVERRIDE; void* tag) override;
bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline) GRPC_OVERRIDE; gpr_timespec deadline) override;
const grpc::string host_; const grpc::string host_;
grpc_channel* const c_channel_; // owned grpc_channel* const c_channel_; // owned

@ -48,12 +48,12 @@ namespace reflection {
class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin { class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin {
public: public:
ProtoServerReflectionPlugin(); ProtoServerReflectionPlugin();
::grpc::string name() GRPC_OVERRIDE; ::grpc::string name() override;
void InitServer(::grpc::ServerInitializer* si) GRPC_OVERRIDE; void InitServer(::grpc::ServerInitializer* si) override;
void Finish(::grpc::ServerInitializer* si) GRPC_OVERRIDE; void Finish(::grpc::ServerInitializer* si) override;
void ChangeArguments(const ::grpc::string& name, void* value) GRPC_OVERRIDE; void ChangeArguments(const ::grpc::string& name, void* value) override;
bool has_async_methods() const GRPC_OVERRIDE; bool has_async_methods() const override;
bool has_sync_methods() const GRPC_OVERRIDE; bool has_sync_methods() const override;
private: private:
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_; std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;

@ -1,188 +0,0 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
// Generated by tools/codegen/extensions/gen_reflection_proto.sh
// If you make any local change, they will be lost.
// source: reflection.proto
// Original file comments:
// Copyright 2016, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Service exported by server reflection
//
#ifndef GRPC_reflection_2eproto__INCLUDED
#define GRPC_reflection_2eproto__INCLUDED
#include <grpc++/ext/reflection.pb.h>
#include <grpc++/impl/codegen/async_stream.h>
#include <grpc++/impl/codegen/async_unary_call.h>
#include <grpc++/impl/codegen/method_handler_impl.h>
#include <grpc++/impl/codegen/proto_utils.h>
#include <grpc++/impl/codegen/rpc_method.h>
#include <grpc++/impl/codegen/service_type.h>
#include <grpc++/impl/codegen/status.h>
#include <grpc++/impl/codegen/stub_options.h>
#include <grpc++/impl/codegen/sync_stream.h>
namespace grpc {
class CompletionQueue;
class Channel;
class RpcService;
class ServerCompletionQueue;
class ServerContext;
} // namespace grpc
namespace grpc {
namespace reflection {
namespace v1alpha {
class ServerReflection GRPC_FINAL {
public:
class StubInterface {
public:
virtual ~StubInterface() {}
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> ServerReflectionInfo(::grpc::ClientContext* context) {
return std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(ServerReflectionInfoRaw(context));
}
std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> AsyncServerReflectionInfo(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(AsyncServerReflectionInfoRaw(context, cq, tag));
}
private:
virtual ::grpc::ClientReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* ServerReflectionInfoRaw(::grpc::ClientContext* context) = 0;
virtual ::grpc::ClientAsyncReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* AsyncServerReflectionInfoRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0;
};
class Stub GRPC_FINAL : public StubInterface {
public:
Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
std::unique_ptr< ::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> ServerReflectionInfo(::grpc::ClientContext* context) {
return std::unique_ptr< ::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(ServerReflectionInfoRaw(context));
}
std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> AsyncServerReflectionInfo(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(AsyncServerReflectionInfoRaw(context, cq, tag));
}
private:
std::shared_ptr< ::grpc::ChannelInterface> channel_;
::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* ServerReflectionInfoRaw(::grpc::ClientContext* context) GRPC_OVERRIDE;
::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* AsyncServerReflectionInfoRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;
const ::grpc::RpcMethod rpcmethod_ServerReflectionInfo_;
};
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
class Service : public ::grpc::Service {
public:
Service();
virtual ~Service();
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
virtual ::grpc::Status ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream);
};
template <class BaseClass>
class WithAsyncMethod_ServerReflectionInfo : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithAsyncMethod_ServerReflectionInfo() {
::grpc::Service::MarkMethodAsync(0);
}
~WithAsyncMethod_ServerReflectionInfo() GRPC_OVERRIDE {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream) GRPC_FINAL GRPC_OVERRIDE {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncBidiStreaming(0, context, stream, new_call_cq, notification_cq, tag);
}
};
typedef WithAsyncMethod_ServerReflectionInfo<Service > AsyncService;
template <class BaseClass>
class WithGenericMethod_ServerReflectionInfo : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithGenericMethod_ServerReflectionInfo() {
::grpc::Service::MarkMethodGeneric(0);
}
~WithGenericMethod_ServerReflectionInfo() GRPC_OVERRIDE {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream) GRPC_FINAL GRPC_OVERRIDE {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
typedef Service StreamedUnaryService;
typedef Service SplitStreamedService;
typedef Service StreamedService;
};
} // namespace v1alpha
} // namespace reflection
} // namespace grpc
#endif // GRPC_reflection_2eproto__INCLUDED

File diff suppressed because it is too large Load Diff

@ -44,7 +44,7 @@ namespace grpc {
typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer> typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer>
GenericServerAsyncReaderWriter; GenericServerAsyncReaderWriter;
class GenericServerContext GRPC_FINAL : public ServerContext { class GenericServerContext final : public ServerContext {
public: public:
const grpc::string& method() const { return method_; } const grpc::string& method() const { return method_; }
const grpc::string& host() const { return host_; } const grpc::string& host() const { return host_; }
@ -57,7 +57,7 @@ class GenericServerContext GRPC_FINAL : public ServerContext {
grpc::string host_; grpc::string host_;
}; };
class AsyncGenericService GRPC_FINAL { class AsyncGenericService final {
public: public:
AsyncGenericService() : server_(nullptr) {} AsyncGenericService() : server_(nullptr) {}

@ -45,7 +45,7 @@ typedef ClientAsyncReaderWriter<ByteBuffer, ByteBuffer>
// Generic stubs provide a type-unsafe interface to call gRPC methods // Generic stubs provide a type-unsafe interface to call gRPC methods
// by name. // by name.
class GenericStub GRPC_FINAL { class GenericStub final {
public: public:
explicit GenericStub(std::shared_ptr<ChannelInterface> channel) explicit GenericStub(std::shared_ptr<ChannelInterface> channel)
: channel_(channel) {} : channel_(channel) {}

@ -108,7 +108,7 @@ class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface,
public AsyncReaderInterface<R> {}; public AsyncReaderInterface<R> {};
template <class R> template <class R>
class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface<R> { class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
public: public:
/// Create a stream and write the first request out. /// Create a stream and write the first request out.
template <class W> template <class W>
@ -125,7 +125,7 @@ class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface<R> {
call_.PerformOps(&init_ops_); call_.PerformOps(&init_ops_);
} }
void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { void ReadInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
@ -133,7 +133,7 @@ class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface<R> {
call_.PerformOps(&meta_ops_); call_.PerformOps(&meta_ops_);
} }
void Read(R* msg, void* tag) GRPC_OVERRIDE { void Read(R* msg, void* tag) override {
read_ops_.set_output_tag(tag); read_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
read_ops_.RecvInitialMetadata(context_); read_ops_.RecvInitialMetadata(context_);
@ -142,7 +142,7 @@ class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface<R> {
call_.PerformOps(&read_ops_); call_.PerformOps(&read_ops_);
} }
void Finish(Status* status, void* tag) GRPC_OVERRIDE { void Finish(Status* status, void* tag) override {
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -174,7 +174,7 @@ class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface,
}; };
template <class W> template <class W>
class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> { class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
public: public:
template <class R> template <class R>
ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq, ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq,
@ -190,7 +190,7 @@ class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> {
call_.PerformOps(&init_ops_); call_.PerformOps(&init_ops_);
} }
void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { void ReadInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
@ -198,20 +198,20 @@ class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> {
call_.PerformOps(&meta_ops_); call_.PerformOps(&meta_ops_);
} }
void Write(const W& msg, void* tag) GRPC_OVERRIDE { void Write(const W& msg, void* tag) override {
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void WritesDone(void* tag) GRPC_OVERRIDE { void WritesDone(void* tag) override {
writes_done_ops_.set_output_tag(tag); writes_done_ops_.set_output_tag(tag);
writes_done_ops_.ClientSendClose(); writes_done_ops_.ClientSendClose();
call_.PerformOps(&writes_done_ops_); call_.PerformOps(&writes_done_ops_);
} }
void Finish(Status* status, void* tag) GRPC_OVERRIDE { void Finish(Status* status, void* tag) override {
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -246,7 +246,7 @@ class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface,
}; };
template <class W, class R> template <class W, class R>
class ClientAsyncReaderWriter GRPC_FINAL class ClientAsyncReaderWriter final
: public ClientAsyncReaderWriterInterface<W, R> { : public ClientAsyncReaderWriterInterface<W, R> {
public: public:
ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq, ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq,
@ -259,7 +259,7 @@ class ClientAsyncReaderWriter GRPC_FINAL
call_.PerformOps(&init_ops_); call_.PerformOps(&init_ops_);
} }
void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { void ReadInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
@ -267,7 +267,7 @@ class ClientAsyncReaderWriter GRPC_FINAL
call_.PerformOps(&meta_ops_); call_.PerformOps(&meta_ops_);
} }
void Read(R* msg, void* tag) GRPC_OVERRIDE { void Read(R* msg, void* tag) override {
read_ops_.set_output_tag(tag); read_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
read_ops_.RecvInitialMetadata(context_); read_ops_.RecvInitialMetadata(context_);
@ -276,20 +276,20 @@ class ClientAsyncReaderWriter GRPC_FINAL
call_.PerformOps(&read_ops_); call_.PerformOps(&read_ops_);
} }
void Write(const W& msg, void* tag) GRPC_OVERRIDE { void Write(const W& msg, void* tag) override {
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void WritesDone(void* tag) GRPC_OVERRIDE { void WritesDone(void* tag) override {
writes_done_ops_.set_output_tag(tag); writes_done_ops_.set_output_tag(tag);
writes_done_ops_.ClientSendClose(); writes_done_ops_.ClientSendClose();
call_.PerformOps(&writes_done_ops_); call_.PerformOps(&writes_done_ops_);
} }
void Finish(Status* status, void* tag) GRPC_OVERRIDE { void Finish(Status* status, void* tag) override {
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -319,12 +319,12 @@ class ServerAsyncReaderInterface : public ServerAsyncStreamingInterface,
}; };
template <class W, class R> template <class W, class R>
class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> { class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
public: public:
explicit ServerAsyncReader(ServerContext* ctx) explicit ServerAsyncReader(ServerContext* ctx)
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {} : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
void SendInitialMetadata(void* tag) GRPC_OVERRIDE { void SendInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
@ -337,13 +337,13 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
call_.PerformOps(&meta_ops_); call_.PerformOps(&meta_ops_);
} }
void Read(R* msg, void* tag) GRPC_OVERRIDE { void Read(R* msg, void* tag) override {
read_ops_.set_output_tag(tag); read_ops_.set_output_tag(tag);
read_ops_.RecvMessage(msg); read_ops_.RecvMessage(msg);
call_.PerformOps(&read_ops_); call_.PerformOps(&read_ops_);
} }
void Finish(const W& msg, const Status& status, void* tag) GRPC_OVERRIDE { void Finish(const W& msg, const Status& status, void* tag) override {
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_, finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
@ -363,7 +363,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
call_.PerformOps(&finish_ops_); call_.PerformOps(&finish_ops_);
} }
void FinishWithError(const Status& status, void* tag) GRPC_OVERRIDE { void FinishWithError(const Status& status, void* tag) override {
GPR_CODEGEN_ASSERT(!status.ok()); GPR_CODEGEN_ASSERT(!status.ok());
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
@ -379,7 +379,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
} }
private: private:
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } void BindCall(Call* call) override { call_ = *call; }
Call call_; Call call_;
ServerContext* ctx_; ServerContext* ctx_;
@ -398,12 +398,12 @@ class ServerAsyncWriterInterface : public ServerAsyncStreamingInterface,
}; };
template <class W> template <class W>
class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> { class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
public: public:
explicit ServerAsyncWriter(ServerContext* ctx) explicit ServerAsyncWriter(ServerContext* ctx)
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {} : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
void SendInitialMetadata(void* tag) GRPC_OVERRIDE { void SendInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
@ -416,7 +416,7 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
call_.PerformOps(&meta_ops_); call_.PerformOps(&meta_ops_);
} }
void Write(const W& msg, void* tag) GRPC_OVERRIDE { void Write(const W& msg, void* tag) override {
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
write_ops_.SendInitialMetadata(ctx_->initial_metadata_, write_ops_.SendInitialMetadata(ctx_->initial_metadata_,
@ -431,7 +431,7 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void Finish(const Status& status, void* tag) GRPC_OVERRIDE { void Finish(const Status& status, void* tag) override {
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_, finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
@ -446,7 +446,7 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
} }
private: private:
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } void BindCall(Call* call) override { call_ = *call; }
Call call_; Call call_;
ServerContext* ctx_; ServerContext* ctx_;
@ -465,13 +465,13 @@ class ServerAsyncReaderWriterInterface : public ServerAsyncStreamingInterface,
}; };
template <class W, class R> template <class W, class R>
class ServerAsyncReaderWriter GRPC_FINAL class ServerAsyncReaderWriter final
: public ServerAsyncReaderWriterInterface<W, R> { : public ServerAsyncReaderWriterInterface<W, R> {
public: public:
explicit ServerAsyncReaderWriter(ServerContext* ctx) explicit ServerAsyncReaderWriter(ServerContext* ctx)
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {} : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
void SendInitialMetadata(void* tag) GRPC_OVERRIDE { void SendInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
@ -484,13 +484,13 @@ class ServerAsyncReaderWriter GRPC_FINAL
call_.PerformOps(&meta_ops_); call_.PerformOps(&meta_ops_);
} }
void Read(R* msg, void* tag) GRPC_OVERRIDE { void Read(R* msg, void* tag) override {
read_ops_.set_output_tag(tag); read_ops_.set_output_tag(tag);
read_ops_.RecvMessage(msg); read_ops_.RecvMessage(msg);
call_.PerformOps(&read_ops_); call_.PerformOps(&read_ops_);
} }
void Write(const W& msg, void* tag) GRPC_OVERRIDE { void Write(const W& msg, void* tag) override {
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
write_ops_.SendInitialMetadata(ctx_->initial_metadata_, write_ops_.SendInitialMetadata(ctx_->initial_metadata_,
@ -505,7 +505,7 @@ class ServerAsyncReaderWriter GRPC_FINAL
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void Finish(const Status& status, void* tag) GRPC_OVERRIDE { void Finish(const Status& status, void* tag) override {
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_, finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
@ -522,7 +522,7 @@ class ServerAsyncReaderWriter GRPC_FINAL
private: private:
friend class ::grpc::Server; friend class ::grpc::Server;
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } void BindCall(Call* call) override { call_ = *call; }
Call call_; Call call_;
ServerContext* ctx_; ServerContext* ctx_;

@ -55,7 +55,7 @@ class ClientAsyncResponseReaderInterface {
}; };
template <class R> template <class R>
class ClientAsyncResponseReader GRPC_FINAL class ClientAsyncResponseReader final
: public ClientAsyncResponseReaderInterface<R> { : public ClientAsyncResponseReaderInterface<R> {
public: public:
template <class W> template <class W>
@ -113,13 +113,12 @@ class ClientAsyncResponseReader GRPC_FINAL
}; };
template <class W> template <class W>
class ServerAsyncResponseWriter GRPC_FINAL class ServerAsyncResponseWriter final : public ServerAsyncStreamingInterface {
: public ServerAsyncStreamingInterface {
public: public:
explicit ServerAsyncResponseWriter(ServerContext* ctx) explicit ServerAsyncResponseWriter(ServerContext* ctx)
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {} : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
void SendInitialMetadata(void* tag) GRPC_OVERRIDE { void SendInitialMetadata(void* tag) override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
meta_buf_.set_output_tag(tag); meta_buf_.set_output_tag(tag);
@ -168,7 +167,7 @@ class ServerAsyncResponseWriter GRPC_FINAL
} }
private: private:
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } void BindCall(Call* call) override { call_ = *call; }
Call call_; Call call_;
ServerContext* ctx_; ServerContext* ctx_;

@ -337,16 +337,16 @@ class DeserializeFunc {
}; };
template <class R> template <class R>
class DeserializeFuncType GRPC_FINAL : public DeserializeFunc { class DeserializeFuncType final : public DeserializeFunc {
public: public:
DeserializeFuncType(R* message) : message_(message) {} DeserializeFuncType(R* message) : message_(message) {}
Status Deserialize(grpc_byte_buffer* buf, Status Deserialize(grpc_byte_buffer* buf,
int max_receive_message_size) GRPC_OVERRIDE { int max_receive_message_size) override {
return SerializationTraits<R>::Deserialize(buf, message_, return SerializationTraits<R>::Deserialize(buf, message_,
max_receive_message_size); max_receive_message_size);
} }
~DeserializeFuncType() GRPC_OVERRIDE {} ~DeserializeFuncType() override {}
private: private:
R* message_; // Not a managed pointer because management is external to this R* message_; // Not a managed pointer because management is external to this
@ -603,7 +603,7 @@ class CallOpSet : public CallOpSetInterface,
public Op6 { public Op6 {
public: public:
CallOpSet() : return_tag_(this) {} CallOpSet() : return_tag_(this) {}
void FillOps(grpc_op* ops, size_t* nops) GRPC_OVERRIDE { void FillOps(grpc_op* ops, size_t* nops) override {
this->Op1::AddOp(ops, nops); this->Op1::AddOp(ops, nops);
this->Op2::AddOp(ops, nops); this->Op2::AddOp(ops, nops);
this->Op3::AddOp(ops, nops); this->Op3::AddOp(ops, nops);
@ -612,7 +612,7 @@ class CallOpSet : public CallOpSetInterface,
this->Op6::AddOp(ops, nops); this->Op6::AddOp(ops, nops);
} }
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
this->Op1::FinishOp(status, max_receive_message_size_); this->Op1::FinishOp(status, max_receive_message_size_);
this->Op2::FinishOp(status, max_receive_message_size_); this->Op2::FinishOp(status, max_receive_message_size_);
this->Op3::FinishOp(status, max_receive_message_size_); this->Op3::FinishOp(status, max_receive_message_size_);
@ -639,14 +639,14 @@ template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>> class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> { class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> {
public: public:
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
typedef CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> Base; typedef CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> Base;
return Base::FinalizeResult(tag, status) && false; return Base::FinalizeResult(tag, status) && false;
} }
}; };
// Straightforward wrapping of the C call object // Straightforward wrapping of the C call object
class Call GRPC_FINAL { class Call final {
public: public:
/* call is owned by the caller */ /* call is owned by the caller */
Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq) Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq)

@ -51,6 +51,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <grpc++/impl/codegen/config.h> #include <grpc++/impl/codegen/config.h>
@ -59,7 +60,6 @@
#include <grpc++/impl/codegen/security/auth_context.h> #include <grpc++/impl/codegen/security/auth_context.h>
#include <grpc++/impl/codegen/status.h> #include <grpc++/impl/codegen/status.h>
#include <grpc++/impl/codegen/string_ref.h> #include <grpc++/impl/codegen/string_ref.h>
#include <grpc++/impl/codegen/sync.h>
#include <grpc++/impl/codegen/time.h> #include <grpc++/impl/codegen/time.h>
#include <grpc/impl/codegen/compression_types.h> #include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/propagation_bits.h> #include <grpc/impl/codegen/propagation_bits.h>
@ -235,12 +235,10 @@ class ClientContext {
/// DEPRECATED: Use set_wait_for_ready() instead. /// DEPRECATED: Use set_wait_for_ready() instead.
void set_fail_fast(bool fail_fast) { set_wait_for_ready(!fail_fast); } void set_fail_fast(bool fail_fast) { set_wait_for_ready(!fail_fast); }
#ifndef GRPC_CXX0X_NO_CHRONO
/// Return the deadline for the client call. /// Return the deadline for the client call.
std::chrono::system_clock::time_point deadline() const { std::chrono::system_clock::time_point deadline() const {
return Timespec2Timepoint(deadline_); return Timespec2Timepoint(deadline_);
} }
#endif // !GRPC_CXX0X_NO_CHRONO
/// Return a \a gpr_timespec representation of the client call's deadline. /// Return a \a gpr_timespec representation of the client call's deadline.
gpr_timespec raw_deadline() const { return deadline_; } gpr_timespec raw_deadline() const { return deadline_; }
@ -368,7 +366,7 @@ class ClientContext {
bool idempotent_; bool idempotent_;
bool cacheable_; bool cacheable_;
std::shared_ptr<Channel> channel_; std::shared_ptr<Channel> channel_;
grpc::mutex mu_; std::mutex mu_;
grpc_call* call_; grpc_call* call_;
bool call_canceled_; bool call_canceled_;
gpr_timespec deadline_; gpr_timespec deadline_;

@ -34,80 +34,6 @@
#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_H #ifndef GRPCXX_IMPL_CODEGEN_CONFIG_H
#define GRPCXX_IMPL_CODEGEN_CONFIG_H #define GRPCXX_IMPL_CODEGEN_CONFIG_H
#if !defined(GRPC_NO_AUTODETECT_PLATFORM)
#ifdef _MSC_VER
// Visual Studio 2010 is 1600.
#if _MSC_VER < 1600
#error "gRPC is only supported with Visual Studio starting at 2010"
// Visual Studio 2013 is 1800.
#elif _MSC_VER < 1800
#define GRPC_CXX0X_NO_FINAL 1
#define GRPC_CXX0X_NO_OVERRIDE 1
#define GRPC_CXX0X_NO_CHRONO 1
#define GRPC_CXX0X_NO_THREAD 1
#endif
#endif // Visual Studio
#ifndef __clang__
#ifdef __GNUC__
// nullptr was added in gcc 4.6
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 406)
#define GRPC_CXX0X_NO_NULLPTR 1
#define GRPC_CXX0X_LIMITED_TOSTRING 1
#endif
// final and override were added in gcc 4.7
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 407)
#define GRPC_CXX0X_NO_FINAL 1
#define GRPC_CXX0X_NO_OVERRIDE 1
#endif
#endif
#endif
#endif
#ifdef GRPC_CXX0X_NO_FINAL
#define GRPC_FINAL
#else
#define GRPC_FINAL final
#endif
#ifdef GRPC_CXX0X_NO_OVERRIDE
#define GRPC_OVERRIDE
#else
#define GRPC_OVERRIDE override
#endif
#ifdef GRPC_CXX0X_NO_NULLPTR
#include <functional>
#include <memory>
namespace grpc {
const class {
public:
template <class T>
operator T *() const {
return static_cast<T *>(0);
}
template <class T>
operator std::unique_ptr<T>() const {
return std::unique_ptr<T>(static_cast<T *>(0));
}
template <class T>
operator std::shared_ptr<T>() const {
return std::shared_ptr<T>(static_cast<T *>(0));
}
operator bool() const { return false; }
template <class F>
operator std::function<F>() const {
return std::function<F>();
}
private:
void operator&() const = delete;
} nullptr = {};
}
#endif
#ifndef GRPC_CUSTOM_STRING #ifndef GRPC_CUSTOM_STRING
#include <string> #include <string>
#define GRPC_CUSTOM_STRING std::string #define GRPC_CUSTOM_STRING std::string
@ -117,16 +43,7 @@ namespace grpc {
typedef GRPC_CUSTOM_STRING string; typedef GRPC_CUSTOM_STRING string;
#ifdef GRPC_CXX0X_LIMITED_TOSTRING
inline grpc::string to_string(const int x) {
return std::to_string(static_cast<const long long int>(x));
}
inline grpc::string to_string(const unsigned int x) {
return std::to_string(static_cast<const long long unsigned int>(x));
}
#else
using std::to_string; using std::to_string;
#endif
} // namespace grpc } // namespace grpc

@ -45,56 +45,53 @@ namespace grpc {
/// Implementation of the core codegen interface. /// Implementation of the core codegen interface.
class CoreCodegen : public CoreCodegenInterface { class CoreCodegen : public CoreCodegenInterface {
private: private:
grpc_completion_queue* grpc_completion_queue_create(void* reserved) grpc_completion_queue* grpc_completion_queue_create(void* reserved) override;
GRPC_OVERRIDE; void grpc_completion_queue_destroy(grpc_completion_queue* cq) override;
void grpc_completion_queue_destroy(grpc_completion_queue* cq) GRPC_OVERRIDE;
grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
gpr_timespec deadline, gpr_timespec deadline,
void* reserved) GRPC_OVERRIDE; void* reserved) override;
void* gpr_malloc(size_t size) GRPC_OVERRIDE; void* gpr_malloc(size_t size) override;
void gpr_free(void* p) GRPC_OVERRIDE; void gpr_free(void* p) override;
void gpr_mu_init(gpr_mu* mu) GRPC_OVERRIDE; void gpr_mu_init(gpr_mu* mu) override;
void gpr_mu_destroy(gpr_mu* mu) GRPC_OVERRIDE; void gpr_mu_destroy(gpr_mu* mu) override;
void gpr_mu_lock(gpr_mu* mu) GRPC_OVERRIDE; void gpr_mu_lock(gpr_mu* mu) override;
void gpr_mu_unlock(gpr_mu* mu) GRPC_OVERRIDE; void gpr_mu_unlock(gpr_mu* mu) override;
void gpr_cv_init(gpr_cv* cv) GRPC_OVERRIDE; void gpr_cv_init(gpr_cv* cv) override;
void gpr_cv_destroy(gpr_cv* cv) GRPC_OVERRIDE; void gpr_cv_destroy(gpr_cv* cv) override;
int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) override;
gpr_timespec abs_deadline) GRPC_OVERRIDE; void gpr_cv_signal(gpr_cv* cv) override;
void gpr_cv_signal(gpr_cv* cv) GRPC_OVERRIDE; void gpr_cv_broadcast(gpr_cv* cv) override;
void gpr_cv_broadcast(gpr_cv* cv) GRPC_OVERRIDE;
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) GRPC_OVERRIDE; void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader, int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_byte_buffer* buffer) GRPC_OVERRIDE; grpc_byte_buffer* buffer) override;
void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader) void grpc_byte_buffer_reader_destroy(
GRPC_OVERRIDE; grpc_byte_buffer_reader* reader) override;
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
gpr_slice* slice) GRPC_OVERRIDE; gpr_slice* slice) override;
grpc_byte_buffer* grpc_raw_byte_buffer_create(gpr_slice* slice, grpc_byte_buffer* grpc_raw_byte_buffer_create(gpr_slice* slice,
size_t nslices) GRPC_OVERRIDE; size_t nslices) override;
gpr_slice gpr_slice_malloc(size_t length) GRPC_OVERRIDE; gpr_slice gpr_slice_malloc(size_t length) override;
void gpr_slice_unref(gpr_slice slice) GRPC_OVERRIDE; void gpr_slice_unref(gpr_slice slice) override;
gpr_slice gpr_slice_split_tail(gpr_slice* s, size_t split) GRPC_OVERRIDE; gpr_slice gpr_slice_split_tail(gpr_slice* s, size_t split) override;
void gpr_slice_buffer_add(gpr_slice_buffer* sb, void gpr_slice_buffer_add(gpr_slice_buffer* sb, gpr_slice slice) override;
gpr_slice slice) GRPC_OVERRIDE; void gpr_slice_buffer_pop(gpr_slice_buffer* sb) override;
void gpr_slice_buffer_pop(gpr_slice_buffer* sb) GRPC_OVERRIDE;
void grpc_metadata_array_init(grpc_metadata_array* array) GRPC_OVERRIDE; void grpc_metadata_array_init(grpc_metadata_array* array) override;
void grpc_metadata_array_destroy(grpc_metadata_array* array) GRPC_OVERRIDE; void grpc_metadata_array_destroy(grpc_metadata_array* array) override;
gpr_timespec gpr_inf_future(gpr_clock_type type) GRPC_OVERRIDE; gpr_timespec gpr_inf_future(gpr_clock_type type) override;
gpr_timespec gpr_time_0(gpr_clock_type type) GRPC_OVERRIDE; gpr_timespec gpr_time_0(gpr_clock_type type) override;
virtual const Status& ok() GRPC_OVERRIDE; virtual const Status& ok() override;
virtual const Status& cancelled() GRPC_OVERRIDE; virtual const Status& cancelled() override;
void assert_fail(const char* failed_assertion) GRPC_OVERRIDE; void assert_fail(const char* failed_assertion) override;
}; };
} // namespace grpc } // namespace grpc

@ -50,7 +50,7 @@ class RpcMethodHandler : public MethodHandler {
ServiceType* service) ServiceType* service)
: func_(func), service_(service) {} : func_(func), service_(service) {}
void RunHandler(const HandlerParameter& param) GRPC_FINAL { void RunHandler(const HandlerParameter& param) final {
RequestType req; RequestType req;
Status status = SerializationTraits<RequestType>::Deserialize( Status status = SerializationTraits<RequestType>::Deserialize(
param.request, &req, param.max_receive_message_size); param.request, &req, param.max_receive_message_size);
@ -96,7 +96,7 @@ class ClientStreamingHandler : public MethodHandler {
ServiceType* service) ServiceType* service)
: func_(func), service_(service) {} : func_(func), service_(service) {}
void RunHandler(const HandlerParameter& param) GRPC_FINAL { void RunHandler(const HandlerParameter& param) final {
ServerReader<RequestType> reader(param.call, param.server_context); ServerReader<RequestType> reader(param.call, param.server_context);
ResponseType rsp; ResponseType rsp;
Status status = func_(service_, param.server_context, &reader, &rsp); Status status = func_(service_, param.server_context, &reader, &rsp);
@ -136,7 +136,7 @@ class ServerStreamingHandler : public MethodHandler {
ServiceType* service) ServiceType* service)
: func_(func), service_(service) {} : func_(func), service_(service) {}
void RunHandler(const HandlerParameter& param) GRPC_FINAL { void RunHandler(const HandlerParameter& param) final {
RequestType req; RequestType req;
Status status = SerializationTraits<RequestType>::Deserialize( Status status = SerializationTraits<RequestType>::Deserialize(
param.request, &req, param.max_receive_message_size); param.request, &req, param.max_receive_message_size);
@ -180,7 +180,7 @@ class TemplatedBidiStreamingHandler : public MethodHandler {
std::function<Status(ServerContext*, Streamer*)> func) std::function<Status(ServerContext*, Streamer*)> func)
: func_(func), write_needed_(WriteNeeded) {} : func_(func), write_needed_(WriteNeeded) {}
void RunHandler(const HandlerParameter& param) GRPC_FINAL { void RunHandler(const HandlerParameter& param) final {
Streamer stream(param.call, param.server_context); Streamer stream(param.call, param.server_context);
Status status = func_(param.server_context, &stream); Status status = func_(param.server_context, &stream);
@ -266,7 +266,7 @@ class UnknownMethodHandler : public MethodHandler {
ops->ServerSendStatus(context->trailing_metadata_, status); ops->ServerSendStatus(context->trailing_metadata_, status);
} }
void RunHandler(const HandlerParameter& param) GRPC_FINAL { void RunHandler(const HandlerParameter& param) final {
CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops; CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops;
FillOps(param.server_context, &ops); FillOps(param.server_context, &ops);
param.call->PerformOps(&ops); param.call->PerformOps(&ops);

@ -52,7 +52,7 @@ namespace internal {
const int kGrpcBufferWriterMaxBufferLength = 8192; const int kGrpcBufferWriterMaxBufferLength = 8192;
class GrpcBufferWriter GRPC_FINAL class GrpcBufferWriter final
: public ::grpc::protobuf::io::ZeroCopyOutputStream { : 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)
@ -61,13 +61,13 @@ class GrpcBufferWriter GRPC_FINAL
slice_buffer_ = &(*bp)->data.raw.slice_buffer; slice_buffer_ = &(*bp)->data.raw.slice_buffer;
} }
~GrpcBufferWriter() GRPC_OVERRIDE { ~GrpcBufferWriter() override {
if (have_backup_) { if (have_backup_) {
g_core_codegen_interface->gpr_slice_unref(backup_slice_); g_core_codegen_interface->gpr_slice_unref(backup_slice_);
} }
} }
bool Next(void** data, int* size) GRPC_OVERRIDE { bool Next(void** data, int* size) override {
if (have_backup_) { if (have_backup_) {
slice_ = backup_slice_; slice_ = backup_slice_;
have_backup_ = false; have_backup_ = false;
@ -82,7 +82,7 @@ class GrpcBufferWriter GRPC_FINAL
return true; return true;
} }
void BackUp(int count) GRPC_OVERRIDE { void BackUp(int count) override {
g_core_codegen_interface->gpr_slice_buffer_pop(slice_buffer_); g_core_codegen_interface->gpr_slice_buffer_pop(slice_buffer_);
if (count == block_size_) { if (count == block_size_) {
backup_slice_ = slice_; backup_slice_ = slice_;
@ -95,7 +95,7 @@ class GrpcBufferWriter GRPC_FINAL
byte_count_ -= count; byte_count_ -= count;
} }
grpc::protobuf::int64 ByteCount() const GRPC_OVERRIDE { return byte_count_; } grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
private: private:
const int block_size_; const int block_size_;
@ -106,7 +106,7 @@ class GrpcBufferWriter GRPC_FINAL
gpr_slice slice_; gpr_slice slice_;
}; };
class GrpcBufferReader GRPC_FINAL class GrpcBufferReader final
: public ::grpc::protobuf::io::ZeroCopyInputStream { : public ::grpc::protobuf::io::ZeroCopyInputStream {
public: public:
explicit GrpcBufferReader(grpc_byte_buffer* buffer) explicit GrpcBufferReader(grpc_byte_buffer* buffer)
@ -117,11 +117,11 @@ class GrpcBufferReader GRPC_FINAL
"Couldn't initialize byte buffer reader"); "Couldn't initialize byte buffer reader");
} }
} }
~GrpcBufferReader() GRPC_OVERRIDE { ~GrpcBufferReader() override {
g_core_codegen_interface->grpc_byte_buffer_reader_destroy(&reader_); g_core_codegen_interface->grpc_byte_buffer_reader_destroy(&reader_);
} }
bool Next(const void** data, int* size) GRPC_OVERRIDE { bool Next(const void** data, int* size) override {
if (!status_.ok()) { if (!status_.ok()) {
return false; return false;
} }
@ -147,9 +147,9 @@ class GrpcBufferReader GRPC_FINAL
Status status() const { return status_; } Status status() const { return status_; }
void BackUp(int count) GRPC_OVERRIDE { backup_count_ = count; } void BackUp(int count) override { backup_count_ = count; }
bool Skip(int count) GRPC_OVERRIDE { bool Skip(int count) override {
const void* data; const void* data;
int size; int size;
while (Next(&data, &size)) { while (Next(&data, &size)) {
@ -164,7 +164,7 @@ class GrpcBufferReader GRPC_FINAL
return false; return false;
} }
grpc::protobuf::int64 ByteCount() const GRPC_OVERRIDE { grpc::protobuf::int64 ByteCount() const override {
return byte_count_ - backup_count_; return byte_count_ - backup_count_;
} }

@ -94,11 +94,9 @@ class ServerContext {
ServerContext(); // for async calls ServerContext(); // for async calls
~ServerContext(); ~ServerContext();
#ifndef GRPC_CXX0X_NO_CHRONO
std::chrono::system_clock::time_point deadline() const { std::chrono::system_clock::time_point deadline() const {
return Timespec2Timepoint(deadline_); return Timespec2Timepoint(deadline_);
} }
#endif // !GRPC_CXX0X_NO_CHRONO
gpr_timespec raw_deadline() const { return deadline_; } gpr_timespec raw_deadline() const { return deadline_; }

@ -142,7 +142,7 @@ class ServerInterface : public CallHook {
bool delete_on_finalize); bool delete_on_finalize);
virtual ~BaseAsyncRequest() {} virtual ~BaseAsyncRequest() {}
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; bool FinalizeResult(void** tag, bool* status) override;
protected: protected:
ServerInterface* const server_; ServerInterface* const server_;
@ -168,7 +168,7 @@ class ServerInterface : public CallHook {
ServerCompletionQueue* notification_cq); ServerCompletionQueue* notification_cq);
}; };
class NoPayloadAsyncRequest GRPC_FINAL : public RegisteredAsyncRequest { class NoPayloadAsyncRequest final : public RegisteredAsyncRequest {
public: public:
NoPayloadAsyncRequest(void* registered_method, ServerInterface* server, NoPayloadAsyncRequest(void* registered_method, ServerInterface* server,
ServerContext* context, ServerContext* context,
@ -183,7 +183,7 @@ class ServerInterface : public CallHook {
}; };
template <class Message> template <class Message>
class PayloadAsyncRequest GRPC_FINAL : public RegisteredAsyncRequest { class PayloadAsyncRequest final : public RegisteredAsyncRequest {
public: public:
PayloadAsyncRequest(void* registered_method, ServerInterface* server, PayloadAsyncRequest(void* registered_method, ServerInterface* server,
ServerContext* context, ServerContext* context,
@ -196,7 +196,7 @@ class ServerInterface : public CallHook {
IssueRequest(registered_method, &payload_, notification_cq); IssueRequest(registered_method, &payload_, notification_cq);
} }
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
bool serialization_status = bool serialization_status =
*status && payload_ && *status && payload_ &&
SerializationTraits<Message>::Deserialize( SerializationTraits<Message>::Deserialize(
@ -220,7 +220,7 @@ class ServerInterface : public CallHook {
ServerCompletionQueue* notification_cq, void* tag, ServerCompletionQueue* notification_cq, void* tag,
bool delete_on_finalize); bool delete_on_finalize);
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; bool FinalizeResult(void** tag, bool* status) override;
private: private:
grpc_call_details call_details_; grpc_call_details call_details_;

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

@ -1,111 +0,0 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPCXX_IMPL_CODEGEN_SYNC_NO_CXX11_H
#define GRPCXX_IMPL_CODEGEN_SYNC_NO_CXX11_H
#include <grpc++/impl/codegen/core_codegen_interface.h>
namespace grpc {
extern CoreCodegenInterface *g_core_codegen_interface;
template <class mutex>
class lock_guard;
class condition_variable;
class mutex {
public:
mutex() { g_core_codegen_interface->gpr_mu_init(&mu_); }
~mutex() { g_core_codegen_interface->gpr_mu_destroy(&mu_); }
private:
::gpr_mu mu_;
template <class mutex>
friend class lock_guard;
friend class condition_variable;
};
template <class mutex>
class lock_guard {
public:
lock_guard(mutex &mu) : mu_(mu), locked(true) {
g_core_codegen_interface->gpr_mu_lock(&mu.mu_);
}
~lock_guard() { unlock_internal(); }
protected:
void lock_internal() {
if (!locked) g_core_codegen_interface->gpr_mu_lock(&mu_.mu_);
locked = true;
}
void unlock_internal() {
if (locked) g_core_codegen_interface->gpr_mu_unlock(&mu_.mu_);
locked = false;
}
private:
mutex &mu_;
bool locked;
friend class condition_variable;
};
template <class mutex>
class unique_lock : public lock_guard<mutex> {
public:
unique_lock(mutex &mu) : lock_guard<mutex>(mu) {}
void lock() { this->lock_internal(); }
void unlock() { this->unlock_internal(); }
};
class condition_variable {
public:
condition_variable() { g_core_codegen_interface->gpr_cv_init(&cv_); }
~condition_variable() { g_core_codegen_interface->gpr_cv_destroy(&cv_); }
void wait(lock_guard<mutex> &mu) {
mu.locked = false;
g_core_codegen_interface->gpr_cv_wait(
&cv_, &mu.mu_.mu_,
g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME));
mu.locked = true;
}
void notify_one() { g_core_codegen_interface->gpr_cv_signal(&cv_); }
void notify_all() { g_core_codegen_interface->gpr_cv_broadcast(&cv_); }
private:
gpr_cv cv_;
};
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_SYNC_NO_CXX11_H

@ -131,7 +131,7 @@ class ClientReaderInterface : public ClientStreamingInterface,
}; };
template <class R> template <class R>
class ClientReader GRPC_FINAL : public ClientReaderInterface<R> { class ClientReader final : public ClientReaderInterface<R> {
public: public:
/// Blocking create a stream and write the first request out. /// Blocking create a stream and write the first request out.
template <class W> template <class W>
@ -150,7 +150,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> {
cq_.Pluck(&ops); cq_.Pluck(&ops);
} }
void WaitForInitialMetadata() GRPC_OVERRIDE { void WaitForInitialMetadata() override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
CallOpSet<CallOpRecvInitialMetadata> ops; CallOpSet<CallOpRecvInitialMetadata> ops;
@ -159,12 +159,12 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> {
cq_.Pluck(&ops); /// status ignored cq_.Pluck(&ops); /// status ignored
} }
bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { bool NextMessageSize(uint32_t* sz) override {
*sz = call_.max_receive_message_size(); *sz = call_.max_receive_message_size();
return true; return true;
} }
bool Read(R* msg) GRPC_OVERRIDE { bool Read(R* msg) override {
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops; CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops;
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
ops.RecvInitialMetadata(context_); ops.RecvInitialMetadata(context_);
@ -174,7 +174,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> {
return cq_.Pluck(&ops) && ops.got_message; return cq_.Pluck(&ops) && ops.got_message;
} }
Status Finish() GRPC_OVERRIDE { Status Finish() override {
CallOpSet<CallOpClientRecvStatus> ops; CallOpSet<CallOpClientRecvStatus> ops;
Status status; Status status;
ops.ClientRecvStatus(context_, &status); ops.ClientRecvStatus(context_, &status);
@ -230,7 +230,7 @@ class ClientWriter : public ClientWriterInterface<W> {
} }
using WriterInterface<W>::Write; using WriterInterface<W>::Write;
bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { bool Write(const W& msg, const WriteOptions& options) override {
CallOpSet<CallOpSendMessage> ops; CallOpSet<CallOpSendMessage> ops;
if (!ops.SendMessage(msg, options).ok()) { if (!ops.SendMessage(msg, options).ok()) {
return false; return false;
@ -239,7 +239,7 @@ class ClientWriter : public ClientWriterInterface<W> {
return cq_.Pluck(&ops); return cq_.Pluck(&ops);
} }
bool WritesDone() GRPC_OVERRIDE { bool WritesDone() override {
CallOpSet<CallOpClientSendClose> ops; CallOpSet<CallOpClientSendClose> ops;
ops.ClientSendClose(); ops.ClientSendClose();
call_.PerformOps(&ops); call_.PerformOps(&ops);
@ -247,7 +247,7 @@ class ClientWriter : public ClientWriterInterface<W> {
} }
/// Read the final response and wait for the final status. /// Read the final response and wait for the final status.
Status Finish() GRPC_OVERRIDE { Status Finish() override {
Status status; Status status;
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -287,7 +287,7 @@ class ClientReaderWriterInterface : public ClientStreamingInterface,
}; };
template <class W, class R> template <class W, class R>
class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> { class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
public: public:
/// Blocking create a stream. /// Blocking create a stream.
ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method,
@ -300,7 +300,7 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> {
cq_.Pluck(&ops); cq_.Pluck(&ops);
} }
void WaitForInitialMetadata() GRPC_OVERRIDE { void WaitForInitialMetadata() override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
CallOpSet<CallOpRecvInitialMetadata> ops; CallOpSet<CallOpRecvInitialMetadata> ops;
@ -309,12 +309,12 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> {
cq_.Pluck(&ops); // status ignored cq_.Pluck(&ops); // status ignored
} }
bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { bool NextMessageSize(uint32_t* sz) override {
*sz = call_.max_receive_message_size(); *sz = call_.max_receive_message_size();
return true; return true;
} }
bool Read(R* msg) GRPC_OVERRIDE { bool Read(R* msg) override {
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops; CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops;
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
ops.RecvInitialMetadata(context_); ops.RecvInitialMetadata(context_);
@ -325,21 +325,21 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> {
} }
using WriterInterface<W>::Write; using WriterInterface<W>::Write;
bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { bool Write(const W& msg, const WriteOptions& options) override {
CallOpSet<CallOpSendMessage> ops; CallOpSet<CallOpSendMessage> ops;
if (!ops.SendMessage(msg, options).ok()) return false; if (!ops.SendMessage(msg, options).ok()) return false;
call_.PerformOps(&ops); call_.PerformOps(&ops);
return cq_.Pluck(&ops); return cq_.Pluck(&ops);
} }
bool WritesDone() GRPC_OVERRIDE { bool WritesDone() override {
CallOpSet<CallOpClientSendClose> ops; CallOpSet<CallOpClientSendClose> ops;
ops.ClientSendClose(); ops.ClientSendClose();
call_.PerformOps(&ops); call_.PerformOps(&ops);
return cq_.Pluck(&ops); return cq_.Pluck(&ops);
} }
Status Finish() GRPC_OVERRIDE { Status Finish() override {
CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> ops; CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> ops;
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
ops.RecvInitialMetadata(context_); ops.RecvInitialMetadata(context_);
@ -363,11 +363,11 @@ class ServerReaderInterface : public ServerStreamingInterface,
public ReaderInterface<R> {}; public ReaderInterface<R> {};
template <class R> template <class R>
class ServerReader GRPC_FINAL : public ServerReaderInterface<R> { class ServerReader final : public ServerReaderInterface<R> {
public: public:
ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
void SendInitialMetadata() GRPC_OVERRIDE { void SendInitialMetadata() override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata> ops; CallOpSet<CallOpSendInitialMetadata> ops;
@ -381,12 +381,12 @@ class ServerReader GRPC_FINAL : public ServerReaderInterface<R> {
call_->cq()->Pluck(&ops); call_->cq()->Pluck(&ops);
} }
bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { bool NextMessageSize(uint32_t* sz) override {
*sz = call_->max_receive_message_size(); *sz = call_->max_receive_message_size();
return true; return true;
} }
bool Read(R* msg) GRPC_OVERRIDE { bool Read(R* msg) override {
CallOpSet<CallOpRecvMessage<R>> ops; CallOpSet<CallOpRecvMessage<R>> ops;
ops.RecvMessage(msg); ops.RecvMessage(msg);
call_->PerformOps(&ops); call_->PerformOps(&ops);
@ -404,11 +404,11 @@ class ServerWriterInterface : public ServerStreamingInterface,
public WriterInterface<W> {}; public WriterInterface<W> {};
template <class W> template <class W>
class ServerWriter GRPC_FINAL : public ServerWriterInterface<W> { class ServerWriter final : public ServerWriterInterface<W> {
public: public:
ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
void SendInitialMetadata() GRPC_OVERRIDE { void SendInitialMetadata() override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata> ops; CallOpSet<CallOpSendInitialMetadata> ops;
@ -423,7 +423,7 @@ class ServerWriter GRPC_FINAL : public ServerWriterInterface<W> {
} }
using WriterInterface<W>::Write; using WriterInterface<W>::Write;
bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { bool Write(const W& msg, const WriteOptions& options) override {
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> ops; CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> ops;
if (!ops.SendMessage(msg, options).ok()) { if (!ops.SendMessage(msg, options).ok()) {
return false; return false;
@ -454,7 +454,7 @@ class ServerReaderWriterInterface : public ServerStreamingInterface,
// Actual implementation of bi-directional streaming // Actual implementation of bi-directional streaming
namespace internal { namespace internal {
template <class W, class R> template <class W, class R>
class ServerReaderWriterBody GRPC_FINAL { class ServerReaderWriterBody final {
public: public:
ServerReaderWriterBody(Call* call, ServerContext* ctx) ServerReaderWriterBody(Call* call, ServerContext* ctx)
: call_(call), ctx_(ctx) {} : call_(call), ctx_(ctx) {}
@ -510,20 +510,20 @@ class ServerReaderWriterBody GRPC_FINAL {
// class to represent the user API for a bidirectional streaming call // class to represent the user API for a bidirectional streaming call
template <class W, class R> template <class W, class R>
class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface<W, R> { class ServerReaderWriter final : public ServerReaderWriterInterface<W, R> {
public: public:
ServerReaderWriter(Call* call, ServerContext* ctx) : body_(call, ctx) {} ServerReaderWriter(Call* call, ServerContext* ctx) : body_(call, ctx) {}
void SendInitialMetadata() GRPC_OVERRIDE { body_.SendInitialMetadata(); } void SendInitialMetadata() override { body_.SendInitialMetadata(); }
bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { bool NextMessageSize(uint32_t* sz) override {
return body_.NextMessageSize(sz); return body_.NextMessageSize(sz);
} }
bool Read(R* msg) GRPC_OVERRIDE { return body_.Read(msg); } bool Read(R* msg) override { return body_.Read(msg); }
using WriterInterface<W>::Write; using WriterInterface<W>::Write;
bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { bool Write(const W& msg, const WriteOptions& options) override {
return body_.Write(msg, options); return body_.Write(msg, options);
} }
@ -541,19 +541,19 @@ class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface<W, R> {
/// must have exactly 1 Read and exactly 1 Write, in that order, to function /// must have exactly 1 Read and exactly 1 Write, in that order, to function
/// correctly. Otherwise, the RPC is in error. /// correctly. Otherwise, the RPC is in error.
template <class RequestType, class ResponseType> template <class RequestType, class ResponseType>
class ServerUnaryStreamer GRPC_FINAL class ServerUnaryStreamer final
: public ServerReaderWriterInterface<ResponseType, RequestType> { : public ServerReaderWriterInterface<ResponseType, RequestType> {
public: public:
ServerUnaryStreamer(Call* call, ServerContext* ctx) ServerUnaryStreamer(Call* call, ServerContext* ctx)
: body_(call, ctx), read_done_(false), write_done_(false) {} : body_(call, ctx), read_done_(false), write_done_(false) {}
void SendInitialMetadata() GRPC_OVERRIDE { body_.SendInitialMetadata(); } void SendInitialMetadata() override { body_.SendInitialMetadata(); }
bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { bool NextMessageSize(uint32_t* sz) override {
return body_.NextMessageSize(sz); return body_.NextMessageSize(sz);
} }
bool Read(RequestType* request) GRPC_OVERRIDE { bool Read(RequestType* request) override {
if (read_done_) { if (read_done_) {
return false; return false;
} }
@ -563,7 +563,7 @@ class ServerUnaryStreamer GRPC_FINAL
using WriterInterface<ResponseType>::Write; using WriterInterface<ResponseType>::Write;
bool Write(const ResponseType& response, bool Write(const ResponseType& response,
const WriteOptions& options) GRPC_OVERRIDE { const WriteOptions& options) override {
if (write_done_ || !read_done_) { if (write_done_ || !read_done_) {
return false; return false;
} }
@ -583,19 +583,19 @@ class ServerUnaryStreamer GRPC_FINAL
/// but the server responds to it as though it were a bidi streaming call that /// but the server responds to it as though it were a bidi streaming call that
/// must first have exactly 1 Read and then any number of Writes. /// must first have exactly 1 Read and then any number of Writes.
template <class RequestType, class ResponseType> template <class RequestType, class ResponseType>
class ServerSplitStreamer GRPC_FINAL class ServerSplitStreamer final
: public ServerReaderWriterInterface<ResponseType, RequestType> { : public ServerReaderWriterInterface<ResponseType, RequestType> {
public: public:
ServerSplitStreamer(Call* call, ServerContext* ctx) ServerSplitStreamer(Call* call, ServerContext* ctx)
: body_(call, ctx), read_done_(false) {} : body_(call, ctx), read_done_(false) {}
void SendInitialMetadata() GRPC_OVERRIDE { body_.SendInitialMetadata(); } void SendInitialMetadata() override { body_.SendInitialMetadata(); }
bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { bool NextMessageSize(uint32_t* sz) override {
return body_.NextMessageSize(sz); return body_.NextMessageSize(sz);
} }
bool Read(RequestType* request) GRPC_OVERRIDE { bool Read(RequestType* request) override {
if (read_done_) { if (read_done_) {
return false; return false;
} }
@ -605,7 +605,7 @@ class ServerSplitStreamer GRPC_FINAL
using WriterInterface<ResponseType>::Write; using WriterInterface<ResponseType>::Write;
bool Write(const ResponseType& response, bool Write(const ResponseType& response,
const WriteOptions& options) GRPC_OVERRIDE { const WriteOptions& options) override {
return read_done_ && body_.Write(response, options); return read_done_ && body_.Write(response, options);
} }

@ -75,8 +75,6 @@ class TimePoint<gpr_timespec> {
} // namespace grpc } // namespace grpc
#ifndef GRPC_CXX0X_NO_CHRONO
#include <chrono> #include <chrono>
#include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/grpc_types.h>
@ -106,6 +104,4 @@ class TimePoint<std::chrono::system_clock::time_point> {
} // namespace grpc } // namespace grpc
#endif // !GRPC_CXX0X_NO_CHRONO
#endif // GRPCXX_IMPL_CODEGEN_TIME_H #endif // GRPCXX_IMPL_CODEGEN_TIME_H

@ -44,17 +44,17 @@
namespace grpc { namespace grpc {
namespace internal { namespace internal {
class GrpcLibrary GRPC_FINAL : public GrpcLibraryInterface { class GrpcLibrary final : public GrpcLibraryInterface {
public: public:
void init() GRPC_OVERRIDE { grpc_init(); } void init() override { grpc_init(); }
void shutdown() GRPC_OVERRIDE { grpc_shutdown(); } void shutdown() override { grpc_shutdown(); }
}; };
static GrpcLibrary g_gli; static GrpcLibrary g_gli;
static CoreCodegen g_core_codegen; static CoreCodegen g_core_codegen;
/// Instantiating this class ensures the proper initialization of gRPC. /// Instantiating this class ensures the proper initialization of gRPC.
class GrpcLibraryInitializer GRPC_FINAL { class GrpcLibraryInitializer final {
public: public:
GrpcLibraryInitializer() { GrpcLibraryInitializer() {
if (grpc::g_glip == nullptr) { if (grpc::g_glip == nullptr) {

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

@ -1,117 +0,0 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPCXX_IMPL_THD_NO_CXX11_H
#define GRPCXX_IMPL_THD_NO_CXX11_H
#include <grpc/support/thd.h>
namespace grpc {
class thread {
public:
template <class T>
thread(void (T::*fptr)(), T *obj) {
func_ = new thread_function<T>(fptr, obj);
joined_ = false;
start();
}
template <class T, class U>
thread(void (T::*fptr)(U arg), T *obj, U arg) {
func_ = new thread_function_arg<T, U>(fptr, obj, arg);
joined_ = false;
start();
}
~thread() {
if (!joined_) std::terminate();
delete func_;
}
thread(thread &&other)
: func_(other.func_), thd_(other.thd_), joined_(other.joined_) {
other.joined_ = true;
other.func_ = NULL;
}
void join() {
gpr_thd_join(thd_);
joined_ = true;
}
private:
void start() {
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
gpr_thd_new(&thd_, thread_func, (void *)func_, &options);
}
static void thread_func(void *arg) {
thread_function_base *func = (thread_function_base *)arg;
func->call();
}
class thread_function_base {
public:
virtual ~thread_function_base() {}
virtual void call() = 0;
};
template <class T>
class thread_function : public thread_function_base {
public:
thread_function(void (T::*fptr)(), T *obj) : fptr_(fptr), obj_(obj) {}
virtual void call() { (obj_->*fptr_)(); }
private:
void (T::*fptr_)();
T *obj_;
};
template <class T, class U>
class thread_function_arg : public thread_function_base {
public:
thread_function_arg(void (T::*fptr)(U arg), T *obj, U arg)
: fptr_(fptr), obj_(obj), arg_(arg) {}
virtual void call() { (obj_->*fptr_)(arg_); }
private:
void (T::*fptr_)(U arg);
T *obj_;
U arg_;
};
thread_function_base *func_;
gpr_thd_id thd_;
bool joined_;
// Disallow copy and assign.
thread(const thread &);
void operator=(const thread &);
};
} // namespace grpc
#endif // GRPCXX_IMPL_THD_NO_CXX11_H

@ -44,7 +44,7 @@ namespace grpc {
/// A ResourceQuota can be attached to a server (via ServerBuilder), or a client /// A ResourceQuota can be attached to a server (via ServerBuilder), or a client
/// channel (via ChannelArguments). gRPC will attempt to keep memory used by /// channel (via ChannelArguments). gRPC will attempt to keep memory used by
/// all attached entities below the ResourceQuota bound. /// all attached entities below the ResourceQuota bound.
class ResourceQuota GRPC_FINAL { class ResourceQuota final {
public: public:
explicit ResourceQuota(const grpc::string& name); explicit ResourceQuota(const grpc::string& name);
ResourceQuota(); ResourceQuota();

@ -34,8 +34,10 @@
#ifndef GRPCXX_SERVER_H #ifndef GRPCXX_SERVER_H
#define GRPCXX_SERVER_H #define GRPCXX_SERVER_H
#include <condition_variable>
#include <list> #include <list>
#include <memory> #include <memory>
#include <mutex>
#include <vector> #include <vector>
#include <grpc++/completion_queue.h> #include <grpc++/completion_queue.h>
@ -43,7 +45,6 @@
#include <grpc++/impl/codegen/grpc_library.h> #include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/server_interface.h> #include <grpc++/impl/codegen/server_interface.h>
#include <grpc++/impl/rpc_service_method.h> #include <grpc++/impl/rpc_service_method.h>
#include <grpc++/impl/sync.h>
#include <grpc++/security/server_credentials.h> #include <grpc++/security/server_credentials.h>
#include <grpc++/support/channel_arguments.h> #include <grpc++/support/channel_arguments.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
@ -64,7 +65,7 @@ class ThreadPoolInterface;
/// Models a gRPC server. /// Models a gRPC server.
/// ///
/// Servers are configured and started via \a grpc::ServerBuilder. /// Servers are configured and started via \a grpc::ServerBuilder.
class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen { class Server final : public ServerInterface, private GrpcLibraryCodegen {
public: public:
~Server(); ~Server();
@ -72,7 +73,7 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen {
/// ///
/// \warning The server must be either shutting down or some other thread must /// \warning The server must be either shutting down or some other thread must
/// call \a Shutdown for this function to ever return. /// call \a Shutdown for this function to ever return.
void Wait() GRPC_OVERRIDE; void Wait() override;
/// Global Callbacks /// Global Callbacks
/// ///
@ -143,12 +144,11 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen {
/// Register a service. This call does not take ownership of the service. /// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the Server instance. /// The service must exist for the lifetime of the Server instance.
bool RegisterService(const grpc::string* host, bool RegisterService(const grpc::string* host, Service* service) override;
Service* service) GRPC_OVERRIDE;
/// Register a generic service. This call does not take ownership of the /// Register a generic service. This call does not take ownership of the
/// service. The service must exist for the lifetime of the Server instance. /// service. The service must exist for the lifetime of the Server instance.
void RegisterAsyncGenericService(AsyncGenericService* service) GRPC_OVERRIDE; void RegisterAsyncGenericService(AsyncGenericService* service) override;
/// Tries to bind \a server to the given \a addr. /// Tries to bind \a server to the given \a addr.
/// ///
@ -162,7 +162,7 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen {
/// ///
/// \warning It's an error to call this method on an already started server. /// \warning It's an error to call this method on an already started server.
int AddListeningPort(const grpc::string& addr, int AddListeningPort(const grpc::string& addr,
ServerCredentials* creds) GRPC_OVERRIDE; ServerCredentials* creds) override;
/// Start the server. /// Start the server.
/// ///
@ -172,17 +172,17 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen {
/// \param num_cqs How many completion queues does \a cqs hold. /// \param num_cqs How many completion queues does \a cqs hold.
/// ///
/// \return true on a successful shutdown. /// \return true on a successful shutdown.
bool Start(ServerCompletionQueue** cqs, size_t num_cqs) GRPC_OVERRIDE; bool Start(ServerCompletionQueue** cqs, size_t num_cqs) override;
void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE; void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override;
void ShutdownInternal(gpr_timespec deadline) GRPC_OVERRIDE; void ShutdownInternal(gpr_timespec deadline) override;
int max_receive_message_size() const GRPC_OVERRIDE { int max_receive_message_size() const override {
return max_receive_message_size_; return max_receive_message_size_;
}; };
grpc_server* server() GRPC_OVERRIDE { return server_; }; grpc_server* server() override { return server_; };
ServerInitializer* initializer(); ServerInitializer* initializer();
@ -198,12 +198,12 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen {
std::vector<std::unique_ptr<SyncRequestThreadManager>> sync_req_mgrs_; std::vector<std::unique_ptr<SyncRequestThreadManager>> sync_req_mgrs_;
// Sever status // Sever status
grpc::mutex mu_; std::mutex mu_;
bool started_; bool started_;
bool shutdown_; bool shutdown_;
bool shutdown_notified_; // Was notify called on the shutdown_cv_ bool shutdown_notified_; // Was notify called on the shutdown_cv_
grpc::condition_variable shutdown_cv_; std::condition_variable shutdown_cv_;
std::shared_ptr<GlobalCallbacks> global_callbacks_; std::shared_ptr<GlobalCallbacks> global_callbacks_;

@ -47,7 +47,7 @@
namespace grpc { namespace grpc {
/// A sequence of bytes. /// A sequence of bytes.
class ByteBuffer GRPC_FINAL { class ByteBuffer final {
public: public:
/// Constuct an empty buffer. /// Constuct an empty buffer.
ByteBuffer() : buffer_(nullptr) {} ByteBuffer() : buffer_(nullptr) {}

@ -85,6 +85,11 @@ class ChannelArguments {
/// The given buffer pool will be attached to the constructed channel /// The given buffer pool will be attached to the constructed channel
void SetResourceQuota(const ResourceQuota& resource_quota); void SetResourceQuota(const ResourceQuota& resource_quota);
/// Set LB policy name.
/// Note that if the name resolver returns only balancer addresses, the
/// grpclb LB policy will be used, regardless of what is specified here.
void SetLoadBalancingPolicyName(const grpc::string& lb_policy_name);
// Generic channel argument setters. Only for advanced use cases. // Generic channel argument setters. Only for advanced use cases.
/// Set an integer argument \a value under \a key. /// Set an integer argument \a value under \a key.
void SetInt(const grpc::string& key, int value); void SetInt(const grpc::string& key, int value);

@ -44,7 +44,7 @@ namespace grpc {
/// A slice represents a contiguous reference counted array of bytes. /// A slice represents a contiguous reference counted array of bytes.
/// It is cheap to take references to a slice, and it is cheap to create a /// It is cheap to take references to a slice, and it is cheap to create a
/// slice pointing to a subset of another slice. /// slice pointing to a subset of another slice.
class Slice GRPC_FINAL { class Slice final {
public: public:
/// Construct an empty slice. /// Construct an empty slice.
Slice(); Slice();

@ -266,6 +266,7 @@
<file baseinstalldir="/" name="src/core/lib/transport/metadata.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/method_config.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/method_config.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/pid_controller.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/static_metadata.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/static_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/transport.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/transport.h" role="src" />
@ -454,6 +455,7 @@
<file baseinstalldir="/" name="src/core/lib/transport/metadata.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/metadata.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/method_config.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/method_config.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/pid_controller.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/static_metadata.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/static_metadata.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/transport.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/transport/transport.c" role="src" />

@ -52,6 +52,7 @@ PYTHON_STEM = os.path.join('src', 'python', 'grpcio')
CORE_INCLUDE = ('include', '.',) CORE_INCLUDE = ('include', '.',)
BORINGSSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),) BORINGSSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),)
ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),) ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),)
README = os.path.join(PYTHON_STEM, 'README.rst')
# Ensure we're in the proper directory whether or not we're being used by pip. # Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__))) os.chdir(os.path.dirname(os.path.abspath(__file__)))
@ -259,6 +260,7 @@ setuptools.setup(
name='grpcio', name='grpcio',
version=grpc_version.VERSION, version=grpc_version.VERSION,
license=LICENSE, license=LICENSE,
long_description=open(README).read(),
ext_modules=CYTHON_EXTENSION_MODULES, ext_modules=CYTHON_EXTENSION_MODULES,
packages=list(PACKAGES), packages=list(PACKAGES),
package_dir=PACKAGE_DIRECTORIES, package_dir=PACKAGE_DIRECTORIES,

@ -322,7 +322,7 @@ void PrintHeaderClientMethod(Printer *printer, const Method *method,
printer->Print( printer->Print(
*vars, *vars,
"::grpc::Status $Method$(::grpc::ClientContext* context, " "::grpc::Status $Method$(::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response) GRPC_OVERRIDE;\n"); "const $Request$& request, $Response$* response) override;\n");
printer->Print( printer->Print(
*vars, *vars,
"std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> " "std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> "
@ -417,37 +417,34 @@ void PrintHeaderClientMethod(Printer *printer, const Method *method,
"::grpc::ClientAsyncResponseReader< $Response$>* " "::grpc::ClientAsyncResponseReader< $Response$>* "
"Async$Method$Raw(::grpc::ClientContext* context, " "Async$Method$Raw(::grpc::ClientContext* context, "
"const $Request$& request, " "const $Request$& request, "
"::grpc::CompletionQueue* cq) GRPC_OVERRIDE;\n"); "::grpc::CompletionQueue* cq) override;\n");
} else if (method->ClientOnlyStreaming()) { } else if (method->ClientOnlyStreaming()) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* $Method$Raw(" "::grpc::ClientWriter< $Request$>* $Method$Raw("
"::grpc::ClientContext* context, $Response$* response) " "::grpc::ClientContext* context, $Response$* response) "
"GRPC_OVERRIDE;\n"); "override;\n");
printer->Print( printer->Print(*vars,
*vars,
"::grpc::ClientAsyncWriter< $Request$>* Async$Method$Raw(" "::grpc::ClientAsyncWriter< $Request$>* Async$Method$Raw("
"::grpc::ClientContext* context, $Response$* response, " "::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n"); "::grpc::CompletionQueue* cq, void* tag) override;\n");
} else if (method->ServerOnlyStreaming()) { } else if (method->ServerOnlyStreaming()) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::ClientReader< $Response$>* $Method$Raw(" "::grpc::ClientReader< $Response$>* $Method$Raw("
"::grpc::ClientContext* context, const $Request$& request)" "::grpc::ClientContext* context, const $Request$& request)"
" GRPC_OVERRIDE;\n"); " override;\n");
printer->Print( printer->Print(
*vars, *vars,
"::grpc::ClientAsyncReader< $Response$>* Async$Method$Raw(" "::grpc::ClientAsyncReader< $Response$>* Async$Method$Raw("
"::grpc::ClientContext* context, const $Request$& request, " "::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n"); "::grpc::CompletionQueue* cq, void* tag) override;\n");
} else if (method->BidiStreaming()) { } else if (method->BidiStreaming()) {
printer->Print( printer->Print(*vars,
*vars,
"::grpc::ClientReaderWriter< $Request$, $Response$>* " "::grpc::ClientReaderWriter< $Request$, $Response$>* "
"$Method$Raw(::grpc::ClientContext* context) GRPC_OVERRIDE;\n"); "$Method$Raw(::grpc::ClientContext* context) override;\n");
printer->Print( printer->Print(*vars,
*vars,
"::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* "
"Async$Method$Raw(::grpc::ClientContext* context, " "Async$Method$Raw(::grpc::ClientContext* context, "
"::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n"); "::grpc::CompletionQueue* cq, void* tag) override;\n");
} }
} }
} }
@ -509,7 +506,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method,
" ::grpc::Service::MarkMethodAsync($Idx$);\n" " ::grpc::Service::MarkMethodAsync($Idx$);\n"
"}\n"); "}\n");
printer->Print(*vars, printer->Print(*vars,
"~WithAsyncMethod_$Method$() GRPC_OVERRIDE {\n" "~WithAsyncMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n" " BaseClassMustBeDerivedFromService(this);\n"
"}\n"); "}\n");
if (method->NoStreaming()) { if (method->NoStreaming()) {
@ -518,7 +515,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method,
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" "$Response$* response) final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -540,7 +537,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method,
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
"::grpc::ServerReader< $Request$>* reader, " "::grpc::ServerReader< $Request$>* reader, "
"$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" "$Response$* response) final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -561,7 +558,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method,
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer) GRPC_FINAL GRPC_OVERRIDE " "::grpc::ServerWriter< $Response$>* writer) final override "
"{\n" "{\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
@ -585,7 +582,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method,
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
"::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) "
"GRPC_FINAL GRPC_OVERRIDE {\n" "final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -632,7 +629,7 @@ void PrintHeaderServerMethodStreamedUnary(
"std::placeholders::_2)));\n" "std::placeholders::_2)));\n"
"}\n"); "}\n");
printer->Print(*vars, printer->Print(*vars,
"~WithStreamedUnaryMethod_$Method$() GRPC_OVERRIDE {\n" "~WithStreamedUnaryMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n" " BaseClassMustBeDerivedFromService(this);\n"
"}\n"); "}\n");
printer->Print( printer->Print(
@ -640,7 +637,7 @@ void PrintHeaderServerMethodStreamedUnary(
"// disable regular version of this method\n" "// disable regular version of this method\n"
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" "$Response$* response) final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -683,7 +680,7 @@ void PrintHeaderServerMethodSplitStreaming(
"std::placeholders::_2)));\n" "std::placeholders::_2)));\n"
"}\n"); "}\n");
printer->Print(*vars, printer->Print(*vars,
"~WithSplitStreamingMethod_$Method$() GRPC_OVERRIDE {\n" "~WithSplitStreamingMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n" " BaseClassMustBeDerivedFromService(this);\n"
"}\n"); "}\n");
printer->Print( printer->Print(
@ -691,7 +688,7 @@ void PrintHeaderServerMethodSplitStreaming(
"// disable regular version of this method\n" "// disable regular version of this method\n"
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer) GRPC_FINAL GRPC_OVERRIDE " "::grpc::ServerWriter< $Response$>* writer) final override "
"{\n" "{\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
@ -727,7 +724,7 @@ void PrintHeaderServerMethodGeneric(
" ::grpc::Service::MarkMethodGeneric($Idx$);\n" " ::grpc::Service::MarkMethodGeneric($Idx$);\n"
"}\n"); "}\n");
printer->Print(*vars, printer->Print(*vars,
"~WithGenericMethod_$Method$() GRPC_OVERRIDE {\n" "~WithGenericMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n" " BaseClassMustBeDerivedFromService(this);\n"
"}\n"); "}\n");
if (method->NoStreaming()) { if (method->NoStreaming()) {
@ -736,7 +733,7 @@ void PrintHeaderServerMethodGeneric(
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" "$Response$* response) final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -747,7 +744,7 @@ void PrintHeaderServerMethodGeneric(
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
"::grpc::ServerReader< $Request$>* reader, " "::grpc::ServerReader< $Request$>* reader, "
"$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" "$Response$* response) final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -757,7 +754,7 @@ void PrintHeaderServerMethodGeneric(
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer) GRPC_FINAL GRPC_OVERRIDE " "::grpc::ServerWriter< $Response$>* writer) final override "
"{\n" "{\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
@ -769,7 +766,7 @@ void PrintHeaderServerMethodGeneric(
"::grpc::Status $Method$(" "::grpc::Status $Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
"::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) "
"GRPC_FINAL GRPC_OVERRIDE {\n" "final override {\n"
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
@ -784,7 +781,7 @@ void PrintHeaderService(Printer *printer, const Service *service,
printer->Print(service->GetLeadingComments().c_str()); printer->Print(service->GetLeadingComments().c_str());
printer->Print(*vars, printer->Print(*vars,
"class $Service$ GRPC_FINAL {\n" "class $Service$ final {\n"
" public:\n"); " public:\n");
printer->Indent(); printer->Indent();
@ -810,7 +807,7 @@ void PrintHeaderService(Printer *printer, const Service *service,
printer->Outdent(); printer->Outdent();
printer->Print("};\n"); printer->Print("};\n");
printer->Print( printer->Print(
"class Stub GRPC_FINAL : public StubInterface" "class Stub final : public StubInterface"
" {\n public:\n"); " {\n public:\n");
printer->Indent(); printer->Indent();
printer->Print( printer->Print(

@ -35,6 +35,8 @@
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
#include <cstring> #include <cstring>
#include <fstream>
#include <iostream>
#include <map> #include <map>
#include <memory> #include <memory>
#include <ostream> #include <ostream>
@ -66,66 +68,11 @@ using std::vector;
namespace grpc_python_generator { namespace grpc_python_generator {
GeneratorConfiguration::GeneratorConfiguration()
: grpc_package_root("grpc"), beta_package_root("grpc.beta") {}
PythonGrpcGenerator::PythonGrpcGenerator(const GeneratorConfiguration& config)
: config_(config) {}
PythonGrpcGenerator::~PythonGrpcGenerator() {}
bool PythonGrpcGenerator::Generate(const FileDescriptor* file,
const grpc::string& parameter,
GeneratorContext* context,
grpc::string* error) const {
// Get output file name.
grpc::string file_name;
static const int proto_suffix_length = strlen(".proto");
if (file->name().size() > static_cast<size_t>(proto_suffix_length) &&
file->name().find_last_of(".proto") == file->name().size() - 1) {
file_name =
file->name().substr(0, file->name().size() - proto_suffix_length) +
"_pb2.py";
} else {
*error = "Invalid proto file name. Proto file must end with .proto";
return false;
}
std::unique_ptr<ZeroCopyOutputStream> output(
context->OpenForInsert(file_name, "module_scope"));
CodedOutputStream coded_out(output.get());
bool success = false;
grpc::string code = "";
tie(success, code) = grpc_python_generator::GetServices(file, config_);
if (success) {
coded_out.WriteRaw(code.data(), code.size());
return true;
} else {
return false;
}
}
namespace { namespace {
//////////////////////////////////
// BEGIN FORMATTING BOILERPLATE // typedef vector<const Descriptor*> DescriptorVector;
////////////////////////////////// typedef map<grpc::string, grpc::string> StringMap;
typedef vector<grpc::string> StringVector;
// Converts an initializer list of the form { key0, value0, key1, value1, ... }
// into a map of key* to value*. Is merely a readability helper for later code.
map<grpc::string, grpc::string> ListToDict(
const initializer_list<grpc::string>& values) {
assert(values.size() % 2 == 0);
map<grpc::string, grpc::string> value_map;
auto value_iter = values.begin();
for (unsigned i = 0; i < values.size() / 2; ++i) {
grpc::string key = *value_iter;
++value_iter;
grpc::string value = *value_iter;
value_map[key] = value;
++value_iter;
}
return value_map;
}
// Provides RAII indentation handling. Use as: // Provides RAII indentation handling. Use as:
// { // {
@ -146,10 +93,6 @@ class IndentScope {
Printer* printer_; Printer* printer_;
}; };
////////////////////////////////
// END FORMATTING BOILERPLATE //
////////////////////////////////
// TODO(https://github.com/google/protobuf/issues/888): // TODO(https://github.com/google/protobuf/issues/888):
// Export `ModuleName` from protobuf's // Export `ModuleName` from protobuf's
// `src/google/protobuf/compiler/python/python_generator.cc` file. // `src/google/protobuf/compiler/python/python_generator.cc` file.
@ -173,11 +116,61 @@ grpc::string ModuleAlias(const grpc::string& filename) {
return module_name; return module_name;
} }
bool GetModuleAndMessagePath(const Descriptor* type, // Tucks all generator state in an anonymous namespace away from
const ServiceDescriptor* service, // PythonGrpcGenerator and the header file, mostly to encourage future changes
// to not require updates to the grpcio-tools C++ code part. Assumes that it is
// only ever used from a single thread.
struct PrivateGenerator {
const GeneratorConfiguration& config;
const FileDescriptor* file;
bool generate_in_pb2_grpc;
Printer* out;
PrivateGenerator(const GeneratorConfiguration& config,
const FileDescriptor* file);
std::pair<bool, grpc::string> GetGrpcServices();
private:
bool PrintPreamble();
bool PrintBetaPreamble();
bool PrintGAServices();
bool PrintBetaServices();
bool PrintAddServicerToServer(
const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service);
bool PrintServicer(const ServiceDescriptor* service);
bool PrintStub(const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service);
bool PrintBetaServicer(const ServiceDescriptor* service);
bool PrintBetaServerFactory(
const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service);
bool PrintBetaStub(const ServiceDescriptor* service);
bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service);
// Get all comments (leading, leading_detached, trailing) and print them as a
// docstring. Any leading space of a line will be removed, but the line
// wrapping will not be changed.
template <typename DescriptorType>
void PrintAllComments(const DescriptorType* descriptor);
bool GetModuleAndMessagePath(const Descriptor* type, grpc::string* out);
};
PrivateGenerator::PrivateGenerator(const GeneratorConfiguration& config,
const FileDescriptor* file)
: config(config), file(file) {}
bool PrivateGenerator::GetModuleAndMessagePath(const Descriptor* type,
grpc::string* out) { grpc::string* out) {
const Descriptor* path_elem_type = type; const Descriptor* path_elem_type = type;
vector<const Descriptor*> message_path; DescriptorVector message_path;
do { do {
message_path.push_back(path_elem_type); message_path.push_back(path_elem_type);
path_elem_type = path_elem_type->containing_type(); path_elem_type = path_elem_type->containing_type();
@ -188,12 +181,16 @@ bool GetModuleAndMessagePath(const Descriptor* type,
file_name.find_last_of(".proto") == file_name.size() - 1)) { file_name.find_last_of(".proto") == file_name.size() - 1)) {
return false; return false;
} }
grpc::string service_file_name = service->file()->name(); grpc::string generator_file_name = file->name();
grpc::string module = grpc::string module;
service_file_name == file_name ? "" : ModuleAlias(file_name) + "."; if (generator_file_name != file_name || generate_in_pb2_grpc) {
module = ModuleAlias(file_name) + ".";
} else {
module = "";
}
grpc::string message_type; grpc::string message_type;
for (auto path_iter = message_path.rbegin(); path_iter != message_path.rend(); for (DescriptorVector::reverse_iterator path_iter = message_path.rbegin();
++path_iter) { path_iter != message_path.rend(); ++path_iter) {
message_type += (*path_iter)->name() + "."; message_type += (*path_iter)->name() + ".";
} }
// no pop_back prior to C++11 // no pop_back prior to C++11
@ -202,33 +199,31 @@ bool GetModuleAndMessagePath(const Descriptor* type,
return true; return true;
} }
// Get all comments (leading, leading_detached, trailing) and print them as a
// docstring. Any leading space of a line will be removed, but the line wrapping
// will not be changed.
template <typename DescriptorType> template <typename DescriptorType>
static void PrintAllComments(const DescriptorType* desc, Printer* printer) { void PrivateGenerator::PrintAllComments(const DescriptorType* descriptor) {
std::vector<grpc::string> comments; StringVector comments;
grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED, grpc_generator::GetComment(
&comments); descriptor, grpc_generator::COMMENTTYPE_LEADING_DETACHED, &comments);
grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING, grpc_generator::GetComment(descriptor, grpc_generator::COMMENTTYPE_LEADING,
&comments); &comments);
grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_TRAILING, grpc_generator::GetComment(descriptor, grpc_generator::COMMENTTYPE_TRAILING,
&comments); &comments);
if (comments.empty()) { if (comments.empty()) {
return; return;
} }
printer->Print("\"\"\""); out->Print("\"\"\"");
for (auto it = comments.begin(); it != comments.end(); ++it) { for (StringVector::iterator it = comments.begin(); it != comments.end();
++it) {
size_t start_pos = it->find_first_not_of(' '); size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) { if (start_pos != grpc::string::npos) {
printer->Print(it->c_str() + start_pos); out->Print(it->c_str() + start_pos);
} }
printer->Print("\n"); out->Print("\n");
} }
printer->Print("\"\"\"\n"); out->Print("\"\"\"\n");
} }
bool PrintBetaServicer(const ServiceDescriptor* service, Printer* out) { bool PrivateGenerator::PrintBetaServicer(const ServiceDescriptor* service) {
out->Print("\n\n"); out->Print("\n\n");
out->Print("class Beta$Service$Servicer(object):\n", "Service", out->Print("class Beta$Service$Servicer(object):\n", "Service",
service->name()); service->name());
@ -241,16 +236,16 @@ bool PrintBetaServicer(const ServiceDescriptor* service, Printer* out) {
"generated\n" "generated\n"
"only to ease transition from grpcio<0.15.0 to " "only to ease transition from grpcio<0.15.0 to "
"grpcio>=0.15.0.\"\"\"\n"); "grpcio>=0.15.0.\"\"\"\n");
PrintAllComments(service, out); PrintAllComments(service);
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto meth = service->method(i); const MethodDescriptor* method = service->method(i);
grpc::string arg_name = grpc::string arg_name =
meth->client_streaming() ? "request_iterator" : "request"; method->client_streaming() ? "request_iterator" : "request";
out->Print("def $Method$(self, $ArgName$, context):\n", "Method", out->Print("def $Method$(self, $ArgName$, context):\n", "Method",
meth->name(), "ArgName", arg_name); method->name(), "ArgName", arg_name);
{ {
IndentScope raii_method_indent(out); IndentScope raii_method_indent(out);
PrintAllComments(meth, out); PrintAllComments(method);
out->Print("context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)\n"); out->Print("context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)\n");
} }
} }
@ -258,7 +253,7 @@ bool PrintBetaServicer(const ServiceDescriptor* service, Printer* out) {
return true; return true;
} }
bool PrintBetaStub(const ServiceDescriptor* service, Printer* out) { bool PrivateGenerator::PrintBetaStub(const ServiceDescriptor* service) {
out->Print("\n\n"); out->Print("\n\n");
out->Print("class Beta$Service$Stub(object):\n", "Service", service->name()); out->Print("class Beta$Service$Stub(object):\n", "Service", service->name());
{ {
@ -270,30 +265,33 @@ bool PrintBetaStub(const ServiceDescriptor* service, Printer* out) {
"generated\n" "generated\n"
"only to ease transition from grpcio<0.15.0 to " "only to ease transition from grpcio<0.15.0 to "
"grpcio>=0.15.0.\"\"\"\n"); "grpcio>=0.15.0.\"\"\"\n");
PrintAllComments(service, out); PrintAllComments(service);
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* meth = service->method(i); const MethodDescriptor* method = service->method(i);
grpc::string arg_name = grpc::string arg_name =
meth->client_streaming() ? "request_iterator" : "request"; method->client_streaming() ? "request_iterator" : "request";
auto methdict = ListToDict({"Method", meth->name(), "ArgName", arg_name}); StringMap method_dict;
out->Print(methdict, method_dict["Method"] = method->name();
method_dict["ArgName"] = arg_name;
out->Print(method_dict,
"def $Method$(self, $ArgName$, timeout, metadata=None, " "def $Method$(self, $ArgName$, timeout, metadata=None, "
"with_call=False, protocol_options=None):\n"); "with_call=False, protocol_options=None):\n");
{ {
IndentScope raii_method_indent(out); IndentScope raii_method_indent(out);
PrintAllComments(meth, out); PrintAllComments(method);
out->Print("raise NotImplementedError()\n"); out->Print("raise NotImplementedError()\n");
} }
if (!meth->server_streaming()) { if (!method->server_streaming()) {
out->Print(methdict, "$Method$.future = None\n"); out->Print(method_dict, "$Method$.future = None\n");
} }
} }
} }
return true; return true;
} }
bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name, bool PrivateGenerator::PrintBetaServerFactory(
const ServiceDescriptor* service, Printer* out) { const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service) {
out->Print("\n\n"); out->Print("\n\n");
out->Print( out->Print(
"def beta_create_$Service$_server(servicer, pool=None, " "def beta_create_$Service$_server(servicer, pool=None, "
@ -307,9 +305,9 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name,
"file not marked beta) for all further purposes. This function was\n" "file not marked beta) for all further purposes. This function was\n"
"generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0" "generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"
"\"\"\"\n"); "\"\"\"\n");
map<grpc::string, grpc::string> method_implementation_constructors; StringMap method_implementation_constructors;
map<grpc::string, grpc::string> input_message_modules_and_classes; StringMap input_message_modules_and_classes;
map<grpc::string, grpc::string> output_message_modules_and_classes; StringMap output_message_modules_and_classes;
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* method = service->method(i); const MethodDescriptor* method = service->method(i);
const grpc::string method_implementation_constructor = const grpc::string method_implementation_constructor =
@ -317,12 +315,12 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name,
grpc::string(method->server_streaming() ? "stream_" : "unary_") + grpc::string(method->server_streaming() ? "stream_" : "unary_") +
"inline"; "inline";
grpc::string input_message_module_and_class; grpc::string input_message_module_and_class;
if (!GetModuleAndMessagePath(method->input_type(), service, if (!GetModuleAndMessagePath(method->input_type(),
&input_message_module_and_class)) { &input_message_module_and_class)) {
return false; return false;
} }
grpc::string output_message_module_and_class; grpc::string output_message_module_and_class;
if (!GetModuleAndMessagePath(method->output_type(), service, if (!GetModuleAndMessagePath(method->output_type(),
&output_message_module_and_class)) { &output_message_module_and_class)) {
return false; return false;
} }
@ -334,7 +332,7 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name,
make_pair(method->name(), output_message_module_and_class)); make_pair(method->name(), output_message_module_and_class));
} }
out->Print("request_deserializers = {\n"); out->Print("request_deserializers = {\n");
for (auto name_and_input_module_class_pair = for (StringMap::iterator name_and_input_module_class_pair =
input_message_modules_and_classes.begin(); input_message_modules_and_classes.begin();
name_and_input_module_class_pair != name_and_input_module_class_pair !=
input_message_modules_and_classes.end(); input_message_modules_and_classes.end();
@ -349,7 +347,7 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name,
} }
out->Print("}\n"); out->Print("}\n");
out->Print("response_serializers = {\n"); out->Print("response_serializers = {\n");
for (auto name_and_output_module_class_pair = for (StringMap::iterator name_and_output_module_class_pair =
output_message_modules_and_classes.begin(); output_message_modules_and_classes.begin();
name_and_output_module_class_pair != name_and_output_module_class_pair !=
output_message_modules_and_classes.end(); output_message_modules_and_classes.end();
@ -365,7 +363,7 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name,
} }
out->Print("}\n"); out->Print("}\n");
out->Print("method_implementations = {\n"); out->Print("method_implementations = {\n");
for (auto name_and_implementation_constructor = for (StringMap::iterator name_and_implementation_constructor =
method_implementation_constructors.begin(); method_implementation_constructors.begin();
name_and_implementation_constructor != name_and_implementation_constructor !=
method_implementation_constructors.end(); method_implementation_constructors.end();
@ -395,11 +393,11 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name,
return true; return true;
} }
bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name, bool PrivateGenerator::PrintBetaStubFactory(
const ServiceDescriptor* service, Printer* out) { const grpc::string& package_qualified_service_name,
map<grpc::string, grpc::string> dict = ListToDict({ const ServiceDescriptor* service) {
"Service", service->name(), StringMap dict;
}); dict["Service"] = service->name();
out->Print("\n\n"); out->Print("\n\n");
out->Print(dict, out->Print(dict,
"def beta_create_$Service$_stub(channel, host=None," "def beta_create_$Service$_stub(channel, host=None,"
@ -412,21 +410,21 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
"file not marked beta) for all further purposes. This function was\n" "file not marked beta) for all further purposes. This function was\n"
"generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0" "generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"
"\"\"\"\n"); "\"\"\"\n");
map<grpc::string, grpc::string> method_cardinalities; StringMap method_cardinalities;
map<grpc::string, grpc::string> input_message_modules_and_classes; StringMap input_message_modules_and_classes;
map<grpc::string, grpc::string> output_message_modules_and_classes; StringMap output_message_modules_and_classes;
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* method = service->method(i); const MethodDescriptor* method = service->method(i);
const grpc::string method_cardinality = const grpc::string method_cardinality =
grpc::string(method->client_streaming() ? "STREAM" : "UNARY") + "_" + grpc::string(method->client_streaming() ? "STREAM" : "UNARY") + "_" +
grpc::string(method->server_streaming() ? "STREAM" : "UNARY"); grpc::string(method->server_streaming() ? "STREAM" : "UNARY");
grpc::string input_message_module_and_class; grpc::string input_message_module_and_class;
if (!GetModuleAndMessagePath(method->input_type(), service, if (!GetModuleAndMessagePath(method->input_type(),
&input_message_module_and_class)) { &input_message_module_and_class)) {
return false; return false;
} }
grpc::string output_message_module_and_class; grpc::string output_message_module_and_class;
if (!GetModuleAndMessagePath(method->output_type(), service, if (!GetModuleAndMessagePath(method->output_type(),
&output_message_module_and_class)) { &output_message_module_and_class)) {
return false; return false;
} }
@ -438,7 +436,7 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
make_pair(method->name(), output_message_module_and_class)); make_pair(method->name(), output_message_module_and_class));
} }
out->Print("request_serializers = {\n"); out->Print("request_serializers = {\n");
for (auto name_and_input_module_class_pair = for (StringMap::iterator name_and_input_module_class_pair =
input_message_modules_and_classes.begin(); input_message_modules_and_classes.begin();
name_and_input_module_class_pair != name_and_input_module_class_pair !=
input_message_modules_and_classes.end(); input_message_modules_and_classes.end();
@ -453,7 +451,7 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
} }
out->Print("}\n"); out->Print("}\n");
out->Print("response_deserializers = {\n"); out->Print("response_deserializers = {\n");
for (auto name_and_output_module_class_pair = for (StringMap::iterator name_and_output_module_class_pair =
output_message_modules_and_classes.begin(); output_message_modules_and_classes.begin();
name_and_output_module_class_pair != name_and_output_module_class_pair !=
output_message_modules_and_classes.end(); output_message_modules_and_classes.end();
@ -469,7 +467,8 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
} }
out->Print("}\n"); out->Print("}\n");
out->Print("cardinalities = {\n"); out->Print("cardinalities = {\n");
for (auto name_and_cardinality = method_cardinalities.begin(); for (StringMap::iterator name_and_cardinality =
method_cardinalities.begin();
name_and_cardinality != method_cardinalities.end(); name_and_cardinality != method_cardinalities.end();
name_and_cardinality++) { name_and_cardinality++) {
IndentScope raii_descriptions_indent(out); IndentScope raii_descriptions_indent(out);
@ -493,13 +492,14 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
return true; return true;
} }
bool PrintStub(const grpc::string& package_qualified_service_name, bool PrivateGenerator::PrintStub(
const ServiceDescriptor* service, Printer* out) { const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service) {
out->Print("\n\n"); out->Print("\n\n");
out->Print("class $Service$Stub(object):\n", "Service", service->name()); out->Print("class $Service$Stub(object):\n", "Service", service->name());
{ {
IndentScope raii_class_indent(out); IndentScope raii_class_indent(out);
PrintAllComments(service, out); PrintAllComments(service);
out->Print("\n"); out->Print("\n");
out->Print("def __init__(self, channel):\n"); out->Print("def __init__(self, channel):\n");
{ {
@ -513,17 +513,17 @@ bool PrintStub(const grpc::string& package_qualified_service_name,
} }
out->Print("\"\"\"\n"); out->Print("\"\"\"\n");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); const MethodDescriptor* method = service->method(i);
auto multi_callable_constructor = grpc::string multi_callable_constructor =
grpc::string(method->client_streaming() ? "stream" : "unary") + grpc::string(method->client_streaming() ? "stream" : "unary") +
"_" + grpc::string(method->server_streaming() ? "stream" : "unary"); "_" + grpc::string(method->server_streaming() ? "stream" : "unary");
grpc::string request_module_and_class; grpc::string request_module_and_class;
if (!GetModuleAndMessagePath(method->input_type(), service, if (!GetModuleAndMessagePath(method->input_type(),
&request_module_and_class)) { &request_module_and_class)) {
return false; return false;
} }
grpc::string response_module_and_class; grpc::string response_module_and_class;
if (!GetModuleAndMessagePath(method->output_type(), service, if (!GetModuleAndMessagePath(method->output_type(),
&response_module_and_class)) { &response_module_and_class)) {
return false; return false;
} }
@ -550,14 +550,14 @@ bool PrintStub(const grpc::string& package_qualified_service_name,
return true; return true;
} }
bool PrintServicer(const ServiceDescriptor* service, Printer* out) { bool PrivateGenerator::PrintServicer(const ServiceDescriptor* service) {
out->Print("\n\n"); out->Print("\n\n");
out->Print("class $Service$Servicer(object):\n", "Service", service->name()); out->Print("class $Service$Servicer(object):\n", "Service", service->name());
{ {
IndentScope raii_class_indent(out); IndentScope raii_class_indent(out);
PrintAllComments(service, out); PrintAllComments(service);
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); const MethodDescriptor* method = service->method(i);
grpc::string arg_name = grpc::string arg_name =
method->client_streaming() ? "request_iterator" : "request"; method->client_streaming() ? "request_iterator" : "request";
out->Print("\n"); out->Print("\n");
@ -565,7 +565,7 @@ bool PrintServicer(const ServiceDescriptor* service, Printer* out) {
method->name(), "ArgName", arg_name); method->name(), "ArgName", arg_name);
{ {
IndentScope raii_method_indent(out); IndentScope raii_method_indent(out);
PrintAllComments(method, out); PrintAllComments(method);
out->Print("context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n"); out->Print("context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n");
out->Print("context.set_details('Method not implemented!')\n"); out->Print("context.set_details('Method not implemented!')\n");
out->Print("raise NotImplementedError('Method not implemented!')\n"); out->Print("raise NotImplementedError('Method not implemented!')\n");
@ -575,9 +575,9 @@ bool PrintServicer(const ServiceDescriptor* service, Printer* out) {
return true; return true;
} }
bool PrintAddServicerToServer( bool PrivateGenerator::PrintAddServicerToServer(
const grpc::string& package_qualified_service_name, const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service, Printer* out) { const ServiceDescriptor* service) {
out->Print("\n\n"); out->Print("\n\n");
out->Print("def add_$Service$Servicer_to_server(servicer, server):\n", out->Print("def add_$Service$Servicer_to_server(servicer, server):\n",
"Service", service->name()); "Service", service->name());
@ -588,19 +588,19 @@ bool PrintAddServicerToServer(
IndentScope raii_dict_first_indent(out); IndentScope raii_dict_first_indent(out);
IndentScope raii_dict_second_indent(out); IndentScope raii_dict_second_indent(out);
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); const MethodDescriptor* method = service->method(i);
auto method_handler_constructor = grpc::string method_handler_constructor =
grpc::string(method->client_streaming() ? "stream" : "unary") + grpc::string(method->client_streaming() ? "stream" : "unary") +
"_" + "_" +
grpc::string(method->server_streaming() ? "stream" : "unary") + grpc::string(method->server_streaming() ? "stream" : "unary") +
"_rpc_method_handler"; "_rpc_method_handler";
grpc::string request_module_and_class; grpc::string request_module_and_class;
if (!GetModuleAndMessagePath(method->input_type(), service, if (!GetModuleAndMessagePath(method->input_type(),
&request_module_and_class)) { &request_module_and_class)) {
return false; return false;
} }
grpc::string response_module_and_class; grpc::string response_module_and_class;
if (!GetModuleAndMessagePath(method->output_type(), service, if (!GetModuleAndMessagePath(method->output_type(),
&response_module_and_class)) { &response_module_and_class)) {
return false; return false;
} }
@ -635,53 +635,173 @@ bool PrintAddServicerToServer(
return true; return true;
} }
bool PrintPreamble(const FileDescriptor* file, bool PrivateGenerator::PrintBetaPreamble() {
const GeneratorConfiguration& config, Printer* out) {
out->Print("import $Package$\n", "Package", config.grpc_package_root);
out->Print("from $Package$ import implementations as beta_implementations\n", out->Print("from $Package$ import implementations as beta_implementations\n",
"Package", config.beta_package_root); "Package", config.beta_package_root);
out->Print("from $Package$ import interfaces as beta_interfaces\n", "Package", out->Print("from $Package$ import interfaces as beta_interfaces\n", "Package",
config.beta_package_root); config.beta_package_root);
return true;
}
bool PrivateGenerator::PrintPreamble() {
out->Print("import $Package$\n", "Package", config.grpc_package_root);
out->Print("from grpc.framework.common import cardinality\n"); out->Print("from grpc.framework.common import cardinality\n");
out->Print( out->Print(
"from grpc.framework.interfaces.face import utilities as " "from grpc.framework.interfaces.face import utilities as "
"face_utilities\n"); "face_utilities\n");
if (generate_in_pb2_grpc) {
out->Print("\n");
for (int i = 0; i < file->service_count(); ++i) {
const ServiceDescriptor* service = file->service(i);
for (int j = 0; j < service->method_count(); ++j) {
const MethodDescriptor* method = service->method(j);
const Descriptor* types[2] = {method->input_type(),
method->output_type()};
for (int k = 0; k < 2; ++k) {
const Descriptor* type = types[k];
grpc::string type_file_name = type->file()->name();
grpc::string module_name = ModuleName(type_file_name);
grpc::string module_alias = ModuleAlias(type_file_name);
out->Print("import $ModuleName$ as $ModuleAlias$\n", "ModuleName",
module_name, "ModuleAlias", module_alias);
}
}
}
}
return true; return true;
} }
} // namespace bool PrivateGenerator::PrintGAServices() {
grpc::string package = file->package();
if (!package.empty()) {
package = package.append(".");
}
for (int i = 0; i < file->service_count(); ++i) {
const ServiceDescriptor* service = file->service(i);
grpc::string package_qualified_service_name = package + service->name();
if (!(PrintStub(package_qualified_service_name, service) &&
PrintServicer(service) &&
PrintAddServicerToServer(package_qualified_service_name, service))) {
return false;
}
}
return true;
}
bool PrivateGenerator::PrintBetaServices() {
grpc::string package = file->package();
if (!package.empty()) {
package = package.append(".");
}
for (int i = 0; i < file->service_count(); ++i) {
const ServiceDescriptor* service = file->service(i);
grpc::string package_qualified_service_name = package + service->name();
if (!(PrintBetaServicer(service) && PrintBetaStub(service) &&
PrintBetaServerFactory(package_qualified_service_name, service) &&
PrintBetaStubFactory(package_qualified_service_name, service))) {
return false;
}
}
return true;
}
pair<bool, grpc::string> GetServices(const FileDescriptor* file, pair<bool, grpc::string> PrivateGenerator::GetGrpcServices() {
const GeneratorConfiguration& config) {
grpc::string output; grpc::string output;
{ {
// Scope the output stream so it closes and finalizes output to the string. // Scope the output stream so it closes and finalizes output to the string.
StringOutputStream output_stream(&output); StringOutputStream output_stream(&output);
Printer out(&output_stream, '$'); Printer out_printer(&output_stream, '$');
if (!PrintPreamble(file, config, &out)) { out = &out_printer;
if (generate_in_pb2_grpc) {
if (!PrintPreamble()) {
return make_pair(false, ""); return make_pair(false, "");
} }
auto package = file->package(); if (!PrintGAServices()) {
if (!package.empty()) { return make_pair(false, "");
package = package.append(".");
} }
for (int i = 0; i < file->service_count(); ++i) { } else {
auto service = file->service(i); out->Print("try:\n");
auto package_qualified_service_name = package + service->name(); {
if (!(PrintStub(package_qualified_service_name, service, &out) && IndentScope raii_dict_try_indent(out);
PrintServicer(service, &out) && out->Print(
PrintAddServicerToServer(package_qualified_service_name, service, "# THESE ELEMENTS WILL BE DEPRECATED.\n"
&out) && "# Please use the generated *_pb2_grpc.py files instead.\n");
PrintBetaServicer(service, &out) && PrintBetaStub(service, &out) && if (!PrintPreamble()) {
PrintBetaServerFactory(package_qualified_service_name, service, return make_pair(false, "");
&out) && }
PrintBetaStubFactory(package_qualified_service_name, service, if (!PrintBetaPreamble()) {
&out))) { return make_pair(false, "");
}
if (!PrintGAServices()) {
return make_pair(false, ""); return make_pair(false, "");
} }
if (!PrintBetaServices()) {
return make_pair(false, "");
}
}
out->Print("except ImportError:\n");
{
IndentScope raii_dict_except_indent(out);
out->Print("pass");
}
} }
} }
return make_pair(true, std::move(output)); return make_pair(true, std::move(output));
} }
} // namespace
GeneratorConfiguration::GeneratorConfiguration()
: grpc_package_root("grpc"), beta_package_root("grpc.beta") {}
PythonGrpcGenerator::PythonGrpcGenerator(const GeneratorConfiguration& config)
: config_(config) {}
PythonGrpcGenerator::~PythonGrpcGenerator() {}
bool PythonGrpcGenerator::Generate(const FileDescriptor* file,
const grpc::string& parameter,
GeneratorContext* context,
grpc::string* error) const {
// Get output file name.
grpc::string pb2_file_name;
grpc::string pb2_grpc_file_name;
static const int proto_suffix_length = strlen(".proto");
if (file->name().size() > static_cast<size_t>(proto_suffix_length) &&
file->name().find_last_of(".proto") == file->name().size() - 1) {
grpc::string base =
file->name().substr(0, file->name().size() - proto_suffix_length);
pb2_file_name = base + "_pb2.py";
pb2_grpc_file_name = base + "_pb2_grpc.py";
} else {
*error = "Invalid proto file name. Proto file must end with .proto";
return false;
}
PrivateGenerator generator(config_, file);
std::unique_ptr<ZeroCopyOutputStream> pb2_output(
context->OpenForAppend(pb2_file_name));
std::unique_ptr<ZeroCopyOutputStream> grpc_output(
context->Open(pb2_grpc_file_name));
CodedOutputStream pb2_coded_out(pb2_output.get());
CodedOutputStream grpc_coded_out(grpc_output.get());
bool success = false;
grpc::string pb2_code;
grpc::string grpc_code;
generator.generate_in_pb2_grpc = false;
tie(success, pb2_code) = generator.GetGrpcServices();
if (success) {
generator.generate_in_pb2_grpc = true;
tie(success, grpc_code) = generator.GetGrpcServices();
if (success) {
pb2_coded_out.WriteRaw(pb2_code.data(), pb2_code.size());
grpc_coded_out.WriteRaw(grpc_code.data(), grpc_code.size());
return true;
}
}
return false;
}
} // namespace grpc_python_generator } // namespace grpc_python_generator

@ -62,10 +62,6 @@ class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
GeneratorConfiguration config_; GeneratorConfiguration config_;
}; };
std::pair<bool, grpc::string> GetServices(
const grpc::protobuf::FileDescriptor* file,
const GeneratorConfiguration& config);
} // namespace grpc_python_generator } // namespace grpc_python_generator
#endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H #endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H

@ -109,10 +109,16 @@ struct grpc_lb_policy_vtable {
/*#define GRPC_LB_POLICY_REFCOUNT_DEBUG*/ /*#define GRPC_LB_POLICY_REFCOUNT_DEBUG*/
#ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG
/* Strong references: the policy will shutdown when they reach zero */
#define GRPC_LB_POLICY_REF(p, r) \ #define GRPC_LB_POLICY_REF(p, r) \
grpc_lb_policy_ref((p), __FILE__, __LINE__, (r)) grpc_lb_policy_ref((p), __FILE__, __LINE__, (r))
#define GRPC_LB_POLICY_UNREF(exec_ctx, p, r) \ #define GRPC_LB_POLICY_UNREF(exec_ctx, p, r) \
grpc_lb_policy_unref((exec_ctx), (p), __FILE__, __LINE__, (r)) grpc_lb_policy_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
/* Weak references: they don't prevent the shutdown of the LB policy. When no
* strong references are left but there are still weak ones, shutdown is called.
* Once the weak reference also reaches zero, the LB policy is destroyed. */
#define GRPC_LB_POLICY_WEAK_REF(p, r) \ #define GRPC_LB_POLICY_WEAK_REF(p, r) \
grpc_lb_policy_weak_ref((p), __FILE__, __LINE__, (r)) grpc_lb_policy_weak_ref((p), __FILE__, __LINE__, (r))
#define GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, p, r) \ #define GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, p, r) \

@ -43,30 +43,23 @@
* policy to select from this list of LB server backends. * policy to select from this list of LB server backends.
* *
* The first time the policy gets a request for a pick, a ping, or to exit the * The first time the policy gets a request for a pick, a ping, or to exit the
* idle state, \a query_for_backends() is called. It creates an instance of \a * idle state, \a query_for_backends_locked() is called. This function sets up
* lb_client_data, an internal struct meant to contain the data associated with * and initiates the internal communication with the LB server. In particular,
* the internal communication with the LB server. This instance is created via * it's responsible for instantiating the internal *streaming* call to the LB
* \a lb_client_data_create(). There, the call over lb_channel to pick-first * server (whichever address from {a1..an} pick-first chose). This call is
* from {a1..an} is created, the \a LoadBalancingRequest message is assembled * serviced by two callbacks, \a lb_on_server_status_received and \a
* and all necessary callbacks for the progress of the internal call configured. * lb_on_response_received. The former will be called when the call to the LB
* server completes. This can happen if the LB server closes the connection or
* if this policy itself cancels the call (for example because it's shutting
* down). If the internal call times out, the usual behavior of pick-first
* applies, continuing to pick from the list {a1..an}.
* *
* Back in \a query_for_backends(), the internal *streaming* call to the LB * Upon sucesss, the incoming \a LoadBalancingResponse is processed by \a
* server (whichever address from {a1..an} pick-first chose) is kicked off. * res_recv. An invalid one results in the termination of the streaming call. A
* It'll progress over the callbacks configured in \a lb_client_data_create() * new streaming call should be created if possible, failing the original call
* (see the field docstrings of \a lb_client_data for more details). * otherwise. For a valid \a LoadBalancingResponse, the server list of actual
* * backends is extracted. A Round Robin policy will be created from this list.
* If the call fails with UNIMPLEMENTED, the original call will also fail. * There are two possible scenarios:
* There's a misconfiguration somewhere: at least one of {a1..an} isn't a LB
* server, which contradicts the LB bit being set. If the internal call times
* out, the usual behavior of pick-first applies, continuing to pick from the
* list {a1..an}.
*
* Upon sucesss, a \a LoadBalancingResponse is expected in \a res_recv_cb. An
* invalid one results in the termination of the streaming call. A new streaming
* call should be created if possible, failing the original call otherwise.
* For a valid \a LoadBalancingResponse, the server list of actual backends is
* extracted. A Round Robin policy will be created from this list. There are two
* possible scenarios:
* *
* 1. This is the first server list received. There was no previous instance of * 1. This is the first server list received. There was no previous instance of
* the Round Robin policy. \a rr_handover_locked() will instantiate the RR * the Round Robin policy. \a rr_handover_locked() will instantiate the RR
@ -84,10 +77,10 @@
* Once a RR policy instance is in place (and getting updated as described), * Once a RR policy instance is in place (and getting updated as described),
* calls to for a pick, a ping or a cancellation will be serviced right away by * calls to for a pick, a ping or a cancellation will be serviced right away by
* forwarding them to the RR instance. Any time there's no RR policy available * forwarding them to the RR instance. Any time there's no RR policy available
* (ie, right after the creation of the gRPCLB policy, if an empty serverlist * (ie, right after the creation of the gRPCLB policy, if an empty serverlist is
* is received, etc), pick/ping requests are added to a list of pending * received, etc), pick/ping requests are added to a list of pending picks/pings
* picks/pings to be flushed and serviced as part of \a rr_handover_locked() the * to be flushed and serviced as part of \a rr_handover_locked() the moment the
* moment the RR policy instance becomes available. * RR policy instance becomes available.
* *
* \see https://github.com/grpc/grpc/blob/master/doc/load-balancing.md for the * \see https://github.com/grpc/grpc/blob/master/doc/load-balancing.md for the
* high level design and details. */ * high level design and details. */
@ -120,12 +113,20 @@
#include "src/core/ext/lb_policy/grpclb/grpclb.h" #include "src/core/ext/lb_policy/grpclb/grpclb.h"
#include "src/core/ext/lb_policy/grpclb/load_balancer_api.h" #include "src/core/ext/lb_policy/grpclb/load_balancer_api.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/support/backoff.h"
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
#include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/static_metadata.h"
#define BACKOFF_MULTIPLIER 1.6
#define BACKOFF_JITTER 0.2
#define BACKOFF_MIN_SECONDS 10
#define BACKOFF_MAX_SECONDS 60
int grpc_lb_glb_trace = 0; int grpc_lb_glb_trace = 0;
/* add lb_token of selected subchannel (address) to the call's initial /* add lb_token of selected subchannel (address) to the call's initial
@ -174,13 +175,12 @@ typedef struct wrapped_rr_closure_arg {
static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg, static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
wrapped_rr_closure_arg *wc_arg = arg; wrapped_rr_closure_arg *wc_arg = arg;
if (wc_arg->rr_policy != NULL) {
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")",
(intptr_t)wc_arg->rr_policy);
}
GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "wrapped_rr_closure");
GPR_ASSERT(wc_arg->wrapped_closure != NULL);
grpc_exec_ctx_sched(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error),
NULL);
if (wc_arg->rr_policy != NULL) {
/* if target is NULL, no pick has been made by the RR policy (eg, all /* if target is NULL, no pick has been made by the RR policy (eg, all
* addresses failed to connect). There won't be any user_data/token * addresses failed to connect). There won't be any user_data/token
* available */ * available */
@ -189,10 +189,12 @@ static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
wc_arg->lb_token_mdelem_storage, wc_arg->lb_token_mdelem_storage,
GRPC_MDELEM_REF(wc_arg->lb_token)); GRPC_MDELEM_REF(wc_arg->lb_token));
} }
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")",
(intptr_t)wc_arg->rr_policy);
}
GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "wrapped_rr_closure");
} }
GPR_ASSERT(wc_arg->wrapped_closure != NULL);
grpc_exec_ctx_sched(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error),
NULL);
GPR_ASSERT(wc_arg->free_when_done != NULL); GPR_ASSERT(wc_arg->free_when_done != NULL);
gpr_free(wc_arg->free_when_done); gpr_free(wc_arg->free_when_done);
} }
@ -264,7 +266,6 @@ static void add_pending_ping(pending_ping **root, grpc_closure *notify) {
* glb_lb_policy * glb_lb_policy
*/ */
typedef struct rr_connectivity_data rr_connectivity_data; typedef struct rr_connectivity_data rr_connectivity_data;
struct lb_client_data;
static const grpc_lb_policy_vtable glb_lb_policy_vtable; static const grpc_lb_policy_vtable glb_lb_policy_vtable;
typedef struct glb_lb_policy { typedef struct glb_lb_policy {
/** base policy: must be first */ /** base policy: must be first */
@ -296,20 +297,47 @@ typedef struct glb_lb_policy {
* response has arrived. */ * response has arrived. */
grpc_grpclb_serverlist *serverlist; grpc_grpclb_serverlist *serverlist;
/** addresses from \a serverlist */
grpc_lb_addresses *addresses;
/** list of picks that are waiting on RR's policy connectivity */ /** list of picks that are waiting on RR's policy connectivity */
pending_pick *pending_picks; pending_pick *pending_picks;
/** list of pings that are waiting on RR's policy connectivity */ /** list of pings that are waiting on RR's policy connectivity */
pending_ping *pending_pings; pending_ping *pending_pings;
/** client data associated with the LB server communication */ bool shutting_down;
struct lb_client_data *lb_client;
/************************************************************/
/* client data associated with the LB server communication */
/************************************************************/
/* Status from the LB server has been received. This signals the end of the LB
* call. */
grpc_closure lb_on_server_status_received;
/* A response from the LB server has been received. Process it */
grpc_closure lb_on_response_received;
grpc_call *lb_call; /* streaming call to the LB server, */
grpc_metadata_array lb_initial_metadata_recv; /* initial MD from LB server */
grpc_metadata_array
lb_trailing_metadata_recv; /* trailing MD from LB server */
/* what's being sent to the LB server. Note that its value may vary if the LB
* server indicates a redirect. */
grpc_byte_buffer *lb_request_payload;
/* response the LB server, if any. Processed in lb_on_response_received() */
grpc_byte_buffer *lb_response_payload;
/* call status code and details, set in lb_on_server_status_received() */
grpc_status_code lb_call_status;
char *lb_call_status_details;
size_t lb_call_status_details_capacity;
/** for tracking of the RR connectivity */ /** LB call retry backoff state */
rr_connectivity_data *rr_connectivity; gpr_backoff lb_call_backoff_state;
/** LB call retry timer */
grpc_timer lb_call_retry_timer;
} glb_lb_policy; } glb_lb_policy;
/* Keeps track and reacts to changes in connectivity of the RR instance */ /* Keeps track and reacts to changes in connectivity of the RR instance */
@ -358,6 +386,28 @@ static int lb_token_cmp(void *token1, void *token2) {
static const grpc_lb_user_data_vtable lb_token_vtable = { static const grpc_lb_user_data_vtable lb_token_vtable = {
lb_token_copy, lb_token_destroy, lb_token_cmp}; lb_token_copy, lb_token_destroy, lb_token_cmp};
static void parse_server(const grpc_grpclb_server *server,
grpc_resolved_address *addr) {
const uint16_t netorder_port = htons((uint16_t)server->port);
/* the addresses are given in binary format (a in(6)_addr struct) in
* server->ip_address.bytes. */
const grpc_grpclb_ip_address *ip = &server->ip_address;
memset(addr, 0, sizeof(*addr));
if (ip->size == 4) {
addr->len = sizeof(struct sockaddr_in);
struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr->addr;
addr4->sin_family = AF_INET;
memcpy(&addr4->sin_addr, ip->bytes, ip->size);
addr4->sin_port = netorder_port;
} else if (ip->size == 16) {
addr->len = sizeof(struct sockaddr_in6);
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr->addr;
addr6->sin6_family = AF_INET6;
memcpy(&addr6->sin6_addr, ip->bytes, ip->size);
addr6->sin6_port = netorder_port;
}
}
/* Returns addresses extracted from \a serverlist. */ /* Returns addresses extracted from \a serverlist. */
static grpc_lb_addresses *process_serverlist( static grpc_lb_addresses *process_serverlist(
const grpc_grpclb_serverlist *serverlist) { const grpc_grpclb_serverlist *serverlist) {
@ -384,33 +434,18 @@ static grpc_lb_addresses *process_serverlist(
if (!is_server_valid(serverlist->servers[sl_idx], sl_idx, false)) continue; if (!is_server_valid(serverlist->servers[sl_idx], sl_idx, false)) continue;
/* address processing */ /* address processing */
const uint16_t netorder_port = htons((uint16_t)server->port);
/* the addresses are given in binary format (a in(6)_addr struct) in
* server->ip_address.bytes. */
const grpc_grpclb_ip_address *ip = &server->ip_address;
grpc_resolved_address addr; grpc_resolved_address addr;
memset(&addr, 0, sizeof(addr)); parse_server(server, &addr);
if (ip->size == 4) {
addr.len = sizeof(struct sockaddr_in);
struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr.addr;
addr4->sin_family = AF_INET;
memcpy(&addr4->sin_addr, ip->bytes, ip->size);
addr4->sin_port = netorder_port;
} else if (ip->size == 16) {
addr.len = sizeof(struct sockaddr_in6);
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr.addr;
addr6->sin6_family = AF_INET;
memcpy(&addr6->sin6_addr, ip->bytes, ip->size);
addr6->sin6_port = netorder_port;
}
/* lb token processing */ /* lb token processing */
void *user_data; void *user_data;
if (server->has_load_balance_token) { if (server->has_load_balance_token) {
const size_t lb_token_size = const size_t lb_token_max_length =
GPR_ARRAY_SIZE(server->load_balance_token) - 1; GPR_ARRAY_SIZE(server->load_balance_token);
const size_t lb_token_length =
strnlen(server->load_balance_token, lb_token_max_length);
grpc_mdstr *lb_token_mdstr = grpc_mdstr_from_buffer( grpc_mdstr *lb_token_mdstr = grpc_mdstr_from_buffer(
(uint8_t *)server->load_balance_token, lb_token_size); (uint8_t *)server->load_balance_token, lb_token_length);
user_data = grpc_mdelem_from_metadata_strings(GRPC_MDSTR_LB_TOKEN, user_data = grpc_mdelem_from_metadata_strings(GRPC_MDSTR_LB_TOKEN,
lb_token_mdstr); lb_token_mdstr);
} else { } else {
@ -427,7 +462,6 @@ static grpc_lb_addresses *process_serverlist(
++addr_idx; ++addr_idx;
} }
GPR_ASSERT(addr_idx == num_valid); GPR_ASSERT(addr_idx == num_valid);
return lb_addresses; return lb_addresses;
} }
@ -448,7 +482,7 @@ static bool pick_from_internal_rr_locked(
gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")", gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")",
(intptr_t)wc_arg->rr_policy); (intptr_t)wc_arg->rr_policy);
} }
GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick"); GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync");
/* add the load reporting initial metadata */ /* add the load reporting initial metadata */
initial_metadata_add_lb_token(pick_args->initial_metadata, initial_metadata_add_lb_token(pick_args->initial_metadata,
@ -461,7 +495,6 @@ static bool pick_from_internal_rr_locked(
* pending pick list inside the RR policy (glb_policy->rr_policy). * pending pick list inside the RR policy (glb_policy->rr_policy).
* Eventually, wrapped_on_complete will be called, which will -among other * Eventually, wrapped_on_complete will be called, which will -among other
* things- add the LB token to the call's initial metadata */ * things- add the LB token to the call's initial metadata */
return pick_done; return pick_done;
} }
@ -470,54 +503,70 @@ static grpc_lb_policy *create_rr_locked(
glb_lb_policy *glb_policy) { glb_lb_policy *glb_policy) {
GPR_ASSERT(serverlist != NULL && serverlist->num_servers > 0); GPR_ASSERT(serverlist != NULL && serverlist->num_servers > 0);
if (glb_policy->addresses != NULL) {
/* dispose of the previous version */
grpc_lb_addresses_destroy(glb_policy->addresses);
}
glb_policy->addresses = process_serverlist(serverlist);
grpc_lb_policy_args args; grpc_lb_policy_args args;
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
args.client_channel_factory = glb_policy->cc_factory; args.client_channel_factory = glb_policy->cc_factory;
grpc_lb_addresses *addresses = process_serverlist(serverlist);
// Replace the LB addresses in the channel args that we pass down to // Replace the LB addresses in the channel args that we pass down to
// the subchannel. // the subchannel.
static const char *keys_to_remove[] = {GRPC_ARG_LB_ADDRESSES}; static const char *keys_to_remove[] = {GRPC_ARG_LB_ADDRESSES};
const grpc_arg arg = const grpc_arg arg = grpc_lb_addresses_create_channel_arg(addresses);
grpc_lb_addresses_create_channel_arg(glb_policy->addresses);
args.args = grpc_channel_args_copy_and_add_and_remove( args.args = grpc_channel_args_copy_and_add_and_remove(
glb_policy->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &arg, glb_policy->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &arg,
1); 1);
grpc_lb_policy *rr = grpc_lb_policy_create(exec_ctx, "round_robin", &args); grpc_lb_policy *rr = grpc_lb_policy_create(exec_ctx, "round_robin", &args);
GPR_ASSERT(rr != NULL);
grpc_lb_addresses_destroy(addresses);
grpc_channel_args_destroy(args.args); grpc_channel_args_destroy(args.args);
return rr; return rr;
} }
static void glb_rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error);
/* glb_policy->rr_policy may be NULL (initial handover) */
static void rr_handover_locked(grpc_exec_ctx *exec_ctx, static void rr_handover_locked(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy, grpc_error *error) { glb_lb_policy *glb_policy, grpc_error *error) {
GPR_ASSERT(glb_policy->serverlist != NULL && GPR_ASSERT(glb_policy->serverlist != NULL &&
glb_policy->serverlist->num_servers > 0); glb_policy->serverlist->num_servers > 0);
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "RR handover. Old RR: %p", (void *)glb_policy->rr_policy);
}
if (glb_policy->rr_policy != NULL) {
/* if we are phasing out an existing RR instance, unref it. */
GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "rr_handover");
}
glb_policy->rr_policy = glb_policy->rr_policy =
create_rr_locked(exec_ctx, glb_policy->serverlist, glb_policy); create_rr_locked(exec_ctx, glb_policy->serverlist, glb_policy);
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Created RR policy (0x%" PRIxPTR ")", gpr_log(GPR_INFO, "Created RR policy (%p)", (void *)glb_policy->rr_policy);
(intptr_t)glb_policy->rr_policy);
} }
GPR_ASSERT(glb_policy->rr_policy != NULL); GPR_ASSERT(glb_policy->rr_policy != NULL);
grpc_pollset_set_add_pollset_set(exec_ctx, grpc_pollset_set_add_pollset_set(exec_ctx,
glb_policy->rr_policy->interested_parties, glb_policy->rr_policy->interested_parties,
glb_policy->base.interested_parties); glb_policy->base.interested_parties);
glb_policy->rr_connectivity->state = grpc_lb_policy_check_connectivity(
rr_connectivity_data *rr_connectivity =
gpr_malloc(sizeof(rr_connectivity_data));
memset(rr_connectivity, 0, sizeof(rr_connectivity_data));
grpc_closure_init(&rr_connectivity->on_change, glb_rr_connectivity_changed,
rr_connectivity);
rr_connectivity->glb_policy = glb_policy;
rr_connectivity->state = grpc_lb_policy_check_connectivity(
exec_ctx, glb_policy->rr_policy, &error); exec_ctx, glb_policy->rr_policy, &error);
grpc_lb_policy_notify_on_state_change(
exec_ctx, glb_policy->rr_policy, &glb_policy->rr_connectivity->state,
&glb_policy->rr_connectivity->on_change);
grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker, grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker,
glb_policy->rr_connectivity->state, rr_connectivity->state, GRPC_ERROR_REF(error),
GRPC_ERROR_REF(error), "rr_handover"); "rr_handover");
/* subscribe */
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "rr_connectivity_cb");
grpc_lb_policy_notify_on_state_change(exec_ctx, glb_policy->rr_policy,
&rr_connectivity->state,
&rr_connectivity->on_change);
grpc_lb_policy_exit_idle(exec_ctx, glb_policy->rr_policy); grpc_lb_policy_exit_idle(exec_ctx, glb_policy->rr_policy);
/* flush pending ops */ /* flush pending ops */
@ -551,37 +600,29 @@ static void rr_handover_locked(grpc_exec_ctx *exec_ctx,
static void glb_rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg, static void glb_rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
/* If shutdown or error free the arg. Rely on the rest of the code to set the
* right grpclb status. */
rr_connectivity_data *rr_conn_data = arg; rr_connectivity_data *rr_conn_data = arg;
glb_lb_policy *glb_policy = rr_conn_data->glb_policy; glb_lb_policy *glb_policy = rr_conn_data->glb_policy;
if (rr_conn_data->state == GRPC_CHANNEL_SHUTDOWN) { if (rr_conn_data->state != GRPC_CHANNEL_SHUTDOWN &&
if (glb_policy->serverlist != NULL) { !glb_policy->shutting_down) {
/* a RR policy is shutting down but there's a serverlist available ->
* perform a handover */
gpr_mu_lock(&glb_policy->mu);
rr_handover_locked(exec_ctx, glb_policy, error);
gpr_mu_unlock(&glb_policy->mu);
} else {
/* shutting down and no new serverlist available. Bail out. */
gpr_free(rr_conn_data);
}
} else {
if (error == GRPC_ERROR_NONE) {
gpr_mu_lock(&glb_policy->mu); gpr_mu_lock(&glb_policy->mu);
/* RR not shutting down. Mimic the RR's policy state */ /* RR not shutting down. Mimic the RR's policy state */
grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker, grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker,
rr_conn_data->state, GRPC_ERROR_REF(error), rr_conn_data->state, GRPC_ERROR_REF(error),
"glb_rr_connectivity_changed"); "rr_connectivity_cb");
/* resubscribe */ /* resubscribe. Reuse the "rr_connectivity_cb" weak ref. */
grpc_lb_policy_notify_on_state_change(exec_ctx, glb_policy->rr_policy, grpc_lb_policy_notify_on_state_change(exec_ctx, glb_policy->rr_policy,
&rr_conn_data->state, &rr_conn_data->state,
&rr_conn_data->on_change); &rr_conn_data->on_change);
gpr_mu_unlock(&glb_policy->mu); gpr_mu_unlock(&glb_policy->mu);
} else { /* error */ } else {
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"rr_connectivity_cb");
gpr_free(rr_conn_data); gpr_free(rr_conn_data);
} }
} }
}
static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx, static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
grpc_lb_policy_factory *factory, grpc_lb_policy_factory *factory,
@ -682,18 +723,11 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
return NULL; return NULL;
} }
rr_connectivity_data *rr_connectivity =
gpr_malloc(sizeof(rr_connectivity_data));
memset(rr_connectivity, 0, sizeof(rr_connectivity_data));
grpc_closure_init(&rr_connectivity->on_change, glb_rr_connectivity_changed,
rr_connectivity);
rr_connectivity->glb_policy = glb_policy;
glb_policy->rr_connectivity = rr_connectivity;
grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable); grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable);
gpr_mu_init(&glb_policy->mu); gpr_mu_init(&glb_policy->mu);
grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE, grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE,
"grpclb"); "grpclb");
return &glb_policy->base; return &glb_policy->base;
} }
@ -710,14 +744,13 @@ static void glb_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
grpc_grpclb_destroy_serverlist(glb_policy->serverlist); grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
} }
gpr_mu_destroy(&glb_policy->mu); gpr_mu_destroy(&glb_policy->mu);
grpc_lb_addresses_destroy(glb_policy->addresses);
gpr_free(glb_policy); gpr_free(glb_policy);
} }
static void lb_client_data_destroy(struct lb_client_data *lb_client);
static void glb_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { static void glb_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
glb_lb_policy *glb_policy = (glb_lb_policy *)pol; glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
gpr_mu_lock(&glb_policy->mu); gpr_mu_lock(&glb_policy->mu);
glb_policy->shutting_down = true;
pending_pick *pp = glb_policy->pending_picks; pending_pick *pp = glb_policy->pending_picks;
glb_policy->pending_picks = NULL; glb_policy->pending_picks = NULL;
@ -741,15 +774,16 @@ static void glb_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
} }
if (glb_policy->rr_policy) { if (glb_policy->rr_policy) {
/* unsubscribe */
grpc_lb_policy_notify_on_state_change(
exec_ctx, glb_policy->rr_policy, NULL,
&glb_policy->rr_connectivity->on_change);
GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "glb_shutdown"); GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "glb_shutdown");
} }
lb_client_data_destroy(glb_policy->lb_client); if (glb_policy->started_picking) {
glb_policy->lb_client = NULL; if (glb_policy->lb_call != NULL) {
grpc_call_cancel(glb_policy->lb_call, NULL);
/* lb_on_server_status_received will pick up the cancellation and clean up
*/
}
}
grpc_connectivity_state_set( grpc_connectivity_state_set(
exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN, exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN,
@ -780,17 +814,12 @@ static void glb_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
static grpc_call *lb_client_data_get_call(struct lb_client_data *lb_client);
static void glb_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, static void glb_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
uint32_t initial_metadata_flags_mask, uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq, uint32_t initial_metadata_flags_eq,
grpc_error *error) { grpc_error *error) {
glb_lb_policy *glb_policy = (glb_lb_policy *)pol; glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
gpr_mu_lock(&glb_policy->mu); gpr_mu_lock(&glb_policy->mu);
if (glb_policy->lb_client != NULL) {
/* cancel the call to the load balancer service, if any */
grpc_call_cancel(lb_client_data_get_call(glb_policy->lb_client), NULL);
}
pending_pick *pp = glb_policy->pending_picks; pending_pick *pp = glb_policy->pending_picks;
glb_policy->pending_picks = NULL; glb_policy->pending_picks = NULL;
while (pp != NULL) { while (pp != NULL) {
@ -810,18 +839,20 @@ static void glb_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
static void query_for_backends(grpc_exec_ctx *exec_ctx, static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy); glb_lb_policy *glb_policy);
static void start_picking(grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy) { static void start_picking_locked(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy) {
glb_policy->started_picking = true; glb_policy->started_picking = true;
query_for_backends(exec_ctx, glb_policy); gpr_backoff_reset(&glb_policy->lb_call_backoff_state);
query_for_backends_locked(exec_ctx, glb_policy);
} }
static void glb_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { static void glb_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
glb_lb_policy *glb_policy = (glb_lb_policy *)pol; glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
gpr_mu_lock(&glb_policy->mu); gpr_mu_lock(&glb_policy->mu);
if (!glb_policy->started_picking) { if (!glb_policy->started_picking) {
start_picking(exec_ctx, glb_policy); start_picking_locked(exec_ctx, glb_policy);
} }
gpr_mu_unlock(&glb_policy->mu); gpr_mu_unlock(&glb_policy->mu);
} }
@ -847,8 +878,8 @@ static int glb_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
if (glb_policy->rr_policy != NULL) { if (glb_policy->rr_policy != NULL) {
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "about to PICK from 0x%" PRIxPTR "", gpr_log(GPR_INFO, "grpclb %p about to PICK from RR %p",
(intptr_t)glb_policy->rr_policy); (void *)glb_policy, (void *)glb_policy->rr_policy);
} }
GRPC_LB_POLICY_REF(glb_policy->rr_policy, "glb_pick"); GRPC_LB_POLICY_REF(glb_policy->rr_policy, "glb_pick");
@ -865,11 +896,17 @@ static int glb_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
pick_done = pick_from_internal_rr_locked(exec_ctx, glb_policy->rr_policy, pick_done = pick_from_internal_rr_locked(exec_ctx, glb_policy->rr_policy,
pick_args, target, wc_arg); pick_args, target, wc_arg);
} else { } else {
if (grpc_lb_glb_trace) {
gpr_log(GPR_DEBUG,
"No RR policy in grpclb instance %p. Adding to grpclb's pending "
"picks",
(void *)(glb_policy));
}
add_pending_pick(&glb_policy->pending_picks, pick_args, target, add_pending_pick(&glb_policy->pending_picks, pick_args, target,
on_complete); on_complete);
if (!glb_policy->started_picking) { if (!glb_policy->started_picking) {
start_picking(exec_ctx, glb_policy); start_picking_locked(exec_ctx, glb_policy);
} }
pick_done = false; pick_done = false;
} }
@ -898,7 +935,7 @@ static void glb_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
} else { } else {
add_pending_ping(&glb_policy->pending_pings, closure); add_pending_ping(&glb_policy->pending_pings, closure);
if (!glb_policy->started_picking) { if (!glb_policy->started_picking) {
start_picking(exec_ctx, glb_policy); start_picking_locked(exec_ctx, glb_policy);
} }
} }
gpr_mu_unlock(&glb_policy->mu); gpr_mu_unlock(&glb_policy->mu);
@ -916,250 +953,182 @@ static void glb_notify_on_state_change(grpc_exec_ctx *exec_ctx,
gpr_mu_unlock(&glb_policy->mu); gpr_mu_unlock(&glb_policy->mu);
} }
/* static void lb_on_server_status_received(grpc_exec_ctx *exec_ctx, void *arg,
* lb_client_data
*
* Used internally for the client call to the LB */
typedef struct lb_client_data {
gpr_mu mu;
/* called once initial metadata's been sent */
grpc_closure md_sent;
/* called once the LoadBalanceRequest has been sent to the LB server. See
* src/proto/grpc/.../load_balancer.proto */
grpc_closure req_sent;
/* A response from the LB server has been received (or error). Process it */
grpc_closure res_rcvd;
/* After the client has sent a close to the LB server */
grpc_closure close_sent;
/* ... and the status from the LB server has been received */
grpc_closure srv_status_rcvd;
grpc_call *lb_call; /* streaming call to the LB server, */
gpr_timespec deadline; /* for the streaming call to the LB server */
grpc_metadata_array initial_metadata_recv; /* initial MD from LB server */
grpc_metadata_array trailing_metadata_recv; /* trailing MD from LB server */
/* what's being sent to the LB server. Note that its value may vary if the LB
* server indicates a redirect. */
grpc_byte_buffer *request_payload;
/* response from the LB server, if any. Processed in res_recv_cb() */
grpc_byte_buffer *response_payload;
/* the call's status and status detailset in srv_status_rcvd_cb() */
grpc_status_code status;
char *status_details;
size_t status_details_capacity;
/* pointer back to the enclosing policy */
glb_lb_policy *glb_policy;
} lb_client_data;
static void md_sent_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error);
static void req_sent_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error);
static void res_recv_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error);
static void close_sent_cb(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error); grpc_error *error);
static void srv_status_rcvd_cb(grpc_exec_ctx *exec_ctx, void *arg, static void lb_on_response_received(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error); grpc_error *error);
static void lb_call_init(glb_lb_policy *glb_policy) {
static lb_client_data *lb_client_data_create(glb_lb_policy *glb_policy) {
GPR_ASSERT(glb_policy->server_name != NULL); GPR_ASSERT(glb_policy->server_name != NULL);
GPR_ASSERT(glb_policy->server_name[0] != '\0'); GPR_ASSERT(glb_policy->server_name[0] != '\0');
lb_client_data *lb_client = gpr_malloc(sizeof(lb_client_data));
memset(lb_client, 0, sizeof(lb_client_data));
gpr_mu_init(&lb_client->mu);
grpc_closure_init(&lb_client->md_sent, md_sent_cb, lb_client);
grpc_closure_init(&lb_client->req_sent, req_sent_cb, lb_client);
grpc_closure_init(&lb_client->res_rcvd, res_recv_cb, lb_client);
grpc_closure_init(&lb_client->close_sent, close_sent_cb, lb_client);
grpc_closure_init(&lb_client->srv_status_rcvd, srv_status_rcvd_cb, lb_client);
lb_client->deadline = glb_policy->deadline;
/* Note the following LB call progresses every time there's activity in \a /* Note the following LB call progresses every time there's activity in \a
* glb_policy->base.interested_parties, which is comprised of the polling * glb_policy->base.interested_parties, which is comprised of the polling
* entities from \a client_channel. */ * entities from \a client_channel. */
lb_client->lb_call = grpc_channel_create_pollset_set_call( glb_policy->lb_call = grpc_channel_create_pollset_set_call(
glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS,
glb_policy->base.interested_parties, glb_policy->base.interested_parties,
"/grpc.lb.v1.LoadBalancer/BalanceLoad", glb_policy->server_name, "/grpc.lb.v1.LoadBalancer/BalanceLoad", glb_policy->server_name,
lb_client->deadline, NULL); glb_policy->deadline, NULL);
grpc_metadata_array_init(&lb_client->initial_metadata_recv); grpc_metadata_array_init(&glb_policy->lb_initial_metadata_recv);
grpc_metadata_array_init(&lb_client->trailing_metadata_recv); grpc_metadata_array_init(&glb_policy->lb_trailing_metadata_recv);
grpc_grpclb_request *request = grpc_grpclb_request *request =
grpc_grpclb_request_create(glb_policy->server_name); grpc_grpclb_request_create(glb_policy->server_name);
gpr_slice request_payload_slice = grpc_grpclb_request_encode(request); gpr_slice request_payload_slice = grpc_grpclb_request_encode(request);
lb_client->request_payload = glb_policy->lb_request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_slice_unref(request_payload_slice); gpr_slice_unref(request_payload_slice);
grpc_grpclb_request_destroy(request); grpc_grpclb_request_destroy(request);
lb_client->status_details = NULL; glb_policy->lb_call_status_details = NULL;
lb_client->status_details_capacity = 0; glb_policy->lb_call_status_details_capacity = 0;
lb_client->glb_policy = glb_policy;
return lb_client; grpc_closure_init(&glb_policy->lb_on_server_status_received,
lb_on_server_status_received, glb_policy);
grpc_closure_init(&glb_policy->lb_on_response_received,
lb_on_response_received, glb_policy);
gpr_backoff_init(&glb_policy->lb_call_backoff_state, BACKOFF_MULTIPLIER,
BACKOFF_JITTER, BACKOFF_MIN_SECONDS * 1000,
BACKOFF_MAX_SECONDS * 1000);
} }
static void lb_client_data_destroy(lb_client_data *lb_client) { static void lb_call_destroy(glb_lb_policy *glb_policy) {
grpc_call_destroy(lb_client->lb_call); GPR_ASSERT(glb_policy->lb_call != NULL);
grpc_metadata_array_destroy(&lb_client->initial_metadata_recv); grpc_call_destroy(glb_policy->lb_call);
grpc_metadata_array_destroy(&lb_client->trailing_metadata_recv); glb_policy->lb_call = NULL;
grpc_byte_buffer_destroy(lb_client->request_payload); grpc_metadata_array_destroy(&glb_policy->lb_initial_metadata_recv);
grpc_metadata_array_destroy(&glb_policy->lb_trailing_metadata_recv);
gpr_free(lb_client->status_details); grpc_byte_buffer_destroy(glb_policy->lb_request_payload);
gpr_mu_destroy(&lb_client->mu); gpr_free(glb_policy->lb_call_status_details);
gpr_free(lb_client);
}
static grpc_call *lb_client_data_get_call(lb_client_data *lb_client) {
return lb_client->lb_call;
} }
/* /*
* Auxiliary functions and LB client callbacks. * Auxiliary functions and LB client callbacks.
*/ */
static void query_for_backends(grpc_exec_ctx *exec_ctx, static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy) { glb_lb_policy *glb_policy) {
GPR_ASSERT(glb_policy->lb_channel != NULL); GPR_ASSERT(glb_policy->lb_channel != NULL);
lb_call_init(glb_policy);
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Query for backends (grpclb: %p, lb_call: %p)",
(void *)glb_policy, (void *)glb_policy->lb_call);
}
GPR_ASSERT(glb_policy->lb_call != NULL);
glb_policy->lb_client = lb_client_data_create(glb_policy);
grpc_call_error call_error; grpc_call_error call_error;
grpc_op ops[1]; grpc_op ops[4];
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
grpc_op *op = ops; grpc_op *op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA; op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0; op->data.send_initial_metadata.count = 0;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
call_error = grpc_call_start_batch_and_execute(
exec_ctx, glb_policy->lb_client->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_client->md_sent);
GPR_ASSERT(GRPC_CALL_OK == call_error);
op = ops; op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_initial_metadata = &glb_policy->lb_initial_metadata_recv;
op->data.recv_status_on_client.trailing_metadata =
&glb_policy->lb_client->trailing_metadata_recv;
op->data.recv_status_on_client.status = &glb_policy->lb_client->status;
op->data.recv_status_on_client.status_details =
&glb_policy->lb_client->status_details;
op->data.recv_status_on_client.status_details_capacity =
&glb_policy->lb_client->status_details_capacity;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
call_error = grpc_call_start_batch_and_execute(
exec_ctx, glb_policy->lb_client->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_client->srv_status_rcvd);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
static void md_sent_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
lb_client_data *lb_client = arg;
GPR_ASSERT(lb_client->lb_call);
grpc_op ops[1];
memset(ops, 0, sizeof(ops));
grpc_op *op = ops;
GPR_ASSERT(glb_policy->lb_request_payload != NULL);
op->op = GRPC_OP_SEND_MESSAGE; op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message = lb_client->request_payload; op->data.send_message = glb_policy->lb_request_payload;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
grpc_call_error call_error = grpc_call_start_batch_and_execute(
exec_ctx, lb_client->lb_call, ops, (size_t)(op - ops),
&lb_client->req_sent);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
static void req_sent_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
lb_client_data *lb_client = arg;
GPR_ASSERT(lb_client->lb_call);
grpc_op ops[2]; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
memset(ops, 0, sizeof(ops)); op->data.recv_status_on_client.trailing_metadata =
grpc_op *op = ops; &glb_policy->lb_trailing_metadata_recv;
op->data.recv_status_on_client.status = &glb_policy->lb_call_status;
op->op = GRPC_OP_RECV_INITIAL_METADATA; op->data.recv_status_on_client.status_details =
op->data.recv_initial_metadata = &lb_client->initial_metadata_recv; &glb_policy->lb_call_status_details;
op->data.recv_status_on_client.status_details_capacity =
&glb_policy->lb_call_status_details_capacity;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
/* take a weak ref (won't prevent calling of \a glb_shutdown if the strong ref
* count goes to zero) to be unref'd in lb_on_server_status_received */
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "lb_on_server_status_received");
call_error = grpc_call_start_batch_and_execute(
exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_on_server_status_received);
GPR_ASSERT(GRPC_CALL_OK == call_error);
op = ops;
op->op = GRPC_OP_RECV_MESSAGE; op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &lb_client->response_payload; op->data.recv_message = &glb_policy->lb_response_payload;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
grpc_call_error call_error = grpc_call_start_batch_and_execute( /* take another weak ref to be unref'd in lb_on_response_received */
exec_ctx, lb_client->lb_call, ops, (size_t)(op - ops), GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "lb_on_response_received");
&lb_client->res_rcvd); call_error = grpc_call_start_batch_and_execute(
exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_on_response_received);
GPR_ASSERT(GRPC_CALL_OK == call_error); GPR_ASSERT(GRPC_CALL_OK == call_error);
} }
static void res_recv_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { static void lb_on_response_received(grpc_exec_ctx *exec_ctx, void *arg,
lb_client_data *lb_client = arg; grpc_error *error) {
glb_lb_policy *glb_policy = arg;
grpc_op ops[2]; grpc_op ops[2];
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
grpc_op *op = ops; grpc_op *op = ops;
if (lb_client->response_payload != NULL) { if (glb_policy->lb_response_payload != NULL) {
gpr_backoff_reset(&glb_policy->lb_call_backoff_state);
/* Received data from the LB server. Look inside /* Received data from the LB server. Look inside
* lb_client->response_payload, for a serverlist. */ * glb_policy->lb_response_payload, for a serverlist. */
grpc_byte_buffer_reader bbr; grpc_byte_buffer_reader bbr;
grpc_byte_buffer_reader_init(&bbr, lb_client->response_payload); grpc_byte_buffer_reader_init(&bbr, glb_policy->lb_response_payload);
gpr_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); gpr_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
grpc_byte_buffer_destroy(lb_client->response_payload); grpc_byte_buffer_destroy(glb_policy->lb_response_payload);
grpc_grpclb_serverlist *serverlist = grpc_grpclb_serverlist *serverlist =
grpc_grpclb_response_parse_serverlist(response_slice); grpc_grpclb_response_parse_serverlist(response_slice);
if (serverlist != NULL) { if (serverlist != NULL) {
GPR_ASSERT(glb_policy->lb_call != NULL);
gpr_slice_unref(response_slice); gpr_slice_unref(response_slice);
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Serverlist with %lu servers received", gpr_log(GPR_INFO, "Serverlist with %lu servers received",
(unsigned long)serverlist->num_servers); (unsigned long)serverlist->num_servers);
for (size_t i = 0; i < serverlist->num_servers; ++i) {
grpc_resolved_address addr;
parse_server(serverlist->servers[i], &addr);
char *ipport;
grpc_sockaddr_to_string(&ipport, &addr, false);
gpr_log(GPR_INFO, "Serverlist[%lu]: %s", (unsigned long)i, ipport);
gpr_free(ipport);
}
} }
/* update serverlist */ /* update serverlist */
if (serverlist->num_servers > 0) { if (serverlist->num_servers > 0) {
gpr_mu_lock(&lb_client->glb_policy->mu); gpr_mu_lock(&glb_policy->mu);
if (grpc_grpclb_serverlist_equals(lb_client->glb_policy->serverlist, if (grpc_grpclb_serverlist_equals(glb_policy->serverlist, serverlist)) {
serverlist)) {
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"Incoming server list identical to current, ignoring."); "Incoming server list identical to current, ignoring.");
} }
} else { /* new serverlist */ } else { /* new serverlist */
if (lb_client->glb_policy->serverlist != NULL) { if (glb_policy->serverlist != NULL) {
/* dispose of the old serverlist */ /* dispose of the old serverlist */
grpc_grpclb_destroy_serverlist(lb_client->glb_policy->serverlist); grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
} }
/* and update the copy in the glb_lb_policy instance */ /* and update the copy in the glb_lb_policy instance */
lb_client->glb_policy->serverlist = serverlist; glb_policy->serverlist = serverlist;
}
if (lb_client->glb_policy->rr_policy == NULL) { rr_handover_locked(exec_ctx, glb_policy, error);
/* initial "handover", in this case from a null RR policy, meaning
* it'll just create the first RR policy instance */
rr_handover_locked(exec_ctx, lb_client->glb_policy, error);
} else {
/* unref the RR policy, eventually leading to its substitution with a
* new one constructed from the received serverlist (see
* glb_rr_connectivity_changed) */
GRPC_LB_POLICY_UNREF(exec_ctx, lb_client->glb_policy->rr_policy,
"serverlist_received");
} }
gpr_mu_unlock(&lb_client->glb_policy->mu); gpr_mu_unlock(&glb_policy->mu);
} else { } else {
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -1167,60 +1136,94 @@ static void res_recv_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
"response with > 0 servers is received"); "response with > 0 servers is received");
} }
} }
} else { /* serverlist == NULL */
gpr_log(GPR_ERROR, "Invalid LB response received: '%s'. Ignoring.",
gpr_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX));
gpr_slice_unref(response_slice);
}
if (!glb_policy->shutting_down) {
/* keep listening for serverlist updates */ /* keep listening for serverlist updates */
op->op = GRPC_OP_RECV_MESSAGE; op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &lb_client->response_payload; op->data.recv_message = &glb_policy->lb_response_payload;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
/* reuse the "lb_on_response_received" weak ref taken in
* query_for_backends_locked() */
const grpc_call_error call_error = grpc_call_start_batch_and_execute( const grpc_call_error call_error = grpc_call_start_batch_and_execute(
exec_ctx, lb_client->lb_call, ops, (size_t)(op - ops), exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
&lb_client->res_rcvd); /* loop */ &glb_policy->lb_on_response_received); /* loop */
GPR_ASSERT(GRPC_CALL_OK == call_error); GPR_ASSERT(GRPC_CALL_OK == call_error);
return;
} }
} else { /* empty payload: call cancelled. */
GPR_ASSERT(serverlist == NULL); /* dispose of the "lb_on_response_received" weak ref taken in
gpr_log(GPR_ERROR, "Invalid LB response received: '%s'", * query_for_backends_locked() and reused in every reception loop */
gpr_dump_slice(response_slice, GPR_DUMP_ASCII)); GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
gpr_slice_unref(response_slice); "lb_on_response_received_empty_payload");
/* Disconnect from server returning invalid response. */
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
op->reserved = NULL;
op++;
grpc_call_error call_error = grpc_call_start_batch_and_execute(
exec_ctx, lb_client->lb_call, ops, (size_t)(op - ops),
&lb_client->close_sent);
GPR_ASSERT(GRPC_CALL_OK == call_error);
} }
/* empty payload: call cancelled by server. Cleanups happening in
* srv_status_rcvd_cb */
} }
static void close_sent_cb(grpc_exec_ctx *exec_ctx, void *arg, static void lb_call_on_retry_timer(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
glb_lb_policy *glb_policy = arg;
gpr_mu_lock(&glb_policy->mu);
if (!glb_policy->shutting_down) {
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO, "Restaring call to LB server (grpclb %p)",
"Close from LB client sent. Waiting from server status now"); (void *)glb_policy);
} }
GPR_ASSERT(glb_policy->lb_call == NULL);
query_for_backends_locked(exec_ctx, glb_policy);
}
gpr_mu_unlock(&glb_policy->mu);
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"grpclb_on_retry_timer");
} }
static void srv_status_rcvd_cb(grpc_exec_ctx *exec_ctx, void *arg, static void lb_on_server_status_received(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
lb_client_data *lb_client = arg; glb_lb_policy *glb_policy = arg;
gpr_mu_lock(&glb_policy->mu);
GPR_ASSERT(glb_policy->lb_call != NULL);
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, gpr_log(GPR_DEBUG,
"status from lb server received. Status = %d, Details = '%s', " "Status from LB server received. Status = %d, Details = '%s', "
"Capacity " "(call: %p)",
"= %lu", glb_policy->lb_call_status, glb_policy->lb_call_status_details,
lb_client->status, lb_client->status_details, (void *)glb_policy->lb_call);
(unsigned long)lb_client->status_details_capacity); }
}
/* TODO(dgq): deal with stream termination properly (fire up another one? /* We need to performe cleanups no matter what. */
* fail the original call?) */ lb_call_destroy(glb_policy);
if (!glb_policy->shutting_down) {
/* if we aren't shutting down, restart the LB client call after some time */
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try =
gpr_backoff_step(&glb_policy->lb_call_backoff_state, now);
if (grpc_lb_glb_trace) {
gpr_log(GPR_DEBUG, "Connection to LB server lost (grpclb: %p)...",
(void *)glb_policy);
gpr_timespec timeout = gpr_time_sub(next_try, now);
if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
gpr_log(GPR_DEBUG, "... retrying in %" PRId64 ".%09d seconds.",
timeout.tv_sec, timeout.tv_nsec);
} else {
gpr_log(GPR_DEBUG, "... retrying immediately.");
}
}
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "grpclb_retry_timer");
grpc_timer_init(exec_ctx, &glb_policy->lb_call_retry_timer, next_try,
lb_call_on_retry_timer, glb_policy, now);
}
gpr_mu_unlock(&glb_policy->mu);
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"lb_on_server_status_received");
} }
/* Code wiring the policy with the rest of the core */ /* Code wiring the policy with the rest of the core */

@ -77,7 +77,7 @@ typedef struct _grpc_lb_v1_Server {
bool has_port; bool has_port;
int32_t port; int32_t port;
bool has_load_balance_token; bool has_load_balance_token;
char load_balance_token[65]; char load_balance_token[50];
bool has_drop_request; bool has_drop_request;
bool drop_request; bool drop_request;
/* @@protoc_insertion_point(struct:grpc_lb_v1_Server) */ /* @@protoc_insertion_point(struct:grpc_lb_v1_Server) */
@ -172,7 +172,7 @@ extern const pb_field_t grpc_lb_v1_Server_fields[5];
#define grpc_lb_v1_LoadBalanceResponse_size (98 + grpc_lb_v1_ServerList_size) #define grpc_lb_v1_LoadBalanceResponse_size (98 + grpc_lb_v1_ServerList_size)
#define grpc_lb_v1_InitialLoadBalanceResponse_size 90 #define grpc_lb_v1_InitialLoadBalanceResponse_size 90
/* grpc_lb_v1_ServerList_size depends on runtime parameters */ /* grpc_lb_v1_ServerList_size depends on runtime parameters */
#define grpc_lb_v1_Server_size 98 #define grpc_lb_v1_Server_size 83
/* Message IDs (where set with "msgid" option) */ /* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID #ifdef PB_MSGID

@ -120,6 +120,8 @@ typedef struct {
grpc_connectivity_state connectivity_state; grpc_connectivity_state connectivity_state;
/** the subchannel's target user data */ /** the subchannel's target user data */
void *user_data; void *user_data;
/** vtable to operate over \a user_data */
const grpc_lb_user_data_vtable *user_data_vtable;
} subchannel_data; } subchannel_data;
struct round_robin_lb_policy { struct round_robin_lb_policy {
@ -186,9 +188,13 @@ static void advance_last_picked_locked(round_robin_lb_policy *p) {
} }
if (grpc_lb_round_robin_trace) { if (grpc_lb_round_robin_trace) {
gpr_log(GPR_DEBUG, "[READYLIST] ADVANCED LAST PICK. NOW AT NODE %p (SC %p)", gpr_log(GPR_DEBUG,
(void *)p->ready_list_last_pick, "[READYLIST, RR: %p] ADVANCED LAST PICK. NOW AT NODE %p (SC %p, "
(void *)p->ready_list_last_pick->subchannel); "CSC %p)",
(void *)p, (void *)p->ready_list_last_pick,
(void *)p->ready_list_last_pick->subchannel,
(void *)grpc_subchannel_get_connected_subchannel(
p->ready_list_last_pick->subchannel));
} }
} }
@ -255,9 +261,18 @@ static void remove_disconnected_sc_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;
ready_list *elem; ready_list *elem;
if (grpc_lb_round_robin_trace) {
gpr_log(GPR_DEBUG, "Destroying Round Robin policy at %p", (void *)pol);
}
for (size_t i = 0; i < p->num_subchannels; i++) { for (size_t i = 0; i < p->num_subchannels; i++) {
subchannel_data *sd = p->subchannels[i]; subchannel_data *sd = p->subchannels[i];
GRPC_SUBCHANNEL_UNREF(exec_ctx, sd->subchannel, "round_robin"); GRPC_SUBCHANNEL_UNREF(exec_ctx, sd->subchannel, "round_robin_destroy");
if (sd->user_data != NULL) {
GPR_ASSERT(sd->user_data_vtable != NULL);
sd->user_data_vtable->destroy(sd->user_data);
}
gpr_free(sd); gpr_free(sd);
} }
@ -285,6 +300,9 @@ static void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
size_t i; size_t i;
gpr_mu_lock(&p->mu); gpr_mu_lock(&p->mu);
if (grpc_lb_round_robin_trace) {
gpr_log(GPR_DEBUG, "Shutting down Round Robin policy at %p", (void *)pol);
}
p->shutdown = 1; p->shutdown = 1;
while ((pp = p->pending_picks)) { while ((pp = p->pending_picks)) {
@ -296,7 +314,7 @@ static void rr_shutdown(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("Channel Shutdown"), "shutdown"); GRPC_ERROR_CREATE("Channel Shutdown"), "rr_shutdown");
for (i = 0; i < p->num_subchannels; i++) { for (i = 0; i < p->num_subchannels; i++) {
subchannel_data *sd = p->subchannels[i]; subchannel_data *sd = p->subchannels[i];
grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, NULL, grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, NULL,
@ -395,6 +413,11 @@ static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
pending_pick *pp; pending_pick *pp;
ready_list *selected; ready_list *selected;
gpr_mu_lock(&p->mu); gpr_mu_lock(&p->mu);
if (grpc_lb_round_robin_trace) {
gpr_log(GPR_INFO, "Round Robin %p trying to pick", (void *)pol);
}
if ((selected = peek_next_connected_locked(p))) { if ((selected = peek_next_connected_locked(p))) {
/* readily available, report right away */ /* readily available, report right away */
*target = GRPC_CONNECTED_SUBCHANNEL_REF( *target = GRPC_CONNECTED_SUBCHANNEL_REF(
@ -435,7 +458,6 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
subchannel_data *sd = arg; subchannel_data *sd = arg;
round_robin_lb_policy *p = sd->policy; round_robin_lb_policy *p = sd->policy;
pending_pick *pp; pending_pick *pp;
ready_list *selected;
int unref = 0; int unref = 0;
@ -456,12 +478,14 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
/* 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
* ahead and pick one and notify the pending suitors in * ahead and pick one and notify the pending suitors in
* p->pending_picks. This preemtively replicates rr_pick()'s actions. */ * p->pending_picks. This preemtively replicates rr_pick()'s actions. */
selected = peek_next_connected_locked(p); ready_list *selected = peek_next_connected_locked(p);
GPR_ASSERT(selected != NULL);
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 */
advance_last_picked_locked(p); advance_last_picked_locked(p);
} }
while ((pp = p->pending_picks)) { while ((pp = p->pending_picks)) {
p->pending_picks = pp->next; p->pending_picks = pp->next;
@ -585,6 +609,7 @@ static void rr_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_subchannel_get_connected_subchannel(selected->subchannel), grpc_subchannel_get_connected_subchannel(selected->subchannel),
"picked"); "picked");
grpc_connected_subchannel_ping(exec_ctx, target, closure); grpc_connected_subchannel_ping(exec_ctx, target, closure);
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "picked");
} else { } else {
gpr_mu_unlock(&p->mu); gpr_mu_unlock(&p->mu);
grpc_exec_ctx_sched(exec_ctx, closure, grpc_exec_ctx_sched(exec_ctx, closure,
@ -653,7 +678,11 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
sd->policy = p; sd->policy = p;
sd->index = subchannel_idx; sd->index = subchannel_idx;
sd->subchannel = subchannel; sd->subchannel = subchannel;
sd->user_data = addresses->addresses[i].user_data; sd->user_data_vtable = addresses->user_data_vtable;
if (sd->user_data_vtable != NULL) {
sd->user_data =
sd->user_data_vtable->copy(addresses->addresses[i].user_data);
}
++subchannel_idx; ++subchannel_idx;
grpc_closure_init(&sd->connectivity_changed_closure, grpc_closure_init(&sd->connectivity_changed_closure,
rr_connectivity_changed, sd); rr_connectivity_changed, sd);

@ -190,7 +190,7 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(!r->have_retry_timer); GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true; r->have_retry_timer = true;
GRPC_RESOLVER_REF(&r->base, "retry-timer"); GRPC_RESOLVER_REF(&r->base, "retry-timer");
if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) <= 0) { if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec, gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec,
timeout.tv_nsec); timeout.tv_nsec);
} else { } else {

@ -347,7 +347,7 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
&exec_ctx, &f->base, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args); &exec_ctx, &f->base, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
// Clean up. // Clean up.
GRPC_SECURITY_CONNECTOR_UNREF(&f->security_connector->base, GRPC_SECURITY_CONNECTOR_UNREF(&f->security_connector->base,
"client_channel_factory_create_channel"); "secure_client_channel_factory_create_channel");
grpc_channel_args_destroy(new_args); grpc_channel_args_destroy(new_args);
grpc_client_channel_factory_unref(&exec_ctx, &f->base); grpc_client_channel_factory_unref(&exec_ctx, &f->base);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);

@ -50,6 +50,7 @@
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/ext/transport/chttp2/transport/http2_errors.h"
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
@ -1578,6 +1579,20 @@ static const maybe_complete_func_type maybe_complete_funcs[] = {
grpc_chttp2_maybe_complete_recv_initial_metadata, grpc_chttp2_maybe_complete_recv_initial_metadata,
grpc_chttp2_maybe_complete_recv_trailing_metadata}; grpc_chttp2_maybe_complete_recv_trailing_metadata};
static void force_client_rst_stream(grpc_exec_ctx *exec_ctx, void *sp,
grpc_error *error) {
grpc_chttp2_stream *s = sp;
grpc_chttp2_transport *t = s->t;
if (!s->write_closed) {
gpr_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_CHTTP2_NO_ERROR,
&s->stats.outgoing));
grpc_chttp2_initiate_write(exec_ctx, t, false, "force_rst_stream");
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, GRPC_ERROR_NONE);
}
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "final_rst");
}
grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx, grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
void *hpack_parser, void *hpack_parser,
grpc_chttp2_transport *t, grpc_chttp2_transport *t,
@ -1613,6 +1628,17 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
s->header_frames_received++; s->header_frames_received++;
} }
if (parser->is_eof) { if (parser->is_eof) {
if (t->is_client && !s->write_closed) {
/* server eof ==> complete closure; we may need to forcefully close
the stream. Wait until the combiner lock is ready to be released
however -- it might be that we receive a RST_STREAM following this
and can avoid the extra write */
GRPC_CHTTP2_STREAM_REF(s, "final_rst");
grpc_combiner_execute_finally(
exec_ctx, t->combiner,
grpc_closure_create(force_client_rst_stream, s), GRPC_ERROR_NONE,
false);
}
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false,
GRPC_ERROR_NONE); GRPC_ERROR_NONE);
} }

@ -41,7 +41,8 @@
#include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/endpoint_pair.h"
grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name, grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(
const char *name, grpc_resource_quota *resource_quota,
size_t read_slice_size) { size_t read_slice_size) {
grpc_endpoint_pair endpoint_pair; grpc_endpoint_pair endpoint_pair;
// TODO(mlumish): implement this properly under libuv // TODO(mlumish): implement this properly under libuv

@ -46,7 +46,7 @@ static gpr_mu g_endpoint_mutex;
void grpc_network_status_shutdown(void) { void grpc_network_status_shutdown(void) {
if (head != NULL) { if (head != NULL) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Memory leaked as all network endpoints were not shut down"); "Memory leaked as not all network endpoints were shut down");
} }
gpr_mu_destroy(&g_endpoint_mutex); gpr_mu_destroy(&g_endpoint_mutex);
} }

@ -715,3 +715,10 @@ void grpc_resource_user_alloc_slices(
grpc_resource_user_alloc(exec_ctx, slice_allocator->resource_user, grpc_resource_user_alloc(exec_ctx, slice_allocator->resource_user,
count * length, &slice_allocator->on_allocated); count * length, &slice_allocator->on_allocated);
} }
gpr_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx,
grpc_resource_user *resource_user,
size_t size) {
grpc_resource_user_alloc(exec_ctx, resource_user, size, NULL);
return ru_slice_create(resource_user, size);
}

@ -221,4 +221,9 @@ void grpc_resource_user_alloc_slices(
grpc_resource_user_slice_allocator *slice_allocator, size_t length, grpc_resource_user_slice_allocator *slice_allocator, size_t length,
size_t count, gpr_slice_buffer *dest); size_t count, gpr_slice_buffer *dest);
/* Allocate one slice of length \a size synchronously. */
gpr_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx,
grpc_resource_user *resource_user,
size_t size);
#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ #endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */

@ -54,9 +54,12 @@ typedef struct grpc_uv_tcp_connect {
grpc_endpoint **endpoint; grpc_endpoint **endpoint;
int refs; int refs;
char *addr_name; char *addr_name;
grpc_resource_quota *resource_quota;
} grpc_uv_tcp_connect; } grpc_uv_tcp_connect;
static void uv_tcp_connect_cleanup(grpc_uv_tcp_connect *connect) { static void uv_tcp_connect_cleanup(grpc_exec_ctx *exec_ctx,
grpc_uv_tcp_connect *connect) {
grpc_resource_quota_internal_unref(exec_ctx, connect->resource_quota);
gpr_free(connect); gpr_free(connect);
} }
@ -74,7 +77,7 @@ static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp,
} }
done = (--connect->refs == 0); done = (--connect->refs == 0);
if (done) { if (done) {
uv_tcp_connect_cleanup(connect); uv_tcp_connect_cleanup(exec_ctx, connect);
} }
} }
@ -86,8 +89,8 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) {
grpc_closure *closure = connect->closure; grpc_closure *closure = connect->closure;
grpc_timer_cancel(&exec_ctx, &connect->alarm); grpc_timer_cancel(&exec_ctx, &connect->alarm);
if (status == 0) { if (status == 0) {
*connect->endpoint = *connect->endpoint = grpc_tcp_create(
grpc_tcp_create(connect->tcp_handle, connect->addr_name); connect->tcp_handle, connect->resource_quota, connect->addr_name);
} else { } else {
error = GRPC_ERROR_CREATE("Failed to connect to remote host"); error = GRPC_ERROR_CREATE("Failed to connect to remote host");
error = grpc_error_set_int(error, GRPC_ERROR_INT_ERRNO, -status); error = grpc_error_set_int(error, GRPC_ERROR_INT_ERRNO, -status);
@ -105,7 +108,7 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) {
} }
done = (--connect->refs == 0); done = (--connect->refs == 0);
if (done) { if (done) {
uv_tcp_connect_cleanup(connect); uv_tcp_connect_cleanup(&exec_ctx, connect);
} }
grpc_exec_ctx_sched(&exec_ctx, closure, error, NULL); grpc_exec_ctx_sched(&exec_ctx, closure, error, NULL);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
@ -114,16 +117,31 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) {
static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
grpc_closure *closure, grpc_endpoint **ep, grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, grpc_pollset_set *interested_parties,
const grpc_channel_args *channel_args,
const grpc_resolved_address *resolved_addr, const grpc_resolved_address *resolved_addr,
gpr_timespec deadline) { gpr_timespec deadline) {
grpc_uv_tcp_connect *connect; grpc_uv_tcp_connect *connect;
grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
(void)channel_args;
(void)interested_parties; (void)interested_parties;
if (channel_args != NULL) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
grpc_resource_quota_internal_unref(exec_ctx, resource_quota);
resource_quota = grpc_resource_quota_internal_ref(
channel_args->args[i].value.pointer.p);
}
}
}
connect = gpr_malloc(sizeof(grpc_uv_tcp_connect)); connect = gpr_malloc(sizeof(grpc_uv_tcp_connect));
memset(connect, 0, sizeof(grpc_uv_tcp_connect)); memset(connect, 0, sizeof(grpc_uv_tcp_connect));
connect->closure = closure; connect->closure = closure;
connect->endpoint = ep; connect->endpoint = ep;
connect->tcp_handle = gpr_malloc(sizeof(uv_tcp_t)); connect->tcp_handle = gpr_malloc(sizeof(uv_tcp_t));
connect->addr_name = grpc_sockaddr_to_uri(resolved_addr); connect->addr_name = grpc_sockaddr_to_uri(resolved_addr);
connect->resource_quota = resource_quota;
uv_tcp_init(uv_default_loop(), connect->tcp_handle); uv_tcp_init(uv_default_loop(), connect->tcp_handle);
connect->connect_req.data = connect; connect->connect_req.data = connect;
// TODO(murgatroid99): figure out what the return value here means // TODO(murgatroid99): figure out what the return value here means
@ -138,16 +156,18 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
// overridden by api_fuzzer.c // overridden by api_fuzzer.c
void (*grpc_tcp_client_connect_impl)( void (*grpc_tcp_client_connect_impl)(
grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, const grpc_resolved_address *addr, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
const grpc_resolved_address *addr,
gpr_timespec deadline) = tcp_client_connect_impl; gpr_timespec deadline) = tcp_client_connect_impl;
void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_endpoint **ep, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, grpc_pollset_set *interested_parties,
const grpc_channel_args *channel_args,
const grpc_resolved_address *addr, const grpc_resolved_address *addr,
gpr_timespec deadline) { gpr_timespec deadline) {
grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, addr, grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
deadline); channel_args, addr, deadline);
} }
#endif /* GRPC_UV */ #endif /* GRPC_UV */

@ -657,41 +657,46 @@ done:
} }
} }
unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s, /* Return listener at port_index or NULL. Should only be called with s->mu
locked. */
static grpc_tcp_listener *get_port_index(grpc_tcp_server *s,
unsigned port_index) { unsigned port_index) {
unsigned num_fds = 0; unsigned num_ports = 0;
grpc_tcp_listener *sp; grpc_tcp_listener *sp;
gpr_mu_lock(&s->mu); for (sp = s->head; sp; sp = sp->next) {
for (sp = s->head; sp && port_index != 0; sp = sp->next) {
if (!sp->is_sibling) { if (!sp->is_sibling) {
--port_index; if (++num_ports > port_index) {
return sp;
}
} }
} }
for (; sp; sp = sp->sibling, ++num_fds) return NULL;
; }
unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s,
unsigned port_index) {
unsigned num_fds = 0;
gpr_mu_lock(&s->mu);
grpc_tcp_listener *sp = get_port_index(s, port_index);
for (; sp; sp = sp->sibling) {
++num_fds;
}
gpr_mu_unlock(&s->mu); gpr_mu_unlock(&s->mu);
return num_fds; return num_fds;
} }
int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index, int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index,
unsigned fd_index) { unsigned fd_index) {
grpc_tcp_listener *sp;
int fd;
gpr_mu_lock(&s->mu); gpr_mu_lock(&s->mu);
for (sp = s->head; sp && port_index != 0; sp = sp->next) { grpc_tcp_listener *sp = get_port_index(s, port_index);
if (!sp->is_sibling) { for (; sp; sp = sp->sibling, --fd_index) {
--port_index; if (fd_index == 0) {
} gpr_mu_unlock(&s->mu);
return sp->fd;
} }
for (; sp && fd_index != 0; sp = sp->sibling, --fd_index)
;
if (sp) {
fd = sp->fd;
} else {
fd = -1;
} }
gpr_mu_unlock(&s->mu); gpr_mu_unlock(&s->mu);
return fd; return -1;
} }
void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s, void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s,

@ -76,13 +76,30 @@ struct grpc_tcp_server {
/* shutdown callback */ /* shutdown callback */
grpc_closure *shutdown_complete; grpc_closure *shutdown_complete;
grpc_resource_quota *resource_quota;
}; };
grpc_error *grpc_tcp_server_create(grpc_closure *shutdown_complete, grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
grpc_closure *shutdown_complete,
const grpc_channel_args *args, const grpc_channel_args *args,
grpc_tcp_server **server) { grpc_tcp_server **server) {
grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server)); grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
(void)args; s->resource_quota = grpc_resource_quota_create(NULL);
for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) {
if (0 == strcmp(GRPC_ARG_RESOURCE_QUOTA, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_POINTER) {
grpc_resource_quota_internal_unref(exec_ctx, s->resource_quota);
s->resource_quota =
grpc_resource_quota_internal_ref(args->args[i].value.pointer.p);
} else {
grpc_resource_quota_internal_unref(exec_ctx, s->resource_quota);
gpr_free(s);
return GRPC_ERROR_CREATE(GRPC_ARG_RESOURCE_QUOTA
" must be a pointer to a buffer pool");
}
}
}
gpr_ref_init(&s->refs, 1); gpr_ref_init(&s->refs, 1);
s->on_accept_cb = NULL; s->on_accept_cb = NULL;
s->on_accept_cb_arg = NULL; s->on_accept_cb_arg = NULL;
@ -119,6 +136,7 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
gpr_free(sp->handle); gpr_free(sp->handle);
gpr_free(sp); gpr_free(sp);
} }
grpc_resource_quota_internal_unref(exec_ctx, s->resource_quota);
gpr_free(s); gpr_free(s);
} }
@ -201,7 +219,7 @@ static void on_connect(uv_stream_t *server, int status) {
} else { } else {
gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", uv_strerror(status)); gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", uv_strerror(status));
} }
ep = grpc_tcp_create(client, peer_name_string); ep = grpc_tcp_create(client, sp->server->resource_quota, peer_name_string);
sp->server->on_accept_cb(&exec_ctx, sp->server->on_accept_cb_arg, ep, NULL, sp->server->on_accept_cb(&exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
&acceptor); &acceptor);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);

@ -54,6 +54,9 @@ typedef struct {
grpc_endpoint base; grpc_endpoint base;
gpr_refcount refcount; gpr_refcount refcount;
uv_write_t write_req;
uv_shutdown_t shutdown_req;
uv_tcp_t *handle; uv_tcp_t *handle;
grpc_closure *read_cb; grpc_closure *read_cb;
@ -64,14 +67,23 @@ typedef struct {
gpr_slice_buffer *write_slices; gpr_slice_buffer *write_slices;
uv_buf_t *write_buffers; uv_buf_t *write_buffers;
grpc_resource_user resource_user;
bool shutting_down; bool shutting_down;
bool resource_user_shutting_down;
char *peer_string; char *peer_string;
grpc_pollset *pollset; grpc_pollset *pollset;
} grpc_tcp; } grpc_tcp;
static void uv_close_callback(uv_handle_t *handle) { gpr_free(handle); } static void uv_close_callback(uv_handle_t *handle) { gpr_free(handle); }
static void tcp_free(grpc_tcp *tcp) { gpr_free(tcp); } static void tcp_free(grpc_tcp *tcp) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resource_user_destroy(&exec_ctx, &tcp->resource_user);
gpr_free(tcp);
grpc_exec_ctx_finish(&exec_ctx);
}
/*#define GRPC_TCP_REFCOUNT_DEBUG*/ /*#define GRPC_TCP_REFCOUNT_DEBUG*/
#ifdef GRPC_TCP_REFCOUNT_DEBUG #ifdef GRPC_TCP_REFCOUNT_DEBUG
@ -106,11 +118,14 @@ static void tcp_ref(grpc_tcp *tcp) { gpr_ref(&tcp->refcount); }
static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size, static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size,
uv_buf_t *buf) { uv_buf_t *buf) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_tcp *tcp = handle->data; grpc_tcp *tcp = handle->data;
(void)suggested_size; (void)suggested_size;
tcp->read_slice = gpr_slice_malloc(GRPC_TCP_DEFAULT_READ_SLICE_SIZE); tcp->read_slice = grpc_resource_user_slice_malloc(
&exec_ctx, &tcp->resource_user, GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
buf->base = (char *)GPR_SLICE_START_PTR(tcp->read_slice); buf->base = (char *)GPR_SLICE_START_PTR(tcp->read_slice);
buf->len = GPR_SLICE_LENGTH(tcp->read_slice); buf->len = GPR_SLICE_LENGTH(tcp->read_slice);
grpc_exec_ctx_finish(&exec_ctx);
} }
static void read_callback(uv_stream_t *stream, ssize_t nread, static void read_callback(uv_stream_t *stream, ssize_t nread,
@ -198,7 +213,8 @@ static void write_callback(uv_write_t *req, int status) {
gpr_log(GPR_DEBUG, "write complete on %p: error=%s", tcp, str); gpr_log(GPR_DEBUG, "write complete on %p: error=%s", tcp, str);
} }
gpr_free(tcp->write_buffers); gpr_free(tcp->write_buffers);
gpr_free(req); grpc_resource_user_free(&exec_ctx, &tcp->resource_user,
sizeof(uv_buf_t) * tcp->write_slices->count);
grpc_exec_ctx_sched(&exec_ctx, cb, error, NULL); grpc_exec_ctx_sched(&exec_ctx, cb, error, NULL);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }
@ -243,12 +259,15 @@ static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
tcp->write_cb = cb; tcp->write_cb = cb;
buffer_count = (unsigned int)tcp->write_slices->count; buffer_count = (unsigned int)tcp->write_slices->count;
buffers = gpr_malloc(sizeof(uv_buf_t) * buffer_count); buffers = gpr_malloc(sizeof(uv_buf_t) * buffer_count);
grpc_resource_user_alloc(exec_ctx, &tcp->resource_user,
sizeof(uv_buf_t) * buffer_count, NULL);
for (i = 0; i < buffer_count; i++) { for (i = 0; i < buffer_count; i++) {
slice = &tcp->write_slices->slices[i]; slice = &tcp->write_slices->slices[i];
buffers[i].base = (char *)GPR_SLICE_START_PTR(*slice); buffers[i].base = (char *)GPR_SLICE_START_PTR(*slice);
buffers[i].len = GPR_SLICE_LENGTH(*slice); buffers[i].len = GPR_SLICE_LENGTH(*slice);
} }
write_req = gpr_malloc(sizeof(uv_write_t)); tcp->write_buffers = buffers;
write_req = &tcp->write_req;
write_req->data = tcp; write_req->data = tcp;
TCP_REF(tcp, "write"); TCP_REF(tcp, "write");
// TODO(murgatroid99): figure out what the return value here means // TODO(murgatroid99): figure out what the return value here means
@ -274,13 +293,29 @@ static void uv_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
(void)pollset; (void)pollset;
} }
static void shutdown_callback(uv_shutdown_t *req, int status) { gpr_free(req); } static void shutdown_callback(uv_shutdown_t *req, int status) {}
static void resource_user_shutdown_done(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
TCP_UNREF(arg, "resource_user");
}
static void uv_resource_user_maybe_shutdown(grpc_exec_ctx *exec_ctx,
grpc_tcp *tcp) {
if (!tcp->resource_user_shutting_down) {
tcp->resource_user_shutting_down = true;
TCP_REF(tcp, "resource_user");
grpc_resource_user_shutdown(
exec_ctx, &tcp->resource_user,
grpc_closure_create(resource_user_shutdown_done, tcp));
}
}
static void uv_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { static void uv_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
grpc_tcp *tcp = (grpc_tcp *)ep; grpc_tcp *tcp = (grpc_tcp *)ep;
if (!tcp->shutting_down) { if (!tcp->shutting_down) {
tcp->shutting_down = true; tcp->shutting_down = true;
uv_shutdown_t *req = gpr_malloc(sizeof(uv_shutdown_t)); uv_shutdown_t *req = &tcp->shutdown_req;
uv_shutdown(req, (uv_stream_t *)tcp->handle, shutdown_callback); uv_shutdown(req, (uv_stream_t *)tcp->handle, shutdown_callback);
} }
} }
@ -289,6 +324,7 @@ static void uv_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
grpc_network_status_unregister_endpoint(ep); grpc_network_status_unregister_endpoint(ep);
grpc_tcp *tcp = (grpc_tcp *)ep; grpc_tcp *tcp = (grpc_tcp *)ep;
uv_close((uv_handle_t *)tcp->handle, uv_close_callback); uv_close((uv_handle_t *)tcp->handle, uv_close_callback);
uv_resource_user_maybe_shutdown(exec_ctx, tcp);
TCP_UNREF(tcp, "destroy"); TCP_UNREF(tcp, "destroy");
} }
@ -297,18 +333,21 @@ static char *uv_get_peer(grpc_endpoint *ep) {
return gpr_strdup(tcp->peer_string); return gpr_strdup(tcp->peer_string);
} }
static grpc_resource_user *uv_get_resource_user(grpc_endpoint *ep) {
grpc_tcp *tcp = (grpc_tcp *)ep;
return &tcp->resource_user;
}
static grpc_workqueue *uv_get_workqueue(grpc_endpoint *ep) { return NULL; } static grpc_workqueue *uv_get_workqueue(grpc_endpoint *ep) { return NULL; }
static grpc_endpoint_vtable vtable = {uv_endpoint_read, static grpc_endpoint_vtable vtable = {
uv_endpoint_write, uv_endpoint_read, uv_endpoint_write, uv_get_workqueue,
uv_get_workqueue, uv_add_to_pollset, uv_add_to_pollset_set, uv_endpoint_shutdown,
uv_add_to_pollset, uv_destroy, uv_get_resource_user, uv_get_peer};
uv_add_to_pollset_set,
uv_endpoint_shutdown,
uv_destroy,
uv_get_peer};
grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle, char *peer_string) { grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle,
grpc_resource_quota *resource_quota,
char *peer_string) {
grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp)); grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
if (grpc_tcp_trace) { if (grpc_tcp_trace) {
@ -325,6 +364,8 @@ grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle, char *peer_string) {
gpr_ref_init(&tcp->refcount, 1); gpr_ref_init(&tcp->refcount, 1);
tcp->peer_string = gpr_strdup(peer_string); tcp->peer_string = gpr_strdup(peer_string);
tcp->shutting_down = false; tcp->shutting_down = false;
tcp->resource_user_shutting_down = false;
grpc_resource_user_init(&tcp->resource_user, resource_quota, peer_string);
/* Tell network status tracking code about the new endpoint */ /* Tell network status tracking code about the new endpoint */
grpc_network_status_register_endpoint(&tcp->base); grpc_network_status_register_endpoint(&tcp->base);

@ -52,6 +52,8 @@ extern int grpc_tcp_trace;
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 #define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle, char *peer_string); grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle,
grpc_resource_quota *resource_quota,
char *peer_string);
#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */ #endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */

@ -210,11 +210,11 @@ void grpc_security_connector_unref(grpc_security_connector *sc) {
} }
static void connector_pointer_arg_destroy(void *p) { static void connector_pointer_arg_destroy(void *p) {
GRPC_SECURITY_CONNECTOR_UNREF(p, "connector_pointer_arg"); GRPC_SECURITY_CONNECTOR_UNREF(p, "connector_pointer_arg_destroy");
} }
static void *connector_pointer_arg_copy(void *p) { static void *connector_pointer_arg_copy(void *p) {
return GRPC_SECURITY_CONNECTOR_REF(p, "connector_pointer_arg"); return GRPC_SECURITY_CONNECTOR_REF(p, "connector_pointer_arg_copy");
} }
static int connector_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); } static int connector_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -31,19 +31,27 @@
* *
*/ */
#ifndef GRPCXX_IMPL_CODEGEN_SYNC_CXX11_H #include "src/core/lib/transport/pid_controller.h"
#define GRPCXX_IMPL_CODEGEN_SYNC_CXX11_H
#include <condition_variable> void grpc_pid_controller_init(grpc_pid_controller *pid_controller,
#include <mutex> double gain_p, double gain_i, double gain_d) {
pid_controller->gain_p = gain_p;
pid_controller->gain_i = gain_i;
pid_controller->gain_d = gain_d;
grpc_pid_controller_reset(pid_controller);
}
namespace grpc { void grpc_pid_controller_reset(grpc_pid_controller *pid_controller) {
pid_controller->last_error = 0.0;
pid_controller->error_integral = 0.0;
}
using std::condition_variable; double grpc_pid_controller_update(grpc_pid_controller *pid_controller,
using std::mutex; double error, double dt) {
using std::lock_guard; pid_controller->error_integral += error * dt;
using std::unique_lock; double diff_error = (error - pid_controller->last_error) / dt;
pid_controller->last_error = error;
} // namespace grpc return dt * (pid_controller->gain_p * error +
pid_controller->gain_i * pid_controller->error_integral +
#endif // GRPCXX_IMPL_CODEGEN_SYNC_CXX11_H pid_controller->gain_d * diff_error);
}

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -31,15 +31,34 @@
* *
*/ */
#ifndef GRPCXX_IMPL_CODEGEN_IMPL_SYNC_H #ifndef GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H
#define GRPCXX_IMPL_CODEGEN_IMPL_SYNC_H #define GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H
#include <grpc++/impl/codegen/config.h> /* \file Simple PID controller.
Implements a proportional-integral-derivative controller.
Used when we want to iteratively control a variable to converge some other
observed value to a 'set-point'.
Gains can be set to adjust sensitivity to current error (p), the integral
of error (i), and the derivative of error (d). */
#ifdef GRPC_CXX0X_NO_THREAD typedef struct {
#include <grpc++/impl/codegen/sync_no_cxx11.h> double gain_p;
#else double gain_i;
#include <grpc++/impl/codegen/sync_cxx11.h> double gain_d;
#endif double last_error;
double error_integral;
} grpc_pid_controller;
/** Initialize the controller */
void grpc_pid_controller_init(grpc_pid_controller *pid_controller,
double gain_p, double gain_i, double gain_d);
/** Reset the controller: useful when things have changed significantly */
void grpc_pid_controller_reset(grpc_pid_controller *pid_controller);
#endif // GRPCXX_IMPL_CODEGEN_IMPL_SYNC_H /** Update the controller: given a current error estimate, and the time since
the last update, returns a delta to the control value */
double grpc_pid_controller_update(grpc_pid_controller *pid_controller,
double error, double dt);
#endif

@ -31,9 +31,6 @@
* *
*/ */
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils.h"
#include "src/core/lib/tsi/ssl_transport_security.h" #include "src/core/lib/tsi/ssl_transport_security.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -41,6 +38,15 @@
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
/* TODO(jboeuf): refactor inet_ntop into a portability header. */
/* Note: for whomever reads this and tries to refactor this, this
can't be in grpc, it has to be in gpr. */
#ifdef GPR_WINDOWS
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#endif
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
@ -349,7 +355,7 @@ static tsi_result add_subject_alt_names_properties_to_peer(
result = TSI_INTERNAL_ERROR; result = TSI_INTERNAL_ERROR;
break; break;
} }
const char *name = grpc_inet_ntop(af, subject_alt_name->d.iPAddress->data, const char *name = inet_ntop(af, subject_alt_name->d.iPAddress->data,
ntop_buf, INET6_ADDRSTRLEN); ntop_buf, INET6_ADDRSTRLEN);
if (name == NULL) { if (name == NULL) {
gpr_log(GPR_ERROR, "Could not get IP string from asn1 octet."); gpr_log(GPR_ERROR, "Could not get IP string from asn1 octet.");

@ -106,11 +106,11 @@ grpc_connectivity_state Channel::GetState(bool try_to_connect) {
} }
namespace { namespace {
class TagSaver GRPC_FINAL : public CompletionQueueTag { class TagSaver final : public CompletionQueueTag {
public: public:
explicit TagSaver(void* tag) : tag_(tag) {} explicit TagSaver(void* tag) : tag_(tag) {}
~TagSaver() GRPC_OVERRIDE {} ~TagSaver() override {}
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
*tag = tag_; *tag = tag_;
delete this; delete this;
return true; return true;

@ -45,12 +45,12 @@
namespace grpc { namespace grpc {
class DefaultGlobalClientCallbacks GRPC_FINAL class DefaultGlobalClientCallbacks final
: public ClientContext::GlobalCallbacks { : public ClientContext::GlobalCallbacks {
public: public:
~DefaultGlobalClientCallbacks() GRPC_OVERRIDE {} ~DefaultGlobalClientCallbacks() override {}
void DefaultConstructor(ClientContext* context) GRPC_OVERRIDE {} void DefaultConstructor(ClientContext* context) override {}
void Destructor(ClientContext* context) GRPC_OVERRIDE {} void Destructor(ClientContext* context) override {}
}; };
static DefaultGlobalClientCallbacks g_default_client_callbacks; static DefaultGlobalClientCallbacks g_default_client_callbacks;
@ -93,7 +93,7 @@ void ClientContext::AddMetadata(const grpc::string& meta_key,
void ClientContext::set_call(grpc_call* call, void ClientContext::set_call(grpc_call* call,
const std::shared_ptr<Channel>& channel) { const std::shared_ptr<Channel>& channel) {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
GPR_ASSERT(call_ == nullptr); GPR_ASSERT(call_ == nullptr);
call_ = call; call_ = call;
channel_ = channel; channel_ = channel;
@ -119,7 +119,7 @@ void ClientContext::set_compression_algorithm(
} }
void ClientContext::TryCancel() { void ClientContext::TryCancel() {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (call_) { if (call_) {
grpc_call_cancel(call_, nullptr); grpc_call_cancel(call_, nullptr);
} else { } else {

@ -40,12 +40,12 @@
namespace grpc { namespace grpc {
class CronetChannelCredentialsImpl GRPC_FINAL : public ChannelCredentials { class CronetChannelCredentialsImpl final : public ChannelCredentials {
public: public:
CronetChannelCredentialsImpl(void* engine) : engine_(engine) {} CronetChannelCredentialsImpl(void* engine) : engine_(engine) {}
std::shared_ptr<grpc::Channel> CreateChannel( std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) GRPC_OVERRIDE { const string& target, const grpc::ChannelArguments& args) override {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
return CreateChannelInternal( return CreateChannelInternal(
@ -53,9 +53,7 @@ class CronetChannelCredentialsImpl GRPC_FINAL : public ChannelCredentials {
&channel_args, nullptr)); &channel_args, nullptr));
} }
SecureChannelCredentials* AsSecureCredentials() GRPC_OVERRIDE { SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }
return nullptr;
}
private: private:
void* engine_; void* engine_;

@ -43,10 +43,10 @@
namespace grpc { namespace grpc {
namespace { namespace {
class InsecureChannelCredentialsImpl GRPC_FINAL : public ChannelCredentials { class InsecureChannelCredentialsImpl final : public ChannelCredentials {
public: public:
std::shared_ptr<grpc::Channel> CreateChannel( std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) GRPC_OVERRIDE { const string& target, const grpc::ChannelArguments& args) override {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
return CreateChannelInternal( return CreateChannelInternal(
@ -54,9 +54,7 @@ class InsecureChannelCredentialsImpl GRPC_FINAL : public ChannelCredentials {
grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr)); grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr));
} }
SecureChannelCredentials* AsSecureCredentials() GRPC_OVERRIDE { SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }
return nullptr;
}
}; };
} // namespace } // namespace

@ -43,34 +43,34 @@
namespace grpc { namespace grpc {
class SecureChannelCredentials GRPC_FINAL : public ChannelCredentials { class SecureChannelCredentials final : public ChannelCredentials {
public: public:
explicit SecureChannelCredentials(grpc_channel_credentials* c_creds); explicit SecureChannelCredentials(grpc_channel_credentials* c_creds);
~SecureChannelCredentials() { grpc_channel_credentials_release(c_creds_); } ~SecureChannelCredentials() { grpc_channel_credentials_release(c_creds_); }
grpc_channel_credentials* GetRawCreds() { return c_creds_; } grpc_channel_credentials* GetRawCreds() { return c_creds_; }
std::shared_ptr<grpc::Channel> CreateChannel( std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) GRPC_OVERRIDE; const string& target, const grpc::ChannelArguments& args) override;
SecureChannelCredentials* AsSecureCredentials() GRPC_OVERRIDE { return this; } SecureChannelCredentials* AsSecureCredentials() override { return this; }
private: private:
grpc_channel_credentials* const c_creds_; grpc_channel_credentials* const c_creds_;
}; };
class SecureCallCredentials GRPC_FINAL : public CallCredentials { class SecureCallCredentials final : public CallCredentials {
public: public:
explicit SecureCallCredentials(grpc_call_credentials* c_creds); explicit SecureCallCredentials(grpc_call_credentials* c_creds);
~SecureCallCredentials() { grpc_call_credentials_release(c_creds_); } ~SecureCallCredentials() { grpc_call_credentials_release(c_creds_); }
grpc_call_credentials* GetRawCreds() { return c_creds_; } grpc_call_credentials* GetRawCreds() { return c_creds_; }
bool ApplyToCall(grpc_call* call) GRPC_OVERRIDE; bool ApplyToCall(grpc_call* call) override;
SecureCallCredentials* AsSecureCredentials() GRPC_OVERRIDE { return this; } SecureCallCredentials* AsSecureCredentials() override { return this; }
private: private:
grpc_call_credentials* const c_creds_; grpc_call_credentials* const c_creds_;
}; };
class MetadataCredentialsPluginWrapper GRPC_FINAL { class MetadataCredentialsPluginWrapper final {
public: public:
static void Destroy(void* wrapper); static void Destroy(void* wrapper);
static void GetMetadata(void* wrapper, grpc_auth_metadata_context context, static void GetMetadata(void* wrapper, grpc_auth_metadata_context context,

@ -121,6 +121,11 @@ void ChannelArguments::SetResourceQuota(
grpc_resource_quota_arg_vtable()); grpc_resource_quota_arg_vtable());
} }
void ChannelArguments::SetLoadBalancingPolicyName(
const grpc::string& lb_policy_name) {
SetString(GRPC_ARG_LB_POLICY_NAME, lb_policy_name);
}
void ChannelArguments::SetInt(const grpc::string& key, int value) { void ChannelArguments::SetInt(const grpc::string& key, int value) {
grpc_arg arg; grpc_arg arg;
arg.type = GRPC_ARG_INTEGER; arg.type = GRPC_ARG_INTEGER;

@ -268,7 +268,7 @@ namespace internal {
// Members of this class correspond to the members of the C // Members of this class correspond to the members of the C
// grpc_channel_filter struct. // grpc_channel_filter struct.
template <typename ChannelDataType, typename CallDataType> template <typename ChannelDataType, typename CallDataType>
class ChannelFilter GRPC_FINAL { class ChannelFilter final {
public: public:
static const size_t channel_data_size = sizeof(ChannelDataType); static const size_t channel_data_size = sizeof(ChannelDataType);

@ -40,30 +40,29 @@ struct grpc_auth_context;
namespace grpc { namespace grpc {
class SecureAuthContext GRPC_FINAL : public AuthContext { class SecureAuthContext final : public AuthContext {
public: public:
SecureAuthContext(grpc_auth_context* ctx, bool take_ownership); SecureAuthContext(grpc_auth_context* ctx, bool take_ownership);
~SecureAuthContext() GRPC_OVERRIDE; ~SecureAuthContext() override;
bool IsPeerAuthenticated() const GRPC_OVERRIDE; bool IsPeerAuthenticated() const override;
std::vector<grpc::string_ref> GetPeerIdentity() const GRPC_OVERRIDE; std::vector<grpc::string_ref> GetPeerIdentity() const override;
grpc::string GetPeerIdentityPropertyName() const GRPC_OVERRIDE; grpc::string GetPeerIdentityPropertyName() const override;
std::vector<grpc::string_ref> FindPropertyValues( std::vector<grpc::string_ref> FindPropertyValues(
const grpc::string& name) const GRPC_OVERRIDE; const grpc::string& name) const override;
AuthPropertyIterator begin() const GRPC_OVERRIDE; AuthPropertyIterator begin() const override;
AuthPropertyIterator end() const GRPC_OVERRIDE; AuthPropertyIterator end() const override;
void AddProperty(const grpc::string& key, void AddProperty(const grpc::string& key,
const grpc::string_ref& value) GRPC_OVERRIDE; const grpc::string_ref& value) override;
virtual bool SetPeerIdentityPropertyName(const grpc::string& name) virtual bool SetPeerIdentityPropertyName(const grpc::string& name) override;
GRPC_OVERRIDE;
private: private:
grpc_auth_context* ctx_; grpc_auth_context* ctx_;

@ -31,35 +31,18 @@
* *
*/ */
/*
- If the generated header `grpc++/ext/reflection.grpc.pb.h` needs to be
installed, target `grpc++_reflection` in `build.yaml` should use the
filegroup `grpc++_reflection_proto`, and GRPC_NO_GENERATED_CODE should not
be defined.
- If the server reflection library needs to generate `reflection.grpc.pb.h`
from `reflection.proto` at compile time, the generated header
`grpc++/ext/reflection.grpc.pb.h` should not be installed. In this case,
target `grpc++_reflection` should depend on `grpc++_reflection_codegen`, and
GRPC_NO_GENERATED_CODE should be defined.
*/
#ifndef GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H #ifndef GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H
#define GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H #define GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
// GRPC_NO_GENERATED_CODE indicates generated pb files should not be used
#ifdef GRPC_NO_GENERATED_CODE
#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h"
#else
#include <grpc++/ext/reflection.grpc.pb.h>
#endif // GRPC_NO_GENERATED_CODE
#include <grpc++/grpc++.h> #include <grpc++/grpc++.h>
#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h"
namespace grpc { namespace grpc {
class ProtoServerReflection GRPC_FINAL class ProtoServerReflection final
: public reflection::v1alpha::ServerReflection::Service { : public reflection::v1alpha::ServerReflection::Service {
public: public:
ProtoServerReflection(); ProtoServerReflection();
@ -73,7 +56,7 @@ class ProtoServerReflection GRPC_FINAL
ServerContext* context, ServerContext* context,
ServerReaderWriter<reflection::v1alpha::ServerReflectionResponse, ServerReaderWriter<reflection::v1alpha::ServerReflectionResponse,
reflection::v1alpha::ServerReflectionRequest>* stream) reflection::v1alpha::ServerReflectionRequest>* stream)
GRPC_OVERRIDE; override;
private: private:
Status ListService(ServerContext* context, Status ListService(ServerContext* context,

@ -1,97 +0,0 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
// Generated by tools/codegen/extensions/gen_reflection_proto.sh
// If you make any local change, they will be lost.
// source: reflection.proto
#include <grpc++/ext/reflection.pb.h>
#include <grpc++/ext/reflection.grpc.pb.h>
#include <grpc++/impl/codegen/async_stream.h>
#include <grpc++/impl/codegen/async_unary_call.h>
#include <grpc++/impl/codegen/channel_interface.h>
#include <grpc++/impl/codegen/client_unary_call.h>
#include <grpc++/impl/codegen/method_handler_impl.h>
#include <grpc++/impl/codegen/rpc_service_method.h>
#include <grpc++/impl/codegen/service_type.h>
#include <grpc++/impl/codegen/sync_stream.h>
namespace grpc {
namespace reflection {
namespace v1alpha {
static const char* ServerReflection_method_names[] = {
"/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo",
};
std::unique_ptr< ServerReflection::Stub> ServerReflection::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
std::unique_ptr< ServerReflection::Stub> stub(new ServerReflection::Stub(channel));
return stub;
}
ServerReflection::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
: channel_(channel), rpcmethod_ServerReflectionInfo_(ServerReflection_method_names[0], ::grpc::RpcMethod::BIDI_STREAMING, channel)
{}
::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* ServerReflection::Stub::ServerReflectionInfoRaw(::grpc::ClientContext* context) {
return new ::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>(channel_.get(), rpcmethod_ServerReflectionInfo_, context);
}
::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* ServerReflection::Stub::AsyncServerReflectionInfoRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
return new ::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>(channel_.get(), cq, rpcmethod_ServerReflectionInfo_, context, tag);
}
ServerReflection::Service::Service() {
(void)ServerReflection_method_names;
AddMethod(new ::grpc::RpcServiceMethod(
ServerReflection_method_names[0],
::grpc::RpcMethod::BIDI_STREAMING,
new ::grpc::BidiStreamingHandler< ServerReflection::Service, ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>(
std::mem_fn(&ServerReflection::Service::ServerReflectionInfo), this)));
}
ServerReflection::Service::~Service() {
}
::grpc::Status ServerReflection::Service::ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream) {
(void) context;
(void) stream;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
} // namespace grpc
} // namespace reflection
} // namespace v1alpha

File diff suppressed because it is too large Load Diff

@ -31,15 +31,15 @@
* *
*/ */
#include <grpc++/impl/sync.h> #include <mutex>
#include <grpc++/impl/thd.h> #include <thread>
#include "src/cpp/server/dynamic_thread_pool.h" #include "src/cpp/server/dynamic_thread_pool.h"
namespace grpc { namespace grpc {
DynamicThreadPool::DynamicThread::DynamicThread(DynamicThreadPool* pool) DynamicThreadPool::DynamicThread::DynamicThread(DynamicThreadPool* pool)
: pool_(pool), : pool_(pool),
thd_(new grpc::thread(&DynamicThreadPool::DynamicThread::ThreadFunc, thd_(new std::thread(&DynamicThreadPool::DynamicThread::ThreadFunc,
this)) {} this)) {}
DynamicThreadPool::DynamicThread::~DynamicThread() { DynamicThreadPool::DynamicThread::~DynamicThread() {
thd_->join(); thd_->join();
@ -49,7 +49,7 @@ DynamicThreadPool::DynamicThread::~DynamicThread() {
void DynamicThreadPool::DynamicThread::ThreadFunc() { void DynamicThreadPool::DynamicThread::ThreadFunc() {
pool_->ThreadFunc(); pool_->ThreadFunc();
// Now that we have killed ourselves, we should reduce the thread count // Now that we have killed ourselves, we should reduce the thread count
grpc::unique_lock<grpc::mutex> lock(pool_->mu_); std::unique_lock<std::mutex> lock(pool_->mu_);
pool_->nthreads_--; pool_->nthreads_--;
// Move ourselves to dead list // Move ourselves to dead list
pool_->dead_threads_.push_back(this); pool_->dead_threads_.push_back(this);
@ -62,7 +62,7 @@ void DynamicThreadPool::DynamicThread::ThreadFunc() {
void DynamicThreadPool::ThreadFunc() { void DynamicThreadPool::ThreadFunc() {
for (;;) { for (;;) {
// Wait until work is available or we are shutting down. // Wait until work is available or we are shutting down.
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (!shutdown_ && callbacks_.empty()) { if (!shutdown_ && callbacks_.empty()) {
// If there are too many threads waiting, then quit this thread // If there are too many threads waiting, then quit this thread
if (threads_waiting_ >= reserve_threads_) { if (threads_waiting_ >= reserve_threads_) {
@ -91,7 +91,7 @@ DynamicThreadPool::DynamicThreadPool(int reserve_threads)
nthreads_(0), nthreads_(0),
threads_waiting_(0) { threads_waiting_(0) {
for (int i = 0; i < reserve_threads_; i++) { for (int i = 0; i < reserve_threads_; i++) {
grpc::lock_guard<grpc::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
nthreads_++; nthreads_++;
new DynamicThread(this); new DynamicThread(this);
} }
@ -104,7 +104,7 @@ void DynamicThreadPool::ReapThreads(std::list<DynamicThread*>* tlist) {
} }
DynamicThreadPool::~DynamicThreadPool() { DynamicThreadPool::~DynamicThreadPool() {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
shutdown_ = true; shutdown_ = true;
cv_.notify_all(); cv_.notify_all();
while (nthreads_ != 0) { while (nthreads_ != 0) {
@ -114,7 +114,7 @@ DynamicThreadPool::~DynamicThreadPool() {
} }
void DynamicThreadPool::Add(const std::function<void()>& callback) { void DynamicThreadPool::Add(const std::function<void()>& callback) {
grpc::lock_guard<grpc::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
// Add works to the callbacks list // Add works to the callbacks list
callbacks_.push(callback); callbacks_.push(callback);
// Increase pool size or notify as needed // Increase pool size or notify as needed

@ -34,24 +34,25 @@
#ifndef GRPC_INTERNAL_CPP_DYNAMIC_THREAD_POOL_H #ifndef GRPC_INTERNAL_CPP_DYNAMIC_THREAD_POOL_H
#define GRPC_INTERNAL_CPP_DYNAMIC_THREAD_POOL_H #define GRPC_INTERNAL_CPP_DYNAMIC_THREAD_POOL_H
#include <condition_variable>
#include <list> #include <list>
#include <memory> #include <memory>
#include <mutex>
#include <queue> #include <queue>
#include <thread>
#include <grpc++/impl/sync.h>
#include <grpc++/impl/thd.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
#include "src/cpp/server/thread_pool_interface.h" #include "src/cpp/server/thread_pool_interface.h"
namespace grpc { namespace grpc {
class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface { class DynamicThreadPool final : public ThreadPoolInterface {
public: public:
explicit DynamicThreadPool(int reserve_threads); explicit DynamicThreadPool(int reserve_threads);
~DynamicThreadPool(); ~DynamicThreadPool();
void Add(const std::function<void()>& callback) GRPC_OVERRIDE; void Add(const std::function<void()>& callback) override;
private: private:
class DynamicThread { class DynamicThread {
@ -61,12 +62,12 @@ class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface {
private: private:
DynamicThreadPool* pool_; DynamicThreadPool* pool_;
std::unique_ptr<grpc::thread> thd_; std::unique_ptr<std::thread> thd_;
void ThreadFunc(); void ThreadFunc();
}; };
grpc::mutex mu_; std::mutex mu_;
grpc::condition_variable cv_; std::condition_variable cv_;
grpc::condition_variable shutdown_cv_; std::condition_variable shutdown_cv_;
bool shutdown_; bool shutdown_;
std::queue<std::function<void()>> callbacks_; std::queue<std::function<void()>> callbacks_;
int reserve_threads_; int reserve_threads_;

@ -38,14 +38,13 @@
namespace grpc { namespace grpc {
namespace { namespace {
class InsecureServerCredentialsImpl GRPC_FINAL : public ServerCredentials { class InsecureServerCredentialsImpl final : public ServerCredentials {
public: public:
int AddPortToServer(const grpc::string& addr, int AddPortToServer(const grpc::string& addr, grpc_server* server) override {
grpc_server* server) GRPC_OVERRIDE {
return grpc_server_add_insecure_http2_port(server, addr.c_str()); return grpc_server_add_insecure_http2_port(server, addr.c_str());
} }
void SetAuthMetadataProcessor( void SetAuthMetadataProcessor(
const std::shared_ptr<AuthMetadataProcessor>& processor) GRPC_OVERRIDE { const std::shared_ptr<AuthMetadataProcessor>& processor) override {
(void)processor; (void)processor;
GPR_ASSERT(0); // Should not be called on InsecureServerCredentials. GPR_ASSERT(0); // Should not be called on InsecureServerCredentials.
} }

@ -44,7 +44,7 @@
namespace grpc { namespace grpc {
class AuthMetadataProcessorAyncWrapper GRPC_FINAL { class AuthMetadataProcessorAyncWrapper final {
public: public:
static void Destroy(void* wrapper); static void Destroy(void* wrapper);
@ -64,19 +64,18 @@ class AuthMetadataProcessorAyncWrapper GRPC_FINAL {
std::shared_ptr<AuthMetadataProcessor> processor_; std::shared_ptr<AuthMetadataProcessor> processor_;
}; };
class SecureServerCredentials GRPC_FINAL : public ServerCredentials { class SecureServerCredentials final : public ServerCredentials {
public: public:
explicit SecureServerCredentials(grpc_server_credentials* creds) explicit SecureServerCredentials(grpc_server_credentials* creds)
: creds_(creds) {} : creds_(creds) {}
~SecureServerCredentials() GRPC_OVERRIDE { ~SecureServerCredentials() override {
grpc_server_credentials_release(creds_); grpc_server_credentials_release(creds_);
} }
int AddPortToServer(const grpc::string& addr, int AddPortToServer(const grpc::string& addr, grpc_server* server) override;
grpc_server* server) GRPC_OVERRIDE;
void SetAuthMetadataProcessor( void SetAuthMetadataProcessor(
const std::shared_ptr<AuthMetadataProcessor>& processor) GRPC_OVERRIDE; const std::shared_ptr<AuthMetadataProcessor>& processor) override;
private: private:
grpc_server_credentials* creds_; grpc_server_credentials* creds_;

@ -55,11 +55,11 @@
namespace grpc { namespace grpc {
class DefaultGlobalCallbacks GRPC_FINAL : public Server::GlobalCallbacks { class DefaultGlobalCallbacks final : public Server::GlobalCallbacks {
public: public:
~DefaultGlobalCallbacks() GRPC_OVERRIDE {} ~DefaultGlobalCallbacks() override {}
void PreSynchronousRequest(ServerContext* context) GRPC_OVERRIDE {} void PreSynchronousRequest(ServerContext* context) override {}
void PostSynchronousRequest(ServerContext* context) GRPC_OVERRIDE {} void PostSynchronousRequest(ServerContext* context) override {}
}; };
static std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr; static std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr;
@ -79,7 +79,7 @@ class Server::UnimplementedAsyncRequestContext {
GenericServerAsyncReaderWriter generic_stream_; GenericServerAsyncReaderWriter generic_stream_;
}; };
class Server::UnimplementedAsyncRequest GRPC_FINAL class Server::UnimplementedAsyncRequest final
: public UnimplementedAsyncRequestContext, : public UnimplementedAsyncRequestContext,
public GenericAsyncRequest { public GenericAsyncRequest {
public: public:
@ -89,7 +89,7 @@ class Server::UnimplementedAsyncRequest GRPC_FINAL
server_(server), server_(server),
cq_(cq) {} cq_(cq) {}
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; bool FinalizeResult(void** tag, bool* status) override;
ServerContext* context() { return &server_context_; } ServerContext* context() { return &server_context_; }
GenericServerAsyncReaderWriter* stream() { return &generic_stream_; } GenericServerAsyncReaderWriter* stream() { return &generic_stream_; }
@ -101,13 +101,13 @@ class Server::UnimplementedAsyncRequest GRPC_FINAL
typedef SneakyCallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> typedef SneakyCallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus>
UnimplementedAsyncResponseOp; UnimplementedAsyncResponseOp;
class Server::UnimplementedAsyncResponse GRPC_FINAL class Server::UnimplementedAsyncResponse final
: public UnimplementedAsyncResponseOp { : public UnimplementedAsyncResponseOp {
public: public:
UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); UnimplementedAsyncResponse(UnimplementedAsyncRequest* request);
~UnimplementedAsyncResponse() { delete request_; } ~UnimplementedAsyncResponse() { delete request_; }
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
bool r = UnimplementedAsyncResponseOp::FinalizeResult(tag, status); bool r = UnimplementedAsyncResponseOp::FinalizeResult(tag, status);
delete this; delete this;
return r; return r;
@ -122,7 +122,7 @@ class ShutdownTag : public CompletionQueueTag {
bool FinalizeResult(void** tag, bool* status) { return false; } bool FinalizeResult(void** tag, bool* status) { return false; }
}; };
class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { class Server::SyncRequest final : public CompletionQueueTag {
public: public:
SyncRequest(RpcServiceMethod* method, void* tag) SyncRequest(RpcServiceMethod* method, void* tag)
: method_(method), : method_(method),
@ -170,7 +170,7 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
} }
} }
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) override {
if (!*status) { if (!*status) {
grpc_completion_queue_destroy(cq_); grpc_completion_queue_destroy(cq_);
} }
@ -182,7 +182,7 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
return true; return true;
} }
class CallData GRPC_FINAL { class CallData final {
public: public:
explicit CallData(Server* server, SyncRequest* mrd) explicit CallData(Server* server, SyncRequest* mrd)
: cq_(mrd->cq_), : cq_(mrd->cq_),
@ -255,7 +255,7 @@ class Server::SyncRequestThreadManager : public ThreadManager {
cq_timeout_msec_(cq_timeout_msec), cq_timeout_msec_(cq_timeout_msec),
global_callbacks_(global_callbacks) {} global_callbacks_(global_callbacks) {}
WorkStatus PollForWork(void** tag, bool* ok) GRPC_OVERRIDE { WorkStatus PollForWork(void** tag, bool* ok) override {
*tag = nullptr; *tag = nullptr;
gpr_timespec deadline = gpr_timespec deadline =
gpr_time_from_millis(cq_timeout_msec_, GPR_TIMESPAN); gpr_time_from_millis(cq_timeout_msec_, GPR_TIMESPAN);
@ -272,7 +272,7 @@ class Server::SyncRequestThreadManager : public ThreadManager {
GPR_UNREACHABLE_CODE(return TIMEOUT); GPR_UNREACHABLE_CODE(return TIMEOUT);
} }
void DoWork(void* tag, bool ok) GRPC_OVERRIDE { void DoWork(void* tag, bool ok) override {
SyncRequest* sync_req = static_cast<SyncRequest*>(tag); SyncRequest* sync_req = static_cast<SyncRequest*>(tag);
if (!sync_req) { if (!sync_req) {
@ -379,7 +379,7 @@ Server::Server(
Server::~Server() { Server::~Server() {
{ {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (started_ && !shutdown_) { if (started_ && !shutdown_) {
lock.unlock(); lock.unlock();
Shutdown(); Shutdown();
@ -501,7 +501,7 @@ bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
} }
void Server::ShutdownInternal(gpr_timespec deadline) { void Server::ShutdownInternal(gpr_timespec deadline) {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (started_ && !shutdown_) { if (started_ && !shutdown_) {
shutdown_ = true; shutdown_ = true;
@ -549,7 +549,7 @@ void Server::ShutdownInternal(gpr_timespec deadline) {
} }
void Server::Wait() { void Server::Wait() {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
while (started_ && !shutdown_notified_) { while (started_ && !shutdown_notified_) {
shutdown_cv_.wait(lock); shutdown_cv_.wait(lock);
} }

@ -33,9 +33,10 @@
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
#include <mutex>
#include <grpc++/completion_queue.h> #include <grpc++/completion_queue.h>
#include <grpc++/impl/call.h> #include <grpc++/impl/call.h>
#include <grpc++/impl/sync.h>
#include <grpc++/support/time.h> #include <grpc++/support/time.h>
#include <grpc/compression.h> #include <grpc/compression.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -48,7 +49,7 @@ namespace grpc {
// CompletionOp // CompletionOp
class ServerContext::CompletionOp GRPC_FINAL : public CallOpSetInterface { class ServerContext::CompletionOp final : public CallOpSetInterface {
public: public:
// initial refs: one in the server context, one in the cq // initial refs: one in the server context, one in the cq
CompletionOp() CompletionOp()
@ -58,8 +59,8 @@ class ServerContext::CompletionOp GRPC_FINAL : public CallOpSetInterface {
finalized_(false), finalized_(false),
cancelled_(0) {} cancelled_(0) {}
void FillOps(grpc_op* ops, size_t* nops) GRPC_OVERRIDE; void FillOps(grpc_op* ops, size_t* nops) override;
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; bool FinalizeResult(void** tag, bool* status) override;
bool CheckCancelled(CompletionQueue* cq) { bool CheckCancelled(CompletionQueue* cq) {
cq->TryPluck(this); cq->TryPluck(this);
@ -76,20 +77,20 @@ class ServerContext::CompletionOp GRPC_FINAL : public CallOpSetInterface {
private: private:
bool CheckCancelledNoPluck() { bool CheckCancelledNoPluck() {
grpc::lock_guard<grpc::mutex> g(mu_); std::lock_guard<std::mutex> g(mu_);
return finalized_ ? (cancelled_ != 0) : false; return finalized_ ? (cancelled_ != 0) : false;
} }
bool has_tag_; bool has_tag_;
void* tag_; void* tag_;
grpc::mutex mu_; std::mutex mu_;
int refs_; int refs_;
bool finalized_; bool finalized_;
int cancelled_; int cancelled_;
}; };
void ServerContext::CompletionOp::Unref() { void ServerContext::CompletionOp::Unref() {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (--refs_ == 0) { if (--refs_ == 0) {
lock.unlock(); lock.unlock();
delete this; delete this;
@ -105,7 +106,7 @@ void ServerContext::CompletionOp::FillOps(grpc_op* ops, size_t* nops) {
} }
bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) { bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
finalized_ = true; finalized_ = true;
bool ret = false; bool ret = false;
if (has_tag_) { if (has_tag_) {

@ -31,12 +31,13 @@
* *
*/ */
#include <grpc++/impl/sync.h> #include "src/cpp/thread_manager/thread_manager.h"
#include <grpc++/impl/thd.h>
#include <grpc/support/log.h>
#include <climits> #include <climits>
#include <mutex>
#include <thread>
#include "src/cpp/thread_manager/thread_manager.h" #include <grpc/support/log.h>
namespace grpc { namespace grpc {
@ -59,7 +60,7 @@ ThreadManager::ThreadManager(int min_pollers, int max_pollers)
ThreadManager::~ThreadManager() { ThreadManager::~ThreadManager() {
{ {
std::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
GPR_ASSERT(num_threads_ == 0); GPR_ASSERT(num_threads_ == 0);
} }
@ -67,29 +68,29 @@ ThreadManager::~ThreadManager() {
} }
void ThreadManager::Wait() { void ThreadManager::Wait() {
std::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
while (num_threads_ != 0) { while (num_threads_ != 0) {
shutdown_cv_.wait(lock); shutdown_cv_.wait(lock);
} }
} }
void ThreadManager::Shutdown() { void ThreadManager::Shutdown() {
std::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
shutdown_ = true; shutdown_ = true;
} }
bool ThreadManager::IsShutdown() { bool ThreadManager::IsShutdown() {
std::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
return shutdown_; return shutdown_;
} }
void ThreadManager::MarkAsCompleted(WorkerThread* thd) { void ThreadManager::MarkAsCompleted(WorkerThread* thd) {
{ {
std::unique_lock<grpc::mutex> list_lock(list_mu_); std::unique_lock<std::mutex> list_lock(list_mu_);
completed_threads_.push_back(thd); completed_threads_.push_back(thd);
} }
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
num_threads_--; num_threads_--;
if (num_threads_ == 0) { if (num_threads_ == 0) {
shutdown_cv_.notify_one(); shutdown_cv_.notify_one();
@ -97,7 +98,7 @@ void ThreadManager::MarkAsCompleted(WorkerThread* thd) {
} }
void ThreadManager::CleanupCompletedThreads() { void ThreadManager::CleanupCompletedThreads() {
std::unique_lock<grpc::mutex> lock(list_mu_); std::unique_lock<std::mutex> lock(list_mu_);
for (auto thd = completed_threads_.begin(); thd != completed_threads_.end(); for (auto thd = completed_threads_.begin(); thd != completed_threads_.end();
thd = completed_threads_.erase(thd)) { thd = completed_threads_.erase(thd)) {
delete *thd; delete *thd;
@ -114,7 +115,7 @@ void ThreadManager::Initialize() {
// less than max threshold (i.e max_pollers_) and the total number of threads is // less than max threshold (i.e max_pollers_) and the total number of threads is
// below the maximum threshold, we can let the current thread continue as poller // below the maximum threshold, we can let the current thread continue as poller
bool ThreadManager::MaybeContinueAsPoller() { bool ThreadManager::MaybeContinueAsPoller() {
std::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (shutdown_ || num_pollers_ > max_pollers_) { if (shutdown_ || num_pollers_ > max_pollers_) {
return false; return false;
} }
@ -127,7 +128,7 @@ bool ThreadManager::MaybeContinueAsPoller() {
// threads currently blocked in PollForWork()) is below the threshold (i.e // threads currently blocked in PollForWork()) is below the threshold (i.e
// min_pollers_) and the total number of threads is below the maximum threshold // min_pollers_) and the total number of threads is below the maximum threshold
void ThreadManager::MaybeCreatePoller() { void ThreadManager::MaybeCreatePoller() {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
if (!shutdown_ && num_pollers_ < min_pollers_) { if (!shutdown_ && num_pollers_ < min_pollers_) {
num_pollers_++; num_pollers_++;
num_threads_++; num_threads_++;
@ -156,7 +157,7 @@ void ThreadManager::MainWorkLoop() {
WorkStatus work_status = PollForWork(&tag, &ok); WorkStatus work_status = PollForWork(&tag, &ok);
{ {
grpc::unique_lock<grpc::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
num_pollers_--; num_pollers_--;
if (work_status == TIMEOUT && num_pollers_ > min_pollers_) { if (work_status == TIMEOUT && num_pollers_ > min_pollers_) {

@ -34,11 +34,12 @@
#ifndef GRPC_INTERNAL_CPP_THREAD_MANAGER_H #ifndef GRPC_INTERNAL_CPP_THREAD_MANAGER_H
#define GRPC_INTERNAL_CPP_THREAD_MANAGER_H #define GRPC_INTERNAL_CPP_THREAD_MANAGER_H
#include <condition_variable>
#include <list> #include <list>
#include <memory> #include <memory>
#include <mutex>
#include <thread>
#include <grpc++/impl/sync.h>
#include <grpc++/impl/thd.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
namespace grpc { namespace grpc {
@ -115,7 +116,7 @@ class ThreadManager {
void Run(); void Run();
ThreadManager* thd_mgr_; ThreadManager* thd_mgr_;
grpc::thread thd_; std::thread thd_;
}; };
// The main funtion in ThreadManager // The main funtion in ThreadManager
@ -134,10 +135,10 @@ class ThreadManager {
// Protects shutdown_, num_pollers_ and num_threads_ // Protects shutdown_, num_pollers_ and num_threads_
// TODO: sreek - Change num_pollers and num_threads_ to atomics // TODO: sreek - Change num_pollers and num_threads_ to atomics
grpc::mutex mu_; std::mutex mu_;
bool shutdown_; bool shutdown_;
grpc::condition_variable shutdown_cv_; std::condition_variable shutdown_cv_;
// Number of threads doing polling // Number of threads doing polling
int num_pollers_; int num_pollers_;
@ -150,7 +151,7 @@ class ThreadManager {
// currently polling i.e num_pollers_) // currently polling i.e num_pollers_)
int num_threads_; int num_threads_;
grpc::mutex list_mu_; std::mutex list_mu_;
std::list<WorkerThread*> completed_threads_; std::list<WorkerThread*> completed_threads_;
}; };

@ -32,9 +32,6 @@
*/ */
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
#ifndef GRPC_CXX0X_NO_CHRONO
#include <grpc++/support/time.h> #include <grpc++/support/time.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -91,5 +88,3 @@ system_clock::time_point Timespec2Timepoint(gpr_timespec t) {
} }
} // namespace grpc } // namespace grpc
#endif // !GRPC_CXX0X_NO_CHRONO

@ -1,4 +1,5 @@
#!/bin/bash #!/usr/bin/env python2.7
# Copyright 2015, Google Inc. # Copyright 2015, Google Inc.
# All rights reserved. # All rights reserved.
# #
@ -28,23 +29,25 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e import os
import sys
mkdir -p /var/local/git import glob
git clone /var/local/jenkins/grpc /var/local/git/grpc import yaml
# clone gRPC submodules, use data from locally cloned submodules where possible
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
${name}')
cd /var/local/git/grpc os.chdir(os.path.dirname(sys.argv[0])+'/../..')
# build grpc cpp plugin for generating grpc pb files out = {}
make grpc_cpp_plugin
# generate pb files out['libs'] = [{
tools/codegen/extensions/gen_reflection_proto.sh 'name': 'google_benchmark',
'build': 'private',
'language': 'c++',
'secure': 'no',
'defaults': 'google_benchmark',
'src': sorted(glob.glob('third_party/google_benchmark/src/*.cc')),
'headers': sorted(
glob.glob('third_party/google_benchmark/src/*.h') +
glob.glob('third_party/google_benchmark/include/benchmark/*.h')),
}]
# check if the pb files in the checked out codebase are identical with the newly print yaml.dump(out)
# generated ones
git diff --exit-code

@ -40,18 +40,15 @@
@interface GRPCCall (ChannelArg) @interface GRPCCall (ChannelArg)
/** /**
* Use the provided @c userAgentPrefix at the beginning of the HTTP User Agent * Use the provided @c userAgentPrefix at the beginning of the HTTP User Agent string for all calls
* string for all calls to the specified @c host. * to the specified @c host.
*/ */
+ (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix + (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix forHost:(nonnull NSString *)host;
forHost:(nonnull NSString *)host;
/** The default response size limit is 4MB. Set this to override that default. /** The default response size limit is 4MB. Set this to override that default. */
*/
+ (void)setResponseSizeLimit:(NSUInteger)limit forHost:(nonnull NSString *)host; + (void)setResponseSizeLimit:(NSUInteger)limit forHost:(nonnull NSString *)host;
+ (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE( + (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE("The API for this feature is experimental, "
"The API for this feature is experimental, "
"and might be removed or modified at any " "and might be removed or modified at any "
"time."); "time.");
@end @end

@ -33,21 +33,19 @@
#import "GRPCCall.h" #import "GRPCCall.h"
/** Helpers for setting TLS Trusted Roots, Client Certificates, and Private Key /** Helpers for setting TLS Trusted Roots, Client Certificates, and Private Key */
*/
@interface GRPCCall (ChannelCredentials) @interface GRPCCall (ChannelCredentials)
/** /**
* Use the provided @c pemRootCert as the set of trusted root Certificate * Use the provided @c pemRootCert as the set of trusted root Certificate Authorities for @c host.
* Authorities for @c host.
*/ */
+ (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCert + (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCert
forHost:(nonnull NSString *)host forHost:(nonnull NSString *)host
error:(NSError * _Nullable * _Nullable)errorPtr; error:(NSError * _Nullable * _Nullable)errorPtr;
/** /**
* Configures @c host with TLS/SSL Client Credentials and optionally trusted * Configures @c host with TLS/SSL Client Credentials and optionally trusted root Certificate
* root Certificate Authorities. If @c pemRootCerts is nil, the default CA * Authorities. If @c pemRootCerts is nil, the default CA Certificates bundled with gRPC will be
* Certificates bundled with gRPC will be used. * used.
*/ */
+ (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts + (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts
withPrivateKey:(nullable NSString *)pemPrivateKey withPrivateKey:(nullable NSString *)pemPrivateKey

@ -37,17 +37,15 @@
@interface GRPCCall (OAuth2) @interface GRPCCall (OAuth2)
/** /**
* Setting this property is equivalent to setting "Bearer <passed token>" as the * Setting this property is equivalent to setting "Bearer <passed token>" as the value of the
* value of the request header with key "authorization" (the authorization * request header with key "authorization" (the authorization header). Setting it to nil removes the
* header). Setting it to nil removes the authorization header from the request. * authorization header from the request.
* The value obtained by getting the property is the OAuth2 bearer token if the * The value obtained by getting the property is the OAuth2 bearer token if the authorization header
* authorization header of the request has the form "Bearer <token>", or nil * of the request has the form "Bearer <token>", or nil otherwise.
* otherwise.
*/ */
@property(atomic, copy) NSString *oauth2AccessToken; @property(atomic, copy) NSString *oauth2AccessToken;
/** Returns the value (if any) of the "www-authenticate" response header (the /** Returns the value (if any) of the "www-authenticate" response header (the challenge header). */
* challenge header). */
@property(atomic, readonly) NSString *oauth2ChallengeHeader; @property(atomic, readonly) NSString *oauth2ChallengeHeader;
@end @end

@ -34,36 +34,33 @@
#import "GRPCCall.h" #import "GRPCCall.h"
/** /**
* Methods to let tune down the security of gRPC connections for specific hosts. * Methods to let tune down the security of gRPC connections for specific hosts. These shouldn't be
* These shouldn't be used in releases, but are sometimes needed for testing. * used in releases, but are sometimes needed for testing.
*/ */
@interface GRPCCall (Tests) @interface GRPCCall (Tests)
/** /**
* Establish all SSL connections to the provided host using the passed SSL * Establish all SSL connections to the provided host using the passed SSL target name and the root
* target name and the root certificates found in the file at |certsPath|. * certificates found in the file at |certsPath|.
* *
* Must be called before any gRPC call to that host is made. It's illegal to * Must be called before any gRPC call to that host is made. It's illegal to pass the same host to
* pass the same host to more than one invocation of the methods of this * more than one invocation of the methods of this category.
* category.
*/ */
+ (void)useTestCertsPath:(NSString *)certsPath + (void)useTestCertsPath:(NSString *)certsPath
testName:(NSString *)testName testName:(NSString *)testName
forHost:(NSString *)host; forHost:(NSString *)host;
/** /**
* Establish all connections to the provided host using cleartext instead of * Establish all connections to the provided host using cleartext instead of SSL.
* SSL.
* *
* Must be called before any gRPC call to that host is made. It's illegal to * Must be called before any gRPC call to that host is made. It's illegal to pass the same host to
* pass the same host to more than one invocation of the methods of this * more than one invocation of the methods of this category.
* category.
*/ */
+ (void)useInsecureConnectionsForHost:(NSString *)host; + (void)useInsecureConnectionsForHost:(NSString *)host;
/** /**
* Resets all host configurations to their default values, and flushes all * Resets all host configurations to their default values, and flushes all connections from the
* connections from the cache. * cache.
*/ */
+ (void)resetHostSettings; + (void)resetHostSettings;
@end @end

@ -34,18 +34,17 @@
/** /**
* The gRPC protocol is an RPC protocol on top of HTTP2. * The gRPC protocol is an RPC protocol on top of HTTP2.
* *
* While the most common type of RPC receives only one request message and * While the most common type of RPC receives only one request message and returns only one response
* returns only one response message, the protocol also supports RPCs that * message, the protocol also supports RPCs that return multiple individual messages in a streaming
* return multiple individual messages in a streaming fashion, RPCs that accept * fashion, RPCs that accept a stream of request messages, or RPCs with both streaming requests and
* a stream of request messages, or RPCs with both streaming requests and
* responses. * responses.
* *
* Conceptually, each gRPC call consists of a bidirectional stream of binary * Conceptually, each gRPC call consists of a bidirectional stream of binary messages, with RPCs of
* messages, with RPCs of the "non-streaming type" sending only one message in * the "non-streaming type" sending only one message in the corresponding direction (the protocol
* the corresponding direction (the protocol doesn't make any distinction). * doesn't make any distinction).
* *
* Each RPC uses a different HTTP2 stream, and thus multiple simultaneous RPCs * Each RPC uses a different HTTP2 stream, and thus multiple simultaneous RPCs can be multiplexed
* can be multiplexed transparently on the same TCP connection. * transparently on the same TCP connection.
*/ */
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@ -60,56 +59,51 @@ extern NSString *const kGRPCErrorDomain;
/** /**
* gRPC error codes. * gRPC error codes.
* Note that a few of these are never produced by the gRPC libraries, but are of * Note that a few of these are never produced by the gRPC libraries, but are of general utility for
* general utility for server applications to produce. * server applications to produce.
*/ */
typedef NS_ENUM(NSUInteger, GRPCErrorCode) { typedef NS_ENUM(NSUInteger, GRPCErrorCode) {
/** The operation was cancelled (typically by the caller). */ /** The operation was cancelled (typically by the caller). */
GRPCErrorCodeCancelled = 1, GRPCErrorCodeCancelled = 1,
/** /**
* Unknown error. Errors raised by APIs that do not return enough error * Unknown error. Errors raised by APIs that do not return enough error information may be
* information may be
* converted to this error. * converted to this error.
*/ */
GRPCErrorCodeUnknown = 2, GRPCErrorCodeUnknown = 2,
/** /**
* The client specified an invalid argument. Note that this differs from * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION.
* FAILED_PRECONDITION. * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the
* INVALID_ARGUMENT indicates arguments that are problematic regardless of the * server (e.g., a malformed file name).
* state of the server (e.g., a malformed file name).
*/ */
GRPCErrorCodeInvalidArgument = 3, GRPCErrorCodeInvalidArgument = 3,
/** /**
* Deadline expired before operation could complete. For operations that * Deadline expired before operation could complete. For operations that change the state of the
* change the state of the server, this error may be returned even if the * server, this error may be returned even if the operation has completed successfully. For
* operation has completed successfully. For example, a successful response * example, a successful response from the server could have been delayed long enough for the
* from the server could have been delayed long enough for the deadline to * deadline to expire.
* expire.
*/ */
GRPCErrorCodeDeadlineExceeded = 4, GRPCErrorCodeDeadlineExceeded = 4,
/** Some requested entity (e.g., file or directory) was not found. */ /** Some requested entity (e.g., file or directory) was not found. */
GRPCErrorCodeNotFound = 5, GRPCErrorCodeNotFound = 5,
/** Some entity that we attempted to create (e.g., file or directory) already /** Some entity that we attempted to create (e.g., file or directory) already exists. */
exists. */
GRPCErrorCodeAlreadyExists = 6, GRPCErrorCodeAlreadyExists = 6,
/** /**
* The caller does not have permission to execute the specified operation. * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't
* PERMISSION_DENIED isn't used for rejections caused by exhausting some * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for
* resource (RESOURCE_EXHAUSTED is used instead for those errors). * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller
* PERMISSION_DENIED doesn't indicate a failure to identify the caller
* (UNAUTHENTICATED is used instead for those errors). * (UNAUTHENTICATED is used instead for those errors).
*/ */
GRPCErrorCodePermissionDenied = 7, GRPCErrorCodePermissionDenied = 7,
/** /**
* The request does not have valid authentication credentials for the * The request does not have valid authentication credentials for the operation (e.g. the caller's
* operation (e.g. the caller's identity can't be verified). * identity can't be verified).
*/ */
GRPCErrorCodeUnauthenticated = 16, GRPCErrorCodeUnauthenticated = 16,
@ -117,47 +111,42 @@ typedef NS_ENUM(NSUInteger, GRPCErrorCode) {
GRPCErrorCodeResourceExhausted = 8, GRPCErrorCodeResourceExhausted = 8,
/** /**
* The RPC was rejected because the server is not in a state required for the * The RPC was rejected because the server is not in a state required for the procedure's
* procedure's
* execution. For example, a directory to be deleted may be non-empty, etc. * execution. For example, a directory to be deleted may be non-empty, etc.
* The client should not retry until the server state has been explicitly * The client should not retry until the server state has been explicitly fixed (e.g. by
* fixed (e.g. by * performing another RPC). The details depend on the service being called, and should be found in
* performing another RPC). The details depend on the service being called, * the NSError's userInfo.
* and should be found in the NSError's userInfo.
*/ */
GRPCErrorCodeFailedPrecondition = 9, GRPCErrorCodeFailedPrecondition = 9,
/** /**
* The RPC was aborted, typically due to a concurrency issue like sequencer * The RPC was aborted, typically due to a concurrency issue like sequencer check failures,
* check failures, transaction aborts, etc. The client should retry at a * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read-
* higher-level (e.g., restarting a read-modify-write sequence). * modify-write sequence).
*/ */
GRPCErrorCodeAborted = 10, GRPCErrorCodeAborted = 10,
/** /**
* The RPC was attempted past the valid range. E.g., enumerating past the end * The RPC was attempted past the valid range. E.g., enumerating past the end of a list.
* of a list. * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state
* Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked
* if the system state changes. For example, an RPC to get elements of a list * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return
* will generate INVALID_ARGUMENT if asked to return the element at a negative * the element at an index past the current size of the list.
* index, but it will generate OUT_OF_RANGE if asked to return the element at
* an index past the current size of the list.
*/ */
GRPCErrorCodeOutOfRange = 11, GRPCErrorCodeOutOfRange = 11,
/** The procedure is not implemented or not supported/enabled in this server. /** The procedure is not implemented or not supported/enabled in this server. */
*/
GRPCErrorCodeUnimplemented = 12, GRPCErrorCodeUnimplemented = 12,
/** /**
* Internal error. Means some invariant expected by the server application or * Internal error. Means some invariant expected by the server application or the gRPC library has
* the gRPC library has been broken. * been broken.
*/ */
GRPCErrorCodeInternal = 13, GRPCErrorCodeInternal = 13,
/** /**
* The server is currently unavailable. This is most likely a transient * The server is currently unavailable. This is most likely a transient condition and may be
* condition and may be corrected by retrying with a backoff. * corrected by retrying with a backoff.
*/ */
GRPCErrorCodeUnavailable = 14, GRPCErrorCodeUnavailable = 14,
@ -169,19 +158,17 @@ typedef NS_ENUM(NSUInteger, GRPCErrorCode) {
* Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1
*/ */
typedef NS_ENUM(NSUInteger, GRPCCallSafety) { typedef NS_ENUM(NSUInteger, GRPCCallSafety) {
/** Signal that there is no guarantees on how the call affects the server /** Signal that there is no guarantees on how the call affects the server state. */
state. */
GRPCCallSafetyDefault = 0, GRPCCallSafetyDefault = 0,
/** Signal that the call is idempotent. gRPC is free to use PUT verb. */ /** Signal that the call is idempotent. gRPC is free to use PUT verb. */
GRPCCallSafetyIdempotentRequest = 1, GRPCCallSafetyIdempotentRequest = 1,
/** Signal that the call is cacheable and will not affect server state. gRPC /** Signal that the call is cacheable and will not affect server state. gRPC is free to use GET verb. */
is free to use GET verb. */
GRPCCallSafetyCacheableRequest = 2, GRPCCallSafetyCacheableRequest = 2,
}; };
/** /**
* Keys used in |NSError|'s |userInfo| dictionary to store the response headers * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by
* and trailers sent by the server. * the server.
*/ */
extern id const kGRPCHeadersKey; extern id const kGRPCHeadersKey;
extern id const kGRPCTrailersKey; extern id const kGRPCTrailersKey;
@ -192,24 +179,20 @@ extern id const kGRPCTrailersKey;
@interface GRPCCall : GRXWriter @interface GRPCCall : GRXWriter
/** /**
* The container of the request headers of an RPC conforms to this protocol, * The container of the request headers of an RPC conforms to this protocol, which is a subset of
* which is a subset of NSMutableDictionary's interface. It will become a * NSMutableDictionary's interface. It will become a NSMutableDictionary later on.
* NSMutableDictionary later on. The keys of this container are the header * The keys of this container are the header names, which per the HTTP standard are case-
* names, which per the HTTP standard are case-insensitive. They are stored in * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and
* lowercase (which is how HTTP/2 mandates them on the wire), and can only * can only consist of ASCII characters.
* consist of ASCII characters. * A header value is a NSString object (with only ASCII characters), unless the header name has the
* A header value is a NSString object (with only ASCII characters), unless the * suffix "-bin", in which case the value has to be a NSData object.
* header name has the suffix "-bin", in which case the value has to be a NSData
* object.
*/ */
/** /**
* These HTTP headers will be passed to the server as part of this call. Each * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a
* HTTP header is a name-value pair with string names and either string or * name-value pair with string names and either string or binary values.
* binary values.
* *
* The passed dictionary has to use NSString keys, corresponding to the header * The passed dictionary has to use NSString keys, corresponding to the header names. The value
* names. The value associated to each can be a NSString object or a NSData * associated to each can be a NSString object or a NSData object. E.g.:
* object. E.g.:
* *
* call.requestHeaders = @{@"authorization": @"Bearer ..."}; * call.requestHeaders = @{@"authorization": @"Bearer ..."};
* *
@ -222,61 +205,53 @@ extern id const kGRPCTrailersKey;
@property(atomic, readonly) NSMutableDictionary *requestHeaders; @property(atomic, readonly) NSMutableDictionary *requestHeaders;
/** /**
* This dictionary is populated with the HTTP headers received from the server. * This dictionary is populated with the HTTP headers received from the server. This happens before
* This happens before any response message is received from the server. It has * any response message is received from the server. It has the same structure as the request
* the same structure as the request headers dictionary: Keys are NSString * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a
* header names; names ending with the suffix "-bin" have a NSData value; the * NSData value; the others have a NSString value.
* others have a NSString value.
* *
* The value of this property is nil until all response headers are received, * The value of this property is nil until all response headers are received, and will change before
* and will change before any of -writeValue: or -writesFinishedWithError: are * any of -writeValue: or -writesFinishedWithError: are sent to the writeable.
* sent to the writeable.
*/ */
@property(atomic, readonly) NSDictionary *responseHeaders; @property(atomic, readonly) NSDictionary *responseHeaders;
/** /**
* Same as responseHeaders, but populated with the HTTP trailers received from * Same as responseHeaders, but populated with the HTTP trailers received from the server before the
* the server before the call finishes. * call finishes.
* *
* The value of this property is nil until all response trailers are received, * The value of this property is nil until all response trailers are received, and will change
* and will change before -writesFinishedWithError: is sent to the writeable. * before -writesFinishedWithError: is sent to the writeable.
*/ */
@property(atomic, readonly) NSDictionary *responseTrailers; @property(atomic, readonly) NSDictionary *responseTrailers;
/** /**
* The request writer has to write NSData objects into the provided Writeable. * The request writer has to write NSData objects into the provided Writeable. The server will
* The server will receive each of those separately and in order as distinct * receive each of those separately and in order as distinct messages.
* messages. * A gRPC call might not complete until the request writer finishes. On the other hand, the request
* A gRPC call might not complete until the request writer finishes. On the * finishing doesn't necessarily make the call to finish, as the server might continue sending
* other hand, the request finishing doesn't necessarily make the call to * messages to the response side of the call indefinitely (depending on the semantics of the
* finish, as the server might continue sending messages to the response side of * specific remote method called).
* the call indefinitely (depending on the semantics of the specific remote
* method called).
* To finish a call right away, invoke cancel. * To finish a call right away, invoke cancel.
* host parameter should not contain the scheme (http:// or https://), only the * host parameter should not contain the scheme (http:// or https://), only the name or IP addr
* name or IP addr and the port number, for example @"localhost:5050". * and the port number, for example @"localhost:5050".
*/ */
- (instancetype)initWithHost:(NSString *)host - (instancetype)initWithHost:(NSString *)host
path:(NSString *)path path:(NSString *)path
requestsWriter:(GRXWriter *)requestsWriter requestsWriter:(GRXWriter *)requestsWriter NS_DESIGNATED_INITIALIZER;
NS_DESIGNATED_INITIALIZER;
/** /**
* Finishes the request side of this call, notifies the server that the RPC * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and
* should be cancelled, and finishes the response side of the call with an error * finishes the response side of the call with an error of code CANCELED.
* of code CANCELED.
*/ */
- (void)cancel; - (void)cancel;
/** /**
* Set the call flag for a specific host path. * Set the call flag for a specific host path.
* *
* Host parameter should not contain the scheme (http:// or https://), only the * Host parameter should not contain the scheme (http:// or https://), only the name or IP addr
* name or IP addr and the port number, for example @"localhost:5050". * and the port number, for example @"localhost:5050".
*/ */
+ (void)setCallSafety:(GRPCCallSafety)callSafety + (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path;
host:(NSString *)host
path:(NSString *)path;
// TODO(jcanizales): Let specify a deadline. As a category of GRXWriter? // TODO(jcanizales): Let specify a deadline. As a category of GRXWriter?
@end @end

@ -33,9 +33,9 @@
#import "GRPCCall.h" #import "GRPCCall.h"
#import <RxLibrary/GRXConcurrentWriteable.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#import <RxLibrary/GRXConcurrentWriteable.h>
#import "private/GRPCConnectivityMonitor.h" #import "private/GRPCConnectivityMonitor.h"
#import "private/GRPCHost.h" #import "private/GRPCHost.h"
@ -85,21 +85,17 @@ static NSMutableDictionary *callFlags;
// correct ordering. // correct ordering.
GRXConcurrentWriteable *_responseWriteable; GRXConcurrentWriteable *_responseWriteable;
// The network thread wants the requestWriter to resume (when the server is // The network thread wants the requestWriter to resume (when the server is ready for more input),
// ready for more input), or to stop (on errors), concurrently with user // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop
// threads that want to start it, pause it or stop it. Because a writer isn't // it. Because a writer isn't thread-safe, we'll synchronize those operations on it.
// thread-safe, we'll synchronize those operations on it. // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or
// We don't use a dispatch queue for that purpose, because the writer can call // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to
// writeValue: or writesFinishedWithError: on this GRPCCall as part of those // pause the writer immediately on writeValue:, so we need our locking to be recursive.
// operations. We want to be able to pause the writer immediately on
// writeValue:, so we need our locking to be recursive.
GRXWriter *_requestWriter; GRXWriter *_requestWriter;
// To create a retain cycle when a call is started, up until it finishes. See // To create a retain cycle when a call is started, up until it finishes. See
// |startWithWriteable:| and |finishWithError:|. This saves users from having // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a
// to retain a // reference to the call object if all they're interested in is the handler being executed when
// reference to the call object if all they're interested in is the handler
// being executed when
// the response arrives. // the response arrives.
GRPCCall *_retainSelf; GRPCCall *_retainSelf;
@ -108,16 +104,13 @@ static NSMutableDictionary *callFlags;
@synthesize state = _state; @synthesize state = _state;
// TODO(jcanizales): If grpc_init is idempotent, this should be changed from // TODO(jcanizales): If grpc_init is idempotent, this should be changed from load to initialize.
// load to initialize.
+ (void)load { + (void)load {
grpc_init(); grpc_init();
callFlags = [NSMutableDictionary dictionary]; callFlags = [NSMutableDictionary dictionary];
} }
+ (void)setCallSafety:(GRPCCallSafety)callSafety + (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path {
host:(NSString *)host
path:(NSString *)path {
NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path];
switch (callSafety) { switch (callSafety) {
case GRPCCallSafetyDefault: case GRPCCallSafetyDefault:
@ -148,8 +141,7 @@ static NSMutableDictionary *callFlags;
path:(NSString *)path path:(NSString *)path
requestsWriter:(GRXWriter *)requestWriter { requestsWriter:(GRXWriter *)requestWriter {
if (!host || !path) { if (!host || !path) {
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
format:@"Neither host nor path can be nil."];
} }
if (requestWriter.state != GRXWriterStateNotStarted) { if (requestWriter.state != GRXWriterStateNotStarted) {
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException
@ -199,10 +191,7 @@ static NSMutableDictionary *callFlags;
- (void)cancel { - (void)cancel {
[self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeCancelled code:GRPCErrorCodeCancelled
userInfo:@{ userInfo:@{NSLocalizedDescriptionKey: @"Canceled by app"}]];
NSLocalizedDescriptionKey :
@"Canceled by app"
}]];
[self cancelCall]; [self cancelCall];
} }
@ -219,16 +208,13 @@ static NSMutableDictionary *callFlags;
// The handler will be called from the network queue. // The handler will be called from the network queue.
- (void)startReadWithHandler:(void(^)(grpc_byte_buffer *))handler { - (void)startReadWithHandler:(void(^)(grpc_byte_buffer *))handler {
// TODO(jcanizales): Add error handlers for async failures // TODO(jcanizales): Add error handlers for async failures
[_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] [_wrappedCall startBatchWithOperations:@[[[GRPCOpRecvMessage alloc] initWithHandler:handler]]];
initWithHandler:handler] ]];
} }
// Called initially from the network queue once response headers are received, // Called initially from the network queue once response headers are received,
// then "recursively" from the responseWriteable queue after each response from // then "recursively" from the responseWriteable queue after each response from the
// the
// server has been written. // server has been written.
// If the call is currently paused, this is a noop. Restarting the call will // If the call is currently paused, this is a noop. Restarting the call will invoke this
// invoke this
// method. // method.
// TODO(jcanizales): Rename to readResponseIfNotPaused. // TODO(jcanizales): Rename to readResponseIfNotPaused.
- (void)startNextRead { - (void)startNextRead {
@ -251,21 +237,13 @@ static NSMutableDictionary *callFlags;
// don't want to throw, because the app shouldn't crash for a behavior // don't want to throw, because the app shouldn't crash for a behavior
// that's on the hands of any server to have. Instead we finish and ask // that's on the hands of any server to have. Instead we finish and ask
// the server to cancel. // the server to cancel.
[weakSelf [weakSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
finishWithError:[NSError
errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeResourceExhausted code:GRPCErrorCodeResourceExhausted
userInfo:@{ userInfo:@{NSLocalizedDescriptionKey: @"Client does not have enough memory to hold the server response."}]];
NSLocalizedDescriptionKey :
@"Client does not have enough "
@"memory to hold the server "
@"response."
}]];
[weakSelf cancelCall]; [weakSelf cancelCall];
return; return;
} }
[weakWriteable enqueueValue:data [weakWriteable enqueueValue:data completionHandler:^{
completionHandler:^{
[weakSelf startNextRead]; [weakSelf startNextRead];
}]; }];
}]; }];
@ -276,20 +254,17 @@ static NSMutableDictionary *callFlags;
- (void)sendHeaders:(NSDictionary *)headers { - (void)sendHeaders:(NSDictionary *)headers {
// TODO(jcanizales): Add error handlers for async failures // TODO(jcanizales): Add error handlers for async failures
[_wrappedCall startBatchWithOperations:@[ [_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc] initWithMetadata:headers
[[GRPCOpSendMetadata alloc]
initWithMetadata:headers
flags:[GRPCCall callFlagsForHost:_host path:_path] flags:[GRPCCall callFlagsForHost:_host path:_path]
handler:nil] handler:nil]]];
]];
} }
#pragma mark GRXWriteable implementation #pragma mark GRXWriteable implementation
// Only called from the call queue. The error handler will be called from the // Only called from the call queue. The error handler will be called from the
// network queue if the write didn't succeed. // network queue if the write didn't succeed.
- (void)writeMessage:(NSData *)message - (void)writeMessage:(NSData *)message withErrorHandler:(void (^)())errorHandler {
withErrorHandler:(void (^)())errorHandler {
__weak GRPCCall *weakSelf = self; __weak GRPCCall *weakSelf = self;
void(^resumingHandler)(void) = ^{ void(^resumingHandler)(void) = ^{
// Resume the request writer. // Resume the request writer.
@ -300,8 +275,7 @@ static NSMutableDictionary *callFlags;
} }
} }
}; };
[_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendMessage alloc] [_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMessage alloc] initWithMessage:message
initWithMessage:message
handler:resumingHandler]] handler:resumingHandler]]
errorHandler:errorHandler]; errorHandler:errorHandler];
} }
@ -317,10 +291,8 @@ static NSMutableDictionary *callFlags;
__weak GRPCCall *weakSelf = self; __weak GRPCCall *weakSelf = self;
dispatch_async(_callQueue, ^{ dispatch_async(_callQueue, ^{
[weakSelf writeMessage:value [weakSelf writeMessage:value withErrorHandler:^{
withErrorHandler:^{ [weakSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
[weakSelf
finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeInternal code:GRPCErrorCodeInternal
userInfo:nil]]; userInfo:nil]];
}]; }];
@ -351,18 +323,16 @@ static NSMutableDictionary *callFlags;
#pragma mark Invoke #pragma mark Invoke
// Both handlers will eventually be called, from the network queue. Writes can // Both handlers will eventually be called, from the network queue. Writes can start immediately
// start immediately after this. // after this.
// The first one (headersHandler), when the response headers are received. // The first one (headersHandler), when the response headers are received.
// The second one (completionHandler), whenever the RPC finishes for any reason. // The second one (completionHandler), whenever the RPC finishes for any reason.
- (void)invokeCallWithHeadersHandler:(void(^)(NSDictionary *))headersHandler - (void)invokeCallWithHeadersHandler:(void(^)(NSDictionary *))headersHandler
completionHandler: completionHandler:(void(^)(NSError *, NSDictionary *))completionHandler {
(void (^)(NSError *, NSDictionary *))completionHandler {
// TODO(jcanizales): Add error handlers for async failures // TODO(jcanizales): Add error handlers for async failures
[_wrappedCall startBatchWithOperations:@[[[GRPCOpRecvMetadata alloc] [_wrappedCall startBatchWithOperations:@[[[GRPCOpRecvMetadata alloc]
initWithHandler:headersHandler]]]; initWithHandler:headersHandler]]];
[_wrappedCall [_wrappedCall startBatchWithOperations:@[[[GRPCOpRecvStatus alloc]
startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc]
initWithHandler:completionHandler]]]; initWithHandler:completionHandler]]];
} }
@ -371,8 +341,7 @@ static NSMutableDictionary *callFlags;
// Response headers received. // Response headers received.
self.responseHeaders = headers; self.responseHeaders = headers;
[self startNextRead]; [self startNextRead];
} } completionHandler:^(NSError *error, NSDictionary *trailers) {
completionHandler:^(NSError *error, NSDictionary *trailers) {
self.responseTrailers = trailers; self.responseTrailers = trailers;
if (error) { if (error) {
@ -381,18 +350,15 @@ static NSMutableDictionary *callFlags;
[userInfo addEntriesFromDictionary:error.userInfo]; [userInfo addEntriesFromDictionary:error.userInfo];
} }
userInfo[kGRPCTrailersKey] = self.responseTrailers; userInfo[kGRPCTrailersKey] = self.responseTrailers;
// TODO(jcanizales): The C gRPC library doesn't guarantee that the // TODO(jcanizales): The C gRPC library doesn't guarantee that the headers block will be
// headers block will be called before this one, so an error might end // called before this one, so an error might end up with trailers but no headers. We
// up with trailers but no headers. We shouldn't call finishWithError // shouldn't call finishWithError until ater both blocks are called. It is also when this is
// until ater both blocks are called. It is also when this is done // done that we can provide a merged view of response headers and trailers in a thread-safe
// that we can provide a merged view of response headers and trailers // way.
// in a thread-safe way.
if (self.responseHeaders) { if (self.responseHeaders) {
userInfo[kGRPCHeadersKey] = self.responseHeaders; userInfo[kGRPCHeadersKey] = self.responseHeaders;
} }
error = [NSError errorWithDomain:error.domain error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
code:error.code
userInfo:userInfo];
} }
[self finishWithError:error]; [self finishWithError:error];
}]; }];
@ -409,16 +375,14 @@ static NSMutableDictionary *callFlags;
_state = GRXWriterStateStarted; _state = GRXWriterStateStarted;
} }
// Create a retain cycle so that this instance lives until the RPC finishes // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled).
// (or is cancelled). This makes RPCs in which the call isn't externally // This makes RPCs in which the call isn't externally retained possible (as long as it is started
// retained possible (as long as it is started before being autoreleased). // before being autoreleased).
// Care is taken not to retain self strongly in any of the blocks used in this // Care is taken not to retain self strongly in any of the blocks used in this implementation, so
// implementation, so that the life of the instance is determined by this // that the life of the instance is determined by this retain cycle.
// retain cycle.
_retainSelf = self; _retainSelf = self;
_responseWriteable = _responseWriteable = [[GRXConcurrentWriteable alloc] initWithWriteable:writeable];
[[GRXConcurrentWriteable alloc] initWithWriteable:writeable];
_wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path]; _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path];
NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?"); NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?");
@ -427,37 +391,29 @@ static NSMutableDictionary *callFlags;
[self invokeCall]; [self invokeCall];
// TODO(jcanizales): Extract this logic somewhere common. // TODO(jcanizales): Extract this logic somewhere common.
NSString *host = NSString *host = [NSURL URLWithString:[@"https://" stringByAppendingString:_host]].host;
[NSURL URLWithString:[@"https://" stringByAppendingString:_host]].host;
if (!host) { if (!host) {
// TODO(jcanizales): Check this on init. // TODO(jcanizales): Check this on init.
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException format:@"host of %@ is nil", _host];
format:@"host of %@ is nil", _host];
} }
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
_connectivityMonitor = [GRPCConnectivityMonitor monitorWithHost:host]; _connectivityMonitor = [GRPCConnectivityMonitor monitorWithHost:host];
void (^handler)() = ^{ void (^handler)() = ^{
typeof(self) strongSelf = weakSelf; typeof(self) strongSelf = weakSelf;
if (strongSelf) { if (strongSelf) {
[strongSelf [strongSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeUnavailable code:GRPCErrorCodeUnavailable
userInfo:@{ userInfo:@{ NSLocalizedDescriptionKey : @"Connectivity lost." }]];
NSLocalizedDescriptionKey :
@"Connectivity lost."
}]];
} }
}; };
[_connectivityMonitor handleLossWithHandler:handler [_connectivityMonitor handleLossWithHandler:handler
wifiStatusChangeHandler:^{ wifiStatusChangeHandler:nil];
}];
} }
- (void)setState:(GRXWriterState)newState { - (void)setState:(GRXWriterState)newState {
@synchronized(self) { @synchronized(self) {
// Manual transitions are only allowed from the started or paused states. // Manual transitions are only allowed from the started or paused states.
if (_state == GRXWriterStateNotStarted || if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) {
_state == GRXWriterStateFinished) {
return; return;
} }

@ -37,16 +37,15 @@
typedef void(^GRPCQueueCompletionHandler)(bool success); typedef void(^GRPCQueueCompletionHandler)(bool success);
/** /**
* This class lets one more easily use |grpc_completion_queue|. To use it, pass * This class lets one more easily use |grpc_completion_queue|. To use it, pass the value of the
* the value of the |unmanagedQueue| property of an instance of this class to * |unmanagedQueue| property of an instance of this class to |grpc_channel_create_call|. Then for
* |grpc_channel_create_call|. Then for every |grpc_call_*| method that accepts * every |grpc_call_*| method that accepts a tag, you can pass a block of type
* a tag, you can pass a block of type |GRPCQueueCompletionHandler| (remembering * |GRPCQueueCompletionHandler| (remembering to cast it using |__bridge_retained|). The block is
* to cast it using |__bridge_retained|). The block is guaranteed to eventually * guaranteed to eventually be called, by a concurrent queue, and then released. Each such block is
* be called, by a concurrent queue, and then released. Each such block is
* passed a |bool| that tells if the operation was successful. * passed a |bool| that tells if the operation was successful.
* *
* Release the GRPCCompletionQueue object only after you are not going to pass * Release the GRPCCompletionQueue object only after you are not going to pass any more blocks to
* any more blocks to the |grpc_call| that's using it. * the |grpc_call| that's using it.
*/ */
@interface GRPCCompletionQueue : NSObject @interface GRPCCompletionQueue : NSObject
@property(nonatomic, readonly) grpc_completion_queue *unmanagedQueue; @property(nonatomic, readonly) grpc_completion_queue *unmanagedQueue;

@ -60,19 +60,18 @@
- (nonnull instancetype)init NS_UNAVAILABLE; - (nonnull instancetype)init NS_UNAVAILABLE;
/** /**
* Queue on which callbacks will be dispatched. Default is the main queue. Set * Queue on which callbacks will be dispatched. Default is the main queue. Set it before calling
* it before calling handleLossWithHandler:. * handleLossWithHandler:.
*/ */
// TODO(jcanizales): Default to a serial background queue instead. // TODO(jcanizales): Default to a serial background queue instead.
@property(nonatomic, strong, null_resettable) dispatch_queue_t queue; @property(nonatomic, strong, null_resettable) dispatch_queue_t queue;
/** /**
* Calls handler every time the connectivity to this instance's host is lost. If * Calls handler every time the connectivity to this instance's host is lost. If this instance is
* this instance is released before that happens, the handler won't be called. * released before that happens, the handler won't be called.
* Only one handler is active at a time, so if this method is called again * Only one handler is active at a time, so if this method is called again before the previous
* before the previous handler has been called, it might never be called at all * handler has been called, it might never be called at all (or yes, if it has already been queued).
* (or yes, if it has already been queued).
*/ */
- (void)handleLossWithHandler:(nonnull void (^)())handler - (void)handleLossWithHandler:(nullable void (^)())lossHandler
wifiStatusChangeHandler:(nonnull void (^)())wifiStatusChangeHandler; wifiStatusChangeHandler:(nullable void (^)())wifiStatusChangeHandler;
@end @end

@ -66,12 +66,11 @@
#undef GRPC_XMACRO_ITEM #undef GRPC_XMACRO_ITEM
- (BOOL)isHostReachable { - (BOOL)isHostReachable {
// Note: connectionOnDemand means it'll be reachable only if using the // Note: connectionOnDemand means it'll be reachable only if using the CFSocketStream API or APIs
// CFSocketStream API or APIs on top of it. // on top of it.
// connectionRequired means we can't tell until a connection is attempted // connectionRequired means we can't tell until a connection is attempted (e.g. for VPN on
// (e.g. for VPN on demand). // demand).
return self.reachable && !self.interventionRequired && return self.reachable && !self.interventionRequired && !self.connectionOnDemand;
!self.connectionOnDemand;
} }
- (NSString *)description { - (NSString *)description {
@ -92,9 +91,7 @@
#include "GRPCReachabilityFlagNames.xmacro.h" #include "GRPCReachabilityFlagNames.xmacro.h"
#undef GRPC_XMACRO_ITEM #undef GRPC_XMACRO_ITEM
return activeOptions.count == 0 return activeOptions.count == 0 ? @"(none)" : [activeOptions componentsJoinedByString:@", "];
? @"(none)"
: [activeOptions componentsJoinedByString:@", "];
} }
- (BOOL)isEqual:(id)object { - (BOOL)isEqual:(id)object {
@ -109,16 +106,15 @@
#pragma mark Connectivity Monitor #pragma mark Connectivity Monitor
// Assumes the third argument is a block that accepts a GRPCReachabilityFlags // Assumes the third argument is a block that accepts a GRPCReachabilityFlags object, and passes the
// object, and passes the received ones to it. // received ones to it.
static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target, static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
SCNetworkReachabilityFlags flags, SCNetworkReachabilityFlags flags,
void *info) { void *info) {
#pragma unused (target) #pragma unused (target)
// This can be called many times with the same info. The info is retained by // This can be called many times with the same info. The info is retained by SCNetworkReachability
// SCNetworkReachability while this function is being executed. // while this function is being executed.
void (^handler)(GRPCReachabilityFlags *) = void (^handler)(GRPCReachabilityFlags *) = (__bridge void (^)(GRPCReachabilityFlags *))info;
(__bridge void (^)(GRPCReachabilityFlags *))info;
handler([[GRPCReachabilityFlags alloc] initWithFlags:flags]); handler([[GRPCReachabilityFlags alloc] initWithFlags:flags]);
} }
@ -127,8 +123,7 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
GRPCReachabilityFlags *_previousReachabilityFlags; GRPCReachabilityFlags *_previousReachabilityFlags;
} }
- (nullable instancetype)initWithReachability: - (nullable instancetype)initWithReachability:(nullable SCNetworkReachabilityRef)reachability {
(nullable SCNetworkReachabilityRef)reachability {
if (!reachability) { if (!reachability) {
return nil; return nil;
} }
@ -149,23 +144,23 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
SCNetworkReachabilityRef reachability = SCNetworkReachabilityRef reachability =
SCNetworkReachabilityCreateWithName(NULL, hostName); SCNetworkReachabilityCreateWithName(NULL, hostName);
GRPCConnectivityMonitor *returnValue = GRPCConnectivityMonitor *returnValue = [[self alloc] initWithReachability:reachability];
[[self alloc] initWithReachability:reachability];
if (reachability) { if (reachability) {
CFRelease(reachability); CFRelease(reachability);
} }
return returnValue; return returnValue;
} }
- (void)handleLossWithHandler:(void (^)())handler - (void)handleLossWithHandler:(nullable void (^)())lossHandler
wifiStatusChangeHandler:(nonnull void (^)())wifiStatusChangeHandler { wifiStatusChangeHandler:(nullable void (^)())wifiStatusChangeHandler {
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[self startListeningWithHandler:^(GRPCReachabilityFlags *flags) { [self startListeningWithHandler:^(GRPCReachabilityFlags *flags) {
typeof(self) strongSelf = weakSelf; typeof(self) strongSelf = weakSelf;
if (strongSelf) { if (strongSelf) {
if (!flags.reachable) { if (lossHandler && !flags.reachable) {
handler(); lossHandler();
} else if (strongSelf->_previousReachabilityFlags && } else if (wifiStatusChangeHandler &&
strongSelf->_previousReachabilityFlags &&
(flags.isWWAN ^ (flags.isWWAN ^
strongSelf->_previousReachabilityFlags.isWWAN)) { strongSelf->_previousReachabilityFlags.isWWAN)) {
wifiStatusChangeHandler(); wifiStatusChangeHandler();
@ -176,8 +171,8 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
} }
- (void)startListeningWithHandler:(void (^)(GRPCReachabilityFlags *))handler { - (void)startListeningWithHandler:(void (^)(GRPCReachabilityFlags *))handler {
// Copy to ensure the handler block is in the heap (and so can't be // Copy to ensure the handler block is in the heap (and so can't be deallocated when this method
// deallocated when this method returns). // returns).
void (^copiedHandler)(GRPCReachabilityFlags *) = [handler copy]; void (^copiedHandler)(GRPCReachabilityFlags *) = [handler copy];
SCNetworkReachabilityContext context = { SCNetworkReachabilityContext context = {
.version = 0, .version = 0,
@ -185,10 +180,8 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
.retain = CFRetain, .retain = CFRetain,
.release = CFRelease, .release = CFRelease,
}; };
// The following will retain context.info, and release it when the callback is // The following will retain context.info, and release it when the callback is set to NULL.
// set to NULL. SCNetworkReachabilitySetCallback(_reachabilityRef, PassFlagsToContextInfoBlock, &context);
SCNetworkReachabilitySetCallback(_reachabilityRef,
PassFlagsToContextInfoBlock, &context);
SCNetworkReachabilitySetDispatchQueue(_reachabilityRef, _queue); SCNetworkReachabilitySetDispatchQueue(_reachabilityRef, _queue);
} }

@ -33,9 +33,9 @@
#import "GRPCHost.h" #import "GRPCHost.h"
#import <GRPCClient/GRPCCall.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#import <GRPCClient/GRPCCall.h>
#ifdef GRPC_COMPILE_WITH_CRONET #ifdef GRPC_COMPILE_WITH_CRONET
#import <GRPCClient/GRPCCall+ChannelArg.h> #import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Cronet.h> #import <GRPCClient/GRPCCall+Cronet.h>
@ -48,8 +48,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
// TODO(jcanizales): Generate the version in a standalone header, from // TODO(jcanizales): Generate the version in a standalone header, from templates. Like
// templates. Like
// templates/src/core/surface/version.c.template . // templates/src/core/surface/version.c.template .
#define GRPC_OBJC_VERSION_STRING @"1.0.1" #define GRPC_OBJC_VERSION_STRING @"1.0.1"
@ -62,8 +61,7 @@ static NSMutableDictionary *kHostCache;
static GRPCConnectivityMonitor *connectivityMonitor = nil; static GRPCConnectivityMonitor *connectivityMonitor = nil;
@implementation GRPCHost { @implementation GRPCHost {
// TODO(mlumish): Investigate whether caching channels with strong links is a // TODO(mlumish): Investigate whether caching channels with strong links is a good idea.
// good idea.
GRPCChannel *_channel; GRPCChannel *_channel;
} }
@ -83,13 +81,11 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
return nil; return nil;
} }
// To provide a default port, we try to interpret the address. If it's just a // To provide a default port, we try to interpret the address. If it's just a host name without
// host name without scheme and without port, we'll use port 443. If it has a // scheme and without port, we'll use port 443. If it has a scheme, we pass it untouched to the C
// scheme, we pass it untouched to the C gRPC library. // gRPC library.
// TODO(jcanizales): Add unit tests for the types of addresses we want to let // TODO(jcanizales): Add unit tests for the types of addresses we want to let pass untouched.
// pass untouched. NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:address]];
NSURL *hostURL =
[NSURL URLWithString:[@"https://" stringByAppendingString:address]];
if (hostURL.host && !hostURL.port) { if (hostURL.host && !hostURL.port) {
address = [hostURL.host stringByAppendingString:@":443"]; address = [hostURL.host stringByAppendingString:@":443"];
} }
@ -99,7 +95,6 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
dispatch_once(&cacheInitialization, ^{ dispatch_once(&cacheInitialization, ^{
kHostCache = [NSMutableDictionary dictionary]; kHostCache = [NSMutableDictionary dictionary];
}); });
@synchronized(kHostCache) { @synchronized(kHostCache) {
GRPCHost *cachedHost = kHostCache[address]; GRPCHost *cachedHost = kHostCache[address];
if (cachedHost) { if (cachedHost) {
@ -164,16 +159,13 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
static dispatch_once_t loading; static dispatch_once_t loading;
dispatch_once(&loading, ^{ dispatch_once(&loading, ^{
NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
// Do not use NSBundle.mainBundle, as it's nil for tests of library // Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
// projects.
NSBundle *bundle = [NSBundle bundleForClass:self.class]; NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"]; NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"];
NSError *error; NSError *error;
// Files in PEM format can have non-ASCII characters in their comments (e.g. // Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the
// for the name of the issuer). Load them as UTF8 and produce an ASCII // issuer). Load them as UTF8 and produce an ASCII equivalent.
// equivalent. NSString *contentInUTF8 = [NSString stringWithContentsOfFile:path
NSString *contentInUTF8 =
[NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding encoding:NSUTF8StringEncoding
error:&error]; error:&error];
if (contentInUTF8 == nil) { if (contentInUTF8 == nil) {
@ -193,14 +185,10 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
if (errorPtr) { if (errorPtr) {
*errorPtr = kDefaultRootsError; *errorPtr = kDefaultRootsError;
} }
NSAssert(kDefaultRootsASCII, NSAssert(kDefaultRootsASCII, @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
@"Could not read gRPCCertificates.bundle/roots.pem. This file, " "with the root certificates, is needed to establish secure (TLS) connections. "
"with the root certificates, is needed to establish secure " "Because the file is distributed with the gRPC library, this error is usually a sign "
"(TLS) connections. " "that the library wasn't configured correctly for your project. Error: %@",
"Because the file is distributed with the gRPC library, this "
"error is usually a sign "
"that the library wasn't configured correctly for your "
"project. Error: %@",
kDefaultRootsError); kDefaultRootsError);
return NO; return NO;
} }
@ -212,11 +200,9 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL); creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL);
} else { } else {
grpc_ssl_pem_key_cert_pair key_cert_pair; grpc_ssl_pem_key_cert_pair key_cert_pair;
NSData *privateKeyASCII = NSData *privateKeyASCII = [pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding
[pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES]; allowLossyConversion:YES];
NSData *certChainASCII = NSData *certChainASCII = [pemCertChain dataUsingEncoding:NSASCIIStringEncoding
[pemCertChain dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES]; allowLossyConversion:YES];
key_cert_pair.private_key = privateKeyASCII.bytes; key_cert_pair.private_key = privateKeyASCII.bytes;
key_cert_pair.cert_chain = certChainASCII.bytes; key_cert_pair.cert_chain = certChainASCII.bytes;
@ -237,8 +223,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
NSMutableDictionary *args = [NSMutableDictionary dictionary]; NSMutableDictionary *args = [NSMutableDictionary dictionary];
// TODO(jcanizales): Add OS and device information (see // TODO(jcanizales): Add OS and device information (see
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents ).
// ).
NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING; NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING;
if (_userAgentPrefix) { if (_userAgentPrefix) {
userAgent = [_userAgentPrefix stringByAppendingFormat:@" %@", userAgent]; userAgent = [_userAgentPrefix stringByAppendingFormat:@" %@", userAgent];
@ -266,15 +251,12 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
GRPCChannel *channel; GRPCChannel *channel;
@synchronized(self) { @synchronized(self) {
if (_channelCreds == nil) { if (_channelCreds == nil) {
[self setTLSPEMRootCerts:nil [self setTLSPEMRootCerts:nil withPrivateKey:nil withCertChain:nil error:nil];
withPrivateKey:nil
withCertChain:nil
error:nil];
} }
#ifdef GRPC_COMPILE_WITH_CRONET #ifdef GRPC_COMPILE_WITH_CRONET
if (useCronet) { if (useCronet) {
channel = channel = [GRPCChannel secureCronetChannelWithHost:_address
[GRPCChannel secureCronetChannelWithHost:_address channelArgs:args]; channelArgs:args];
} else } else
#endif #endif
{ {
@ -290,8 +272,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
} }
- (NSString *)hostName { - (NSString *)hostName {
// TODO(jcanizales): Default to nil instead of _address when Issue #2635 is // TODO(jcanizales): Default to nil instead of _address when Issue #2635 is clarified.
// clarified.
return _hostNameOverride ?: _address; return _hostNameOverride ?: _address;
} }

@ -40,8 +40,7 @@
// Used by the setter. // Used by the setter.
static void CheckIsNonNilASCII(NSString *name, NSString* value) { static void CheckIsNonNilASCII(NSString *name, NSString* value) {
if (!value) { if (!value) {
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException format:@"%@ cannot be nil", name];
format:@"%@ cannot be nil", name];
} }
if (![value canBeConvertedToEncoding:NSASCIIStringEncoding]) { if (![value canBeConvertedToEncoding:NSASCIIStringEncoding]) {
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException
@ -53,20 +52,15 @@ static void CheckIsNonNilASCII(NSString *name, NSString *value) {
static void CheckKeyValuePairIsValid(NSString *key, id value) { static void CheckKeyValuePairIsValid(NSString *key, id value) {
if ([key hasSuffix:@"-bin"]) { if ([key hasSuffix:@"-bin"]) {
if (![value isKindOfClass:NSData.class]) { if (![value isKindOfClass:NSData.class]) {
[NSException [NSException raise:NSInvalidArgumentException
raise:NSInvalidArgumentException
format:@"Expected NSData value for header %@ ending in \"-bin\", " format:@"Expected NSData value for header %@ ending in \"-bin\", "
@"instead got %@", @"instead got %@", key, value];
key, value];
} }
} else { } else {
if (![value isKindOfClass:NSString.class]) { if (![value isKindOfClass:NSString.class]) {
[NSException [NSException raise:NSInvalidArgumentException
raise:NSInvalidArgumentException format:@"Expected NSString value for header %@ not ending in \"-bin\", "
format: @"instead got %@", key, value];
@"Expected NSString value for header %@ not ending in \"-bin\", "
@"instead got %@",
key, value];
} }
CheckIsNonNilASCII(@"Text header value", (NSString *)value); CheckIsNonNilASCII(@"Text header value", (NSString *)value);
} }
@ -74,10 +68,9 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
@implementation GRPCRequestHeaders { @implementation GRPCRequestHeaders {
__weak GRPCCall *_call; __weak GRPCCall *_call;
// The NSMutableDictionary superclass doesn't hold any storage (so that people // The NSMutableDictionary superclass doesn't hold any storage (so that people can implement their
// can implement their own in subclasses). As that's not the reason we're // own in subclasses). As that's not the reason we're subclassing, we just delegate storage to the
// subclassing, we just delegate storage to the default NSMutableDictionary // default NSMutableDictionary subclass returned by the cluster (e.g. __NSDictionaryM on iOS 9).
// subclass returned by the cluster (e.g. __NSDictionaryM on iOS 9).
NSMutableDictionary *_delegate; NSMutableDictionary *_delegate;
} }
@ -98,8 +91,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
} }
// Designated initializer // Designated initializer
- (instancetype)initWithCall:(GRPCCall *)call - (instancetype)initWithCall:(GRPCCall *)call storage:(NSMutableDictionary *)storage {
storage:(NSMutableDictionary *)storage {
// TODO(jcanizales): Throw if call or storage are nil. // TODO(jcanizales): Throw if call or storage are nil.
if ((self = [super init])) { if ((self = [super init])) {
_call = call; _call = call;
@ -108,8 +100,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
return self; return self;
} }
- (instancetype) - (instancetype)initWithObjects:(const id _Nonnull __unsafe_unretained *)objects
initWithObjects:(const id _Nonnull __unsafe_unretained *)objects
forKeys:(const id<NSCopying> _Nonnull __unsafe_unretained *)keys forKeys:(const id<NSCopying> _Nonnull __unsafe_unretained *)keys
count:(NSUInteger)cnt { count:(NSUInteger)cnt {
return [self init]; return [self init];

@ -34,20 +34,20 @@
#import "GRPCWrappedCall.h" #import "GRPCWrappedCall.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <grpc/byte_buffer.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#import "GRPCCompletionQueue.h" #import "GRPCCompletionQueue.h"
#import "GRPCHost.h" #import "GRPCHost.h"
#import "NSData+GRPC.h"
#import "NSDictionary+GRPC.h" #import "NSDictionary+GRPC.h"
#import "NSData+GRPC.h"
#import "NSError+GRPC.h" #import "NSError+GRPC.h"
@implementation GRPCOperation { @implementation GRPCOperation {
@protected @protected
// Most operation subclasses don't set any flags in the grpc_op, and rely on // Most operation subclasses don't set any flags in the grpc_op, and rely on the flag member being
// the flag member being initialized to zero. // initialized to zero.
grpc_op _op; grpc_op _op;
void(^_handler)(); void(^_handler)();
} }
@ -101,8 +101,7 @@
- (instancetype)initWithMessage:(NSData *)message handler:(void (^)())handler { - (instancetype)initWithMessage:(NSData *)message handler:(void (^)())handler {
if (!message) { if (!message) {
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException format:@"message cannot be nil"];
format:@"message cannot be nil"];
} }
if (self = [super init]) { if (self = [super init]) {
_op.op = GRPC_OP_SEND_MESSAGE; _op.op = GRPC_OP_SEND_MESSAGE;
@ -217,8 +216,7 @@
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
_handler = ^{ _handler = ^{
__strong typeof(self) strongSelf = weakSelf; __strong typeof(self) strongSelf = weakSelf;
NSError *error = NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
[NSError grpc_errorFromStatusCode:strongSelf->_statusCode
details:strongSelf->_details]; details:strongSelf->_details];
NSDictionary *trailers = [NSDictionary NSDictionary *trailers = [NSDictionary
grpc_dictionaryFromMetadataArray:strongSelf->_trailers]; grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
@ -247,21 +245,20 @@
return [self initWithHost:nil path:nil]; return [self initWithHost:nil path:nil];
} }
- (instancetype)initWithHost:(NSString *)host path:(NSString *)path { - (instancetype)initWithHost:(NSString *)host
path:(NSString *)path {
if (!path || !host) { if (!path || !host) {
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException
format:@"path and host cannot be nil."]; format:@"path and host cannot be nil."];
} }
if (self = [super init]) { if (self = [super init]) {
// Each completion queue consumes one thread. There's a trade to be made // Each completion queue consumes one thread. There's a trade to be made between creating and
// between creating and consuming too many threads and having contention of // consuming too many threads and having contention of multiple calls in a single completion
// multiple calls in a single completion queue. Currently we use a singleton // queue. Currently we use a singleton queue.
// queue.
_queue = [GRPCCompletionQueue completionQueue]; _queue = [GRPCCompletionQueue completionQueue];
_call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path completionQueue:_queue];
completionQueue:_queue];
if (_call == NULL) { if (_call == NULL) {
return nil; return nil;
} }
@ -273,16 +270,15 @@
[self startBatchWithOperations:operations errorHandler:nil]; [self startBatchWithOperations:operations errorHandler:nil];
} }
- (void)startBatchWithOperations:(NSArray *)operations - (void)startBatchWithOperations:(NSArray *)operations errorHandler:(void (^)())errorHandler {
errorHandler:(void (^)())errorHandler {
size_t nops = operations.count; size_t nops = operations.count;
grpc_op *ops_array = gpr_malloc(nops * sizeof(grpc_op)); grpc_op *ops_array = gpr_malloc(nops * sizeof(grpc_op));
size_t i = 0; size_t i = 0;
for (GRPCOperation *operation in operations) { for (GRPCOperation *operation in operations) {
ops_array[i++] = operation.op; ops_array[i++] = operation.op;
} }
grpc_call_error error = grpc_call_start_batch( grpc_call_error error = grpc_call_start_batch(_call, ops_array, nops,
_call, ops_array, nops, (__bridge_retained void *)(^(bool success) { (__bridge_retained void *)(^(bool success){
if (!success) { if (!success) {
if (errorHandler) { if (errorHandler) {
errorHandler(); errorHandler();
@ -293,14 +289,12 @@
for (GRPCOperation *operation in operations) { for (GRPCOperation *operation in operations) {
[operation finish]; [operation finish];
} }
}), }), NULL);
NULL);
gpr_free(ops_array); gpr_free(ops_array);
if (error != GRPC_CALL_OK) { if (error != GRPC_CALL_OK) {
[NSException raise:NSInternalInconsistencyException [NSException raise:NSInternalInconsistencyException
format:@"A precondition for calling grpc_call_start_batch " format:@"A precondition for calling grpc_call_start_batch wasn't met. Error %i",
@"wasn't met. Error %i",
error]; error];
} }
} }

@ -36,9 +36,8 @@
@interface NSError (GRPC) @interface NSError (GRPC)
/** /**
* Returns nil if the status code is OK. Otherwise, a NSError whose code is one * Returns nil if the status code is OK. Otherwise, a NSError whose code is one of |GRPCErrorCode|
* of |GRPCErrorCode| and whose domain is |kGRPCErrorDomain|. * and whose domain is |kGRPCErrorDomain|.
*/ */
+ (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode + (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode details:(char *)details;
details:(char *)details;
@end @end

@ -1,6 +1,5 @@
grpc.lb.v1.InitialLoadBalanceRequest.name max_size:128 grpc.lb.v1.InitialLoadBalanceRequest.name max_size:128
grpc.lb.v1.InitialLoadBalanceResponse.client_config max_size:64
grpc.lb.v1.InitialLoadBalanceResponse.load_balancer_delegate max_size:64 grpc.lb.v1.InitialLoadBalanceResponse.load_balancer_delegate max_size:64
grpc.lb.v1.Server.ip_address max_size:16 grpc.lb.v1.Server.ip_address max_size:16
grpc.lb.v1.Server.load_balance_token max_size:65 grpc.lb.v1.Server.load_balance_token max_size:50
load_balancer.proto no_unions:true load_balancer.proto no_unions:true

@ -63,7 +63,8 @@ message LoadBalanceRequest {
} }
message InitialLoadBalanceRequest { message InitialLoadBalanceRequest {
// Name of load balanced service (IE, service.grpc.gslb.google.com) // Name of load balanced service (IE, service.grpc.gslb.google.com). Its
// length should be less than 256 bytes.
string name = 1; string name = 1;
} }
@ -95,7 +96,8 @@ message InitialLoadBalanceResponse {
// This is an application layer redirect that indicates the client should use // This is an application layer redirect that indicates the client should use
// the specified server for load balancing. When this field is non-empty in // the specified server for load balancing. When this field is non-empty in
// the response, the client should open a separate connection to the // the response, the client should open a separate connection to the
// load_balancer_delegate and call the BalanceLoad method. // load_balancer_delegate and call the BalanceLoad method. Its length should
// be less than 64 bytes.
string load_balancer_delegate = 1; string load_balancer_delegate = 1;
// This interval defines how often the client should send the client stats // This interval defines how often the client should send the client stats
@ -130,6 +132,8 @@ message Server {
// frontend requests for that pick must include the token in its initial // frontend requests for that pick must include the token in its initial
// metadata. The token is used by the backend to verify the request and to // metadata. The token is used by the backend to verify the request and to
// allow the backend to report load to the gRPC LB system. // allow the backend to report load to the gRPC LB system.
//
// Its length is variable but less than 50 bytes.
string load_balance_token = 3; string load_balance_token = 3;
// Indicates whether this particular request should be dropped by the client // Indicates whether this particular request should be dropped by the client

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

Loading…
Cancel
Save