diff --git a/.travis.yml b/.travis.yml index 004d44f3a55..16c6390a54a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,23 @@ language: objective-c -osx_image: xcode7.2 +osx_image: xcode7.3 env: global: - CONFIG=opt - TEST=objc - JOBS=1 before_install: + - pod --version + - gem uninstall cocoapods -a + - gem install cocoapods -v '1.0.0' + - pod --version - brew install gflags - # Pod install does this too, but we don't want the output. - - pod repo update --silent + - pushd third_party/protobuf + - git checkout v3.0.0-beta-3 + - popd install: - make grpc_objective_c_plugin - pushd src/objective-c/tests - # Needs to be verbose, or otherwise OpenSSL's prepare_command makes Travis - # time out: - - pod install --verbose + - pod install - popd before_script: - make interop_server @@ -27,6 +30,6 @@ xcode_scheme: - InteropTestsLocalCleartext # TODO(jcanizales): Investigate why they time out: # - InteropTestsRemote -xcode_sdk: iphonesimulator9.2 +xcode_sdk: iphonesimulator9.3 notifications: email: false diff --git a/BUILD b/BUILD index 3b1f04f6d14..f049e3c4056 100644 --- a/BUILD +++ b/BUILD @@ -236,6 +236,7 @@ cc_library( "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/transport.h", "src/core/lib/transport/transport_impl.h", + "src/core/ext/transport/chttp2/transport/bin_decoder.h", "src/core/ext/transport/chttp2/transport/bin_encoder.h", "src/core/ext/transport/chttp2/transport/chttp2_transport.h", "src/core/ext/transport/chttp2/transport/frame.h", @@ -315,7 +316,7 @@ cc_library( "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/http_client_filter.c", "src/core/lib/channel/http_server_filter.c", - "src/core/lib/compression/compression_algorithm.c", + "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", "src/core/lib/debug/trace.c", "src/core/lib/http/format_request.c", @@ -392,6 +393,7 @@ cc_library( "src/core/lib/transport/transport.c", "src/core/lib/transport/transport_op_string.c", "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c", + "src/core/ext/transport/chttp2/transport/bin_decoder.c", "src/core/ext/transport/chttp2/transport/bin_encoder.c", "src/core/ext/transport/chttp2/transport/chttp2_plugin.c", "src/core/ext/transport/chttp2/transport/chttp2_transport.c", @@ -462,7 +464,9 @@ cc_library( "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c", + "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c", "src/core/ext/transport/chttp2/client/insecure/channel_create.c", + "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c", "src/core/ext/lb_policy/grpclb/load_balancer_api.c", "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/lb_policy/pick_first/pick_first.c", @@ -488,6 +492,7 @@ cc_library( "include/grpc/byte_buffer_reader.h", "include/grpc/compression.h", "include/grpc/grpc.h", + "include/grpc/grpc_posix.h", "include/grpc/status.h", "include/grpc/impl/codegen/byte_buffer.h", "include/grpc/impl/codegen/byte_buffer_reader.h", @@ -610,6 +615,7 @@ cc_library( "src/core/lib/transport/transport.h", "src/core/lib/transport/transport_impl.h", "third_party/objective_c/Cronet/cronet_c_for_grpc.h", + "src/core/ext/transport/chttp2/transport/bin_decoder.h", "src/core/ext/transport/chttp2/transport/bin_encoder.h", "src/core/ext/transport/chttp2/transport/chttp2_transport.h", "src/core/ext/transport/chttp2/transport/frame.h", @@ -678,7 +684,7 @@ cc_library( "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/http_client_filter.c", "src/core/lib/channel/http_server_filter.c", - "src/core/lib/compression/compression_algorithm.c", + "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", "src/core/lib/debug/trace.c", "src/core/lib/http/format_request.c", @@ -758,6 +764,7 @@ cc_library( "src/core/ext/transport/cronet/transport/cronet_api_dummy.c", "src/core/ext/transport/cronet/transport/cronet_transport.c", "src/core/ext/transport/chttp2/client/secure/secure_channel_create.c", + "src/core/ext/transport/chttp2/transport/bin_decoder.c", "src/core/ext/transport/chttp2/transport/bin_encoder.c", "src/core/ext/transport/chttp2/transport/chttp2_plugin.c", "src/core/ext/transport/chttp2/transport/chttp2_transport.c", @@ -833,6 +840,7 @@ cc_library( "include/grpc/byte_buffer_reader.h", "include/grpc/compression.h", "include/grpc/grpc.h", + "include/grpc/grpc_posix.h", "include/grpc/status.h", "include/grpc/impl/codegen/byte_buffer.h", "include/grpc/impl/codegen/byte_buffer_reader.h", @@ -949,6 +957,7 @@ cc_library( "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/transport.h", "src/core/lib/transport/transport_impl.h", + "src/core/ext/transport/chttp2/transport/bin_decoder.h", "src/core/ext/transport/chttp2/transport/bin_encoder.h", "src/core/ext/transport/chttp2/transport/chttp2_transport.h", "src/core/ext/transport/chttp2/transport/frame.h", @@ -1006,7 +1015,7 @@ cc_library( "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/http_client_filter.c", "src/core/lib/channel/http_server_filter.c", - "src/core/lib/compression/compression_algorithm.c", + "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", "src/core/lib/debug/trace.c", "src/core/lib/http/format_request.c", @@ -1083,6 +1092,8 @@ cc_library( "src/core/lib/transport/transport.c", "src/core/lib/transport/transport_op_string.c", "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c", + "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c", + "src/core/ext/transport/chttp2/transport/bin_decoder.c", "src/core/ext/transport/chttp2/transport/bin_encoder.c", "src/core/ext/transport/chttp2/transport/chttp2_plugin.c", "src/core/ext/transport/chttp2/transport/chttp2_transport.c", @@ -1106,6 +1117,7 @@ cc_library( "src/core/ext/transport/chttp2/transport/writing.c", "src/core/ext/transport/chttp2/alpn/alpn.c", "src/core/ext/transport/chttp2/client/insecure/channel_create.c", + "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c", "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", @@ -1150,6 +1162,7 @@ cc_library( "include/grpc/byte_buffer_reader.h", "include/grpc/compression.h", "include/grpc/grpc.h", + "include/grpc/grpc_posix.h", "include/grpc/status.h", "include/grpc/impl/codegen/byte_buffer.h", "include/grpc/impl/codegen/byte_buffer_reader.h", @@ -1212,8 +1225,8 @@ cc_library( cc_library( name = "grpc++", srcs = [ + "include/grpc++/impl/codegen/core_codegen.h", "src/cpp/client/secure_credentials.h", - "src/cpp/common/core_codegen.h", "src/cpp/common/secure_auth_context.h", "src/cpp/server/secure_server_credentials.h", "src/cpp/client/create_channel_internal.h", @@ -1229,6 +1242,7 @@ cc_library( "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", + "src/cpp/client/create_channel_posix.cc", "src/cpp/client/credentials.cc", "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", @@ -1244,6 +1258,7 @@ cc_library( "src/cpp/server/server_builder.cc", "src/cpp/server/server_context.cc", "src/cpp/server/server_credentials.cc", + "src/cpp/server/server_posix.cc", "src/cpp/util/byte_buffer.cc", "src/cpp/util/slice.cc", "src/cpp/util/status.cc", @@ -1257,11 +1272,13 @@ cc_library( "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/create_channel.h", + "include/grpc++/create_channel_posix.h", "include/grpc++/generic/async_generic_service.h", "include/grpc++/generic/generic_stub.h", "include/grpc++/grpc++.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", + "include/grpc++/impl/codegen/core_codegen.h", "include/grpc++/impl/grpc_library.h", "include/grpc++/impl/method_handler_impl.h", "include/grpc++/impl/rpc_method.h", @@ -1284,6 +1301,7 @@ cc_library( "include/grpc++/server.h", "include/grpc++/server_builder.h", "include/grpc++/server_context.h", + "include/grpc++/server_posix.h", "include/grpc++/support/async_stream.h", "include/grpc++/support/async_unary_call.h", "include/grpc++/support/byte_buffer.h", @@ -1361,11 +1379,88 @@ cc_library( +cc_library( + name = "grpc++_reflection", + srcs = [ + "src/cpp/ext/proto_server_reflection.h", + "src/cpp/ext/proto_server_reflection.cc", + "src/cpp/ext/proto_server_reflection_plugin.cc", + "src/cpp/ext/reflection.grpc.pb.cc", + "src/cpp/ext/reflection.pb.cc", + ], + hdrs = [ + "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/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.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/alloc.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/log.h", + "include/grpc/impl/codegen/port_platform.h", + "include/grpc/impl/codegen/slice.h", + "include/grpc/impl/codegen/slice_buffer.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/time.h", + "include/grpc++/impl/codegen/config_protobuf.h", + ], + includes = [ + "include", + ".", + ], + deps = [ + ":grpc++", + ], +) + + + cc_library( name = "grpc++_unsecure", srcs = [ "src/cpp/client/create_channel_internal.h", - "src/cpp/common/core_codegen.h", "src/cpp/server/dynamic_thread_pool.h", "src/cpp/server/thread_pool_interface.h", "src/cpp/common/insecure_create_auth_context.cc", @@ -1373,6 +1468,7 @@ cc_library( "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", + "src/cpp/client/create_channel_posix.cc", "src/cpp/client/credentials.cc", "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", @@ -1388,6 +1484,7 @@ cc_library( "src/cpp/server/server_builder.cc", "src/cpp/server/server_context.cc", "src/cpp/server/server_credentials.cc", + "src/cpp/server/server_posix.cc", "src/cpp/util/byte_buffer.cc", "src/cpp/util/slice.cc", "src/cpp/util/status.cc", @@ -1401,11 +1498,13 @@ cc_library( "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/create_channel.h", + "include/grpc++/create_channel_posix.h", "include/grpc++/generic/async_generic_service.h", "include/grpc++/generic/generic_stub.h", "include/grpc++/grpc++.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", + "include/grpc++/impl/codegen/core_codegen.h", "include/grpc++/impl/grpc_library.h", "include/grpc++/impl/method_handler_impl.h", "include/grpc++/impl/rpc_method.h", @@ -1428,6 +1527,7 @@ cc_library( "include/grpc++/server.h", "include/grpc++/server_builder.h", "include/grpc++/server_context.h", + "include/grpc++/server_posix.h", "include/grpc++/support/async_stream.h", "include/grpc++/support/async_unary_call.h", "include/grpc++/support/byte_buffer.h", @@ -1692,7 +1792,7 @@ objc_library( "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/http_client_filter.c", "src/core/lib/channel/http_server_filter.c", - "src/core/lib/compression/compression_algorithm.c", + "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", "src/core/lib/debug/trace.c", "src/core/lib/http/format_request.c", @@ -1769,6 +1869,7 @@ objc_library( "src/core/lib/transport/transport.c", "src/core/lib/transport/transport_op_string.c", "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c", + "src/core/ext/transport/chttp2/transport/bin_decoder.c", "src/core/ext/transport/chttp2/transport/bin_encoder.c", "src/core/ext/transport/chttp2/transport/chttp2_plugin.c", "src/core/ext/transport/chttp2/transport/chttp2_transport.c", @@ -1839,7 +1940,9 @@ objc_library( "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c", + "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c", "src/core/ext/transport/chttp2/client/insecure/channel_create.c", + "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c", "src/core/ext/lb_policy/grpclb/load_balancer_api.c", "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/lb_policy/pick_first/pick_first.c", @@ -1865,6 +1968,7 @@ objc_library( "include/grpc/byte_buffer_reader.h", "include/grpc/compression.h", "include/grpc/grpc.h", + "include/grpc/grpc_posix.h", "include/grpc/status.h", "include/grpc/impl/codegen/byte_buffer.h", "include/grpc/impl/codegen/byte_buffer_reader.h", @@ -1965,6 +2069,7 @@ objc_library( "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/transport.h", "src/core/lib/transport/transport_impl.h", + "src/core/ext/transport/chttp2/transport/bin_decoder.h", "src/core/ext/transport/chttp2/transport/bin_encoder.h", "src/core/ext/transport/chttp2/transport/chttp2_transport.h", "src/core/ext/transport/chttp2/transport/frame.h", diff --git a/Makefile b/Makefile index 7738a8d8ff0..f500c7472f1 100644 --- a/Makefile +++ b/Makefile @@ -889,6 +889,7 @@ algorithm_test: $(BINDIR)/$(CONFIG)/algorithm_test alloc_test: $(BINDIR)/$(CONFIG)/alloc_test alpn_test: $(BINDIR)/$(CONFIG)/alpn_test api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer +bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test census_context_test: $(BINDIR)/$(CONFIG)/census_context_test channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test @@ -1030,6 +1031,7 @@ interop_test: $(BINDIR)/$(CONFIG)/interop_test json_run_localhost: $(BINDIR)/$(CONFIG)/json_run_localhost metrics_client: $(BINDIR)/$(CONFIG)/metrics_client mock_test: $(BINDIR)/$(CONFIG)/mock_test +proto_server_reflection_test: $(BINDIR)/$(CONFIG)/proto_server_reflection_test qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test qps_json_driver: $(BINDIR)/$(CONFIG)/qps_json_driver qps_openloop_test: $(BINDIR)/$(CONFIG)/qps_openloop_test @@ -1103,6 +1105,7 @@ bad_ssl_cert_test: $(BINDIR)/$(CONFIG)/bad_ssl_cert_test h2_census_test: $(BINDIR)/$(CONFIG)/h2_census_test h2_compress_test: $(BINDIR)/$(CONFIG)/h2_compress_test h2_fakesec_test: $(BINDIR)/$(CONFIG)/h2_fakesec_test +h2_fd_test: $(BINDIR)/$(CONFIG)/h2_fd_test h2_full_test: $(BINDIR)/$(CONFIG)/h2_full_test h2_full+pipe_test: $(BINDIR)/$(CONFIG)/h2_full+pipe_test h2_full+trace_test: $(BINDIR)/$(CONFIG)/h2_full+trace_test @@ -1118,6 +1121,7 @@ h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test h2_census_nosec_test: $(BINDIR)/$(CONFIG)/h2_census_nosec_test h2_compress_nosec_test: $(BINDIR)/$(CONFIG)/h2_compress_nosec_test +h2_fd_nosec_test: $(BINDIR)/$(CONFIG)/h2_fd_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+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test @@ -1166,13 +1170,13 @@ static: static_c static_cxx static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc_cronet.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a static_zookeeper_libs -static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a +static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a shared: shared_c shared_cxx shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)gpr$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_zookeeper_libs -shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) +shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_csharp: shared_c $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION).$(SHARED_EXT) ifeq ($(HAS_ZOOKEEPER),true) @@ -1223,6 +1227,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/algorithm_test \ $(BINDIR)/$(CONFIG)/alloc_test \ $(BINDIR)/$(CONFIG)/alpn_test \ + $(BINDIR)/$(CONFIG)/bin_decoder_test \ $(BINDIR)/$(CONFIG)/bin_encoder_test \ $(BINDIR)/$(CONFIG)/census_context_test \ $(BINDIR)/$(CONFIG)/channel_create_test \ @@ -1335,6 +1340,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/h2_census_test \ $(BINDIR)/$(CONFIG)/h2_compress_test \ $(BINDIR)/$(CONFIG)/h2_fakesec_test \ + $(BINDIR)/$(CONFIG)/h2_fd_test \ $(BINDIR)/$(CONFIG)/h2_full_test \ $(BINDIR)/$(CONFIG)/h2_full+pipe_test \ $(BINDIR)/$(CONFIG)/h2_full+trace_test \ @@ -1350,6 +1356,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/h2_uds_test \ $(BINDIR)/$(CONFIG)/h2_census_nosec_test \ $(BINDIR)/$(CONFIG)/h2_compress_nosec_test \ + $(BINDIR)/$(CONFIG)/h2_fd_nosec_test \ $(BINDIR)/$(CONFIG)/h2_full_nosec_test \ $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test \ $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test \ @@ -1397,6 +1404,7 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \ $(BINDIR)/$(CONFIG)/json_run_localhost \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ + $(BINDIR)/$(CONFIG)/proto_server_reflection_test \ $(BINDIR)/$(CONFIG)/qps_interarrival_test \ $(BINDIR)/$(CONFIG)/qps_json_driver \ $(BINDIR)/$(CONFIG)/qps_openloop_test \ @@ -1475,6 +1483,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/alloc_test || ( echo test alloc_test failed ; exit 1 ) $(E) "[RUN] Testing alpn_test" $(Q) $(BINDIR)/$(CONFIG)/alpn_test || ( echo test alpn_test failed ; exit 1 ) + $(E) "[RUN] Testing bin_decoder_test" + $(Q) $(BINDIR)/$(CONFIG)/bin_decoder_test || ( echo test bin_decoder_test failed ; exit 1 ) $(E) "[RUN] Testing bin_encoder_test" $(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 ) $(E) "[RUN] Testing census_context_test" @@ -1723,6 +1733,8 @@ test_cxx: test_zookeeper buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 ) $(E) "[RUN] Testing mock_test" $(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 ) + $(E) "[RUN] Testing proto_server_reflection_test" + $(Q) $(BINDIR)/$(CONFIG)/proto_server_reflection_test || ( echo test proto_server_reflection_test failed ; exit 1 ) $(E) "[RUN] Testing qps_openloop_test" $(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 ) $(E) "[RUN] Testing secure_auth_context_test" @@ -1805,6 +1817,8 @@ strip-static_cxx: static_cxx ifeq ($(CONFIG),opt) $(E) "[STRIP] Stripping libgrpc++.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++.a + $(E) "[STRIP] Stripping libgrpc++_reflection.a" + $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(E) "[STRIP] Stripping libgrpc++_unsecure.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a endif @@ -1829,6 +1843,8 @@ strip-shared_cxx: shared_cxx ifeq ($(CONFIG),opt) $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) + $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT)" + $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) endif @@ -2143,6 +2159,9 @@ install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx $(E) "[INSTALL] Installing libgrpc++.a" $(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(prefix)/lib/libgrpc++.a + $(E) "[INSTALL] Installing libgrpc++_reflection.a" + $(Q) $(INSTALL) -d $(prefix)/lib + $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(prefix)/lib/libgrpc++_reflection.a $(E) "[INSTALL] Installing libgrpc++_unsecure.a" $(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(prefix)/lib/libgrpc++_unsecure.a @@ -2213,6 +2232,15 @@ ifeq ($(SYSTEM),MINGW32) else ifneq ($(SYSTEM),Darwin) $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++.so.0 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++.so +endif + $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT)" + $(Q) $(INSTALL) -d $(prefix)/lib + $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) +ifeq ($(SYSTEM),MINGW32) + $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection-imp.a $(prefix)/lib/libgrpc++_reflection-imp.a +else ifneq ($(SYSTEM),Darwin) + $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++_reflection.so.0 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++_reflection.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)" $(Q) $(INSTALL) -d $(prefix)/lib @@ -2483,7 +2511,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/compression/compression_algorithm.c \ + src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ src/core/lib/http/format_request.c \ @@ -2560,6 +2588,7 @@ LIBGRPC_SRC = \ src/core/lib/transport/transport.c \ src/core/lib/transport/transport_op_string.c \ src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \ + src/core/ext/transport/chttp2/transport/bin_decoder.c \ src/core/ext/transport/chttp2/transport/bin_encoder.c \ src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ src/core/ext/transport/chttp2/transport/chttp2_transport.c \ @@ -2630,7 +2659,9 @@ LIBGRPC_SRC = \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ + src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \ + src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ third_party/nanopb/pb_common.c \ @@ -2659,6 +2690,7 @@ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer_reader.h \ include/grpc/compression.h \ include/grpc/grpc.h \ + include/grpc/grpc_posix.h \ include/grpc/status.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -2746,7 +2778,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/compression/compression_algorithm.c \ + src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ src/core/lib/http/format_request.c \ @@ -2826,6 +2858,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/transport/cronet/transport/cronet_api_dummy.c \ src/core/ext/transport/cronet/transport/cronet_transport.c \ src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \ + src/core/ext/transport/chttp2/transport/bin_decoder.c \ src/core/ext/transport/chttp2/transport/bin_encoder.c \ src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ src/core/ext/transport/chttp2/transport/chttp2_transport.c \ @@ -2901,6 +2934,7 @@ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer_reader.h \ include/grpc/compression.h \ include/grpc/grpc.h \ + include/grpc/grpc_posix.h \ include/grpc/status.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -3080,7 +3114,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/compression/compression_algorithm.c \ + src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ src/core/lib/http/format_request.c \ @@ -3157,6 +3191,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/transport/transport.c \ src/core/lib/transport/transport_op_string.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ + src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ + src/core/ext/transport/chttp2/transport/bin_decoder.c \ src/core/ext/transport/chttp2/transport/bin_encoder.c \ src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ src/core/ext/transport/chttp2/transport/chttp2_transport.c \ @@ -3180,6 +3216,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \ + src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ @@ -3227,6 +3264,7 @@ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer_reader.h \ include/grpc/compression.h \ include/grpc/grpc.h \ + include/grpc/grpc_posix.h \ include/grpc/status.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -3420,6 +3458,7 @@ LIBGRPC++_SRC = \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ + src/cpp/client/create_channel_posix.cc \ src/cpp/client/credentials.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ @@ -3435,6 +3474,7 @@ LIBGRPC++_SRC = \ src/cpp/server/server_builder.cc \ src/cpp/server/server_context.cc \ src/cpp/server/server_credentials.cc \ + src/cpp/server/server_posix.cc \ src/cpp/util/byte_buffer.cc \ src/cpp/util/slice.cc \ src/cpp/util/status.cc \ @@ -3448,11 +3488,13 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/create_channel.h \ + include/grpc++/create_channel_posix.h \ include/grpc++/generic/async_generic_service.h \ include/grpc++/generic/generic_stub.h \ include/grpc++/grpc++.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ + include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/grpc_library.h \ include/grpc++/impl/method_handler_impl.h \ include/grpc++/impl/rpc_method.h \ @@ -3475,6 +3517,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/server.h \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ + include/grpc++/server_posix.h \ include/grpc++/support/async_stream.h \ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ @@ -3602,6 +3645,133 @@ endif endif +LIBGRPC++_REFLECTION_SRC = \ + src/cpp/ext/proto_server_reflection.cc \ + src/cpp/ext/proto_server_reflection_plugin.cc \ + src/cpp/ext/reflection.grpc.pb.cc \ + src/cpp/ext/reflection.pb.cc \ + +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/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.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/alloc.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/log.h \ + include/grpc/impl/codegen/port_platform.h \ + include/grpc/impl/codegen/slice.h \ + include/grpc/impl/codegen/slice_buffer.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/time.h \ + include/grpc++/impl/codegen/config_protobuf.h \ + +LIBGRPC++_REFLECTION_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_SRC)))) + + +ifeq ($(NO_SECURE),true) + +# You can't build secure libraries if you don't have OpenSSL. + +$(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: openssl_dep_error + +$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error + +else + +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)/libgrpc++_reflection.a: protobuf_dep_error + +$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error + +else + +$(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_REFLECTION_OBJS) + $(E) "[AR] Creating $@" + $(Q) mkdir -p `dirname $@` + $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a + $(Q) $(AR) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBGRPC++_REFLECTION_OBJS) +ifeq ($(SYSTEM),Darwin) + $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a +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.0 -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.0 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION).so +endif +endif + +endif + +endif + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(LIBGRPC++_REFLECTION_OBJS:.o=.dep) +endif +endif + + LIBGRPC++_TEST_CONFIG_SRC = \ test/cpp/util/test_config.cc \ @@ -3775,6 +3945,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ + src/cpp/client/create_channel_posix.cc \ src/cpp/client/credentials.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ @@ -3790,6 +3961,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/server/server_builder.cc \ src/cpp/server/server_context.cc \ src/cpp/server/server_credentials.cc \ + src/cpp/server/server_posix.cc \ src/cpp/util/byte_buffer.cc \ src/cpp/util/slice.cc \ src/cpp/util/status.cc \ @@ -3803,11 +3975,13 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/create_channel.h \ + include/grpc++/create_channel_posix.h \ include/grpc++/generic/async_generic_service.h \ include/grpc++/generic/generic_stub.h \ include/grpc++/grpc++.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ + include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/grpc_library.h \ include/grpc++/impl/method_handler_impl.h \ include/grpc++/impl/rpc_method.h \ @@ -3830,6 +4004,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/server.h \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ + include/grpc++/server_posix.h \ include/grpc++/support/async_stream.h \ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ @@ -4253,6 +4428,7 @@ LIBQPS_SRC = \ test/cpp/qps/client_sync.cc \ test/cpp/qps/driver.cc \ test/cpp/qps/limit_cores.cc \ + test/cpp/qps/parse_json.cc \ test/cpp/qps/qps_worker.cc \ test/cpp/qps/report.cc \ test/cpp/qps/server_async.cc \ @@ -4308,6 +4484,7 @@ $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/src/proto/grpc/testin $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/limit_cores.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/parse_json.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc @@ -6469,6 +6646,38 @@ endif endif +BIN_DECODER_TEST_SRC = \ + test/core/transport/chttp2/bin_decoder_test.c \ + +BIN_DECODER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BIN_DECODER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bin_decoder_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/bin_decoder_test: $(BIN_DECODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(BIN_DECODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_decoder_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/transport/chttp2/bin_decoder_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a + +deps_bin_decoder_test: $(BIN_DECODER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BIN_DECODER_TEST_OBJS:.o=.dep) +endif +endif + + BIN_ENCODER_TEST_SRC = \ test/core/transport/chttp2/bin_encoder_test.c \ @@ -11285,6 +11494,52 @@ endif endif +PROTO_SERVER_REFLECTION_TEST_SRC = \ + 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)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/proto_server_reflection_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)/proto_server_reflection_test: protobuf_dep_error + +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 + $(E) "[LD] Linking $@" + $(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 + +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/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) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(PROTO_SERVER_REFLECTION_TEST_OBJS:.o=.dep) +endif +endif + + QPS_INTERARRIVAL_TEST_SRC = \ test/cpp/qps/qps_interarrival_test.cc \ @@ -11329,7 +11584,6 @@ endif QPS_JSON_DRIVER_SRC = \ - test/cpp/qps/parse_json.cc \ test/cpp/qps/qps_json_driver.cc \ QPS_JSON_DRIVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(QPS_JSON_DRIVER_SRC)))) @@ -11361,8 +11615,6 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/parse_json.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a - $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_json_driver.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_qps_json_driver: $(QPS_JSON_DRIVER_OBJS:.o=.dep) @@ -13554,6 +13806,38 @@ endif endif +H2_FD_TEST_SRC = \ + test/core/end2end/fixtures/h2_fd.c \ + +H2_FD_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FD_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/h2_fd_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/h2_fd_test: $(H2_FD_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_FD_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_fd_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_fd.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_fd_test: $(H2_FD_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(H2_FD_TEST_OBJS:.o=.dep) +endif +endif + + H2_FULL_TEST_SRC = \ test/core/end2end/fixtures/h2_full.c \ @@ -14010,6 +14294,26 @@ ifneq ($(NO_DEPS),true) endif +H2_FD_NOSEC_TEST_SRC = \ + test/core/end2end/fixtures/h2_fd.c \ + +H2_FD_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FD_NOSEC_TEST_SRC)))) + + +$(BINDIR)/$(CONFIG)/h2_fd_nosec_test: $(H2_FD_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_FD_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_fd_nosec_test + +$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_fd.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_fd_nosec_test: $(H2_FD_NOSEC_TEST_OBJS:.o=.dep) + +ifneq ($(NO_DEPS),true) +-include $(H2_FD_NOSEC_TEST_OBJS:.o=.dep) +endif + + H2_FULL_NOSEC_TEST_SRC = \ test/core/end2end/fixtures/h2_full.c \ @@ -14552,6 +14856,10 @@ src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP) src/cpp/common/secure_auth_context.cc: $(OPENSSL_DEP) src/cpp/common/secure_channel_arguments.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_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/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP) test/core/bad_client/bad_client.c: $(OPENSSL_DEP) @@ -14575,6 +14883,7 @@ test/cpp/qps/client_async.cc: $(OPENSSL_DEP) test/cpp/qps/client_sync.cc: $(OPENSSL_DEP) test/cpp/qps/driver.cc: $(OPENSSL_DEP) test/cpp/qps/limit_cores.cc: $(OPENSSL_DEP) +test/cpp/qps/parse_json.cc: $(OPENSSL_DEP) test/cpp/qps/qps_worker.cc: $(OPENSSL_DEP) test/cpp/qps/report.cc: $(OPENSSL_DEP) test/cpp/qps/server_async.cc: $(OPENSSL_DEP) diff --git a/binding.gyp b/binding.gyp index 4d9e9a49066..fc61a9d01fc 100644 --- a/binding.gyp +++ b/binding.gyp @@ -571,7 +571,7 @@ 'src/core/lib/channel/connected_channel.c', 'src/core/lib/channel/http_client_filter.c', 'src/core/lib/channel/http_server_filter.c', - 'src/core/lib/compression/compression_algorithm.c', + 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', 'src/core/lib/http/format_request.c', @@ -648,6 +648,7 @@ 'src/core/lib/transport/transport.c', 'src/core/lib/transport/transport_op_string.c', 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c', + 'src/core/ext/transport/chttp2/transport/bin_decoder.c', 'src/core/ext/transport/chttp2/transport/bin_encoder.c', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c', 'src/core/ext/transport/chttp2/transport/chttp2_transport.c', @@ -718,7 +719,9 @@ 'src/core/ext/client_config/subchannel_index.c', 'src/core/ext/client_config/uri_parser.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', + 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c', + 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'third_party/nanopb/pb_common.c', diff --git a/build.yaml b/build.yaml index 335e68409f7..291d3fa4434 100644 --- a/build.yaml +++ b/build.yaml @@ -154,6 +154,7 @@ filegroups: - include/grpc/byte_buffer_reader.h - include/grpc/compression.h - include/grpc/grpc.h + - include/grpc/grpc_posix.h - include/grpc/status.h headers: - src/core/lib/channel/channel_args.h @@ -239,7 +240,7 @@ filegroups: - src/core/lib/channel/connected_channel.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c - - src/core/lib/compression/compression_algorithm.c + - src/core/lib/compression/compression.c - src/core/lib/compression/message_compress.c - src/core/lib/debug/trace.c - src/core/lib/http/format_request.c @@ -505,6 +506,7 @@ filegroups: - gpr_test_util - name: grpc_transport_chttp2 headers: + - src/core/ext/transport/chttp2/transport/bin_decoder.h - src/core/ext/transport/chttp2/transport/bin_encoder.h - src/core/ext/transport/chttp2/transport/chttp2_transport.h - src/core/ext/transport/chttp2/transport/frame.h @@ -526,6 +528,7 @@ filegroups: - src/core/ext/transport/chttp2/transport/timeout_encoding.h - src/core/ext/transport/chttp2/transport/varint.h src: + - src/core/ext/transport/chttp2/transport/bin_decoder.c - src/core/ext/transport/chttp2/transport/bin_encoder.c - src/core/ext/transport/chttp2/transport/chttp2_plugin.c - src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -561,6 +564,7 @@ filegroups: - name: grpc_transport_chttp2_client_insecure src: - src/core/ext/transport/chttp2/client/insecure/channel_create.c + - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c uses: - grpc_transport_chttp2 - grpc_base @@ -576,6 +580,7 @@ filegroups: - name: grpc_transport_chttp2_server_insecure src: - src/core/ext/transport/chttp2/server/insecure/server_chttp2.c + - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c uses: - grpc_transport_chttp2 - grpc_base @@ -632,11 +637,13 @@ filegroups: - include/grpc++/client_context.h - include/grpc++/completion_queue.h - include/grpc++/create_channel.h + - include/grpc++/create_channel_posix.h - include/grpc++/generic/async_generic_service.h - include/grpc++/generic/generic_stub.h - include/grpc++/grpc++.h - include/grpc++/impl/call.h - include/grpc++/impl/client_unary_call.h + - include/grpc++/impl/codegen/core_codegen.h - include/grpc++/impl/grpc_library.h - include/grpc++/impl/method_handler_impl.h - include/grpc++/impl/rpc_method.h @@ -659,6 +666,7 @@ filegroups: - include/grpc++/server.h - include/grpc++/server_builder.h - include/grpc++/server_context.h + - include/grpc++/server_posix.h - include/grpc++/support/async_stream.h - include/grpc++/support/async_unary_call.h - include/grpc++/support/byte_buffer.h @@ -673,7 +681,6 @@ filegroups: - include/grpc++/support/time.h headers: - src/cpp/client/create_channel_internal.h - - src/cpp/common/core_codegen.h - src/cpp/server/dynamic_thread_pool.h - src/cpp/server/thread_pool_interface.h src: @@ -681,6 +688,7 @@ filegroups: - src/cpp/client/client_context.cc - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc + - src/cpp/client/create_channel_posix.cc - src/cpp/client/credentials.cc - src/cpp/client/generic_stub.cc - src/cpp/client/insecure_credentials.cc @@ -696,6 +704,7 @@ filegroups: - src/cpp/server/server_builder.cc - src/cpp/server/server_context.cc - src/cpp/server/server_credentials.cc + - src/cpp/server/server_posix.cc - src/cpp/util/byte_buffer.cc - src/cpp/util/slice.cc - src/cpp/util/status.cc @@ -932,8 +941,8 @@ libs: build: all language: c++ headers: + - include/grpc++/impl/codegen/core_codegen.h - src/cpp/client/secure_credentials.h - - src/cpp/common/core_codegen.h - src/cpp/common/secure_auth_context.h - src/cpp/server/secure_server_credentials.h src: @@ -953,6 +962,24 @@ libs: - grpc++_codegen_base_src secure: check vs_project_guid: '{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}' +- name: grpc++_reflection + build: all + language: c++ + public_headers: + - include/grpc++/ext/proto_server_reflection_plugin.h + - include/grpc++/ext/reflection.grpc.pb.h + - include/grpc++/ext/reflection.pb.h + headers: + - src/cpp/ext/proto_server_reflection.h + src: + - src/cpp/ext/proto_server_reflection.cc + - src/cpp/ext/proto_server_reflection_plugin.cc + - src/cpp/ext/reflection.grpc.pb.cc + - src/cpp/ext/reflection.pb.cc + deps: + - grpc++ + filegroups: + - grpc++_codegen_proto - name: grpc++_test_config build: private language: c++ @@ -1120,6 +1147,7 @@ libs: - test/cpp/qps/histogram.h - test/cpp/qps/interarrival.h - test/cpp/qps/limit_cores.h + - test/cpp/qps/parse_json.h - test/cpp/qps/qps_worker.h - test/cpp/qps/report.h - test/cpp/qps/server.h @@ -1136,6 +1164,7 @@ libs: - test/cpp/qps/client_sync.cc - test/cpp/qps/driver.cc - test/cpp/qps/limit_cores.cc + - test/cpp/qps/parse_json.cc - test/cpp/qps/qps_worker.cc - test/cpp/qps/report.cc - test/cpp/qps/server_async.cc @@ -1220,6 +1249,14 @@ targets: - test/core/end2end/fuzzers/api_fuzzer_corpus dict: test/core/end2end/fuzzers/api_fuzzer.dictionary maxlen: 2048 +- name: bin_decoder_test + build: test + language: c + src: + - test/core/transport/chttp2/bin_decoder_test.c + deps: + - grpc_test_util + - grpc - name: bin_encoder_test build: test language: c @@ -2789,6 +2826,23 @@ targets: - grpc - gpr_test_util - gpr +- name: proto_server_reflection_test + gtest: true + build: test + language: c++ + headers: + - test/cpp/util/proto_reflection_descriptor_database.h + src: + - test/cpp/end2end/proto_server_reflection_test.cc + - test/cpp/util/proto_reflection_descriptor_database.cc + deps: + - grpc++_reflection + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr - name: qps_interarrival_test build: test run: false @@ -2811,10 +2865,7 @@ targets: build: test run: false language: c++ - headers: - - test/cpp/qps/parse_json.h src: - - test/cpp/qps/parse_json.cc - test/cpp/qps/qps_json_driver.cc deps: - qps diff --git a/composer.json b/composer.json index b77a59e351c..05ac0037146 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,6 @@ "name": "grpc/grpc", "type": "library", "description": "gRPC library for PHP", - "version": "0.15.0", "keywords": ["rpc"], "homepage": "http://grpc.io", "license": "BSD-3-Clause", diff --git a/config.m4 b/config.m4 index 54adac1bdc1..bf5aa244ff2 100644 --- a/config.m4 +++ b/config.m4 @@ -90,7 +90,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/connected_channel.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/compression/compression_algorithm.c \ + src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ src/core/lib/http/format_request.c \ @@ -167,6 +167,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/transport/transport.c \ src/core/lib/transport/transport_op_string.c \ src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \ + src/core/ext/transport/chttp2/transport/bin_decoder.c \ src/core/ext/transport/chttp2/transport/bin_encoder.c \ src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ src/core/ext/transport/chttp2/transport/chttp2_transport.c \ @@ -237,7 +238,9 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ + src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \ + src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ third_party/nanopb/pb_common.c \ diff --git a/doc/c-style-guide.md b/doc/c-style-guide.md index 87de8892ddd..d6f9bbd7d4a 100644 --- a/doc/c-style-guide.md +++ b/doc/c-style-guide.md @@ -11,7 +11,7 @@ General - Layout rules are defined by clang-format, and all code should be passed through clang-format. A (docker-based) script to do so is included in - tools/distrib/clang_format_code.sh. + [tools/distrib/clang\_format\_code.sh] (../tools/distrib/clang_format_code.sh). Header Files ------------ diff --git a/doc/command_line_tool.md b/doc/command_line_tool.md new file mode 100644 index 00000000000..89a70548b8b --- /dev/null +++ b/doc/command_line_tool.md @@ -0,0 +1,77 @@ +# gRPC command line tool + +## Overview + +This document describes the command line tool that comes with gRPC repository. It is desireable to have command line +tools written in other languages to roughly follow the same syntax and flags. + +At this point, the tool needs to be built from source, and it should be moved out to grpc-tools repository as a stand +alone application once it is mature enough. + +## Core functionality + +The command line tool can do the following things: + +- Send unary rpc. +- Attach metadata and display received metadata. +- Handle common authentication to server. +- Find the request/response types from a given proto file. +- Read proto request in text form. +- Read request in wire form (for protobuf messages, this means serialized binary form). +- Display proto response in text form. +- Write response in wire form to a file. + +The command line tool should support the following things: + +- List server services and methods through server reflection. +- Infer request/response types from server reflection result. +- Fine-grained auth control (such as, use this oauth token to talk to the server). +- Send streaming rpc. + +## Code location + +To use the tool, you need to get the grpc repository and in the grpc directory execute + +``` +$ make grpc_cli +``` + +The main file can be found at +https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc + +## Usage + +### Basic usage + +Send a rpc to a helloworld server at `localhost:50051`: + +``` +$ bins/opt/grpc_cli call localhost:50051 SayHello examples/protos/helloworld.proto \ + "name: 'world'" --enable_ssl=false +``` + +On success, the tool will print out + +``` +Rpc succeeded with OK status +Response: + message: "Hello world" +``` + +The `localhost:50051` part indicates the server you are connecting to. `SayHello` is (part of) the +gRPC method string. Then there is the path to the proto file containing the service definition, +if it is not under current directory, you can use `--proto_path` to specify a new search root. +`"name: 'world'"` is the text format of the request proto message. +We are not using ssl here by `--enable_ssl=false`. For information on more +flags, look at the comments of `grpc_cli.cc`. + +### Send non-proto rpc + +For using gRPC with protocols other than probobuf, you will need the exact method name string +and a file containing the raw bytes to be sent on the wire + +``` +$ bins/opt/grpc_cli call localhost:50051 /helloworld.Greeter/SayHello --input_binary_file=input.bin \ + --output_binary_file=output.bin +``` +On success, you will need to read or decode the response from the `output.bin` file. diff --git a/doc/cpp-style-guide.md b/doc/cpp-style-guide.md new file mode 100644 index 00000000000..9408c4abd68 --- /dev/null +++ b/doc/cpp-style-guide.md @@ -0,0 +1,85 @@ +GRPC C++ STYLE GUIDE +===================== + +Background +---------- + +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 +so is included in [tools/distrib/clang\_format\_code.sh] +(../tools/distrib/clang_format_code.sh). + + +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 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` 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`. diff --git a/doc/statuscodes.md b/doc/statuscodes.md index 84258c8d122..c918f9ed9ab 100644 --- a/doc/statuscodes.md +++ b/doc/statuscodes.md @@ -21,6 +21,8 @@ Only a subset of the pre-defined status codes are generated by the gRPC librarie | Flow-control protocol violation | INTERNAL | Both | | Error parsing returned status | UNKNOWN | Client | | Incorrect Auth metadata ( Credentials failed to get metadata, Incompatible credentials set on channel and call, Invalid host set in `:authority` metadata, etc.) | UNAUTHENTICATED | Both | +| Request cardinality violation (method requires exactly one request but client sent some other number of requests) | UNIMPLEMENTED | Server| +| Response cardinality violation (method requires exactly one response but server sent some other number of responses) | UNIMPLEMENTED | Client| | Error parsing response proto | INTERNAL | Client| | Error parsing request proto | INTERNAL | Server| diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc index c1f5eb55f05..33de59fb957 100644 --- a/examples/cpp/helloworld/greeter_async_client.cc +++ b/examples/cpp/helloworld/greeter_async_client.cc @@ -87,7 +87,9 @@ class GreeterClient { void* got_tag; bool ok = false; // Block until the next result is available in the completion queue "cq". - cq.Next(&got_tag, &ok); + // The return value of Next should always be checked. This return value + // tells us whether there is any kind of event or the cq_ is shutting down. + GPR_ASSERT(cq.Next(&got_tag, &ok)); // Verify that the result from "cq" corresponds, by its tag, our previous // request. diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc index 64e065b1e40..ead44182e57 100644 --- a/examples/cpp/helloworld/greeter_async_server.cc +++ b/examples/cpp/helloworld/greeter_async_server.cc @@ -160,7 +160,9 @@ class ServerImpl final { // Block waiting to read the next event from the completion queue. The // event is uniquely identified by its tag, which in this case is the // memory address of a CallData instance. - cq_->Next(&tag, &ok); + // The return value of Next should always be checked. This return value + // tells us whether there is any kind of event or cq_ is shutting down. + GPR_ASSERT(cq_->Next(&tag, &ok)); GPR_ASSERT(ok); static_cast(tag)->Proceed(); } diff --git a/examples/php/greeter_client.php b/examples/php/greeter_client.php index 718ef88c644..a5c0865393d 100644 --- a/examples/php/greeter_client.php +++ b/examples/php/greeter_client.php @@ -32,19 +32,21 @@ * */ -require dirname(__FILE__) . '/vendor/autoload.php'; -require dirname(__FILE__) . '/helloworld.php'; +require dirname(__FILE__).'/vendor/autoload.php'; +require dirname(__FILE__).'/helloworld.php'; -function greet($name) { - $client = new helloworld\GreeterClient('localhost:50051', [ - 'credentials' => Grpc\ChannelCredentials::createInsecure() - ]); - $request = new helloworld\HelloRequest(); - $request->setName($name); - list($reply, $status) = $client->SayHello($request)->wait(); - $message = $reply->getMessage(); - return $message; +function greet($name) +{ + $client = new helloworld\GreeterClient('localhost:50051', [ + 'credentials' => Grpc\ChannelCredentials::createInsecure(), + ]); + $request = new helloworld\HelloRequest(); + $request->setName($name); + list($reply, $status) = $client->SayHello($request)->wait(); + $message = $reply->getMessage(); + + return $message; } $name = !empty($argv[1]) ? $argv[1] : 'world'; -print(greet($name)."\n"); +echo greet($name)."\n"; diff --git a/examples/php/helloworld.php b/examples/php/helloworld.php index 50923e6fcdc..697f52aa653 100644 --- a/examples/php/helloworld.php +++ b/examples/php/helloworld.php @@ -5,154 +5,164 @@ namespace helloworld { - class HelloRequest extends \DrSlump\Protobuf\Message { - - /** @var string */ + class HelloRequest extends \DrSlump\Protobuf\Message + { + /** @var string */ public $name = null; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloRequest'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloRequest'); // OPTIONAL STRING name = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "name"; - $f->type = \DrSlump\Protobuf::TYPE_STRING; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); - } + $f->number = 1; + $f->name = 'name'; + $f->type = \DrSlump\Protobuf::TYPE_STRING; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); - return $descriptor; - } + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; + } /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasName(){ - return $this->_has(1); + public function hasName() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \helloworld\HelloRequest */ - public function clearName(){ - return $this->_clear(1); + public function clearName() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return string */ - public function getName(){ - return $this->_get(1); + public function getName() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param string $value + * * @return \helloworld\HelloRequest */ - public function setName( $value){ - return $this->_set(1, $value); + public function setName($value) + { + return $this->_set(1, $value); } } } namespace helloworld { - class HelloReply extends \DrSlump\Protobuf\Message { - - /** @var string */ + class HelloReply extends \DrSlump\Protobuf\Message + { + /** @var string */ public $message = null; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloReply'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloReply'); // OPTIONAL STRING message = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "message"; - $f->type = \DrSlump\Protobuf::TYPE_STRING; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); - } + $f->number = 1; + $f->name = 'message'; + $f->type = \DrSlump\Protobuf::TYPE_STRING; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); - return $descriptor; - } + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; + } /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasMessage(){ - return $this->_has(1); + public function hasMessage() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \helloworld\HelloReply */ - public function clearMessage(){ - return $this->_clear(1); + public function clearMessage() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return string */ - public function getMessage(){ - return $this->_get(1); + public function getMessage() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param string $value + * * @return \helloworld\HelloReply */ - public function setMessage( $value){ - return $this->_set(1, $value); + public function setMessage($value) + { + return $this->_set(1, $value); } } } namespace helloworld { - class GreeterClient extends \Grpc\BaseStub { - - public function __construct($hostname, $opts) { - parent::__construct($hostname, $opts); - } + class GreeterClient extends \Grpc\BaseStub + { + public function __construct($hostname, $opts) + { + parent::__construct($hostname, $opts); + } /** * @param helloworld\HelloRequest $input */ - public function SayHello(\helloworld\HelloRequest $argument, $metadata = array(), $options = array()) { - return $this->_simpleRequest('/helloworld.Greeter/SayHello', $argument, '\helloworld\HelloReply::deserialize', $metadata, $options); + public function SayHello(\helloworld\HelloRequest $argument, $metadata = array(), $options = array()) + { + return $this->_simpleRequest('/helloworld.Greeter/SayHello', $argument, '\helloworld\HelloReply::deserialize', $metadata, $options); } } } diff --git a/examples/php/route_guide/route_guide.php b/examples/php/route_guide/route_guide.php index 0de319890d5..65045d01e17 100644 --- a/examples/php/route_guide/route_guide.php +++ b/examples/php/route_guide/route_guide.php @@ -5,725 +5,785 @@ namespace routeguide { - class Point extends \DrSlump\Protobuf\Message { - - /** @var int */ + class Point extends \DrSlump\Protobuf\Message + { + /** @var int */ public $latitude = 0; - + /** @var int */ public $longitude = 0; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Point'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Point'); // OPTIONAL INT32 latitude = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "latitude"; - $f->type = \DrSlump\Protobuf::TYPE_INT32; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->default = 0; - $descriptor->addField($f); + $f->number = 1; + $f->name = 'latitude'; + $f->type = \DrSlump\Protobuf::TYPE_INT32; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->default = 0; + $descriptor->addField($f); // OPTIONAL INT32 longitude = 2 $f = new \DrSlump\Protobuf\Field(); - $f->number = 2; - $f->name = "longitude"; - $f->type = \DrSlump\Protobuf::TYPE_INT32; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->default = 0; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); + $f->number = 2; + $f->name = 'longitude'; + $f->type = \DrSlump\Protobuf::TYPE_INT32; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->default = 0; + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; } - return $descriptor; - } - /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasLatitude(){ - return $this->_has(1); + public function hasLatitude() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \routeguide\Point */ - public function clearLatitude(){ - return $this->_clear(1); + public function clearLatitude() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return int */ - public function getLatitude(){ - return $this->_get(1); + public function getLatitude() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param int $value + * * @return \routeguide\Point */ - public function setLatitude( $value){ - return $this->_set(1, $value); + public function setLatitude($value) + { + return $this->_set(1, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasLongitude(){ - return $this->_has(2); + public function hasLongitude() + { + return $this->_has(2); } - + /** - * Clear value + * Clear value. * * @return \routeguide\Point */ - public function clearLongitude(){ - return $this->_clear(2); + public function clearLongitude() + { + return $this->_clear(2); } - + /** - * Get value + * Get value. * * @return int */ - public function getLongitude(){ - return $this->_get(2); + public function getLongitude() + { + return $this->_get(2); } - + /** - * Set value + * Set value. * * @param int $value + * * @return \routeguide\Point */ - public function setLongitude( $value){ - return $this->_set(2, $value); + public function setLongitude($value) + { + return $this->_set(2, $value); } } } namespace routeguide { - class Rectangle extends \DrSlump\Protobuf\Message { - - /** @var \routeguide\Point */ + class Rectangle extends \DrSlump\Protobuf\Message + { + /** @var \routeguide\Point */ public $lo = null; - + /** @var \routeguide\Point */ public $hi = null; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Rectangle'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Rectangle'); // OPTIONAL MESSAGE lo = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "lo"; - $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\routeguide\Point'; - $descriptor->addField($f); + $f->number = 1; + $f->name = 'lo'; + $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->reference = '\routeguide\Point'; + $descriptor->addField($f); // OPTIONAL MESSAGE hi = 2 $f = new \DrSlump\Protobuf\Field(); - $f->number = 2; - $f->name = "hi"; - $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\routeguide\Point'; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); + $f->number = 2; + $f->name = 'hi'; + $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->reference = '\routeguide\Point'; + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; } - return $descriptor; - } - /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasLo(){ - return $this->_has(1); + public function hasLo() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \routeguide\Rectangle */ - public function clearLo(){ - return $this->_clear(1); + public function clearLo() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return \routeguide\Point */ - public function getLo(){ - return $this->_get(1); + public function getLo() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param \routeguide\Point $value + * * @return \routeguide\Rectangle */ - public function setLo(\routeguide\Point $value){ - return $this->_set(1, $value); + public function setLo(\routeguide\Point $value) + { + return $this->_set(1, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasHi(){ - return $this->_has(2); + public function hasHi() + { + return $this->_has(2); } - + /** - * Clear value + * Clear value. * * @return \routeguide\Rectangle */ - public function clearHi(){ - return $this->_clear(2); + public function clearHi() + { + return $this->_clear(2); } - + /** - * Get value + * Get value. * * @return \routeguide\Point */ - public function getHi(){ - return $this->_get(2); + public function getHi() + { + return $this->_get(2); } - + /** - * Set value + * Set value. * * @param \routeguide\Point $value + * * @return \routeguide\Rectangle */ - public function setHi(\routeguide\Point $value){ - return $this->_set(2, $value); + public function setHi(\routeguide\Point $value) + { + return $this->_set(2, $value); } } } namespace routeguide { - class Feature extends \DrSlump\Protobuf\Message { - - /** @var string */ + class Feature extends \DrSlump\Protobuf\Message + { + /** @var string */ public $name = null; - + /** @var \routeguide\Point */ public $location = null; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Feature'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Feature'); // OPTIONAL STRING name = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "name"; - $f->type = \DrSlump\Protobuf::TYPE_STRING; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $descriptor->addField($f); + $f->number = 1; + $f->name = 'name'; + $f->type = \DrSlump\Protobuf::TYPE_STRING; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); // OPTIONAL MESSAGE location = 2 $f = new \DrSlump\Protobuf\Field(); - $f->number = 2; - $f->name = "location"; - $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\routeguide\Point'; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); + $f->number = 2; + $f->name = 'location'; + $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->reference = '\routeguide\Point'; + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; } - return $descriptor; - } - /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasName(){ - return $this->_has(1); + public function hasName() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \routeguide\Feature */ - public function clearName(){ - return $this->_clear(1); + public function clearName() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return string */ - public function getName(){ - return $this->_get(1); + public function getName() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param string $value + * * @return \routeguide\Feature */ - public function setName( $value){ - return $this->_set(1, $value); + public function setName($value) + { + return $this->_set(1, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasLocation(){ - return $this->_has(2); + public function hasLocation() + { + return $this->_has(2); } - + /** - * Clear value + * Clear value. * * @return \routeguide\Feature */ - public function clearLocation(){ - return $this->_clear(2); + public function clearLocation() + { + return $this->_clear(2); } - + /** - * Get value + * Get value. * * @return \routeguide\Point */ - public function getLocation(){ - return $this->_get(2); + public function getLocation() + { + return $this->_get(2); } - + /** - * Set value + * Set value. * * @param \routeguide\Point $value + * * @return \routeguide\Feature */ - public function setLocation(\routeguide\Point $value){ - return $this->_set(2, $value); + public function setLocation(\routeguide\Point $value) + { + return $this->_set(2, $value); } } } namespace routeguide { - class RouteNote extends \DrSlump\Protobuf\Message { - - /** @var \routeguide\Point */ + class RouteNote extends \DrSlump\Protobuf\Message + { + /** @var \routeguide\Point */ public $location = null; - + /** @var string */ public $message = null; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteNote'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteNote'); // OPTIONAL MESSAGE location = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "location"; - $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\routeguide\Point'; - $descriptor->addField($f); + $f->number = 1; + $f->name = 'location'; + $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->reference = '\routeguide\Point'; + $descriptor->addField($f); // OPTIONAL STRING message = 2 $f = new \DrSlump\Protobuf\Field(); - $f->number = 2; - $f->name = "message"; - $f->type = \DrSlump\Protobuf::TYPE_STRING; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); - } + $f->number = 2; + $f->name = 'message'; + $f->type = \DrSlump\Protobuf::TYPE_STRING; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); - return $descriptor; - } + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; + } /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasLocation(){ - return $this->_has(1); + public function hasLocation() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \routeguide\RouteNote */ - public function clearLocation(){ - return $this->_clear(1); + public function clearLocation() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return \routeguide\Point */ - public function getLocation(){ - return $this->_get(1); + public function getLocation() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param \routeguide\Point $value + * * @return \routeguide\RouteNote */ - public function setLocation(\routeguide\Point $value){ - return $this->_set(1, $value); + public function setLocation(\routeguide\Point $value) + { + return $this->_set(1, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasMessage(){ - return $this->_has(2); + public function hasMessage() + { + return $this->_has(2); } - + /** - * Clear value + * Clear value. * * @return \routeguide\RouteNote */ - public function clearMessage(){ - return $this->_clear(2); + public function clearMessage() + { + return $this->_clear(2); } - + /** - * Get value + * Get value. * * @return string */ - public function getMessage(){ - return $this->_get(2); + public function getMessage() + { + return $this->_get(2); } - + /** - * Set value + * Set value. * * @param string $value + * * @return \routeguide\RouteNote */ - public function setMessage( $value){ - return $this->_set(2, $value); + public function setMessage($value) + { + return $this->_set(2, $value); } } } namespace routeguide { - class RouteSummary extends \DrSlump\Protobuf\Message { - - /** @var int */ + class RouteSummary extends \DrSlump\Protobuf\Message + { + /** @var int */ public $point_count = 0; - + /** @var int */ public $feature_count = 0; - + /** @var int */ public $distance = 0; - + /** @var int */ public $elapsed_time = 0; - /** @var \Closure[] */ protected static $__extensions = array(); - public static function descriptor() - { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteSummary'); + public static function descriptor() + { + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteSummary'); // OPTIONAL INT32 point_count = 1 $f = new \DrSlump\Protobuf\Field(); - $f->number = 1; - $f->name = "point_count"; - $f->type = \DrSlump\Protobuf::TYPE_INT32; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->default = 0; - $descriptor->addField($f); + $f->number = 1; + $f->name = 'point_count'; + $f->type = \DrSlump\Protobuf::TYPE_INT32; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->default = 0; + $descriptor->addField($f); // OPTIONAL INT32 feature_count = 2 $f = new \DrSlump\Protobuf\Field(); - $f->number = 2; - $f->name = "feature_count"; - $f->type = \DrSlump\Protobuf::TYPE_INT32; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->default = 0; - $descriptor->addField($f); + $f->number = 2; + $f->name = 'feature_count'; + $f->type = \DrSlump\Protobuf::TYPE_INT32; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->default = 0; + $descriptor->addField($f); // OPTIONAL INT32 distance = 3 $f = new \DrSlump\Protobuf\Field(); - $f->number = 3; - $f->name = "distance"; - $f->type = \DrSlump\Protobuf::TYPE_INT32; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->default = 0; - $descriptor->addField($f); + $f->number = 3; + $f->name = 'distance'; + $f->type = \DrSlump\Protobuf::TYPE_INT32; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->default = 0; + $descriptor->addField($f); // OPTIONAL INT32 elapsed_time = 4 $f = new \DrSlump\Protobuf\Field(); - $f->number = 4; - $f->name = "elapsed_time"; - $f->type = \DrSlump\Protobuf::TYPE_INT32; - $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->default = 0; - $descriptor->addField($f); - - foreach (self::$__extensions as $cb) { - $descriptor->addField($cb(), true); + $f->number = 4; + $f->name = 'elapsed_time'; + $f->type = \DrSlump\Protobuf::TYPE_INT32; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $f->default = 0; + $descriptor->addField($f); + + foreach (self::$__extensions as $cb) { + $descriptor->addField($cb(), true); + } + + return $descriptor; } - return $descriptor; - } - /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasPointCount(){ - return $this->_has(1); + public function hasPointCount() + { + return $this->_has(1); } - + /** - * Clear value + * Clear value. * * @return \routeguide\RouteSummary */ - public function clearPointCount(){ - return $this->_clear(1); + public function clearPointCount() + { + return $this->_clear(1); } - + /** - * Get value + * Get value. * * @return int */ - public function getPointCount(){ - return $this->_get(1); + public function getPointCount() + { + return $this->_get(1); } - + /** - * Set value + * Set value. * * @param int $value + * * @return \routeguide\RouteSummary */ - public function setPointCount( $value){ - return $this->_set(1, $value); + public function setPointCount($value) + { + return $this->_set(1, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasFeatureCount(){ - return $this->_has(2); + public function hasFeatureCount() + { + return $this->_has(2); } - + /** - * Clear value + * Clear value. * * @return \routeguide\RouteSummary */ - public function clearFeatureCount(){ - return $this->_clear(2); + public function clearFeatureCount() + { + return $this->_clear(2); } - + /** - * Get value + * Get value. * * @return int */ - public function getFeatureCount(){ - return $this->_get(2); + public function getFeatureCount() + { + return $this->_get(2); } - + /** - * Set value + * Set value. * * @param int $value + * * @return \routeguide\RouteSummary */ - public function setFeatureCount( $value){ - return $this->_set(2, $value); + public function setFeatureCount($value) + { + return $this->_set(2, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasDistance(){ - return $this->_has(3); + public function hasDistance() + { + return $this->_has(3); } - + /** - * Clear value + * Clear value. * * @return \routeguide\RouteSummary */ - public function clearDistance(){ - return $this->_clear(3); + public function clearDistance() + { + return $this->_clear(3); } - + /** - * Get value + * Get value. * * @return int */ - public function getDistance(){ - return $this->_get(3); + public function getDistance() + { + return $this->_get(3); } - + /** - * Set value + * Set value. * * @param int $value + * * @return \routeguide\RouteSummary */ - public function setDistance( $value){ - return $this->_set(3, $value); + public function setDistance($value) + { + return $this->_set(3, $value); } - + /** - * Check if has a value + * Check if has a value. * - * @return boolean + * @return bool */ - public function hasElapsedTime(){ - return $this->_has(4); + public function hasElapsedTime() + { + return $this->_has(4); } - + /** - * Clear value + * Clear value. * * @return \routeguide\RouteSummary */ - public function clearElapsedTime(){ - return $this->_clear(4); + public function clearElapsedTime() + { + return $this->_clear(4); } - + /** - * Get value + * Get value. * * @return int */ - public function getElapsedTime(){ - return $this->_get(4); + public function getElapsedTime() + { + return $this->_get(4); } - + /** - * Set value + * Set value. * * @param int $value + * * @return \routeguide\RouteSummary */ - public function setElapsedTime( $value){ - return $this->_set(4, $value); + public function setElapsedTime($value) + { + return $this->_set(4, $value); } } } namespace routeguide { - class RouteGuideClient extends \Grpc\BaseStub { - - public function __construct($hostname, $opts) { - parent::__construct($hostname, $opts); - } + class RouteGuideClient extends \Grpc\BaseStub + { + public function __construct($hostname, $opts) + { + parent::__construct($hostname, $opts); + } /** * @param routeguide\Point $input */ - public function GetFeature(\routeguide\Point $argument, $metadata = array(), $options = array()) { - return $this->_simpleRequest('/routeguide.RouteGuide/GetFeature', $argument, '\routeguide\Feature::deserialize', $metadata, $options); + public function GetFeature(\routeguide\Point $argument, $metadata = array(), $options = array()) + { + return $this->_simpleRequest('/routeguide.RouteGuide/GetFeature', $argument, '\routeguide\Feature::deserialize', $metadata, $options); } /** * @param routeguide\Rectangle $input */ - public function ListFeatures($argument, $metadata = array(), $options = array()) { - return $this->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures', $argument, '\routeguide\Feature::deserialize', $metadata, $options); + public function ListFeatures($argument, $metadata = array(), $options = array()) + { + return $this->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures', $argument, '\routeguide\Feature::deserialize', $metadata, $options); } /** * @param routeguide\Point $input */ - public function RecordRoute($metadata = array()) { - return $this->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute', '\routeguide\RouteSummary::deserialize', $metadata); + public function RecordRoute($metadata = array()) + { + return $this->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute', '\routeguide\RouteSummary::deserialize', $metadata); } /** * @param routeguide\RouteNote $input */ - public function RouteChat($metadata = array()) { - return $this->_bidiRequest('/routeguide.RouteGuide/RouteChat', '\routeguide\RouteNote::deserialize', $metadata); + public function RouteChat($metadata = array()) + { + return $this->_bidiRequest('/routeguide.RouteGuide/RouteChat', '\routeguide\RouteNote::deserialize', $metadata); } } } diff --git a/examples/php/route_guide/route_guide_client.php b/examples/php/route_guide/route_guide_client.php index 2f9533be4b7..b3cd6067972 100644 --- a/examples/php/route_guide/route_guide_client.php +++ b/examples/php/route_guide/route_guide_client.php @@ -32,48 +32,50 @@ * */ -require dirname(__FILE__) . '/../vendor/autoload.php'; -require dirname(__FILE__) . '/route_guide.php'; +require dirname(__FILE__).'/../vendor/autoload.php'; +require dirname(__FILE__).'/route_guide.php'; define('COORD_FACTOR', 1e7); $client = new routeguide\RouteGuideClient('localhost:50051', [ - 'credentials' => Grpc\ChannelCredentials::createInsecure() + 'credentials' => Grpc\ChannelCredentials::createInsecure(), ]); -function printFeature($feature) { - $name = $feature->getName(); - if (!$name) { - $name_str = "no feature"; - } else { - $name_str = "feature called $name"; - } - print sprintf("Found %s \n at %f, %f\n", $name_str, - $feature->getLocation()->getLatitude() / COORD_FACTOR, - $feature->getLocation()->getLongitude() / COORD_FACTOR); +function printFeature($feature) +{ + $name = $feature->getName(); + if (!$name) { + $name_str = 'no feature'; + } else { + $name_str = "feature called $name"; + } + echo sprintf("Found %s \n at %f, %f\n", $name_str, + $feature->getLocation()->getLatitude() / COORD_FACTOR, + $feature->getLocation()->getLongitude() / COORD_FACTOR); } /** * Run the getFeature demo. Calls getFeature with a point known to have a * feature and a point known not to have a feature. */ -function runGetFeature() { - print "Running GetFeature...\n"; - global $client; - - $point = new routeguide\Point(); - $points = array( - array(409146138, -746188906), - array(0, 0), - ); - - foreach ($points as $p) { - $point->setLatitude($p[0]); - $point->setLongitude($p[1]); - // make a unary grpc call - list($feature, $status) = $client->GetFeature($point)->wait(); - printFeature($feature); - } +function runGetFeature() +{ + echo "Running GetFeature...\n"; + global $client; + + $point = new routeguide\Point(); + $points = array( + array(409146138, -746188906), + array(0, 0), + ); + + foreach ($points as $p) { + $point->setLatitude($p[0]); + $point->setLongitude($p[1]); + // make a unary grpc call + list($feature, $status) = $client->GetFeature($point)->wait(); + printFeature($feature); + } } /** @@ -81,29 +83,30 @@ function runGetFeature() { * containing all of the features in the pre-generated * database. Prints each response as it comes in. */ -function runListFeatures() { - print "Running ListFeatures...\n"; - global $client; - - $lo_point = new routeguide\Point(); - $hi_point = new routeguide\Point(); - - $lo_point->setLatitude(400000000); - $lo_point->setLongitude(-750000000); - $hi_point->setLatitude(420000000); - $hi_point->setLongitude(-730000000); - - $rectangle = new routeguide\Rectangle(); - $rectangle->setLo($lo_point); - $rectangle->setHi($hi_point); - - // start the server streaming call - $call = $client->ListFeatures($rectangle); - // an iterator over the server streaming responses - $features = $call->responses(); - foreach ($features as $feature) { - printFeature($feature); - } +function runListFeatures() +{ + echo "Running ListFeatures...\n"; + global $client; + + $lo_point = new routeguide\Point(); + $hi_point = new routeguide\Point(); + + $lo_point->setLatitude(400000000); + $lo_point->setLongitude(-750000000); + $hi_point->setLatitude(420000000); + $hi_point->setLongitude(-730000000); + + $rectangle = new routeguide\Rectangle(); + $rectangle->setLo($lo_point); + $rectangle->setHi($hi_point); + + // start the server streaming call + $call = $client->ListFeatures($rectangle); + // an iterator over the server streaming responses + $features = $call->responses(); + foreach ($features as $feature) { + printFeature($feature); + } } /** @@ -111,96 +114,99 @@ function runListFeatures() { * pre-generated feature database with a variable delay in between. Prints * the statistics when they are sent from the server. */ -function runRecordRoute() { - print "Running RecordRoute...\n"; - global $client, $argv; - - // start the client streaming call - $call = $client->RecordRoute(); - - $db = json_decode(file_get_contents($argv[1]), true); - $num_points_in_db = count($db); - $num_points = 10; - for ($i = 0; $i < $num_points; $i++) { - $point = new routeguide\Point(); - $index = rand(0, $num_points_in_db - 1); - $lat = $db[$index]['location']['latitude']; - $long = $db[$index]['location']['longitude']; - $feature_name = $db[$index]['name']; - $point->setLatitude($lat); - $point->setLongitude($long); - print sprintf("Visiting point %f, %f,\n with feature name: %s\n", - $lat / COORD_FACTOR, $long / COORD_FACTOR, - $feature_name ? $feature_name : ''); - usleep(rand(300000, 800000)); - $call->write($point); - } - list($route_summary, $status) = $call->wait(); - print sprintf("Finished trip with %d points\nPassed %d features\n". - "Travelled %d meters\nIt took %d seconds\n", - $route_summary->getPointCount(), - $route_summary->getFeatureCount(), - $route_summary->getDistance(), - $route_summary->getElapsedTime()); +function runRecordRoute() +{ + echo "Running RecordRoute...\n"; + global $client, $argv; + + // start the client streaming call + $call = $client->RecordRoute(); + + $db = json_decode(file_get_contents($argv[1]), true); + $num_points_in_db = count($db); + $num_points = 10; + for ($i = 0; $i < $num_points; ++$i) { + $point = new routeguide\Point(); + $index = rand(0, $num_points_in_db - 1); + $lat = $db[$index]['location']['latitude']; + $long = $db[$index]['location']['longitude']; + $feature_name = $db[$index]['name']; + $point->setLatitude($lat); + $point->setLongitude($long); + echo sprintf("Visiting point %f, %f,\n with feature name: %s\n", + $lat / COORD_FACTOR, $long / COORD_FACTOR, + $feature_name ? $feature_name : ''); + usleep(rand(300000, 800000)); + $call->write($point); + } + list($route_summary, $status) = $call->wait(); + echo sprintf("Finished trip with %d points\nPassed %d features\n". + "Travelled %d meters\nIt took %d seconds\n", + $route_summary->getPointCount(), + $route_summary->getFeatureCount(), + $route_summary->getDistance(), + $route_summary->getElapsedTime()); } /** * Run the routeChat demo. Send some chat messages, and print any chat * messages that are sent from the server. */ -function runRouteChat() { - print "Running RouteChat...\n"; - global $client; - - // start the bidirectional streaming call - $call = $client->RouteChat(); - - $notes = array( - array(1, 1, 'first message'), - array(1, 2, 'second message'), - array(2, 1, 'third message'), - array(1, 1, 'fourth message'), - array(1, 1, 'fifth message'), - ); - - foreach ($notes as $n) { - $point = new routeguide\Point(); - $point->setLatitude($lat = $n[0]); - $point->setLongitude($long = $n[1]); - - $route_note = new routeguide\RouteNote(); - $route_note->setLocation($point); - $route_note->setMessage($message = $n[2]); - - print sprintf("Sending message: '%s' at (%d, %d)\n", - $message, $lat, $long); - // send a bunch of messages to the server - $call->write($route_note); - } - $call->writesDone(); - - // read from the server until there's no more - while ($route_note_reply = $call->read()) { - print sprintf("Previous left message at (%d, %d): '%s'\n", - $route_note_reply->getLocation()->getLatitude(), - $route_note_reply->getLocation()->getLongitude(), - $route_note_reply->getMessage()); - } +function runRouteChat() +{ + echo "Running RouteChat...\n"; + global $client; + + // start the bidirectional streaming call + $call = $client->RouteChat(); + + $notes = array( + array(1, 1, 'first message'), + array(1, 2, 'second message'), + array(2, 1, 'third message'), + array(1, 1, 'fourth message'), + array(1, 1, 'fifth message'), + ); + + foreach ($notes as $n) { + $point = new routeguide\Point(); + $point->setLatitude($lat = $n[0]); + $point->setLongitude($long = $n[1]); + + $route_note = new routeguide\RouteNote(); + $route_note->setLocation($point); + $route_note->setMessage($message = $n[2]); + + echo sprintf("Sending message: '%s' at (%d, %d)\n", + $message, $lat, $long); + // send a bunch of messages to the server + $call->write($route_note); + } + $call->writesDone(); + + // read from the server until there's no more + while ($route_note_reply = $call->read()) { + echo sprintf("Previous left message at (%d, %d): '%s'\n", + $route_note_reply->getLocation()->getLatitude(), + $route_note_reply->getLocation()->getLongitude(), + $route_note_reply->getMessage()); + } } /** - * Run all of the demos in order + * Run all of the demos in order. */ -function main() { - runGetFeature(); - runListFeatures(); - runRecordRoute(); - runRouteChat(); +function main() +{ + runGetFeature(); + runListFeatures(); + runRecordRoute(); + runRouteChat(); } if (empty($argv[1])) { - print "Usage: php -d extension=grpc.so route_guide_client.php " . + echo 'Usage: php -d extension=grpc.so route_guide_client.php '. "\n"; - exit(1); + exit(1); } main(); diff --git a/gRPC.podspec b/gRPC.podspec index 8e8f3f551ce..d3665d51744 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -239,6 +239,7 @@ Pod::Spec.new do |s| 'src/core/lib/transport/static_metadata.h', 'src/core/lib/transport/transport.h', 'src/core/lib/transport/transport_impl.h', + 'src/core/ext/transport/chttp2/transport/bin_decoder.h', 'src/core/ext/transport/chttp2/transport/bin_encoder.h', 'src/core/ext/transport/chttp2/transport/chttp2_transport.h', 'src/core/ext/transport/chttp2/transport/frame.h', @@ -318,6 +319,7 @@ Pod::Spec.new do |s| 'include/grpc/byte_buffer_reader.h', 'include/grpc/compression.h', 'include/grpc/grpc.h', + 'include/grpc/grpc_posix.h', 'include/grpc/status.h', 'include/grpc/impl/codegen/byte_buffer.h', 'include/grpc/impl/codegen/byte_buffer_reader.h', @@ -351,7 +353,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/connected_channel.c', 'src/core/lib/channel/http_client_filter.c', 'src/core/lib/channel/http_server_filter.c', - 'src/core/lib/compression/compression_algorithm.c', + 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', 'src/core/lib/http/format_request.c', @@ -428,6 +430,7 @@ Pod::Spec.new do |s| 'src/core/lib/transport/transport.c', 'src/core/lib/transport/transport_op_string.c', 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c', + 'src/core/ext/transport/chttp2/transport/bin_decoder.c', 'src/core/ext/transport/chttp2/transport/bin_encoder.c', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c', 'src/core/ext/transport/chttp2/transport/chttp2_transport.c', @@ -498,7 +501,9 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/subchannel_index.c', 'src/core/ext/client_config/uri_parser.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', + 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c', + 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'third_party/nanopb/pb_common.c', @@ -609,6 +614,7 @@ Pod::Spec.new do |s| 'src/core/lib/transport/static_metadata.h', 'src/core/lib/transport/transport.h', 'src/core/lib/transport/transport_impl.h', + 'src/core/ext/transport/chttp2/transport/bin_decoder.h', 'src/core/ext/transport/chttp2/transport/bin_encoder.h', 'src/core/ext/transport/chttp2/transport/chttp2_transport.h', 'src/core/ext/transport/chttp2/transport/frame.h', diff --git a/grpc.def b/grpc.def index 3477bd91ae8..0046028949e 100644 --- a/grpc.def +++ b/grpc.def @@ -88,6 +88,8 @@ EXPORTS grpc_header_nonbin_value_is_legal grpc_is_binary_header grpc_call_error_to_string + grpc_insecure_channel_create_from_fd + grpc_server_add_insecure_channel_from_fd grpc_auth_property_iterator_next grpc_auth_context_property_iterator grpc_auth_context_peer_identity diff --git a/grpc.gemspec b/grpc.gemspec index 49ea3b0858c..9f3ae048a70 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -147,6 +147,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/byte_buffer_reader.h ) s.files += %w( include/grpc/compression.h ) s.files += %w( include/grpc/grpc.h ) + s.files += %w( include/grpc/grpc_posix.h ) s.files += %w( include/grpc/status.h ) s.files += %w( include/grpc/impl/codegen/byte_buffer.h ) s.files += %w( include/grpc/impl/codegen/byte_buffer_reader.h ) @@ -247,6 +248,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/transport/static_metadata.h ) s.files += %w( src/core/lib/transport/transport.h ) s.files += %w( src/core/lib/transport/transport_impl.h ) + s.files += %w( src/core/ext/transport/chttp2/transport/bin_decoder.h ) s.files += %w( src/core/ext/transport/chttp2/transport/bin_encoder.h ) s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_transport.h ) s.files += %w( src/core/ext/transport/chttp2/transport/frame.h ) @@ -330,7 +332,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/connected_channel.c ) s.files += %w( src/core/lib/channel/http_client_filter.c ) s.files += %w( src/core/lib/channel/http_server_filter.c ) - s.files += %w( src/core/lib/compression/compression_algorithm.c ) + s.files += %w( src/core/lib/compression/compression.c ) s.files += %w( src/core/lib/compression/message_compress.c ) s.files += %w( src/core/lib/debug/trace.c ) s.files += %w( src/core/lib/http/format_request.c ) @@ -407,6 +409,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/transport/transport.c ) s.files += %w( src/core/lib/transport/transport_op_string.c ) s.files += %w( src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c ) + s.files += %w( src/core/ext/transport/chttp2/transport/bin_decoder.c ) s.files += %w( src/core/ext/transport/chttp2/transport/bin_encoder.c ) s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_plugin.c ) s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_transport.c ) @@ -477,7 +480,9 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/subchannel_index.c ) s.files += %w( src/core/ext/client_config/uri_parser.c ) s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2.c ) + s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c ) + s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c ) s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.c ) s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c ) s.files += %w( third_party/nanopb/pb_common.c ) diff --git a/include/grpc++/create_channel_posix.h b/include/grpc++/create_channel_posix.h new file mode 100644 index 00000000000..0d961599420 --- /dev/null +++ b/include/grpc++/create_channel_posix.h @@ -0,0 +1,57 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_CREATE_CHANNEL_POSIX_H +#define GRPCXX_CREATE_CHANNEL_POSIX_H + +#include + +#include +#include + +namespace grpc { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +/// Create a new \a Channel communicating over given file descriptor +/// +/// \param target The name of the target. +/// \param fd The file descriptor representing a socket. +std::shared_ptr CreateInsecureChannelFromFd(const grpc::string& target, + int fd); + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc + +#endif // GRPCXX_CREATE_CHANNEL_POSIX_H diff --git a/include/grpc++/ext/proto_server_reflection_plugin.h b/include/grpc++/ext/proto_server_reflection_plugin.h new file mode 100644 index 00000000000..517c4737f59 --- /dev/null +++ b/include/grpc++/ext/proto_server_reflection_plugin.h @@ -0,0 +1,69 @@ +/* + * + * 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_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H +#define GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H + +#include +#include + +namespace grpc { +class ServerInitializer; +class ProtoServerReflection; +} // namespace grpc + +namespace grpc { +namespace reflection { + +class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin { + public: + ProtoServerReflectionPlugin(); + ::grpc::string name() GRPC_OVERRIDE; + void InitServer(::grpc::ServerInitializer* si) GRPC_OVERRIDE; + void Finish(::grpc::ServerInitializer* si) GRPC_OVERRIDE; + void ChangeArguments(const ::grpc::string& name, void* value) GRPC_OVERRIDE; + bool has_async_methods() const GRPC_OVERRIDE; + bool has_sync_methods() const GRPC_OVERRIDE; + + private: + std::shared_ptr<::grpc::ProtoServerReflection> reflection_service_; +}; + +// Add proto reflection plugin to ServerBuilder. This function should be called +// at the static initialization time. +void InitProtoReflectionServerBuilderPlugin(); + +} // namespace reflection +} // namespace grpc + +#endif // GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H diff --git a/include/grpc++/ext/reflection.grpc.pb.h b/include/grpc++/ext/reflection.grpc.pb.h new file mode 100644 index 00000000000..0b4ef861472 --- /dev/null +++ b/include/grpc++/ext/reflection.grpc.pb.h @@ -0,0 +1,184 @@ +/* + * + * 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 the gRPC protobuf plugin. +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +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 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 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 AsyncService; + template + 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, ""); + } + }; +}; + +} // namespace v1alpha +} // namespace reflection +} // namespace grpc + + +#endif // GRPC_reflection_2eproto__INCLUDED diff --git a/include/grpc++/ext/reflection.pb.h b/include/grpc++/ext/reflection.pb.h new file mode 100644 index 00000000000..00d07735ee8 --- /dev/null +++ b/include/grpc++/ext/reflection.pb.h @@ -0,0 +1,2035 @@ +/* + * + * 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 the protocol buffer compiler. DO NOT EDIT! +// source: reflection.proto + +#ifndef PROTOBUF_reflection_2eproto__INCLUDED +#define PROTOBUF_reflection_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 3000000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace grpc { +namespace reflection { +namespace v1alpha { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_reflection_2eproto(); +void protobuf_AssignDesc_reflection_2eproto(); +void protobuf_ShutdownFile_reflection_2eproto(); + +class ErrorResponse; +class ExtensionNumberResponse; +class ExtensionRequest; +class FileDescriptorResponse; +class ListServiceResponse; +class ServerReflectionRequest; +class ServerReflectionResponse; +class ServiceResponse; + +// =================================================================== + +class ServerReflectionRequest : public ::google::protobuf::Message { + public: + ServerReflectionRequest(); + virtual ~ServerReflectionRequest(); + + ServerReflectionRequest(const ServerReflectionRequest& from); + + inline ServerReflectionRequest& operator=(const ServerReflectionRequest& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ServerReflectionRequest& default_instance(); + + enum MessageRequestCase { + kFileByFilename = 3, + kFileContainingSymbol = 4, + kFileContainingExtension = 5, + kAllExtensionNumbersOfType = 6, + kListServices = 7, + MESSAGE_REQUEST_NOT_SET = 0, + }; + + void Swap(ServerReflectionRequest* other); + + // implements Message ---------------------------------------------- + + inline ServerReflectionRequest* New() const { return New(NULL); } + + ServerReflectionRequest* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ServerReflectionRequest& from); + void MergeFrom(const ServerReflectionRequest& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ServerReflectionRequest* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string host = 1; + void clear_host(); + static const int kHostFieldNumber = 1; + const ::std::string& host() const; + void set_host(const ::std::string& value); + void set_host(const char* value); + void set_host(const char* value, size_t size); + ::std::string* mutable_host(); + ::std::string* release_host(); + void set_allocated_host(::std::string* host); + + // optional string file_by_filename = 3; + private: + bool has_file_by_filename() const; + public: + void clear_file_by_filename(); + static const int kFileByFilenameFieldNumber = 3; + const ::std::string& file_by_filename() const; + void set_file_by_filename(const ::std::string& value); + void set_file_by_filename(const char* value); + void set_file_by_filename(const char* value, size_t size); + ::std::string* mutable_file_by_filename(); + ::std::string* release_file_by_filename(); + void set_allocated_file_by_filename(::std::string* file_by_filename); + + // optional string file_containing_symbol = 4; + private: + bool has_file_containing_symbol() const; + public: + void clear_file_containing_symbol(); + static const int kFileContainingSymbolFieldNumber = 4; + const ::std::string& file_containing_symbol() const; + void set_file_containing_symbol(const ::std::string& value); + void set_file_containing_symbol(const char* value); + void set_file_containing_symbol(const char* value, size_t size); + ::std::string* mutable_file_containing_symbol(); + ::std::string* release_file_containing_symbol(); + void set_allocated_file_containing_symbol(::std::string* file_containing_symbol); + + // optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; + bool has_file_containing_extension() const; + void clear_file_containing_extension(); + static const int kFileContainingExtensionFieldNumber = 5; + const ::grpc::reflection::v1alpha::ExtensionRequest& file_containing_extension() const; + ::grpc::reflection::v1alpha::ExtensionRequest* mutable_file_containing_extension(); + ::grpc::reflection::v1alpha::ExtensionRequest* release_file_containing_extension(); + void set_allocated_file_containing_extension(::grpc::reflection::v1alpha::ExtensionRequest* file_containing_extension); + + // optional string all_extension_numbers_of_type = 6; + private: + bool has_all_extension_numbers_of_type() const; + public: + void clear_all_extension_numbers_of_type(); + static const int kAllExtensionNumbersOfTypeFieldNumber = 6; + const ::std::string& all_extension_numbers_of_type() const; + void set_all_extension_numbers_of_type(const ::std::string& value); + void set_all_extension_numbers_of_type(const char* value); + void set_all_extension_numbers_of_type(const char* value, size_t size); + ::std::string* mutable_all_extension_numbers_of_type(); + ::std::string* release_all_extension_numbers_of_type(); + void set_allocated_all_extension_numbers_of_type(::std::string* all_extension_numbers_of_type); + + // optional string list_services = 7; + private: + bool has_list_services() const; + public: + void clear_list_services(); + static const int kListServicesFieldNumber = 7; + const ::std::string& list_services() const; + void set_list_services(const ::std::string& value); + void set_list_services(const char* value); + void set_list_services(const char* value, size_t size); + ::std::string* mutable_list_services(); + ::std::string* release_list_services(); + void set_allocated_list_services(::std::string* list_services); + + MessageRequestCase message_request_case() const; + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ServerReflectionRequest) + private: + inline void set_has_file_by_filename(); + inline void set_has_file_containing_symbol(); + inline void set_has_file_containing_extension(); + inline void set_has_all_extension_numbers_of_type(); + inline void set_has_list_services(); + + inline bool has_message_request() const; + void clear_message_request(); + inline void clear_has_message_request(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr host_; + union MessageRequestUnion { + MessageRequestUnion() {} + ::google::protobuf::internal::ArenaStringPtr file_by_filename_; + ::google::protobuf::internal::ArenaStringPtr file_containing_symbol_; + ::grpc::reflection::v1alpha::ExtensionRequest* file_containing_extension_; + ::google::protobuf::internal::ArenaStringPtr all_extension_numbers_of_type_; + ::google::protobuf::internal::ArenaStringPtr list_services_; + } message_request_; + mutable int _cached_size_; + ::google::protobuf::uint32 _oneof_case_[1]; + + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ServerReflectionRequest* default_instance_; +}; +// ------------------------------------------------------------------- + +class ExtensionRequest : public ::google::protobuf::Message { + public: + ExtensionRequest(); + virtual ~ExtensionRequest(); + + ExtensionRequest(const ExtensionRequest& from); + + inline ExtensionRequest& operator=(const ExtensionRequest& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ExtensionRequest& default_instance(); + + void Swap(ExtensionRequest* other); + + // implements Message ---------------------------------------------- + + inline ExtensionRequest* New() const { return New(NULL); } + + ExtensionRequest* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ExtensionRequest& from); + void MergeFrom(const ExtensionRequest& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ExtensionRequest* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string containing_type = 1; + void clear_containing_type(); + static const int kContainingTypeFieldNumber = 1; + const ::std::string& containing_type() const; + void set_containing_type(const ::std::string& value); + void set_containing_type(const char* value); + void set_containing_type(const char* value, size_t size); + ::std::string* mutable_containing_type(); + ::std::string* release_containing_type(); + void set_allocated_containing_type(::std::string* containing_type); + + // optional int32 extension_number = 2; + void clear_extension_number(); + static const int kExtensionNumberFieldNumber = 2; + ::google::protobuf::int32 extension_number() const; + void set_extension_number(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ExtensionRequest) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr containing_type_; + ::google::protobuf::int32 extension_number_; + mutable int _cached_size_; + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ExtensionRequest* default_instance_; +}; +// ------------------------------------------------------------------- + +class ServerReflectionResponse : public ::google::protobuf::Message { + public: + ServerReflectionResponse(); + virtual ~ServerReflectionResponse(); + + ServerReflectionResponse(const ServerReflectionResponse& from); + + inline ServerReflectionResponse& operator=(const ServerReflectionResponse& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ServerReflectionResponse& default_instance(); + + enum MessageResponseCase { + kFileDescriptorResponse = 4, + kAllExtensionNumbersResponse = 5, + kListServicesResponse = 6, + kErrorResponse = 7, + MESSAGE_RESPONSE_NOT_SET = 0, + }; + + void Swap(ServerReflectionResponse* other); + + // implements Message ---------------------------------------------- + + inline ServerReflectionResponse* New() const { return New(NULL); } + + ServerReflectionResponse* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ServerReflectionResponse& from); + void MergeFrom(const ServerReflectionResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ServerReflectionResponse* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string valid_host = 1; + void clear_valid_host(); + static const int kValidHostFieldNumber = 1; + const ::std::string& valid_host() const; + void set_valid_host(const ::std::string& value); + void set_valid_host(const char* value); + void set_valid_host(const char* value, size_t size); + ::std::string* mutable_valid_host(); + ::std::string* release_valid_host(); + void set_allocated_valid_host(::std::string* valid_host); + + // optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; + bool has_original_request() const; + void clear_original_request(); + static const int kOriginalRequestFieldNumber = 2; + const ::grpc::reflection::v1alpha::ServerReflectionRequest& original_request() const; + ::grpc::reflection::v1alpha::ServerReflectionRequest* mutable_original_request(); + ::grpc::reflection::v1alpha::ServerReflectionRequest* release_original_request(); + void set_allocated_original_request(::grpc::reflection::v1alpha::ServerReflectionRequest* original_request); + + // optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; + bool has_file_descriptor_response() const; + void clear_file_descriptor_response(); + static const int kFileDescriptorResponseFieldNumber = 4; + const ::grpc::reflection::v1alpha::FileDescriptorResponse& file_descriptor_response() const; + ::grpc::reflection::v1alpha::FileDescriptorResponse* mutable_file_descriptor_response(); + ::grpc::reflection::v1alpha::FileDescriptorResponse* release_file_descriptor_response(); + void set_allocated_file_descriptor_response(::grpc::reflection::v1alpha::FileDescriptorResponse* file_descriptor_response); + + // optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; + bool has_all_extension_numbers_response() const; + void clear_all_extension_numbers_response(); + static const int kAllExtensionNumbersResponseFieldNumber = 5; + const ::grpc::reflection::v1alpha::ExtensionNumberResponse& all_extension_numbers_response() const; + ::grpc::reflection::v1alpha::ExtensionNumberResponse* mutable_all_extension_numbers_response(); + ::grpc::reflection::v1alpha::ExtensionNumberResponse* release_all_extension_numbers_response(); + void set_allocated_all_extension_numbers_response(::grpc::reflection::v1alpha::ExtensionNumberResponse* all_extension_numbers_response); + + // optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; + bool has_list_services_response() const; + void clear_list_services_response(); + static const int kListServicesResponseFieldNumber = 6; + const ::grpc::reflection::v1alpha::ListServiceResponse& list_services_response() const; + ::grpc::reflection::v1alpha::ListServiceResponse* mutable_list_services_response(); + ::grpc::reflection::v1alpha::ListServiceResponse* release_list_services_response(); + void set_allocated_list_services_response(::grpc::reflection::v1alpha::ListServiceResponse* list_services_response); + + // optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; + bool has_error_response() const; + void clear_error_response(); + static const int kErrorResponseFieldNumber = 7; + const ::grpc::reflection::v1alpha::ErrorResponse& error_response() const; + ::grpc::reflection::v1alpha::ErrorResponse* mutable_error_response(); + ::grpc::reflection::v1alpha::ErrorResponse* release_error_response(); + void set_allocated_error_response(::grpc::reflection::v1alpha::ErrorResponse* error_response); + + MessageResponseCase message_response_case() const; + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ServerReflectionResponse) + private: + inline void set_has_file_descriptor_response(); + inline void set_has_all_extension_numbers_response(); + inline void set_has_list_services_response(); + inline void set_has_error_response(); + + inline bool has_message_response() const; + void clear_message_response(); + inline void clear_has_message_response(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr valid_host_; + ::grpc::reflection::v1alpha::ServerReflectionRequest* original_request_; + union MessageResponseUnion { + MessageResponseUnion() {} + ::grpc::reflection::v1alpha::FileDescriptorResponse* file_descriptor_response_; + ::grpc::reflection::v1alpha::ExtensionNumberResponse* all_extension_numbers_response_; + ::grpc::reflection::v1alpha::ListServiceResponse* list_services_response_; + ::grpc::reflection::v1alpha::ErrorResponse* error_response_; + } message_response_; + mutable int _cached_size_; + ::google::protobuf::uint32 _oneof_case_[1]; + + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ServerReflectionResponse* default_instance_; +}; +// ------------------------------------------------------------------- + +class FileDescriptorResponse : public ::google::protobuf::Message { + public: + FileDescriptorResponse(); + virtual ~FileDescriptorResponse(); + + FileDescriptorResponse(const FileDescriptorResponse& from); + + inline FileDescriptorResponse& operator=(const FileDescriptorResponse& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const FileDescriptorResponse& default_instance(); + + void Swap(FileDescriptorResponse* other); + + // implements Message ---------------------------------------------- + + inline FileDescriptorResponse* New() const { return New(NULL); } + + FileDescriptorResponse* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const FileDescriptorResponse& from); + void MergeFrom(const FileDescriptorResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(FileDescriptorResponse* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated bytes file_descriptor_proto = 1; + int file_descriptor_proto_size() const; + void clear_file_descriptor_proto(); + static const int kFileDescriptorProtoFieldNumber = 1; + const ::std::string& file_descriptor_proto(int index) const; + ::std::string* mutable_file_descriptor_proto(int index); + void set_file_descriptor_proto(int index, const ::std::string& value); + void set_file_descriptor_proto(int index, const char* value); + void set_file_descriptor_proto(int index, const void* value, size_t size); + ::std::string* add_file_descriptor_proto(); + void add_file_descriptor_proto(const ::std::string& value); + void add_file_descriptor_proto(const char* value); + void add_file_descriptor_proto(const void* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& file_descriptor_proto() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_descriptor_proto(); + + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.FileDescriptorResponse) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::RepeatedPtrField< ::std::string> file_descriptor_proto_; + mutable int _cached_size_; + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static FileDescriptorResponse* default_instance_; +}; +// ------------------------------------------------------------------- + +class ExtensionNumberResponse : public ::google::protobuf::Message { + public: + ExtensionNumberResponse(); + virtual ~ExtensionNumberResponse(); + + ExtensionNumberResponse(const ExtensionNumberResponse& from); + + inline ExtensionNumberResponse& operator=(const ExtensionNumberResponse& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ExtensionNumberResponse& default_instance(); + + void Swap(ExtensionNumberResponse* other); + + // implements Message ---------------------------------------------- + + inline ExtensionNumberResponse* New() const { return New(NULL); } + + ExtensionNumberResponse* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ExtensionNumberResponse& from); + void MergeFrom(const ExtensionNumberResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ExtensionNumberResponse* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string base_type_name = 1; + void clear_base_type_name(); + static const int kBaseTypeNameFieldNumber = 1; + const ::std::string& base_type_name() const; + void set_base_type_name(const ::std::string& value); + void set_base_type_name(const char* value); + void set_base_type_name(const char* value, size_t size); + ::std::string* mutable_base_type_name(); + ::std::string* release_base_type_name(); + void set_allocated_base_type_name(::std::string* base_type_name); + + // repeated int32 extension_number = 2; + int extension_number_size() const; + void clear_extension_number(); + static const int kExtensionNumberFieldNumber = 2; + ::google::protobuf::int32 extension_number(int index) const; + void set_extension_number(int index, ::google::protobuf::int32 value); + void add_extension_number(::google::protobuf::int32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& + extension_number() const; + ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* + mutable_extension_number(); + + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ExtensionNumberResponse) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr base_type_name_; + ::google::protobuf::RepeatedField< ::google::protobuf::int32 > extension_number_; + mutable int _extension_number_cached_byte_size_; + mutable int _cached_size_; + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ExtensionNumberResponse* default_instance_; +}; +// ------------------------------------------------------------------- + +class ListServiceResponse : public ::google::protobuf::Message { + public: + ListServiceResponse(); + virtual ~ListServiceResponse(); + + ListServiceResponse(const ListServiceResponse& from); + + inline ListServiceResponse& operator=(const ListServiceResponse& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ListServiceResponse& default_instance(); + + void Swap(ListServiceResponse* other); + + // implements Message ---------------------------------------------- + + inline ListServiceResponse* New() const { return New(NULL); } + + ListServiceResponse* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ListServiceResponse& from); + void MergeFrom(const ListServiceResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ListServiceResponse* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; + int service_size() const; + void clear_service(); + static const int kServiceFieldNumber = 1; + const ::grpc::reflection::v1alpha::ServiceResponse& service(int index) const; + ::grpc::reflection::v1alpha::ServiceResponse* mutable_service(int index); + ::grpc::reflection::v1alpha::ServiceResponse* add_service(); + ::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse >* + mutable_service(); + const ::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse >& + service() const; + + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ListServiceResponse) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse > service_; + mutable int _cached_size_; + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ListServiceResponse* default_instance_; +}; +// ------------------------------------------------------------------- + +class ServiceResponse : public ::google::protobuf::Message { + public: + ServiceResponse(); + virtual ~ServiceResponse(); + + ServiceResponse(const ServiceResponse& from); + + inline ServiceResponse& operator=(const ServiceResponse& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ServiceResponse& default_instance(); + + void Swap(ServiceResponse* other); + + // implements Message ---------------------------------------------- + + inline ServiceResponse* New() const { return New(NULL); } + + ServiceResponse* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ServiceResponse& from); + void MergeFrom(const ServiceResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ServiceResponse* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string name = 1; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ServiceResponse) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr name_; + mutable int _cached_size_; + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ServiceResponse* default_instance_; +}; +// ------------------------------------------------------------------- + +class ErrorResponse : public ::google::protobuf::Message { + public: + ErrorResponse(); + virtual ~ErrorResponse(); + + ErrorResponse(const ErrorResponse& from); + + inline ErrorResponse& operator=(const ErrorResponse& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ErrorResponse& default_instance(); + + void Swap(ErrorResponse* other); + + // implements Message ---------------------------------------------- + + inline ErrorResponse* New() const { return New(NULL); } + + ErrorResponse* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ErrorResponse& from); + void MergeFrom(const ErrorResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ErrorResponse* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 error_code = 1; + void clear_error_code(); + static const int kErrorCodeFieldNumber = 1; + ::google::protobuf::int32 error_code() const; + void set_error_code(::google::protobuf::int32 value); + + // optional string error_message = 2; + void clear_error_message(); + static const int kErrorMessageFieldNumber = 2; + const ::std::string& error_message() const; + void set_error_message(const ::std::string& value); + void set_error_message(const char* value); + void set_error_message(const char* value, size_t size); + ::std::string* mutable_error_message(); + ::std::string* release_error_message(); + void set_allocated_error_message(::std::string* error_message); + + // @@protoc_insertion_point(class_scope:grpc.reflection.v1alpha.ErrorResponse) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr error_message_; + ::google::protobuf::int32 error_code_; + mutable int _cached_size_; + friend void protobuf_AddDesc_reflection_2eproto(); + friend void protobuf_AssignDesc_reflection_2eproto(); + friend void protobuf_ShutdownFile_reflection_2eproto(); + + void InitAsDefaultInstance(); + static ErrorResponse* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +#if !PROTOBUF_INLINE_NOT_IN_HEADERS +// ServerReflectionRequest + +// optional string host = 1; +inline void ServerReflectionRequest::clear_host() { + host_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& ServerReflectionRequest::host() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.host) + return host_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ServerReflectionRequest::set_host(const ::std::string& value) { + + host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} +inline void ServerReflectionRequest::set_host(const char* value) { + + host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} +inline void ServerReflectionRequest::set_host(const char* value, size_t size) { + + host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} +inline ::std::string* ServerReflectionRequest::mutable_host() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.host) + return host_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServerReflectionRequest::release_host() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.host) + + return host_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ServerReflectionRequest::set_allocated_host(::std::string* host) { + if (host != NULL) { + + } else { + + } + host_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), host); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} + +// optional string file_by_filename = 3; +inline bool ServerReflectionRequest::has_file_by_filename() const { + return message_request_case() == kFileByFilename; +} +inline void ServerReflectionRequest::set_has_file_by_filename() { + _oneof_case_[0] = kFileByFilename; +} +inline void ServerReflectionRequest::clear_file_by_filename() { + if (has_file_by_filename()) { + message_request_.file_by_filename_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} +inline const ::std::string& ServerReflectionRequest::file_by_filename() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + if (has_file_by_filename()) { + return message_request_.file_by_filename_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} +inline void ServerReflectionRequest::set_file_by_filename(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_by_filename_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} +inline void ServerReflectionRequest::set_file_by_filename(const char* value) { + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_by_filename_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} +inline void ServerReflectionRequest::set_file_by_filename(const char* value, size_t size) { + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_by_filename_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} +inline ::std::string* ServerReflectionRequest::mutable_file_by_filename() { + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + return message_request_.file_by_filename_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServerReflectionRequest::release_file_by_filename() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + if (has_file_by_filename()) { + clear_has_message_request(); + return message_request_.file_by_filename_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} +inline void ServerReflectionRequest::set_allocated_file_by_filename(::std::string* file_by_filename) { + if (!has_file_by_filename()) { + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (file_by_filename != NULL) { + set_has_file_by_filename(); + message_request_.file_by_filename_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + file_by_filename); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} + +// optional string file_containing_symbol = 4; +inline bool ServerReflectionRequest::has_file_containing_symbol() const { + return message_request_case() == kFileContainingSymbol; +} +inline void ServerReflectionRequest::set_has_file_containing_symbol() { + _oneof_case_[0] = kFileContainingSymbol; +} +inline void ServerReflectionRequest::clear_file_containing_symbol() { + if (has_file_containing_symbol()) { + message_request_.file_containing_symbol_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} +inline const ::std::string& ServerReflectionRequest::file_containing_symbol() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + if (has_file_containing_symbol()) { + return message_request_.file_containing_symbol_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} +inline void ServerReflectionRequest::set_file_containing_symbol(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_containing_symbol_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} +inline void ServerReflectionRequest::set_file_containing_symbol(const char* value) { + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_containing_symbol_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} +inline void ServerReflectionRequest::set_file_containing_symbol(const char* value, size_t size) { + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_containing_symbol_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} +inline ::std::string* ServerReflectionRequest::mutable_file_containing_symbol() { + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + return message_request_.file_containing_symbol_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServerReflectionRequest::release_file_containing_symbol() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + if (has_file_containing_symbol()) { + clear_has_message_request(); + return message_request_.file_containing_symbol_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} +inline void ServerReflectionRequest::set_allocated_file_containing_symbol(::std::string* file_containing_symbol) { + if (!has_file_containing_symbol()) { + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (file_containing_symbol != NULL) { + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + file_containing_symbol); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} + +// optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; +inline bool ServerReflectionRequest::has_file_containing_extension() const { + return message_request_case() == kFileContainingExtension; +} +inline void ServerReflectionRequest::set_has_file_containing_extension() { + _oneof_case_[0] = kFileContainingExtension; +} +inline void ServerReflectionRequest::clear_file_containing_extension() { + if (has_file_containing_extension()) { + delete message_request_.file_containing_extension_; + clear_has_message_request(); + } +} +inline const ::grpc::reflection::v1alpha::ExtensionRequest& ServerReflectionRequest::file_containing_extension() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) + return has_file_containing_extension() + ? *message_request_.file_containing_extension_ + : ::grpc::reflection::v1alpha::ExtensionRequest::default_instance(); +} +inline ::grpc::reflection::v1alpha::ExtensionRequest* ServerReflectionRequest::mutable_file_containing_extension() { + if (!has_file_containing_extension()) { + clear_message_request(); + set_has_file_containing_extension(); + message_request_.file_containing_extension_ = new ::grpc::reflection::v1alpha::ExtensionRequest; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) + return message_request_.file_containing_extension_; +} +inline ::grpc::reflection::v1alpha::ExtensionRequest* ServerReflectionRequest::release_file_containing_extension() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) + if (has_file_containing_extension()) { + clear_has_message_request(); + ::grpc::reflection::v1alpha::ExtensionRequest* temp = message_request_.file_containing_extension_; + message_request_.file_containing_extension_ = NULL; + return temp; + } else { + return NULL; + } +} +inline void ServerReflectionRequest::set_allocated_file_containing_extension(::grpc::reflection::v1alpha::ExtensionRequest* file_containing_extension) { + clear_message_request(); + if (file_containing_extension) { + set_has_file_containing_extension(); + message_request_.file_containing_extension_ = file_containing_extension; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) +} + +// optional string all_extension_numbers_of_type = 6; +inline bool ServerReflectionRequest::has_all_extension_numbers_of_type() const { + return message_request_case() == kAllExtensionNumbersOfType; +} +inline void ServerReflectionRequest::set_has_all_extension_numbers_of_type() { + _oneof_case_[0] = kAllExtensionNumbersOfType; +} +inline void ServerReflectionRequest::clear_all_extension_numbers_of_type() { + if (has_all_extension_numbers_of_type()) { + message_request_.all_extension_numbers_of_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} +inline const ::std::string& ServerReflectionRequest::all_extension_numbers_of_type() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + if (has_all_extension_numbers_of_type()) { + return message_request_.all_extension_numbers_of_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} +inline void ServerReflectionRequest::set_all_extension_numbers_of_type(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.all_extension_numbers_of_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} +inline void ServerReflectionRequest::set_all_extension_numbers_of_type(const char* value) { + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.all_extension_numbers_of_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} +inline void ServerReflectionRequest::set_all_extension_numbers_of_type(const char* value, size_t size) { + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.all_extension_numbers_of_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} +inline ::std::string* ServerReflectionRequest::mutable_all_extension_numbers_of_type() { + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + return message_request_.all_extension_numbers_of_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServerReflectionRequest::release_all_extension_numbers_of_type() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + if (has_all_extension_numbers_of_type()) { + clear_has_message_request(); + return message_request_.all_extension_numbers_of_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} +inline void ServerReflectionRequest::set_allocated_all_extension_numbers_of_type(::std::string* all_extension_numbers_of_type) { + if (!has_all_extension_numbers_of_type()) { + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (all_extension_numbers_of_type != NULL) { + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + all_extension_numbers_of_type); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} + +// optional string list_services = 7; +inline bool ServerReflectionRequest::has_list_services() const { + return message_request_case() == kListServices; +} +inline void ServerReflectionRequest::set_has_list_services() { + _oneof_case_[0] = kListServices; +} +inline void ServerReflectionRequest::clear_list_services() { + if (has_list_services()) { + message_request_.list_services_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} +inline const ::std::string& ServerReflectionRequest::list_services() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + if (has_list_services()) { + return message_request_.list_services_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} +inline void ServerReflectionRequest::set_list_services(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.list_services_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} +inline void ServerReflectionRequest::set_list_services(const char* value) { + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.list_services_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} +inline void ServerReflectionRequest::set_list_services(const char* value, size_t size) { + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.list_services_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} +inline ::std::string* ServerReflectionRequest::mutable_list_services() { + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + return message_request_.list_services_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServerReflectionRequest::release_list_services() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + if (has_list_services()) { + clear_has_message_request(); + return message_request_.list_services_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} +inline void ServerReflectionRequest::set_allocated_list_services(::std::string* list_services) { + if (!has_list_services()) { + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (list_services != NULL) { + set_has_list_services(); + message_request_.list_services_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + list_services); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} + +inline bool ServerReflectionRequest::has_message_request() const { + return message_request_case() != MESSAGE_REQUEST_NOT_SET; +} +inline void ServerReflectionRequest::clear_has_message_request() { + _oneof_case_[0] = MESSAGE_REQUEST_NOT_SET; +} +inline ServerReflectionRequest::MessageRequestCase ServerReflectionRequest::message_request_case() const { + return ServerReflectionRequest::MessageRequestCase(_oneof_case_[0]); +} +// ------------------------------------------------------------------- + +// ExtensionRequest + +// optional string containing_type = 1; +inline void ExtensionRequest::clear_containing_type() { + containing_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& ExtensionRequest::containing_type() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionRequest.containing_type) + return containing_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ExtensionRequest::set_containing_type(const ::std::string& value) { + + containing_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} +inline void ExtensionRequest::set_containing_type(const char* value) { + + containing_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} +inline void ExtensionRequest::set_containing_type(const char* value, size_t size) { + + containing_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} +inline ::std::string* ExtensionRequest::mutable_containing_type() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ExtensionRequest.containing_type) + return containing_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ExtensionRequest::release_containing_type() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ExtensionRequest.containing_type) + + return containing_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ExtensionRequest::set_allocated_containing_type(::std::string* containing_type) { + if (containing_type != NULL) { + + } else { + + } + containing_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), containing_type); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} + +// optional int32 extension_number = 2; +inline void ExtensionRequest::clear_extension_number() { + extension_number_ = 0; +} +inline ::google::protobuf::int32 ExtensionRequest::extension_number() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionRequest.extension_number) + return extension_number_; +} +inline void ExtensionRequest::set_extension_number(::google::protobuf::int32 value) { + + extension_number_ = value; + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionRequest.extension_number) +} + +// ------------------------------------------------------------------- + +// ServerReflectionResponse + +// optional string valid_host = 1; +inline void ServerReflectionResponse::clear_valid_host() { + valid_host_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& ServerReflectionResponse::valid_host() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) + return valid_host_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ServerReflectionResponse::set_valid_host(const ::std::string& value) { + + valid_host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} +inline void ServerReflectionResponse::set_valid_host(const char* value) { + + valid_host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} +inline void ServerReflectionResponse::set_valid_host(const char* value, size_t size) { + + valid_host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} +inline ::std::string* ServerReflectionResponse::mutable_valid_host() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) + return valid_host_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServerReflectionResponse::release_valid_host() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) + + return valid_host_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ServerReflectionResponse::set_allocated_valid_host(::std::string* valid_host) { + if (valid_host != NULL) { + + } else { + + } + valid_host_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), valid_host); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} + +// optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; +inline bool ServerReflectionResponse::has_original_request() const { + return !_is_default_instance_ && original_request_ != NULL; +} +inline void ServerReflectionResponse::clear_original_request() { + if (GetArenaNoVirtual() == NULL && original_request_ != NULL) delete original_request_; + original_request_ = NULL; +} +inline const ::grpc::reflection::v1alpha::ServerReflectionRequest& ServerReflectionResponse::original_request() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) + return original_request_ != NULL ? *original_request_ : *default_instance_->original_request_; +} +inline ::grpc::reflection::v1alpha::ServerReflectionRequest* ServerReflectionResponse::mutable_original_request() { + + if (original_request_ == NULL) { + original_request_ = new ::grpc::reflection::v1alpha::ServerReflectionRequest; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) + return original_request_; +} +inline ::grpc::reflection::v1alpha::ServerReflectionRequest* ServerReflectionResponse::release_original_request() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) + + ::grpc::reflection::v1alpha::ServerReflectionRequest* temp = original_request_; + original_request_ = NULL; + return temp; +} +inline void ServerReflectionResponse::set_allocated_original_request(::grpc::reflection::v1alpha::ServerReflectionRequest* original_request) { + delete original_request_; + original_request_ = original_request; + if (original_request) { + + } else { + + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) +} + +// optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; +inline bool ServerReflectionResponse::has_file_descriptor_response() const { + return message_response_case() == kFileDescriptorResponse; +} +inline void ServerReflectionResponse::set_has_file_descriptor_response() { + _oneof_case_[0] = kFileDescriptorResponse; +} +inline void ServerReflectionResponse::clear_file_descriptor_response() { + if (has_file_descriptor_response()) { + delete message_response_.file_descriptor_response_; + clear_has_message_response(); + } +} +inline const ::grpc::reflection::v1alpha::FileDescriptorResponse& ServerReflectionResponse::file_descriptor_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) + return has_file_descriptor_response() + ? *message_response_.file_descriptor_response_ + : ::grpc::reflection::v1alpha::FileDescriptorResponse::default_instance(); +} +inline ::grpc::reflection::v1alpha::FileDescriptorResponse* ServerReflectionResponse::mutable_file_descriptor_response() { + if (!has_file_descriptor_response()) { + clear_message_response(); + set_has_file_descriptor_response(); + message_response_.file_descriptor_response_ = new ::grpc::reflection::v1alpha::FileDescriptorResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) + return message_response_.file_descriptor_response_; +} +inline ::grpc::reflection::v1alpha::FileDescriptorResponse* ServerReflectionResponse::release_file_descriptor_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) + if (has_file_descriptor_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::FileDescriptorResponse* temp = message_response_.file_descriptor_response_; + message_response_.file_descriptor_response_ = NULL; + return temp; + } else { + return NULL; + } +} +inline void ServerReflectionResponse::set_allocated_file_descriptor_response(::grpc::reflection::v1alpha::FileDescriptorResponse* file_descriptor_response) { + clear_message_response(); + if (file_descriptor_response) { + set_has_file_descriptor_response(); + message_response_.file_descriptor_response_ = file_descriptor_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) +} + +// optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; +inline bool ServerReflectionResponse::has_all_extension_numbers_response() const { + return message_response_case() == kAllExtensionNumbersResponse; +} +inline void ServerReflectionResponse::set_has_all_extension_numbers_response() { + _oneof_case_[0] = kAllExtensionNumbersResponse; +} +inline void ServerReflectionResponse::clear_all_extension_numbers_response() { + if (has_all_extension_numbers_response()) { + delete message_response_.all_extension_numbers_response_; + clear_has_message_response(); + } +} +inline const ::grpc::reflection::v1alpha::ExtensionNumberResponse& ServerReflectionResponse::all_extension_numbers_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) + return has_all_extension_numbers_response() + ? *message_response_.all_extension_numbers_response_ + : ::grpc::reflection::v1alpha::ExtensionNumberResponse::default_instance(); +} +inline ::grpc::reflection::v1alpha::ExtensionNumberResponse* ServerReflectionResponse::mutable_all_extension_numbers_response() { + if (!has_all_extension_numbers_response()) { + clear_message_response(); + set_has_all_extension_numbers_response(); + message_response_.all_extension_numbers_response_ = new ::grpc::reflection::v1alpha::ExtensionNumberResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) + return message_response_.all_extension_numbers_response_; +} +inline ::grpc::reflection::v1alpha::ExtensionNumberResponse* ServerReflectionResponse::release_all_extension_numbers_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) + if (has_all_extension_numbers_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::ExtensionNumberResponse* temp = message_response_.all_extension_numbers_response_; + message_response_.all_extension_numbers_response_ = NULL; + return temp; + } else { + return NULL; + } +} +inline void ServerReflectionResponse::set_allocated_all_extension_numbers_response(::grpc::reflection::v1alpha::ExtensionNumberResponse* all_extension_numbers_response) { + clear_message_response(); + if (all_extension_numbers_response) { + set_has_all_extension_numbers_response(); + message_response_.all_extension_numbers_response_ = all_extension_numbers_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) +} + +// optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; +inline bool ServerReflectionResponse::has_list_services_response() const { + return message_response_case() == kListServicesResponse; +} +inline void ServerReflectionResponse::set_has_list_services_response() { + _oneof_case_[0] = kListServicesResponse; +} +inline void ServerReflectionResponse::clear_list_services_response() { + if (has_list_services_response()) { + delete message_response_.list_services_response_; + clear_has_message_response(); + } +} +inline const ::grpc::reflection::v1alpha::ListServiceResponse& ServerReflectionResponse::list_services_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) + return has_list_services_response() + ? *message_response_.list_services_response_ + : ::grpc::reflection::v1alpha::ListServiceResponse::default_instance(); +} +inline ::grpc::reflection::v1alpha::ListServiceResponse* ServerReflectionResponse::mutable_list_services_response() { + if (!has_list_services_response()) { + clear_message_response(); + set_has_list_services_response(); + message_response_.list_services_response_ = new ::grpc::reflection::v1alpha::ListServiceResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) + return message_response_.list_services_response_; +} +inline ::grpc::reflection::v1alpha::ListServiceResponse* ServerReflectionResponse::release_list_services_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) + if (has_list_services_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::ListServiceResponse* temp = message_response_.list_services_response_; + message_response_.list_services_response_ = NULL; + return temp; + } else { + return NULL; + } +} +inline void ServerReflectionResponse::set_allocated_list_services_response(::grpc::reflection::v1alpha::ListServiceResponse* list_services_response) { + clear_message_response(); + if (list_services_response) { + set_has_list_services_response(); + message_response_.list_services_response_ = list_services_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) +} + +// optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; +inline bool ServerReflectionResponse::has_error_response() const { + return message_response_case() == kErrorResponse; +} +inline void ServerReflectionResponse::set_has_error_response() { + _oneof_case_[0] = kErrorResponse; +} +inline void ServerReflectionResponse::clear_error_response() { + if (has_error_response()) { + delete message_response_.error_response_; + clear_has_message_response(); + } +} +inline const ::grpc::reflection::v1alpha::ErrorResponse& ServerReflectionResponse::error_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) + return has_error_response() + ? *message_response_.error_response_ + : ::grpc::reflection::v1alpha::ErrorResponse::default_instance(); +} +inline ::grpc::reflection::v1alpha::ErrorResponse* ServerReflectionResponse::mutable_error_response() { + if (!has_error_response()) { + clear_message_response(); + set_has_error_response(); + message_response_.error_response_ = new ::grpc::reflection::v1alpha::ErrorResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) + return message_response_.error_response_; +} +inline ::grpc::reflection::v1alpha::ErrorResponse* ServerReflectionResponse::release_error_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) + if (has_error_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::ErrorResponse* temp = message_response_.error_response_; + message_response_.error_response_ = NULL; + return temp; + } else { + return NULL; + } +} +inline void ServerReflectionResponse::set_allocated_error_response(::grpc::reflection::v1alpha::ErrorResponse* error_response) { + clear_message_response(); + if (error_response) { + set_has_error_response(); + message_response_.error_response_ = error_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) +} + +inline bool ServerReflectionResponse::has_message_response() const { + return message_response_case() != MESSAGE_RESPONSE_NOT_SET; +} +inline void ServerReflectionResponse::clear_has_message_response() { + _oneof_case_[0] = MESSAGE_RESPONSE_NOT_SET; +} +inline ServerReflectionResponse::MessageResponseCase ServerReflectionResponse::message_response_case() const { + return ServerReflectionResponse::MessageResponseCase(_oneof_case_[0]); +} +// ------------------------------------------------------------------- + +// FileDescriptorResponse + +// repeated bytes file_descriptor_proto = 1; +inline int FileDescriptorResponse::file_descriptor_proto_size() const { + return file_descriptor_proto_.size(); +} +inline void FileDescriptorResponse::clear_file_descriptor_proto() { + file_descriptor_proto_.Clear(); +} +inline const ::std::string& FileDescriptorResponse::file_descriptor_proto(int index) const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_.Get(index); +} +inline ::std::string* FileDescriptorResponse::mutable_file_descriptor_proto(int index) { + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_.Mutable(index); +} +inline void FileDescriptorResponse::set_file_descriptor_proto(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + file_descriptor_proto_.Mutable(index)->assign(value); +} +inline void FileDescriptorResponse::set_file_descriptor_proto(int index, const char* value) { + file_descriptor_proto_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} +inline void FileDescriptorResponse::set_file_descriptor_proto(int index, const void* value, size_t size) { + file_descriptor_proto_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} +inline ::std::string* FileDescriptorResponse::add_file_descriptor_proto() { + // @@protoc_insertion_point(field_add_mutable:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_.Add(); +} +inline void FileDescriptorResponse::add_file_descriptor_proto(const ::std::string& value) { + file_descriptor_proto_.Add()->assign(value); + // @@protoc_insertion_point(field_add:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} +inline void FileDescriptorResponse::add_file_descriptor_proto(const char* value) { + file_descriptor_proto_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} +inline void FileDescriptorResponse::add_file_descriptor_proto(const void* value, size_t size) { + file_descriptor_proto_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} +inline const ::google::protobuf::RepeatedPtrField< ::std::string>& +FileDescriptorResponse::file_descriptor_proto() const { + // @@protoc_insertion_point(field_list:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_; +} +inline ::google::protobuf::RepeatedPtrField< ::std::string>* +FileDescriptorResponse::mutable_file_descriptor_proto() { + // @@protoc_insertion_point(field_mutable_list:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return &file_descriptor_proto_; +} + +// ------------------------------------------------------------------- + +// ExtensionNumberResponse + +// optional string base_type_name = 1; +inline void ExtensionNumberResponse::clear_base_type_name() { + base_type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& ExtensionNumberResponse::base_type_name() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) + return base_type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ExtensionNumberResponse::set_base_type_name(const ::std::string& value) { + + base_type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} +inline void ExtensionNumberResponse::set_base_type_name(const char* value) { + + base_type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} +inline void ExtensionNumberResponse::set_base_type_name(const char* value, size_t size) { + + base_type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} +inline ::std::string* ExtensionNumberResponse::mutable_base_type_name() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) + return base_type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ExtensionNumberResponse::release_base_type_name() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) + + return base_type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ExtensionNumberResponse::set_allocated_base_type_name(::std::string* base_type_name) { + if (base_type_name != NULL) { + + } else { + + } + base_type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), base_type_name); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} + +// repeated int32 extension_number = 2; +inline int ExtensionNumberResponse::extension_number_size() const { + return extension_number_.size(); +} +inline void ExtensionNumberResponse::clear_extension_number() { + extension_number_.Clear(); +} +inline ::google::protobuf::int32 ExtensionNumberResponse::extension_number(int index) const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) + return extension_number_.Get(index); +} +inline void ExtensionNumberResponse::set_extension_number(int index, ::google::protobuf::int32 value) { + extension_number_.Set(index, value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) +} +inline void ExtensionNumberResponse::add_extension_number(::google::protobuf::int32 value) { + extension_number_.Add(value); + // @@protoc_insertion_point(field_add:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +ExtensionNumberResponse::extension_number() const { + // @@protoc_insertion_point(field_list:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) + return extension_number_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +ExtensionNumberResponse::mutable_extension_number() { + // @@protoc_insertion_point(field_mutable_list:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) + return &extension_number_; +} + +// ------------------------------------------------------------------- + +// ListServiceResponse + +// repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; +inline int ListServiceResponse::service_size() const { + return service_.size(); +} +inline void ListServiceResponse::clear_service() { + service_.Clear(); +} +inline const ::grpc::reflection::v1alpha::ServiceResponse& ListServiceResponse::service(int index) const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_.Get(index); +} +inline ::grpc::reflection::v1alpha::ServiceResponse* ListServiceResponse::mutable_service(int index) { + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_.Mutable(index); +} +inline ::grpc::reflection::v1alpha::ServiceResponse* ListServiceResponse::add_service() { + // @@protoc_insertion_point(field_add:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_.Add(); +} +inline ::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse >* +ListServiceResponse::mutable_service() { + // @@protoc_insertion_point(field_mutable_list:grpc.reflection.v1alpha.ListServiceResponse.service) + return &service_; +} +inline const ::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse >& +ListServiceResponse::service() const { + // @@protoc_insertion_point(field_list:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_; +} + +// ------------------------------------------------------------------- + +// ServiceResponse + +// optional string name = 1; +inline void ServiceResponse::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& ServiceResponse::name() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServiceResponse.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ServiceResponse::set_name(const ::std::string& value) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServiceResponse.name) +} +inline void ServiceResponse::set_name(const char* value) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServiceResponse.name) +} +inline void ServiceResponse::set_name(const char* value, size_t size) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServiceResponse.name) +} +inline ::std::string* ServiceResponse::mutable_name() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServiceResponse.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ServiceResponse::release_name() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServiceResponse.name) + + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ServiceResponse::set_allocated_name(::std::string* name) { + if (name != NULL) { + + } else { + + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServiceResponse.name) +} + +// ------------------------------------------------------------------- + +// ErrorResponse + +// optional int32 error_code = 1; +inline void ErrorResponse::clear_error_code() { + error_code_ = 0; +} +inline ::google::protobuf::int32 ErrorResponse::error_code() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ErrorResponse.error_code) + return error_code_; +} +inline void ErrorResponse::set_error_code(::google::protobuf::int32 value) { + + error_code_ = value; + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ErrorResponse.error_code) +} + +// optional string error_message = 2; +inline void ErrorResponse::clear_error_message() { + error_message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& ErrorResponse::error_message() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ErrorResponse.error_message) + return error_message_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ErrorResponse::set_error_message(const ::std::string& value) { + + error_message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ErrorResponse.error_message) +} +inline void ErrorResponse::set_error_message(const char* value) { + + error_message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ErrorResponse.error_message) +} +inline void ErrorResponse::set_error_message(const char* value, size_t size) { + + error_message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ErrorResponse.error_message) +} +inline ::std::string* ErrorResponse::mutable_error_message() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ErrorResponse.error_message) + return error_message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* ErrorResponse::release_error_message() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ErrorResponse.error_message) + + return error_message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void ErrorResponse::set_allocated_error_message(::std::string* error_message) { + if (error_message != NULL) { + + } else { + + } + error_message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), error_message); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ErrorResponse.error_message) +} + +#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace v1alpha +} // namespace reflection +} // namespace grpc + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_reflection_2eproto__INCLUDED diff --git a/include/grpc++/grpc++.h b/include/grpc++/grpc++.h index b7d5fb0bbcd..ef07e199759 100644 --- a/include/grpc++/grpc++.h +++ b/include/grpc++/grpc++.h @@ -57,8 +57,10 @@ #include #include #include +#include #include #include #include +#include #endif // GRPCXX_GRPCXX_H diff --git a/include/grpc++/impl/codegen/async_stream.h b/include/grpc++/impl/codegen/async_stream.h index e2954e3a7ed..0606441549e 100644 --- a/include/grpc++/impl/codegen/async_stream.h +++ b/include/grpc++/impl/codegen/async_stream.h @@ -299,8 +299,16 @@ class ClientAsyncReaderWriter GRPC_FINAL }; template -class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncReaderInterface { +class ServerAsyncReaderInterface : public ServerAsyncStreamingInterface, + public AsyncReaderInterface { + public: + virtual void Finish(const W& msg, const Status& status, void* tag) = 0; + + virtual void FinishWithError(const Status& status, void* tag) = 0; +}; + +template +class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface { public: explicit ServerAsyncReader(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -321,7 +329,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&read_ops_); } - void Finish(const W& msg, const Status& status, void* tag) { + void Finish(const W& msg, const Status& status, void* tag) GRPC_OVERRIDE { finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { finish_ops_.SendInitialMetadata(ctx_->initial_metadata_, @@ -338,7 +346,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&finish_ops_); } - void FinishWithError(const Status& status, void* tag) { + void FinishWithError(const Status& status, void* tag) GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!status.ok()); finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { @@ -363,8 +371,14 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, }; template -class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface { +class ServerAsyncWriterInterface : public ServerAsyncStreamingInterface, + public AsyncWriterInterface { + public: + virtual void Finish(const Status& status, void* tag) = 0; +}; + +template +class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface { public: explicit ServerAsyncWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -391,7 +405,7 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&write_ops_); } - void Finish(const Status& status, void* tag) { + void Finish(const Status& status, void* tag) GRPC_OVERRIDE { finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { finish_ops_.SendInitialMetadata(ctx_->initial_metadata_, @@ -414,9 +428,16 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, /// Server-side interface for asynchronous bi-directional streaming. template -class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { +class ServerAsyncReaderWriterInterface : public ServerAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { + public: + virtual void Finish(const Status& status, void* tag) = 0; +}; + +template +class ServerAsyncReaderWriter GRPC_FINAL + : public ServerAsyncReaderWriterInterface { public: explicit ServerAsyncReaderWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -449,7 +470,7 @@ class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&write_ops_); } - void Finish(const Status& status, void* tag) { + void Finish(const Status& status, void* tag) GRPC_OVERRIDE { finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { finish_ops_.SendInitialMetadata(ctx_->initial_metadata_, diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 4f550b42a2d..d720f27a8fa 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -47,7 +47,9 @@ #include #include #include + #include +#include #include struct grpc_byte_buffer; @@ -187,6 +189,8 @@ class CallOpSendInitialMetadata { flags_ = flags; initial_metadata_count_ = metadata.size(); initial_metadata_ = FillMetadataArray(metadata); + // TODO(dgq): expose compression level in API so it can be properly set. + maybe_compression_level_.is_set = false; } protected: @@ -198,6 +202,10 @@ class CallOpSendInitialMetadata { op->reserved = NULL; op->data.send_initial_metadata.count = initial_metadata_count_; op->data.send_initial_metadata.metadata = initial_metadata_; + op->data.send_initial_metadata.maybe_compression_level.is_set = + maybe_compression_level_.is_set; + op->data.send_initial_metadata.maybe_compression_level.level = + maybe_compression_level_.level; } void FinishOp(bool* status, int max_message_size) { if (!send_) return; @@ -209,6 +217,10 @@ class CallOpSendInitialMetadata { uint32_t flags_; size_t initial_metadata_count_; grpc_metadata* initial_metadata_; + struct { + bool is_set; + grpc_compression_level level; + } maybe_compression_level_; }; class CallOpSendMessage { diff --git a/include/grpc++/impl/codegen/config_protobuf.h b/include/grpc++/impl/codegen/config_protobuf.h index f1b6beaca73..4bee1bc4227 100644 --- a/include/grpc++/impl/codegen/config_protobuf.h +++ b/include/grpc++/impl/codegen/config_protobuf.h @@ -44,6 +44,19 @@ #define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message #endif +#ifndef GRPC_CUSTOM_DESCRIPTOR +#include +#include +#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor +#define GRPC_CUSTOM_DESCRIPTORPOOL ::google::protobuf::DescriptorPool +#define GPRC_CUSTOM_FIELDDESCRIPTOR ::google::protobuf::FieldDescriptor +#define GRPC_CUSTOM_FILEDESCRIPTOR ::google::protobuf::FileDescriptor +#define GRPC_CUSTOM_FILEDESCRIPTORPROTO ::google::protobuf::FileDescriptorProto +#define GRPC_CUSTOM_METHODDESCRIPTOR ::google::protobuf::MethodDescriptor +#define GRPC_CUSTOM_SERVICEDESCRIPTOR ::google::protobuf::ServiceDescriptor +#define GRPC_CUSTOM_SOURCELOCATION ::google::protobuf::SourceLocation +#endif + #ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM #include #include @@ -60,6 +73,15 @@ namespace protobuf { typedef GRPC_CUSTOM_MESSAGE Message; typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; +typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; +typedef GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool; +typedef GPRC_CUSTOM_FIELDDESCRIPTOR FieldDescriptor; +typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor; +typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto; +typedef GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor; +typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor; +typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation; + namespace io { typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; diff --git a/src/cpp/common/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h similarity index 100% rename from src/cpp/common/core_codegen.h rename to include/grpc++/impl/codegen/core_codegen.h diff --git a/include/grpc++/impl/codegen/impl/async_stream.h b/include/grpc++/impl/codegen/impl/async_stream.h index 8f99e7eea43..7d7a9568077 100644 --- a/include/grpc++/impl/codegen/impl/async_stream.h +++ b/include/grpc++/impl/codegen/impl/async_stream.h @@ -295,8 +295,16 @@ class ClientAsyncReaderWriter GRPC_FINAL }; template -class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncReaderInterface { +class ServerAsyncReaderInterface : public ServerAsyncStreamingInterface, + public AsyncReaderInterface { + public: + virtual void Finish(const W& msg, const Status& status, void* tag) = 0; + + virtual void FinishWithError(const Status& status, void* tag) = 0; +}; + +template +class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface { public: explicit ServerAsyncReader(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -316,7 +324,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&read_ops_); } - void Finish(const W& msg, const Status& status, void* tag) { + void Finish(const W& msg, const Status& status, void* tag) GRPC_OVERRIDE { finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); @@ -332,7 +340,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&finish_ops_); } - void FinishWithError(const Status& status, void* tag) { + void FinishWithError(const Status& status, void* tag) GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!status.ok()); finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { @@ -356,8 +364,14 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, }; template -class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface { +class ServerAsyncWriterInterface : public ServerAsyncStreamingInterface, + public AsyncWriterInterface { + public: + virtual void Finish(const Status& status, void* tag) = 0; +}; + +template +class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface { public: explicit ServerAsyncWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -382,7 +396,7 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&write_ops_); } - void Finish(const Status& status, void* tag) { + void Finish(const Status& status, void* tag) GRPC_OVERRIDE { finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); @@ -404,9 +418,16 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, /// Server-side interface for asynchronous bi-directional streaming. template -class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { +class ServerAsyncReaderWriterInterface : public ServerAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { + public: + virtual void Finish(const Status& status, void* tag) = 0; +}; + +template +class ServerAsyncReaderWriter GRPC_FINAL + : public ServerAsyncReaderWriterInterface { public: explicit ServerAsyncReaderWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -437,7 +458,7 @@ class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, call_.PerformOps(&write_ops_); } - void Finish(const Status& status, void* tag) { + void Finish(const Status& status, void* tag) GRPC_OVERRIDE { finish_ops_.set_output_tag(tag); if (!ctx_->sent_initial_metadata_) { finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h index 7b7d5aa90b6..3a3e052d9ef 100644 --- a/include/grpc++/impl/codegen/server_interface.h +++ b/include/grpc++/impl/codegen/server_interface.h @@ -62,6 +62,10 @@ class ServerInterface : public CallHook { /// Shutdown the server, blocking until all rpc processing finishes. /// Forcefully terminate pending calls after \a deadline expires. /// + /// All completion queue associated with the server (for example, for async + /// serving) must be shutdown *after* this method has returned: + /// See \a ServerBuilder::AddCompletionQueue for details. + /// /// \param deadline How long to wait until pending rpcs are forcefully /// terminated. template @@ -70,6 +74,10 @@ class ServerInterface : public CallHook { } /// Shutdown the server, waiting for all rpc processing to finish. + /// + /// All completion queue associated with the server (for example, for async + /// serving) must be shutdown *after* this method has returned: + /// See \a ServerBuilder::AddCompletionQueue for details. void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); } /// Block waiting for all work to complete. diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h index 175cf99a82b..1184d1bf093 100644 --- a/include/grpc++/impl/grpc_library.h +++ b/include/grpc++/impl/grpc_library.h @@ -37,11 +37,10 @@ #include #include +#include #include #include -#include "src/cpp/common/core_codegen.h" - namespace grpc { namespace internal { diff --git a/include/grpc++/server.h b/include/grpc++/server.h index a0ee0e98e47..7a8858ef194 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -93,6 +93,12 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen { /// until all server objects in the process have been destroyed. static void SetGlobalCallbacks(GlobalCallbacks* callbacks); + // Returns a \em raw pointer to the underlying grpc_server instance. + grpc_server* c_server(); + + // Returns a \em raw pointer to the underlying CompletionQueue. + CompletionQueue* completion_queue(); + private: friend class AsyncGenericService; friend class ServerBuilder; diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 8525cb70cbb..aa7588d34d3 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -66,29 +66,43 @@ class ServerBuilder { /// The service must exist for the lifetime of the \a Server instance returned /// by \a BuildAndStart(). /// Matches requests with any :authority - void RegisterService(Service* service); + ServerBuilder& RegisterService(Service* service); /// Register a generic service. /// Matches requests with any :authority - void RegisterAsyncGenericService(AsyncGenericService* service); + ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service); /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the \a Server instance returned /// by BuildAndStart(). /// Only matches requests with :authority \a host - void RegisterService(const grpc::string& host, Service* service); + ServerBuilder& RegisterService(const grpc::string& host, Service* service); /// Set max message size in bytes. - void SetMaxMessageSize(int max_message_size) { + ServerBuilder& SetMaxMessageSize(int max_message_size) { max_message_size_ = max_message_size; + return *this; } - /// Set the compression options to be used by the server. - void SetCompressionOptions(const grpc_compression_options& options) { - compression_options_ = options; - } + /// Set the support status for compression algorithms. All algorithms are + /// enabled by default. + /// + /// Incoming calls compressed with an unsupported algorithm will fail with + /// GRPC_STATUS_UNIMPLEMENTED. + ServerBuilder& SetCompressionAlgorithmSupportStatus( + grpc_compression_algorithm algorithm, bool enabled); + + /// The default compression level to use for all channel calls in the + /// absence of a call-specific level. + ServerBuilder& SetDefaultCompressionLevel(grpc_compression_level level); + + /// The default compression algorithm to use for all channel calls in the + /// absence of a call-specific level. Note that it overrides any compression + /// level set by \a SetDefaultCompressionLevel. + ServerBuilder& SetDefaultCompressionAlgorithm( + grpc_compression_algorithm algorithm); - void SetOption(std::unique_ptr option); + ServerBuilder& SetOption(std::unique_ptr option); /// Tries to bind \a server to the given \a addr. /// @@ -101,13 +115,24 @@ class ServerBuilder { /// number. \a nullptr otherwise. /// // TODO(dgq): the "port" part seems to be a misnomer. - void AddListeningPort(const grpc::string& addr, - std::shared_ptr creds, - int* selected_port = nullptr); + ServerBuilder& AddListeningPort(const grpc::string& addr, + std::shared_ptr creds, + int* selected_port = nullptr); - /// Add a completion queue for handling asynchronous services - /// Caller is required to keep this completion queue live until - /// the server is destroyed. + /// Add a completion queue for handling asynchronous services. + /// + /// Caller is required to shutdown the server prior to shutting down the + /// returned completion queue. A typical usage scenario: + /// + /// // While building the server: + /// ServerBuilder builder; + /// ... + /// cq_ = builder.AddCompletionQueue(); + /// server_ = builder.BuildAndStart(); + /// + /// // While shutting down the server; + /// server_->Shutdown(); + /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()! /// /// \param is_frequently_polled This is an optional parameter to inform GRPC /// library about whether this completion queue would be frequently polled @@ -144,7 +169,6 @@ class ServerBuilder { }; int max_message_size_; - grpc_compression_options compression_options_; std::vector> options_; std::vector> services_; std::vector ports_; @@ -152,6 +176,15 @@ class ServerBuilder { std::shared_ptr creds_; std::map> plugins_; AsyncGenericService* generic_service_; + struct { + bool is_set; + grpc_compression_level level; + } maybe_default_compression_level_; + struct { + bool is_set; + grpc_compression_algorithm algorithm; + } maybe_default_compression_algorithm_; + uint32_t enabled_compression_algorithms_bitset_; }; } // namespace grpc diff --git a/include/grpc++/server_posix.h b/include/grpc++/server_posix.h new file mode 100644 index 00000000000..e6066d4eaab --- /dev/null +++ b/include/grpc++/server_posix.h @@ -0,0 +1,56 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_SERVER_POSIX_H +#define GRPCXX_SERVER_POSIX_H + +#include + +#include +#include + +namespace grpc { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +/// Adds new client to a \a Server communicating over given file descriptor +/// +/// \param server The server to add a client to. +/// \param fd The file descriptor representing a socket. +void AddInsecureChannelFromFd(Server* server, int fd); + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc + +#endif // GRPCXX_SERVER_POSIX_H diff --git a/include/grpc/compression.h b/include/grpc/compression.h index 8de4b133d4c..22bcf0e3020 100644 --- a/include/grpc/compression.h +++ b/include/grpc/compression.h @@ -51,7 +51,8 @@ GRPCAPI int grpc_compression_algorithm_parse( grpc_compression_algorithm *algorithm); /** Updates \a name with the encoding name corresponding to a valid \a - * algorithm. Returns 1 upon success, 0 otherwise. */ + * algorithm. Note that \a name is statically allocated and must *not* be freed. + * Returns 1 upon success, 0 otherwise. */ GRPCAPI int grpc_compression_algorithm_name( grpc_compression_algorithm algorithm, char **name); diff --git a/include/grpc/grpc_posix.h b/include/grpc/grpc_posix.h new file mode 100644 index 00000000000..9742b83374a --- /dev/null +++ b/include/grpc/grpc_posix.h @@ -0,0 +1,70 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_GRPC_POSIX_H +#define GRPC_GRPC_POSIX_H + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \mainpage GRPC Core POSIX + * + * The GRPC Core POSIX library provides some POSIX-specific low-level + * functionality on top of GRPC Core. + */ + +/** Create a client channel to 'target' using file descriptor 'fd'. The 'target' + argument will be used to indicate the name for this channel. See the comment + for grpc_insecure_channel_create for description of 'args' argument. */ +GRPCAPI grpc_channel *grpc_insecure_channel_create_from_fd( + const char *target, int fd, const grpc_channel_args *args); + +/** Add the connected communication channel based on file descriptor 'fd' to the + 'server'. The 'fd' must be an open file descriptor corresponding to a + connected socket. The 'cq' is a completion queue that will be getting events + from that descriptor. */ +GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server *server, + grpc_completion_queue *cq, + int fd); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_GRPC_POSIX_H */ diff --git a/include/grpc/impl/codegen/compression_types.h b/include/grpc/impl/codegen/compression_types.h index 8d2ec3b9d71..9065d1edd02 100644 --- a/include/grpc/impl/codegen/compression_types.h +++ b/include/grpc/impl/codegen/compression_types.h @@ -35,11 +35,17 @@ #define GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H #include +#include #ifdef __cplusplus extern "C" { #endif +/** To be used as initial metadata key for the request of a concrete compression + * algorithm */ +#define GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \ + "grpc-internal-encoding-request" + /** To be used in channel arguments */ #define GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM \ "grpc.default_compression_algorithm" @@ -74,15 +80,24 @@ typedef struct grpc_compression_options { */ uint32_t enabled_algorithms_bitset; - /** The default channel compression algorithm. It'll be used in the absence of + /** The default channel compression level. It'll be used in the absence of * call specific settings. This option corresponds to the channel argument key - * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM */ - grpc_compression_algorithm default_compression_algorithm; + * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL. If present, takes + * precedence over \a default_algorithm. + * TODO(dgq): currently only available for server channels. */ + struct { + bool is_set; + grpc_compression_level level; + } default_level; - /** The default channel compression level. It'll be used in the absence of + /** The default channel compression algorithm. It'll be used in the absence of * call specific settings. This option corresponds to the channel argument key - * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL */ - grpc_compression_algorithm default_compression_level; + * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM. */ + struct { + bool is_set; + grpc_compression_algorithm algorithm; + } default_algorithm; + } grpc_compression_options; #ifdef __cplusplus diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 7181be4a34d..c51ffa44930 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -334,6 +334,12 @@ typedef struct grpc_op { struct { size_t count; grpc_metadata *metadata; + /** If \a is_set, \a compression_level will be used for the call. + * Otherwise, \a compression_level won't be considered */ + struct { + uint8_t is_set; + grpc_compression_level level; + } maybe_compression_level; } send_initial_metadata; grpc_byte_buffer *send_message; struct { diff --git a/include/grpc/impl/codegen/log.h b/include/grpc/impl/codegen/log.h index aa86fc4c179..e5010c29da8 100644 --- a/include/grpc/impl/codegen/log.h +++ b/include/grpc/impl/codegen/log.h @@ -34,6 +34,7 @@ #ifndef GRPC_IMPL_CODEGEN_LOG_H #define GRPC_IMPL_CODEGEN_LOG_H +#include #include #include /* for abort() */ @@ -74,7 +75,7 @@ const char *gpr_log_severity_string(gpr_log_severity severity); /* Log a message. It's advised to use GPR_xxx above to generate the context * for each message */ GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...); + const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); GPRAPI void gpr_log_message(const char *file, int line, gpr_log_severity severity, const char *message); diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index be4215a54bf..b8aa199aa84 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -129,6 +129,7 @@ #define GPR_POSIX_SOCKETADDR 1 #define GPR_POSIX_NO_SPECIAL_WAKEUP_FD 1 #define GPR_POSIX_SOCKETUTILS 1 +#define GPR_SUPPORT_CHANNELS_FROM_FD 1 #define GPR_HAVE_UNIX_SOCKET 1 #define GPR_HAVE_IP_PKTINFO 1 #define GPR_HAVE_IPV6_RECVPKTINFO 1 @@ -149,7 +150,11 @@ #elif defined(ANDROID) || defined(__ANDROID__) #define GPR_PLATFORM_STRING "android" #define GPR_ANDROID 1 +#ifdef _LP64 +#define GPR_ARCH_64 1 +#else /* _LP64 */ #define GPR_ARCH_32 1 +#endif /* _LP64 */ #define GPR_CPU_LINUX 1 #define GPR_GCC_SYNC 1 #define GPR_GCC_TLS 1 @@ -168,6 +173,7 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 #define GPR_GETPID_IN_UNISTD_H 1 +#define GPR_SUPPORT_CHANNELS_FROM_FD 1 #define GPR_HAVE_MSG_NOSIGNAL 1 #define GPR_HAVE_UNIX_SOCKET 1 #define GPR_HAVE_IP_PKTINFO 1 @@ -194,6 +200,7 @@ #define GPR_POSIX_WAKEUP_FD 1 #define GPR_POSIX_SOCKET 1 #define GPR_POSIX_SOCKETADDR 1 +#define GPR_SUPPORT_CHANNELS_FROM_FD 1 #define GPR_HAVE_UNIX_SOCKET 1 #define GPR_HAVE_IP_PKTINFO 1 #define GPR_HAVE_IPV6_RECVPKTINFO 1 @@ -258,6 +265,7 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 #define GPR_GETPID_IN_UNISTD_H 1 +#define GPR_SUPPORT_CHANNELS_FROM_FD 1 #define GPR_HAVE_SO_NOSIGPIPE 1 #define GPR_HAVE_UNIX_SOCKET 1 #define GPR_HAVE_IP_PKTINFO 1 @@ -289,6 +297,7 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 #define GPR_GETPID_IN_UNISTD_H 1 +#define GPR_SUPPORT_CHANNELS_FROM_FD 1 #define GPR_HAVE_SO_NOSIGPIPE 1 #define GPR_HAVE_UNIX_SOCKET 1 #define GPR_HAVE_IP_PKTINFO 1 @@ -429,6 +438,15 @@ typedef unsigned __int64 uint64_t; #endif #endif +#ifndef GPRC_PRINT_FORMAT_CHECK +#ifdef __GNUC__ +#define GPRC_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS) \ + __attribute__((format(printf, FORMAT_STR, ARGS))) +#else +#define GPRC_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS) +#endif +#endif /* GPRC_PRINT_FORMAT_CHECK */ + #if GPR_FORBID_UNREACHABLE_CODE #define GPR_UNREACHABLE_CODE(STATEMENT) #else diff --git a/include/grpc/support/string_util.h b/include/grpc/support/string_util.h index f981bc0db0b..952cbfc26b9 100644 --- a/include/grpc/support/string_util.h +++ b/include/grpc/support/string_util.h @@ -54,7 +54,8 @@ GPRAPI char *gpr_strdup(const char *src); On error, returns -1 and sets *strp to NULL. If the format string is bad, the result is undefined. */ -GPRAPI int gpr_asprintf(char **strp, const char *format, ...); +GPRAPI int gpr_asprintf(char **strp, const char *format, ...) + GPRC_PRINT_FORMAT_CHECK(2, 3); #ifdef __cplusplus } diff --git a/package.xml b/package.xml index f780f8025b9..b25e42c1c01 100644 --- a/package.xml +++ b/package.xml @@ -154,6 +154,7 @@ + @@ -254,6 +255,7 @@ + @@ -337,7 +339,7 @@ - + @@ -414,6 +416,7 @@ + @@ -484,7 +487,9 @@ + + @@ -1069,20 +1074,5 @@ Update to wrap gRPC C Core version 0.10.0 - Updated functions with TSRM macros for ZTS support #6607 - - - 0.15.0 - 0.15.0 - - - beta - beta - - 2016-05-19 - BSD - -- TBD - - diff --git a/setup.py b/setup.py index f96824fa883..e2de96de358 100644 --- a/setup.py +++ b/setup.py @@ -33,9 +33,11 @@ import os import os.path import shutil import sys +import sysconfig from distutils import core as _core from distutils import extension as _extension +import pkg_resources import setuptools from setuptools.command import egg_info @@ -110,6 +112,16 @@ if "linux" in sys.platform or "darwin" in sys.platform: DEFINE_MACROS += (('PyMODINIT_FUNC', pymodinit),) +# By default, Python3 distutils enforces compatibility of +# c plugins (.so files) with the OSX version Python3 was built with. +# For Python3.4, this is OSX 10.6, but we need Thread Local Support (__thread) +if 'darwin' in sys.platform and PY3: + mac_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') + if mac_target and (pkg_resources.parse_version(mac_target) < + pkg_resources.parse_version('10.7.0')): + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.7' + + def cython_extensions(module_names, extra_sources, include_dirs, libraries, define_macros, build_with_cython=False): # Set compiler directives linetrace argument only if we care about tracing; @@ -202,7 +214,7 @@ TEST_PACKAGE_DATA = { } TESTS_REQUIRE = ( - 'oauth2client>=1.4.7', + 'oauth2client>=2.1.0', 'protobuf>=3.0.0a3', 'coverage>=4.0', ) + INSTALL_REQUIRES @@ -234,8 +246,7 @@ setuptools.setup( ext_modules=CYTHON_EXTENSION_MODULES, packages=list(PACKAGES), package_dir=PACKAGE_DIRECTORIES, - # TODO(atash): Figure out why auditwheel doesn't like namespace packages. - #namespace_packages=['grpc'], + namespace_packages=['grpc'], package_data=PACKAGE_DATA, install_requires=INSTALL_REQUIRES, setup_requires=SETUP_REQUIRES, diff --git a/src/compiler/config.h b/src/compiler/config.h index f2abb851867..1cbd842f0af 100644 --- a/src/compiler/config.h +++ b/src/compiler/config.h @@ -36,17 +36,6 @@ #include -#ifndef GRPC_CUSTOM_DESCRIPTOR -#include -#include -#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor -#define GRPC_CUSTOM_FILEDESCRIPTOR ::google::protobuf::FileDescriptor -#define GRPC_CUSTOM_FILEDESCRIPTORPROTO ::google::protobuf::FileDescriptorProto -#define GRPC_CUSTOM_METHODDESCRIPTOR ::google::protobuf::MethodDescriptor -#define GRPC_CUSTOM_SERVICEDESCRIPTOR ::google::protobuf::ServiceDescriptor -#define GRPC_CUSTOM_SOURCELOCATION ::google::protobuf::SourceLocation -#endif - #ifndef GRPC_CUSTOM_CODEGENERATOR #include #define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator @@ -84,12 +73,7 @@ namespace grpc { typedef GRPC_CUSTOM_STRING string; namespace protobuf { -typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; -typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor; -typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto; -typedef GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor; -typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor; -typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation; + namespace compiler { typedef GRPC_CUSTOM_CODEGENERATOR CodeGenerator; typedef GRPC_CUSTOM_GENERATORCONTEXT GeneratorContext; diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 465491e385f..4be8cb41879 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -60,9 +60,34 @@ void PrintProtoRpcDeclarationAsPragma(Printer *printer, " returns ($server_stream$$response_type$)\n\n"); } +template +static void PrintAllComments(const DescriptorType* desc, Printer* printer) { + std::vector comments; + grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED, + &comments); + grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING, + &comments); + grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_TRAILING, + &comments); + if (comments.empty()) { + return; + } + printer->Print("/**\n"); + for (auto it = comments.begin(); it != comments.end(); ++it) { + printer->Print(" * "); + size_t start_pos = it->find_first_not_of(' '); + if (start_pos != grpc::string::npos) { + printer->Print(it->c_str() + start_pos); + } + printer->Print("\n"); + } + printer->Print(" */\n"); +} + void PrintMethodSignature(Printer *printer, const MethodDescriptor *method, const map< ::grpc::string, ::grpc::string> &vars) { - // TODO(jcanizales): Print method comments. + // Print comment + PrintAllComments(method, printer); printer->Print(vars, "- ($return_type$)$method_name$With"); if (method->client_streaming()) { @@ -94,7 +119,7 @@ void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method, void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method, map< ::grpc::string, ::grpc::string> vars) { vars["method_name"] = "RPCTo" + vars["method_name"]; - vars["return_type"] = "ProtoRPC *"; + vars["return_type"] = "GRPCProtoCall *"; PrintMethodSignature(printer, method, vars); } @@ -195,11 +220,13 @@ void PrintMethodImplementations(Printer *printer, printer.Print("@end\n\n"); printer.Print( - "// Basic service implementation, over gRPC, that only does" - " marshalling and parsing.\n"); + "/**\n" + " * Basic service implementation, over gRPC, that only does\n" + " * marshalling and parsing.\n" + " */\n"); printer.Print(vars, "@interface $service_class$ :" - " ProtoService<$service_class$>\n"); + " GRPCProtoService<$service_class$>\n"); printer.Print( "- (instancetype)initWithHost:(NSString *)host" " NS_DESIGNATED_INITIALIZER;\n"); @@ -220,18 +247,13 @@ void PrintMethodImplementations(Printer *printer, {"service_class", ServiceClassName(service)}, {"package", service->file()->package()}}; - printer.Print(vars, - "static NSString *const kPackageName = @\"$package$\";\n"); - printer.Print( - vars, "static NSString *const kServiceName = @\"$service_name$\";\n\n"); - printer.Print(vars, "@implementation $service_class$\n\n"); printer.Print("// Designated initializer\n"); printer.Print("- (instancetype)initWithHost:(NSString *)host {\n"); - printer.Print( + printer.Print(vars, " return (self = [super initWithHost:host" - " packageName:kPackageName serviceName:kServiceName]);\n"); + " packageName:@\"$package$\" serviceName:@\"$service_name$\"]);\n"); printer.Print("}\n\n"); printer.Print( "// Override superclass initializer to disallow different" diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index cd5ddd88326..15cda474ccd 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -342,7 +342,7 @@ bool PrintBetaServerFactory(const grpc::string& package_qualified_service_name, out->Print("}\n"); out->Print("method_implementations = {\n"); for (auto name_and_implementation_constructor = - method_implementation_constructors.begin(); + method_implementation_constructors.begin(); name_and_implementation_constructor != method_implementation_constructors.end(); name_and_implementation_constructor++) { @@ -457,8 +457,149 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name, return true; } +bool PrintStub(const grpc::string& package_qualified_service_name, + const ServiceDescriptor* service, Printer* out) { + out->Print("\n\n"); + out->Print("class $Service$Stub(object):\n", "Service", service->name()); + { + IndentScope raii_class_indent(out); + PrintAllComments(service, out); + out->Print("\n"); + out->Print("def __init__(self, channel):\n"); + { + IndentScope raii_init_indent(out); + out->Print("\"\"\"Constructor.\n"); + out->Print("\n"); + out->Print("Args:\n"); + { + IndentScope raii_args_indent(out); + out->Print("channel: A grpc.Channel.\n"); + } + out->Print("\"\"\"\n"); + for (int i = 0; i < service->method_count(); ++i) { + auto method = service->method(i); + auto multi_callable_constructor = + grpc::string(method->client_streaming() ? "stream" : "unary") + + "_" + + grpc::string(method->server_streaming() ? "stream" : "unary"); + grpc::string request_module_and_class; + if (!GetModuleAndMessagePath(method->input_type(), service, + &request_module_and_class)) { + return false; + } + grpc::string response_module_and_class; + if (!GetModuleAndMessagePath(method->output_type(), service, + &response_module_and_class)) { + return false; + } + out->Print("self.$Method$ = channel.$MultiCallableConstructor$(\n", + "Method", method->name(), + "MultiCallableConstructor", multi_callable_constructor); + { + IndentScope raii_first_attribute_indent(out); + IndentScope raii_second_attribute_indent(out); + out->Print( + "'/$PackageQualifiedService$/$Method$',\n", + "PackageQualifiedService", package_qualified_service_name, + "Method", method->name()); + out->Print( + "request_serializer=$RequestModuleAndClass$.SerializeToString,\n", + "RequestModuleAndClass", request_module_and_class); + out->Print( + "response_deserializer=$ResponseModuleAndClass$.FromString,\n", + "ResponseModuleAndClass", response_module_and_class); + out->Print(")\n"); + } + } + } + } + return true; +} + +bool PrintServicer(const ServiceDescriptor* service, Printer* out) { + out->Print("\n\n"); + out->Print("class $Service$Servicer(object):\n", "Service", service->name()); + { + IndentScope raii_class_indent(out); + PrintAllComments(service, out); + for (int i = 0; i < service->method_count(); ++i) { + auto method = service->method(i); + grpc::string arg_name = method->client_streaming() ? + "request_iterator" : "request"; + out->Print("\n"); + out->Print("def $Method$(self, $ArgName$, context):\n", + "Method", method->name(), "ArgName", arg_name); + { + IndentScope raii_method_indent(out); + PrintAllComments(method, out); + out->Print("context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n"); + out->Print("context.set_details('Method not implemented!')\n"); + out->Print("raise NotImplementedError('Method not implemented!')\n"); + } + } + } + return true; +} + +bool PrintAddServicerToServer(const grpc::string& package_qualified_service_name, + const ServiceDescriptor* service, Printer* out) { + out->Print("\n\n"); + out->Print("def add_$Service$Servicer_to_server(servicer, server):\n", + "Service", service->name()); + { + IndentScope raii_class_indent(out); + out->Print("rpc_method_handlers = {\n"); + { + IndentScope raii_dict_first_indent(out); + IndentScope raii_dict_second_indent(out); + for (int i = 0; i < service->method_count(); ++i) { + auto method = service->method(i); + auto method_handler_constructor = + grpc::string(method->client_streaming() ? "stream" : "unary") + + "_" + + grpc::string(method->server_streaming() ? "stream" : "unary") + + "_rpc_method_handler"; + grpc::string request_module_and_class; + if (!GetModuleAndMessagePath(method->input_type(), service, + &request_module_and_class)) { + return false; + } + grpc::string response_module_and_class; + if (!GetModuleAndMessagePath(method->output_type(), service, + &response_module_and_class)) { + return false; + } + out->Print("'$Method$': grpc.$MethodHandlerConstructor$(\n", + "Method", method->name(), + "MethodHandlerConstructor", method_handler_constructor); + { + IndentScope raii_call_first_indent(out); + IndentScope raii_call_second_indent(out); + out->Print("servicer.$Method$,\n", "Method", method->name()); + out->Print("request_deserializer=$RequestModuleAndClass$.FromString,\n", + "RequestModuleAndClass", request_module_and_class); + out->Print("response_serializer=$ResponseModuleAndClass$.SerializeToString,\n", + "ResponseModuleAndClass", response_module_and_class); + } + out->Print("),\n"); + } + } + out->Print("}\n"); + out->Print("generic_handler = grpc.method_handlers_generic_handler(\n"); + { + IndentScope raii_call_first_indent(out); + IndentScope raii_call_second_indent(out); + out->Print("'$PackageQualifiedServiceName$', rpc_method_handlers)\n", + "PackageQualifiedServiceName", package_qualified_service_name); + } + out->Print("server.add_generic_rpc_handlers((generic_handler,))\n"); + } + return true; +} + bool PrintPreamble(const FileDescriptor* file, 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", "Package", config.beta_package_root); out->Print("from $Package$ import interfaces as beta_interfaces\n", @@ -487,7 +628,10 @@ pair GetServices(const FileDescriptor* file, for (int i = 0; i < file->service_count(); ++i) { auto service = file->service(i); auto package_qualified_service_name = package + service->name(); - if (!(PrintBetaServicer(service, &out) && + if (!(PrintStub(package_qualified_service_name, service, &out) && + PrintServicer(service, &out) && + PrintAddServicerToServer(package_qualified_service_name, service, &out) && + PrintBetaServicer(service, &out) && PrintBetaStub(service, &out) && PrintBetaServerFactory(package_qualified_service_name, service, &out) && PrintBetaStubFactory(package_qualified_service_name, service, &out))) { diff --git a/src/compiler/python_generator.h b/src/compiler/python_generator.h index e56b6790ef9..fc51b48daec 100644 --- a/src/compiler/python_generator.h +++ b/src/compiler/python_generator.h @@ -43,6 +43,7 @@ namespace grpc_python_generator { // Data pertaining to configuration of the generator with respect to anything // that may be used internally at Google. struct GeneratorConfiguration { + grpc::string grpc_package_root; grpc::string beta_package_root; }; diff --git a/src/compiler/python_plugin.cc b/src/compiler/python_plugin.cc index 92a07b2f80a..fc76ee5ec6d 100644 --- a/src/compiler/python_plugin.cc +++ b/src/compiler/python_plugin.cc @@ -38,6 +38,7 @@ int main(int argc, char* argv[]) { grpc_python_generator::GeneratorConfiguration config; + config.grpc_package_root = "grpc"; config.beta_package_root = "grpc.beta"; grpc_python_generator::PythonGrpcGenerator generator(config); return grpc::protobuf::compiler::PluginMain(argc, argv, &generator); diff --git a/src/core/ext/client_config/lb_policy.c b/src/core/ext/client_config/lb_policy.c index 20535398d69..dc1612428ec 100644 --- a/src/core/ext/client_config/lb_policy.c +++ b/src/core/ext/client_config/lb_policy.c @@ -60,8 +60,9 @@ static gpr_atm ref_mutate(grpc_lb_policy *c, gpr_atm delta, : gpr_atm_no_barrier_fetch_add(&c->ref_pair, delta); #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "LB_POLICY: %p % 12s 0x%08x -> 0x%08x [%s]", c, purpose, old_val, - old_val + delta, reason); + "LB_POLICY: 0x%" PRIxPTR " %12s 0x%" PRIxPTR " -> 0x%" PRIxPTR + " [%s]", + (intptr_t)c, purpose, old_val, old_val + delta, reason); #endif return old_val; } diff --git a/src/core/ext/lb_policy/round_robin/round_robin.c b/src/core/ext/lb_policy/round_robin/round_robin.c index 8645333c8e3..40dd7c59400 100644 --- a/src/core/ext/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/lb_policy/round_robin/round_robin.c @@ -31,6 +31,34 @@ * */ +/** Round Robin Policy. + * + * This policy keeps: + * - A circular list of ready (connected) subchannels, the *readylist*. An empty + * readylist consists solely of its root (dummy) node. + * - A pointer to the last element picked from the readylist, the *lastpick*. + * Initially set to point to the readylist's root. + * + * Behavior: + * - When a subchannel connects, it's *prepended* to the readylist's root node. + * Ie, if readylist = A <-> B <-> ROOT <-> C + * ^ ^ + * |____________________| + * and subchannel D becomes connected, the addition of D to the readylist + * results in readylist = A <-> B <-> D <-> ROOT <-> C + * ^ ^ + * |__________________________| + * - When a subchannel disconnects, it's removed from the readylist. If the + * subchannel being removed was the most recently picked, the *lastpick* + * pointer moves to the removed node's previous element. Note that if the + * readylist only had one element, this is still legal, as the lastpick would + * point to the dummy root node, for an empty readylist. + * - Upon picking, *lastpick* is updated to point to the returned (connected) + * subchannel. Note that it's possible that the selected subchannel becomes + * disconnected in the interim between the selection and the actual usage of + * the subchannel by the caller. + */ + #include #include @@ -173,9 +201,7 @@ static void remove_disconnected_sc_locked(round_robin_lb_policy *p, return; } if (node == p->ready_list_last_pick) { - /* If removing the lastly picked node, reset the last pick pointer to the - * dummy root of the list */ - p->ready_list_last_pick = &p->ready_list; + p->ready_list_last_pick = p->ready_list_last_pick->prev; } /* removing last item */ @@ -307,7 +333,7 @@ static void start_picking(grpc_exec_ctx *exec_ctx, round_robin_lb_policy *p) { p->started_picking = 1; if (grpc_lb_round_robin_trace) { - gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%d", p, + gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%" PRIuPTR, p, p->num_subchannels); } @@ -345,8 +371,8 @@ static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, *target = grpc_subchannel_get_connected_subchannel(selected->subchannel); if (grpc_lb_round_robin_trace) { gpr_log(GPR_DEBUG, - "[RR PICK] TARGET <-- CONNECTED SUBCHANNEL %p (NODE %p)", - selected->subchannel, selected); + "[RR PICK] TARGET <-- CONNECTED SUBCHANNEL %p (NODE %p)", *target, + selected); } /* only advance the last picked pointer if the selection was used */ advance_last_picked_locked(p); @@ -526,7 +552,7 @@ static void round_robin_factory_ref(grpc_lb_policy_factory *factory) {} static void round_robin_factory_unref(grpc_lb_policy_factory *factory) {} -static grpc_lb_policy *create_round_robin(grpc_exec_ctx *exec_ctx, +static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx, grpc_lb_policy_factory *factory, grpc_lb_policy_args *args) { GPR_ASSERT(args->addresses != NULL); @@ -582,7 +608,7 @@ static grpc_lb_policy *create_round_robin(grpc_exec_ctx *exec_ctx, } static const grpc_lb_policy_factory_vtable round_robin_factory_vtable = { - round_robin_factory_ref, round_robin_factory_unref, create_round_robin, + round_robin_factory_ref, round_robin_factory_unref, round_robin_create, "round_robin"}; static grpc_lb_policy_factory round_robin_lb_policy_factory = { diff --git a/src/core/ext/load_reporting/load_reporting.c b/src/core/ext/load_reporting/load_reporting.c index 60082dbaaae..9e4d32676fc 100644 --- a/src/core/ext/load_reporting/load_reporting.c +++ b/src/core/ext/load_reporting/load_reporting.c @@ -76,7 +76,8 @@ static bool is_load_reporting_enabled(const grpc_channel_args *a) { if (a == NULL) return false; for (size_t i = 0; i < a->num_args; i++) { if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_LOAD_REPORTING)) { - return a->args[i].value.pointer.p != NULL; + return a->args[i].type == GRPC_ARG_POINTER && + a->args[i].value.pointer.p != NULL; } } return false; diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c index 620ba4e2aa0..5efc95e0fa6 100644 --- a/src/core/ext/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/resolver/dns/native/dns_resolver.c @@ -183,7 +183,8 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now); gpr_timespec timeout = gpr_time_sub(next_try, now); - gpr_log(GPR_DEBUG, "dns resolution failed: retrying in %d.%09d seconds", + gpr_log(GPR_DEBUG, + "dns resolution failed: retrying in %" PRId64 ".%09d seconds", timeout.tv_sec, timeout.tv_nsec); GPR_ASSERT(!r->have_retry_timer); r->have_retry_timer = true; diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c new file mode 100644 index 00000000000..ca435c25cec --- /dev/null +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c @@ -0,0 +1,95 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +#include + +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/tcp_posix.h" +#include "src/core/lib/surface/api_trace.h" +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/transport/transport.h" + +grpc_channel *grpc_insecure_channel_create_from_fd( + const char *target, int fd, const grpc_channel_args *args) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + GRPC_API_TRACE("grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3, + (target, fd, args)); + + grpc_arg default_authority_arg; + default_authority_arg.type = GRPC_ARG_STRING; + default_authority_arg.key = GRPC_ARG_DEFAULT_AUTHORITY; + default_authority_arg.value.string = "test.authority"; + grpc_channel_args *final_args = + grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); + + int flags = fcntl(fd, F_GETFL, 0); + GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); + + grpc_endpoint *client = + grpc_tcp_create(grpc_fd_create(fd, "client"), + GRPC_TCP_DEFAULT_READ_SLICE_SIZE, "fd-client"); + + grpc_transport *transport = + grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1); + GPR_ASSERT(transport); + grpc_channel *channel = grpc_channel_create( + &exec_ctx, target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_channel_args_destroy(final_args); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + + grpc_exec_ctx_finish(&exec_ctx); + + return channel != NULL ? channel : grpc_lame_client_channel_create( + target, GRPC_STATUS_INTERNAL, + "Failed to create client channel"); +} + +#else // !GPR_SUPPORT_CHANNELS_FROM_FD + +grpc_channel *grpc_insecure_channel_create_from_fd( + const char *target, int fd, const grpc_channel_args *args) { + GPR_ASSERT(0); + return NULL; +} + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c index 0428bb1e3dc..c95dd20d1d8 100644 --- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c @@ -111,13 +111,14 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) { } } if (count == 0) { - gpr_log(GPR_ERROR, "No address added out of total %d resolved", + gpr_log(GPR_ERROR, "No address added out of total %" PRIuPTR " resolved", resolved->naddrs); goto error; } if (count != resolved->naddrs) { - gpr_log(GPR_ERROR, "Only %d addresses added out of total %d resolved", - count, resolved->naddrs); + gpr_log(GPR_ERROR, + "Only %d addresses added out of total %" PRIuPTR " resolved", count, + resolved->naddrs); } grpc_resolved_addresses_destroy(resolved); diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c new file mode 100644 index 00000000000..96bf4d6f308 --- /dev/null +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c @@ -0,0 +1,82 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +#include +#include + +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/tcp_posix.h" +#include "src/core/lib/surface/completion_queue.h" +#include "src/core/lib/surface/server.h" + +void grpc_server_add_insecure_channel_from_fd(grpc_server *server, + grpc_completion_queue *cq, + int fd) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + + char *name; + gpr_asprintf(&name, "fd:%d", fd); + + grpc_endpoint *server_endpoint = grpc_tcp_create( + grpc_fd_create(fd, name), GRPC_TCP_DEFAULT_READ_SLICE_SIZE, name); + + gpr_free(name); + + const grpc_channel_args *server_args = grpc_server_get_channel_args(server); + grpc_transport *transport = grpc_create_chttp2_transport( + &exec_ctx, server_args, server_endpoint, 0 /* is_client */); + grpc_endpoint_add_to_pollset(&exec_ctx, server_endpoint, grpc_cq_pollset(cq)); + grpc_server_setup_transport(&exec_ctx, server, transport, NULL, server_args); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); +} + +#else // !GPR_SUPPORT_CHANNELS_FROM_FD + +void grpc_server_add_insecure_channel_from_fd(grpc_server *server, + grpc_completion_queue *cq, + int fd) { + GPR_ASSERT(0); +} + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c index ebbefbcd893..e3437e5ed3d 100644 --- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c @@ -229,13 +229,14 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, } } if (count == 0) { - gpr_log(GPR_ERROR, "No address added out of total %d resolved", + gpr_log(GPR_ERROR, "No address added out of total %" PRIuPTR " resolved", resolved->naddrs); goto error; } if (count != resolved->naddrs) { - gpr_log(GPR_ERROR, "Only %d addresses added out of total %d resolved", - count, resolved->naddrs); + gpr_log(GPR_ERROR, + "Only %d addresses added out of total %" PRIuPTR " resolved", count, + resolved->naddrs); /* if it's an error, don't we want to goto error; here ? */ } grpc_resolved_addresses_destroy(resolved); diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.c b/src/core/ext/transport/chttp2/transport/bin_decoder.c new file mode 100644 index 00000000000..2d90b01cd8b --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.c @@ -0,0 +1,232 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/ext/transport/chttp2/transport/bin_decoder.h" +#include +#include +#include "src/core/lib/support/string.h" + +static uint8_t decode_table[] = { + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 62, 0x40, 0x40, 0x40, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40}; + +static const uint8_t tail_xtra[4] = {0, 0, 1, 2}; + +static bool input_is_valid(uint8_t *input_ptr, size_t length) { + size_t i; + + for (i = 0; i < length; ++i) { + if ((decode_table[input_ptr[i]] & 0xC0) != 0) { + gpr_log(GPR_ERROR, + "Base64 decoding failed, invalid character '%c' in base64 " + "input.\n", + (char)(*input_ptr)); + return false; + } + } + return true; +} + +#define COMPOSE_OUTPUT_BYTE_0(input_ptr) \ + (uint8_t)((decode_table[input_ptr[0]] << 2) | \ + (decode_table[input_ptr[1]] >> 4)) + +#define COMPOSE_OUTPUT_BYTE_1(input_ptr) \ + (uint8_t)((decode_table[input_ptr[1]] << 4) | \ + (decode_table[input_ptr[2]] >> 2)) + +#define COMPOSE_OUTPUT_BYTE_2(input_ptr) \ + (uint8_t)((decode_table[input_ptr[2]] << 6) | decode_table[input_ptr[3]]) + +bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) { + size_t input_tail; + + if (ctx->input_cur > ctx->input_end || ctx->output_cur > ctx->output_end) { + return false; + } + + // Process a block of 4 input characters and 3 output bytes + while (ctx->input_end >= ctx->input_cur + 4 && + ctx->output_end >= ctx->output_cur + 3) { + if (!input_is_valid(ctx->input_cur, 4)) return false; + ctx->output_cur[0] = COMPOSE_OUTPUT_BYTE_0(ctx->input_cur); + ctx->output_cur[1] = COMPOSE_OUTPUT_BYTE_1(ctx->input_cur); + ctx->output_cur[2] = COMPOSE_OUTPUT_BYTE_2(ctx->input_cur); + ctx->output_cur += 3; + ctx->input_cur += 4; + } + + // Process the tail of input data + input_tail = (size_t)(ctx->input_end - ctx->input_cur); + if (input_tail == 4) { + // Process the input data with pad chars + if (ctx->input_cur[3] == '=') { + if (ctx->input_cur[2] == '=' && ctx->output_end >= ctx->output_cur + 1) { + if (!input_is_valid(ctx->input_cur, 2)) return false; + *(ctx->output_cur++) = COMPOSE_OUTPUT_BYTE_0(ctx->input_cur); + ctx->input_cur += 4; + } else if (ctx->output_end >= ctx->output_cur + 2) { + if (!input_is_valid(ctx->input_cur, 3)) return false; + *(ctx->output_cur++) = COMPOSE_OUTPUT_BYTE_0(ctx->input_cur); + *(ctx->output_cur++) = COMPOSE_OUTPUT_BYTE_1(ctx->input_cur); + ; + ctx->input_cur += 4; + } + } + + } else if (ctx->contains_tail && input_tail > 1) { + // Process the input data without pad chars, but constains_tail is set + if (ctx->output_end >= ctx->output_cur + tail_xtra[input_tail]) { + if (!input_is_valid(ctx->input_cur, input_tail)) return false; + switch (input_tail) { + case 3: + ctx->output_cur[1] = COMPOSE_OUTPUT_BYTE_1(ctx->input_cur); + case 2: + ctx->output_cur[0] = COMPOSE_OUTPUT_BYTE_0(ctx->input_cur); + } + ctx->output_cur += tail_xtra[input_tail]; + ctx->input_cur += input_tail; + } + } + + return true; +} + +gpr_slice grpc_chttp2_base64_decode(gpr_slice input) { + size_t input_length = GPR_SLICE_LENGTH(input); + size_t output_length = input_length / 4 * 3; + struct grpc_base64_decode_context ctx; + gpr_slice output; + + if (input_length % 4 != 0) { + gpr_log(GPR_ERROR, + "Base64 decoding failed, input of " + "grpc_chttp2_base64_decode has a length of %d, which is not a " + "multiple of 4.\n", + (int)input_length); + return gpr_empty_slice(); + } + + if (input_length > 0) { + uint8_t *input_end = GPR_SLICE_END_PTR(input); + if (*(--input_end) == '=') { + output_length--; + if (*(--input_end) == '=') { + output_length--; + } + } + } + output = gpr_slice_malloc(output_length); + + ctx.input_cur = GPR_SLICE_START_PTR(input); + ctx.input_end = GPR_SLICE_END_PTR(input); + ctx.output_cur = GPR_SLICE_START_PTR(output); + ctx.output_end = GPR_SLICE_END_PTR(output); + ctx.contains_tail = false; + + if (!grpc_base64_decode_partial(&ctx)) { + char *s = gpr_dump_slice(input, GPR_DUMP_ASCII); + gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s); + gpr_free(s); + gpr_slice_unref(output); + return gpr_empty_slice(); + } + GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output)); + GPR_ASSERT(ctx.input_cur == GPR_SLICE_END_PTR(input)); + return output; +} + +gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, + size_t output_length) { + size_t input_length = GPR_SLICE_LENGTH(input); + gpr_slice output = gpr_slice_malloc(output_length); + struct grpc_base64_decode_context ctx; + + // The length of a base64 string cannot be 4 * n + 1 + if (input_length % 4 == 1) { + gpr_log(GPR_ERROR, + "Base64 decoding failed, input of " + "grpc_chttp2_base64_decode_with_length has a length of %d, which " + "has a tail of 1 byte.\n", + (int)input_length); + gpr_slice_unref(output); + return gpr_empty_slice(); + } + + if (output_length > input_length / 4 * 3 + tail_xtra[input_length % 4]) { + gpr_log(GPR_ERROR, + "Base64 decoding failed, output_length %d is longer " + "than the max possible output length %d.\n", + (int)output_length, + (int)(input_length / 4 * 3 + tail_xtra[input_length % 4])); + gpr_slice_unref(output); + return gpr_empty_slice(); + } + + ctx.input_cur = GPR_SLICE_START_PTR(input); + ctx.input_end = GPR_SLICE_END_PTR(input); + ctx.output_cur = GPR_SLICE_START_PTR(output); + ctx.output_end = GPR_SLICE_END_PTR(output); + ctx.contains_tail = true; + + if (!grpc_base64_decode_partial(&ctx)) { + char *s = gpr_dump_slice(input, GPR_DUMP_ASCII); + gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s); + gpr_free(s); + gpr_slice_unref(output); + return gpr_empty_slice(); + } + GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output)); + GPR_ASSERT(ctx.input_cur <= GPR_SLICE_END_PTR(input)); + return output; +} diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h new file mode 100644 index 00000000000..b9d40c9b74b --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -0,0 +1,66 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H + +#include +#include + +struct grpc_base64_decode_context { + /* input/output: */ + uint8_t *input_cur; + uint8_t *input_end; + uint8_t *output_cur; + uint8_t *output_end; + /* Indicate if the decoder should handle the tail of input data*/ + bool contains_tail; +}; + +/* base64 decode a grpc_base64_decode_context util either input_end is reached + or output_end is reached. When input_end is reached, (input_end - input_cur) + is less than 4. When output_end is reached, (output_end - output_cur) is less + than 3. Returns false if decoding is failed. */ +bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx); + +/* base64 decode a slice with pad chars. Returns a new slice, does not take + ownership of the input. Returns an empty slice if decoding is failed. */ +gpr_slice grpc_chttp2_base64_decode(gpr_slice input); + +/* base64 decode a slice without pad chars, data length is needed. Returns a new + slice, does not take ownership of the input. Returns an empty slice if + decoding is failed. */ +gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, + size_t output_length); + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 046b3950012..6e8640f1b32 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -47,6 +47,7 @@ #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/status_conversion.h" #include "src/core/ext/transport/chttp2/transport/timeout_encoding.h" +#include "src/core/lib/http/parser.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/support/string.h" #include "src/core/lib/transport/static_metadata.h" @@ -107,7 +108,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, static void cancel_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global, - grpc_status_code status); + grpc_status_code status, + gpr_slice *optional_message); static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, @@ -161,6 +163,8 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx, GPR_ASSERT(t->ep == NULL); + gpr_slice_unref(t->optional_drop_message); + gpr_slice_buffer_destroy(&t->global.qbuf); gpr_slice_buffer_destroy(&t->writing.outbuf); @@ -260,6 +264,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->parsing.deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; t->writing.is_client = is_client; + t->optional_drop_message = gpr_empty_slice(); grpc_connectivity_state_init( &t->channel_callback.state_tracker, GRPC_CHANNEL_READY, is_client ? "client_transport" : "server_transport"); @@ -804,8 +809,10 @@ void grpc_chttp2_add_incoming_goaway( gpr_free(msg); gpr_slice_unref(goaway_text); transport_global->seen_goaway = 1; - connectivity_state_set(exec_ctx, transport_global, GRPC_CHANNEL_SHUTDOWN, - "got_goaway"); + /* lie: use transient failure from the transport to indicate goaway has been + * received */ + connectivity_state_set(exec_ctx, transport_global, + GRPC_CHANNEL_TRANSIENT_FAILURE, "got_goaway"); } static void maybe_start_some_streams( @@ -859,7 +866,7 @@ static void maybe_start_some_streams( grpc_chttp2_list_pop_waiting_for_concurrency(transport_global, &stream_global)) { cancel_from_api(exec_ctx, transport_global, stream_global, - GRPC_STATUS_UNAVAILABLE); + GRPC_STATUS_UNAVAILABLE, NULL); } } @@ -936,7 +943,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, if (op->cancel_with_status != GRPC_STATUS_OK) { cancel_from_api(exec_ctx, transport_global, stream_global, - op->cancel_with_status); + op->cancel_with_status, op->optional_close_message); } if (op->close_with_status != GRPC_STATUS_OK) { @@ -957,10 +964,10 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, if (metadata_size > metadata_peer_limit) { gpr_log(GPR_DEBUG, "to-be-sent initial metadata size exceeds peer limit " - "(%lu vs. %lu)", + "(%" PRIuPTR " vs. %" PRIuPTR ")", metadata_size, metadata_peer_limit); cancel_from_api(exec_ctx, transport_global, stream_global, - GRPC_STATUS_RESOURCE_EXHAUSTED); + GRPC_STATUS_RESOURCE_EXHAUSTED, NULL); } else { if (contains_non_ok_status(transport_global, op->send_initial_metadata)) { stream_global->seen_error = true; @@ -1012,10 +1019,10 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, if (metadata_size > metadata_peer_limit) { gpr_log(GPR_DEBUG, "to-be-sent trailing metadata size exceeds peer limit " - "(%lu vs. %lu)", + "(%" PRIuPTR " vs. %" PRIuPTR ")", metadata_size, metadata_peer_limit); cancel_from_api(exec_ctx, transport_global, stream_global, - GRPC_STATUS_RESOURCE_EXHAUSTED); + GRPC_STATUS_RESOURCE_EXHAUSTED, NULL); } else { if (contains_non_ok_status(transport_global, op->send_trailing_metadata)) { @@ -1201,7 +1208,7 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx, } if (stream_global->exceeded_metadata_size) { cancel_from_api(exec_ctx, transport_global, stream_global, - GRPC_STATUS_RESOURCE_EXHAUSTED); + GRPC_STATUS_RESOURCE_EXHAUSTED, NULL); } } grpc_chttp2_incoming_metadata_buffer_publish( @@ -1240,7 +1247,7 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx, } if (stream_global->exceeded_metadata_size) { cancel_from_api(exec_ctx, transport_global, stream_global, - GRPC_STATUS_RESOURCE_EXHAUSTED); + GRPC_STATUS_RESOURCE_EXHAUSTED, NULL); } } if (stream_global->all_incoming_byte_streams_finished) { @@ -1303,7 +1310,8 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, static void cancel_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global, - grpc_status_code status) { + grpc_status_code status, + gpr_slice *optional_message) { if (!stream_global->read_closed || !stream_global->write_closed) { if (stream_global->id != 0) { gpr_slice_buffer_add( @@ -1313,8 +1321,12 @@ static void cancel_from_api(grpc_exec_ctx *exec_ctx, (uint32_t)grpc_chttp2_grpc_status_to_http2_error(status), &stream_global->stats.outgoing)); } + + if (optional_message) { + gpr_slice_ref(*optional_message); + } grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global, status, - NULL); + optional_message); } if (status != GRPC_STATUS_OK && !stream_global->seen_error) { stream_global->seen_error = true; @@ -1524,8 +1536,12 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, static void cancel_stream_cb(grpc_chttp2_transport_global *transport_global, void *user_data, grpc_chttp2_stream_global *stream_global) { + grpc_chttp2_transport *transport = TRANSPORT_FROM_GLOBAL(transport_global); cancel_from_api(user_data, transport_global, stream_global, - GRPC_STATUS_UNAVAILABLE); + GRPC_STATUS_UNAVAILABLE, + GPR_SLICE_IS_EMPTY(transport->optional_drop_message) + ? NULL + : &transport->optional_drop_message); } static void end_all_the_calls(grpc_exec_ctx *exec_ctx, @@ -1601,6 +1617,29 @@ static void reading_action_locked(grpc_exec_ctx *exec_ctx, } } +static bool try_http_parsing(grpc_exec_ctx *exec_ctx, + grpc_chttp2_transport *t) { + grpc_http_parser parser; + size_t i = 0; + bool success = false; + + grpc_http_parser_init(&parser); + + for (; i < t->read_buffer.count && + grpc_http_parser_parse(&parser, t->read_buffer.slices[i]); + i++) + ; + if (grpc_http_parser_eof(&parser) && parser.type == GRPC_HTTP_RESPONSE) { + success = true; + GRPC_CHTTP2_IF_TRACING(gpr_log( + GPR_DEBUG, "Trying to connect an http1.x server, received status:%d", + parser.http.response.status)); + } + + grpc_http_parser_destroy(&parser); + return success; +} + static void parsing_action(grpc_exec_ctx *exec_ctx, void *arg, bool success) { grpc_chttp2_transport *t = arg; GPR_TIMER_BEGIN("reading_action.parse", 0); @@ -1612,6 +1651,14 @@ static void parsing_action(grpc_exec_ctx *exec_ctx, void *arg, bool success) { ; if (i != t->read_buffer.count) { success = false; + gpr_slice_unref(t->optional_drop_message); + if (try_http_parsing(exec_ctx, t)) { + t->optional_drop_message = gpr_slice_from_copied_string( + "Connection dropped: received http1.x response"); + } else { + t->optional_drop_message = gpr_slice_from_copied_string( + "Connection dropped: received unparseable response"); + } } GPR_TIMER_END("reading_action.parse", 0); grpc_chttp2_run_with_global_lock(exec_ctx, t, NULL, post_parse_locked, @@ -1972,10 +2019,13 @@ static char *format_flowctl_context_var(const char *context, const char *var, int64_t val, uint32_t id, char **scope) { char *underscore_pos; + char *buf; char *result; if (context == NULL) { *scope = NULL; - gpr_asprintf(&result, "%s(%lld)", var, val); + gpr_asprintf(&buf, "%s(%" PRId64 ")", var, val); + result = gpr_leftpad(buf, ' ', 40); + gpr_free(buf); return result; } underscore_pos = strchr(context, '_'); @@ -1986,7 +2036,9 @@ static char *format_flowctl_context_var(const char *context, const char *var, gpr_asprintf(scope, "%s[%d]", tmp, id); gpr_free(tmp); } - gpr_asprintf(&result, "%s.%s(%lld)", underscore_pos + 1, var, val); + gpr_asprintf(&buf, "%s.%s(%" PRId64 ")", underscore_pos + 1, var, val); + result = gpr_leftpad(buf, ' ', 40); + gpr_free(buf); return result; } @@ -2007,6 +2059,8 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase, uint32_t stream_id, int64_t val1, int64_t val2) { char *scope1; char *scope2; + char *tmp_phase; + char *tmp_scope1; char *label1 = format_flowctl_context_var(context1, var1, val1, stream_id, &scope1); char *label2 = @@ -2014,14 +2068,18 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase, char *clisvr = is_client ? "client" : "server"; char *prefix; - gpr_asprintf(&prefix, "FLOW % 8s: %s % 11s ", phase, clisvr, scope1); + tmp_phase = gpr_leftpad(phase, ' ', 8); + tmp_scope1 = gpr_leftpad(scope1, ' ', 11); + gpr_asprintf(&prefix, "FLOW %s: %s %s ", phase, clisvr, scope1); + gpr_free(tmp_phase); + gpr_free(tmp_scope1); switch (op) { case GRPC_CHTTP2_FLOWCTL_MOVE: GPR_ASSERT(samestr(scope1, scope2)); if (val2 != 0) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "%sMOVE % 40s <- % 40s giving %d", prefix, label1, label2, + "%sMOVE %s <- %s giving %" PRId64, prefix, label1, label2, val1 + val2); } break; @@ -2029,7 +2087,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase, GPR_ASSERT(val2 >= 0); if (val2 != 0) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "%sCREDIT % 40s by % 40s giving %d", prefix, label1, label2, + "%sCREDIT %s by %s giving %" PRId64, prefix, label1, label2, val1 + val2); } break; @@ -2037,7 +2095,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase, GPR_ASSERT(val2 >= 0); if (val2 != 0) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "%sDEBIT % 40s by % 40s giving %d", prefix, label1, label2, + "%sDEBIT %s by %s giving %" PRId64, prefix, label1, label2, val1 - val2); } break; diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 5872fd8e0a4..7f3339a6204 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -383,6 +383,9 @@ struct grpc_chttp2_transport { /** Transport op to be applied post-parsing */ grpc_transport_op *post_parsing_op; + + /** Message explaining the reason of dropping connection */ + gpr_slice optional_drop_message; }; typedef struct { diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 4bd374b7fa7..3c74258352e 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -534,14 +534,14 @@ static grpc_chttp2_parse_error update_incoming_window( grpc_chttp2_stream_parsing *stream_parsing) { uint32_t incoming_frame_size = transport_parsing->incoming_frame_size; if (incoming_frame_size > transport_parsing->incoming_window) { - gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %d", + gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %" PRId64, transport_parsing->incoming_frame_size, transport_parsing->incoming_window); return GRPC_CHTTP2_CONNECTION_ERROR; } if (incoming_frame_size > stream_parsing->incoming_window) { - gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %d", + gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %" PRId64, transport_parsing->incoming_frame_size, stream_parsing->incoming_window); return GRPC_CHTTP2_CONNECTION_ERROR; @@ -649,7 +649,8 @@ static void on_initial_header(void *tp, grpc_mdelem *md) { if (new_size > metadata_size_limit) { if (!stream_parsing->exceeded_metadata_size) { gpr_log(GPR_DEBUG, - "received initial metadata size exceeds limit (%lu vs. %lu)", + "received initial metadata size exceeds limit (%" PRIuPTR + " vs. %" PRIuPTR ")", new_size, metadata_size_limit); stream_parsing->seen_error = true; stream_parsing->exceeded_metadata_size = true; @@ -695,7 +696,8 @@ static void on_trailing_header(void *tp, grpc_mdelem *md) { if (new_size > metadata_size_limit) { if (!stream_parsing->exceeded_metadata_size) { gpr_log(GPR_DEBUG, - "received trailing metadata size exceeds limit (%lu vs. %lu)", + "received trailing metadata size exceeds limit (%" PRIuPTR + " vs. %" PRIuPTR ")", new_size, metadata_size_limit); stream_parsing->seen_error = true; stream_parsing->exceeded_metadata_size = true; diff --git a/src/core/lib/channel/channel_args.c b/src/core/lib/channel/channel_args.c index 569be4dc282..d53ce904a99 100644 --- a/src/core/lib/channel/channel_args.c +++ b/src/core/lib/channel/channel_args.c @@ -35,6 +35,7 @@ #include #include "src/core/lib/support/string.h" +#include #include #include #include @@ -181,6 +182,7 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( grpc_channel_args *grpc_channel_args_set_compression_algorithm( grpc_channel_args *a, grpc_compression_algorithm algorithm) { + GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT); grpc_arg tmp; tmp.type = GRPC_ARG_INTEGER; tmp.key = GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM; @@ -200,7 +202,8 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args *a, !strcmp(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET, a->args[i].key)) { *states_arg = &a->args[i].value.integer; - return 1; /* GPR_TRUE */ + **states_arg |= 0x1; /* forcefully enable support for no compression */ + return 1; } } } @@ -214,10 +217,18 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state( const int states_arg_found = find_compression_algorithm_states_bitset(*a, &states_arg); - if (states_arg_found) { + if (grpc_channel_args_get_compression_algorithm(*a) == algorithm && + state == 0) { + char *algo_name = NULL; + GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0); + gpr_log(GPR_ERROR, + "Tried to disable default compression algorithm '%s'. The " + "operation has been ignored.", + algo_name); + } else if (states_arg_found) { if (state != 0) { GPR_BITSET((unsigned *)states_arg, algorithm); - } else { + } else if (algorithm != GRPC_COMPRESS_NONE) { GPR_BITCLEAR((unsigned *)states_arg, algorithm); } } else { @@ -229,7 +240,7 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state( tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; if (state != 0) { GPR_BITSET((unsigned *)&tmp.value.integer, algorithm); - } else { + } else if (algorithm != GRPC_COMPRESS_NONE) { GPR_BITCLEAR((unsigned *)&tmp.value.integer, algorithm); } result = grpc_channel_args_copy_and_add(*a, &tmp, 1); @@ -239,11 +250,11 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state( return result; } -int grpc_channel_args_compression_algorithm_get_states( +uint32_t grpc_channel_args_compression_algorithm_get_states( const grpc_channel_args *a) { int *states_arg; if (find_compression_algorithm_states_bitset(a, &states_arg)) { - return *states_arg; + return (uint32_t)*states_arg; } else { return (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; /* All algs. enabled */ } diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 23c7b7b897b..653d04f4279 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -81,7 +81,7 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state( * * The i-th bit of the returned bitset corresponds to the i-th entry in the * grpc_compression_algorithm enum. */ -int grpc_channel_args_compression_algorithm_get_states( +uint32_t grpc_channel_args_compression_algorithm_get_states( const grpc_channel_args *a); int grpc_channel_args_compare(const grpc_channel_args *a, diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.c index 5c161652acb..bbba85d80ba 100644 --- a/src/core/lib/channel/channel_stack.c +++ b/src/core/lib/channel/channel_stack.c @@ -106,6 +106,7 @@ void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx, int initial_refs, const grpc_channel_filter **filters, size_t filter_count, const grpc_channel_args *channel_args, + grpc_transport *optional_transport, const char *name, grpc_channel_stack *stack) { size_t call_size = ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) + @@ -127,6 +128,7 @@ void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx, int initial_refs, for (i = 0; i < filter_count; i++) { args.channel_stack = stack; args.channel_args = channel_args; + args.optional_transport = optional_transport; args.is_first = i == 0; args.is_last = i == (filter_count - 1); elems[i].filter = filters[i]; diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index 3ca643c893b..41dd4a0d8a1 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -60,6 +60,8 @@ typedef struct grpc_call_stack grpc_call_stack; typedef struct { grpc_channel_stack *channel_stack; const grpc_channel_args *channel_args; + /** Transport, iff it is known */ + grpc_transport *optional_transport; int is_first; int is_last; } grpc_channel_element_args; @@ -198,6 +200,7 @@ void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx, int initial_refs, grpc_iomgr_cb_func destroy, void *destroy_arg, const grpc_channel_filter **filters, size_t filter_count, const grpc_channel_args *args, + grpc_transport *optional_transport, const char *name, grpc_channel_stack *stack); /* Destroy a channel stack */ void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx, diff --git a/src/core/lib/channel/channel_stack_builder.c b/src/core/lib/channel/channel_stack_builder.c index a8646c95657..eda4968f486 100644 --- a/src/core/lib/channel/channel_stack_builder.c +++ b/src/core/lib/channel/channel_stack_builder.c @@ -257,8 +257,8 @@ void *grpc_channel_stack_builder_finish(grpc_exec_ctx *exec_ctx, // and initialize it grpc_channel_stack_init(exec_ctx, initial_refs, destroy, destroy_arg == NULL ? result : destroy_arg, filters, - num_filters, builder->args, builder->name, - channel_stack); + num_filters, builder->args, builder->transport, + builder->name, channel_stack); // run post-initialization functions i = 0; diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c index 7c8c1d6f31a..32f4f8d37e5 100644 --- a/src/core/lib/channel/compress_filter.c +++ b/src/core/lib/channel/compress_filter.c @@ -73,8 +73,8 @@ typedef struct call_data { typedef struct channel_data { /** The default, channel-level, compression algorithm */ grpc_compression_algorithm default_compression_algorithm; - /** Compression options for the channel */ - grpc_compression_options compression_options; + /** Bitset of enabled algorithms */ + uint32_t enabled_algorithms_bitset; /** Supported compression algorithms */ uint32_t supported_compression_algorithms; } channel_data; @@ -96,9 +96,8 @@ static grpc_mdelem *compression_md_filter(void *user_data, grpc_mdelem *md) { md_c_str); calld->compression_algorithm = GRPC_COMPRESS_NONE; } - if (grpc_compression_options_is_algorithm_enabled( - &channeld->compression_options, calld->compression_algorithm) == - 0) { + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + calld->compression_algorithm)) { gpr_log(GPR_ERROR, "Invalid compression algorithm: '%s' (previously disabled). " "Ignoring.", @@ -178,8 +177,8 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx, const float savings_ratio = 1.0f - (float)after_size / (float)before_size; GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, &algo_name)); - gpr_log(GPR_DEBUG, - "Compressed[%s] %d bytes vs. %d bytes (%.2f%% savings)", + gpr_log(GPR_DEBUG, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR + " bytes (%.2f%% savings)", algo_name, before_size, after_size, 100 * savings_ratio); } gpr_slice_buffer_swap(&calld->slices, &tmp); @@ -189,10 +188,10 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx, char *algo_name; GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, &algo_name)); - gpr_log( - GPR_DEBUG, - "Algorithm '%s' enabled but decided not to compress. Input size: %d", - algo_name, calld->slices.length); + gpr_log(GPR_DEBUG, + "Algorithm '%s' enabled but decided not to compress. Input size: " + "%" PRIuPTR, + algo_name, calld->slices.length); } } @@ -282,32 +281,26 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_channel_element_args *args) { channel_data *channeld = elem->channel_data; - grpc_compression_algorithm algo_idx; - grpc_compression_options_init(&channeld->compression_options); - channeld->compression_options.enabled_algorithms_bitset = - (uint32_t)grpc_channel_args_compression_algorithm_get_states( - args->channel_args); + channeld->enabled_algorithms_bitset = + grpc_channel_args_compression_algorithm_get_states(args->channel_args); channeld->default_compression_algorithm = grpc_channel_args_get_compression_algorithm(args->channel_args); /* Make sure the default isn't disabled. */ - if (!grpc_compression_options_is_algorithm_enabled( - &channeld->compression_options, - channeld->default_compression_algorithm)) { + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + channeld->default_compression_algorithm)) { gpr_log(GPR_DEBUG, "compression algorithm %d not enabled: switching to none", channeld->default_compression_algorithm); channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; } - channeld->compression_options.default_compression_algorithm = - channeld->default_compression_algorithm; - channeld->supported_compression_algorithms = 0; - for (algo_idx = 0; algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { + channeld->supported_compression_algorithms = 1; /* always support identity */ + for (grpc_compression_algorithm algo_idx = 1; + algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { /* skip disabled algorithms */ - if (grpc_compression_options_is_algorithm_enabled( - &channeld->compression_options, algo_idx) == 0) { + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, algo_idx)) { continue; } channeld->supported_compression_algorithms |= 1u << algo_idx; diff --git a/src/core/lib/channel/compress_filter.h b/src/core/lib/channel/compress_filter.h index 0ce5d08837d..e4a2a829d59 100644 --- a/src/core/lib/channel/compress_filter.h +++ b/src/core/lib/channel/compress_filter.h @@ -34,9 +34,9 @@ #ifndef GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H #define GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H -#include "src/core/lib/channel/channel_stack.h" +#include -#define GRPC_COMPRESS_REQUEST_ALGORITHM_KEY "grpc-internal-encoding-request" +#include "src/core/lib/channel/channel_stack.h" extern int grpc_compression_trace; @@ -48,7 +48,7 @@ extern int grpc_compression_trace; * - Channel configuration, as established at channel creation time. * - The metadata accompanying the outgoing data to be compressed. This is * taken as a request only. We may choose not to honor it. The metadata key - * is given by \a GRPC_COMPRESS_REQUEST_ALGORITHM_KEY. + * is given by \a GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY. * * Compression can be disabled for concrete messages (for instance in order to * prevent CRIME/BEAST type attacks) by having the GRPC_WRITE_NO_COMPRESS set in diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 7cb66797ebc..792f0d8ae68 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -38,6 +38,10 @@ #include "src/core/lib/profiling/timers.h" #include "src/core/lib/support/string.h" #include "src/core/lib/transport/static_metadata.h" +#include "src/core/lib/transport/transport_impl.h" + +#define EXPECTED_CONTENT_TYPE "application/grpc" +#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1 typedef struct call_data { grpc_linked_mdelem method; @@ -74,7 +78,24 @@ static grpc_mdelem *client_recv_filter(void *user_data, grpc_mdelem *md) { } else if (md->key == GRPC_MDSTR_STATUS) { grpc_call_element_send_cancel(a->exec_ctx, a->elem); return NULL; + } else if (md == GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC) { + return NULL; } else if (md->key == GRPC_MDSTR_CONTENT_TYPE) { + const char *value_str = grpc_mdstr_as_c_string(md->value); + if (strncmp(value_str, EXPECTED_CONTENT_TYPE, + EXPECTED_CONTENT_TYPE_LENGTH) == 0 && + (value_str[EXPECTED_CONTENT_TYPE_LENGTH] == '+' || + value_str[EXPECTED_CONTENT_TYPE_LENGTH] == ';')) { + /* Although the C implementation doesn't (currently) generate them, + any custom +-suffix is explicitly valid. */ + /* TODO(klempner): We should consider preallocating common values such + as +proto or +json, or at least stashing them if we see them. */ + /* TODO(klempner): Should we be surfacing this to application code? */ + } else { + /* TODO(klempner): We're currently allowing this, but we shouldn't + see it without a proxy so log for now. */ + gpr_log(GPR_INFO, "Unexpected content-type '%s'", value_str); + } return NULL; } return md; @@ -179,7 +200,8 @@ static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) { return GRPC_MDELEM_SCHEME_HTTP; } -static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args) { +static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args, + const char *transport_name) { gpr_strvec v; size_t i; int is_first = 1; @@ -201,8 +223,8 @@ static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args) { } } - gpr_asprintf(&tmp, "%sgrpc-c/%s (%s)", is_first ? "" : " ", - grpc_version_string(), GPR_PLATFORM_STRING); + gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s)", is_first ? "" : " ", + grpc_version_string(), GPR_PLATFORM_STRING, transport_name); is_first = 0; gpr_strvec_add(&v, tmp); @@ -233,9 +255,12 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, grpc_channel_element_args *args) { channel_data *chand = elem->channel_data; GPR_ASSERT(!args->is_last); + GPR_ASSERT(args->optional_transport != NULL); chand->static_scheme = scheme_from_args(args->channel_args); chand->user_agent = grpc_mdelem_from_metadata_strings( - GRPC_MDSTR_USER_AGENT, user_agent_from_args(args->channel_args)); + GRPC_MDSTR_USER_AGENT, + user_agent_from_args(args->channel_args, + args->optional_transport->vtable->name)); } /* Destructor for channel data */ diff --git a/src/core/lib/channel/http_client_filter.h b/src/core/lib/channel/http_client_filter.h index a884b36318a..47081175ea9 100644 --- a/src/core/lib/channel/http_client_filter.h +++ b/src/core/lib/channel/http_client_filter.h @@ -1,5 +1,4 @@ /* - * * Copyright 2015, Google Inc. * All rights reserved. * @@ -39,6 +38,7 @@ /* Processes metadata on the client side for HTTP2 transports */ extern const grpc_channel_filter grpc_http_client_filter; +/* Channel arg to override the http2 :scheme header */ #define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" #endif /* GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H */ diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index aa8e377571b..922f771cf1d 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -108,7 +108,7 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { } else { /* TODO(klempner): We're currently allowing this, but we shouldn't see it without a proxy so log for now. */ - gpr_log(GPR_INFO, "Unexpected content-type %s", value_str); + gpr_log(GPR_INFO, "Unexpected content-type '%s'", value_str); } return NULL; } else if (md->key == GRPC_MDSTR_TE || md->key == GRPC_MDSTR_METHOD || diff --git a/src/core/lib/compression/compression_algorithm.c b/src/core/lib/compression/compression.c similarity index 98% rename from src/core/lib/compression/compression_algorithm.c rename to src/core/lib/compression/compression.c index 820871d579b..54efb5e855c 100644 --- a/src/core/lib/compression/compression_algorithm.c +++ b/src/core/lib/compression/compression.c @@ -125,6 +125,28 @@ grpc_mdelem *grpc_compression_encoding_mdelem( return NULL; } +void grpc_compression_options_init(grpc_compression_options *opts) { + memset(opts, 0, sizeof(*opts)); + /* all enabled by default */ + opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; +} + +void grpc_compression_options_enable_algorithm( + grpc_compression_options *opts, grpc_compression_algorithm algorithm) { + GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm); +} + +void grpc_compression_options_disable_algorithm( + grpc_compression_options *opts, grpc_compression_algorithm algorithm) { + GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm); +} + +int grpc_compression_options_is_algorithm_enabled( + const grpc_compression_options *opts, + grpc_compression_algorithm algorithm) { + return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm); +} + /* TODO(dgq): Add the ability to specify parameters to the individual * compression algorithms */ grpc_compression_algorithm grpc_compression_algorithm_for_level( @@ -180,25 +202,3 @@ grpc_compression_algorithm grpc_compression_algorithm_for_level( abort(); }; } - -void grpc_compression_options_init(grpc_compression_options *opts) { - opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; - opts->default_compression_algorithm = GRPC_COMPRESS_NONE; -} - -void grpc_compression_options_enable_algorithm( - grpc_compression_options *opts, grpc_compression_algorithm algorithm) { - GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm); -} - -void grpc_compression_options_disable_algorithm( - grpc_compression_options *opts, grpc_compression_algorithm algorithm) { - GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm); -} - -int grpc_compression_options_is_algorithm_enabled( - const grpc_compression_options *opts, - grpc_compression_algorithm algorithm) { - if (algorithm >= GRPC_COMPRESS_ALGORITHMS_COUNT) return 0; - return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm); -} diff --git a/src/core/lib/iomgr/iomgr.c b/src/core/lib/iomgr/iomgr.c index 60cef8ba777..89292a153ed 100644 --- a/src/core/lib/iomgr/iomgr.c +++ b/src/core/lib/iomgr/iomgr.c @@ -96,7 +96,8 @@ void grpc_iomgr_shutdown(void) { gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time), gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) { if (g_root_object.next != &g_root_object) { - gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed", + gpr_log(GPR_DEBUG, + "Waiting for %" PRIuPTR " iomgr objects to be destroyed", count_objects()); } last_warning_time = gpr_now(GPR_CLOCK_REALTIME); @@ -114,9 +115,9 @@ void grpc_iomgr_shutdown(void) { if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) { if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) { if (g_root_object.next != &g_root_object) { - gpr_log(GPR_DEBUG, - "Failed to free %d iomgr objects before shutdown deadline: " - "memory leaks are likely", + gpr_log(GPR_DEBUG, "Failed to free %" PRIuPTR + " iomgr objects before shutdown deadline: " + "memory leaks are likely", count_objects()); dump_objects("LEAKED"); if (grpc_iomgr_abort_on_leaks()) { diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.c index fa83ceef301..2147c86d4d1 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.c +++ b/src/core/lib/iomgr/socket_utils_common_posix.c @@ -111,6 +111,16 @@ int grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) { #endif } +int grpc_set_socket_sndbuf(int fd, int buffer_size_bytes) { + return 0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buffer_size_bytes, + sizeof(buffer_size_bytes)); +} + +int grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) { + return 0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buffer_size_bytes, + sizeof(buffer_size_bytes)); +} + /* set a socket to close on exec */ int grpc_set_socket_cloexec(int fd, int close_on_exec) { int oldflags = fcntl(fd, F_GETFD, 0); diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h index a8f6e5e6586..7e41d1c8700 100644 --- a/src/core/lib/iomgr/socket_utils_posix.h +++ b/src/core/lib/iomgr/socket_utils_posix.h @@ -78,6 +78,14 @@ int grpc_set_socket_ip_pktinfo_if_possible(int fd); If IPV6_RECVPKTINFO is not available, returns 1. */ int grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd); +/* Tries to set the socket's send buffer to given size. + Returns 1 on success, 0 on failure. */ +int grpc_set_socket_sndbuf(int fd, int buffer_size_bytes); + +/* Tries to set the socket's receive buffer to given size. + Returns 1 on success, 0 on failure. */ +int grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes); + /* An enum to keep track of IPv4/IPv6 socket modes. Currently, this information is only used when a socket is first created, but diff --git a/src/core/lib/iomgr/timer.c b/src/core/lib/iomgr/timer.c index 05a2fc104fc..69d3babfdb4 100644 --- a/src/core/lib/iomgr/timer.c +++ b/src/core/lib/iomgr/timer.c @@ -278,9 +278,8 @@ static int refill_queue(shard_type *shard, gpr_timespec now) { return !grpc_timer_heap_is_empty(&shard->heap); } -/* This pollent the next non-cancelled timer with deadline <= now from the - queue, - or returns NULL if there isn't one. +/* This pops the next non-cancelled timer with deadline <= now from the + queue, or returns NULL if there isn't one. REQUIRES: shard->mu locked */ static grpc_timer *pop_one(shard_type *shard, gpr_timespec now) { grpc_timer *timer; diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c index 98ffccd59b7..16150687d3d 100644 --- a/src/core/lib/iomgr/udp_server.c +++ b/src/core/lib/iomgr/udp_server.c @@ -210,6 +210,8 @@ static int prepare_socket(int fd, const struct sockaddr *addr, size_t addr_len) { struct sockaddr_storage sockname_temp; socklen_t sockname_len; + /* Set send/receive socket buffers to 1 MB */ + int buffer_size_bytes = 1024 * 1024; if (fd < 0) { goto error; @@ -239,6 +241,18 @@ static int prepare_socket(int fd, const struct sockaddr *addr, goto error; } + if (!grpc_set_socket_sndbuf(fd, buffer_size_bytes)) { + gpr_log(GPR_ERROR, "Failed to set send buffer size to %d bytes", + buf_size_bytes); + goto error; + } + + if (!grpc_set_socket_rcvbuf(fd, buffer_size_bytes)) { + gpr_log(GPR_ERROR, "Failed to set receive buffer size to %d bytes", + buf_size_bytes); + goto error; + } + return grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp); error: diff --git a/src/core/lib/support/log_linux.c b/src/core/lib/support/log_linux.c index ca04c022e3f..508fae4eec3 100644 --- a/src/core/lib/support/log_linux.c +++ b/src/core/lib/support/log_linux.c @@ -95,9 +95,9 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]", + gpr_asprintf(&prefix, "%s%s.%09" PRId32 " %7ld %s:%d]", gpr_log_severity_string(args->severity), time_buffer, - (int)(now.tv_nsec), gettid(), display_file, args->line); + now.tv_nsec, gettid(), display_file, args->line); fprintf(stderr, "%-60s %s\n", prefix, args->message); gpr_free(prefix); diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index a2ab6c5f1fc..30c1e67647a 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -194,6 +194,16 @@ int int64_ttoa(int64_t value, char *string) { return i; } +char *gpr_leftpad(const char *str, char flag, size_t length) { + const size_t str_length = strlen(str); + const size_t out_length = str_length > length ? str_length : length; + char *out = gpr_malloc(out_length + 1); + memset(out, flag, out_length - str_length); + memcpy(out + out_length - str_length, str, str_length); + out[out_length] = 0; + return out; +} + char *gpr_strjoin(const char **strs, size_t nstrs, size_t *final_length) { return gpr_strjoin_sep(strs, nstrs, "", final_length); } diff --git a/src/core/lib/support/string.h b/src/core/lib/support/string.h index ea58610914e..2b6bb3eec61 100644 --- a/src/core/lib/support/string.h +++ b/src/core/lib/support/string.h @@ -83,6 +83,10 @@ int int64_ttoa(int64_t value, char *output); /* Reverse a run of bytes */ void gpr_reverse_bytes(char *str, int len); +/* Pad a string with flag characters. The given length specifies the minimum + field width. The input string is never truncated. */ +char *gpr_leftpad(const char *str, char flag, size_t length); + /* Join a set of strings, returning the resulting string. Total combined length (excluding null terminator) is returned in total_length if it is non-null. */ diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index e899bc8098b..c613f325dc1 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,9 @@ #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" +#include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" +#include "src/core/lib/transport/transport.h" /** The maximum number of concurrent batches possible. Based upon the maximum number of individually queueable ops in the batch @@ -154,8 +157,8 @@ struct grpc_call { /* Call stats: only valid after trailing metadata received */ grpc_call_stats stats; - /* Compression algorithm for the call */ - grpc_compression_algorithm compression_algorithm; + /* Compression algorithm for *incoming* data */ + grpc_compression_algorithm incoming_compression_algorithm; /* Supported encodings (compression algorithms), a bitset */ uint32_t encodings_accepted_by_peer; @@ -214,6 +217,9 @@ static void execute_op(grpc_exec_ctx *exec_ctx, grpc_call *call, static grpc_call_error cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c, grpc_status_code status, const char *description); +static grpc_call_error close_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c, + grpc_status_code status, + const char *description); static void destroy_call(grpc_exec_ctx *exec_ctx, void *call_stack, bool success); static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp, @@ -399,21 +405,27 @@ static void set_status_code(grpc_call *call, status_source source, /* TODO(ctiller): what to do about the flush that was previously here */ } -static void set_compression_algorithm(grpc_call *call, - grpc_compression_algorithm algo) { +static void set_incoming_compression_algorithm( + grpc_call *call, grpc_compression_algorithm algo) { GPR_ASSERT(algo < GRPC_COMPRESS_ALGORITHMS_COUNT); - call->compression_algorithm = algo; + call->incoming_compression_algorithm = algo; } grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm( grpc_call *call) { grpc_compression_algorithm algorithm; gpr_mu_lock(&call->mu); - algorithm = call->compression_algorithm; + algorithm = call->incoming_compression_algorithm; gpr_mu_unlock(&call->mu); return algorithm; } +static grpc_compression_algorithm compression_algorithm_for_level_locked( + grpc_call *call, grpc_compression_level level) { + return grpc_compression_algorithm_for_level(level, + call->encodings_accepted_by_peer); +} + uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) { uint32_t flags; gpr_mu_lock(&call->mu); @@ -539,15 +551,28 @@ static grpc_linked_mdelem *linked_from_md(grpc_metadata *md) { return (grpc_linked_mdelem *)&md->internal_data; } +static grpc_metadata *get_md_elem(grpc_metadata *metadata, + grpc_metadata *additional_metadata, int i, + int count) { + grpc_metadata *res = + i < count ? &metadata[i] : &additional_metadata[i - count]; + GPR_ASSERT(res); + return res; +} + static int prepare_application_metadata(grpc_call *call, int count, grpc_metadata *metadata, int is_trailing, - int prepend_extra_metadata) { + int prepend_extra_metadata, + grpc_metadata *additional_metadata, + int additional_metadata_count) { + int total_count = count + additional_metadata_count; int i; grpc_metadata_batch *batch = &call->metadata_batch[0 /* is_receiving */][is_trailing]; - for (i = 0; i < count; i++) { - grpc_metadata *md = &metadata[i]; + for (i = 0; i < total_count; i++) { + const grpc_metadata *md = + get_md_elem(metadata, additional_metadata, i, count); grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data; GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data)); l->md = grpc_mdelem_from_string_and_buffer( @@ -566,9 +591,10 @@ static int prepare_application_metadata(grpc_call *call, int count, break; } } - if (i != count) { + if (i != total_count) { for (int j = 0; j <= i; j++) { - grpc_metadata *md = &metadata[j]; + const grpc_metadata *md = + get_md_elem(metadata, additional_metadata, j, count); grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data; GRPC_MDELEM_UNREF(l->md); } @@ -589,24 +615,36 @@ static int prepare_application_metadata(grpc_call *call, int count, } } } - for (i = 1; i < count; i++) { - linked_from_md(&metadata[i])->prev = linked_from_md(&metadata[i - 1]); + for (i = 1; i < total_count; i++) { + grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count); + grpc_metadata *prev_md = + get_md_elem(metadata, additional_metadata, i - 1, count); + linked_from_md(md)->prev = linked_from_md(prev_md); } - for (i = 0; i < count - 1; i++) { - linked_from_md(&metadata[i])->next = linked_from_md(&metadata[i + 1]); + for (i = 0; i < total_count - 1; i++) { + grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count); + grpc_metadata *next_md = + get_md_elem(metadata, additional_metadata, i + 1, count); + linked_from_md(md)->next = linked_from_md(next_md); } - switch (prepend_extra_metadata * 2 + (count != 0)) { + + switch (prepend_extra_metadata * 2 + (total_count != 0)) { case 0: /* no prepend, no metadata => nothing to do */ batch->list.head = batch->list.tail = NULL; break; - case 1: + case 1: { /* metadata, but no prepend */ - batch->list.head = linked_from_md(&metadata[0]); - batch->list.tail = linked_from_md(&metadata[count - 1]); + grpc_metadata *first_md = + get_md_elem(metadata, additional_metadata, 0, count); + grpc_metadata *last_md = + get_md_elem(metadata, additional_metadata, total_count - 1, count); + batch->list.head = linked_from_md(first_md); + batch->list.tail = linked_from_md(last_md); batch->list.head->prev = NULL; batch->list.tail->next = NULL; break; + } case 2: /* prepend, but no md */ batch->list.head = &call->send_extra_metadata[0]; @@ -615,17 +653,22 @@ static int prepare_application_metadata(grpc_call *call, int count, batch->list.head->prev = NULL; batch->list.tail->next = NULL; break; - case 3: + case 3: { /* prepend AND md */ + grpc_metadata *first_md = + get_md_elem(metadata, additional_metadata, 0, count); + grpc_metadata *last_md = + get_md_elem(metadata, additional_metadata, total_count - 1, count); batch->list.head = &call->send_extra_metadata[0]; call->send_extra_metadata[call->send_extra_metadata_count - 1].next = - linked_from_md(&metadata[0]); - linked_from_md(&metadata[0])->prev = + linked_from_md(first_md); + linked_from_md(first_md)->prev = &call->send_extra_metadata[call->send_extra_metadata_count - 1]; - batch->list.tail = linked_from_md(&metadata[count - 1]); + batch->list.tail = linked_from_md(last_md); batch->list.head->prev = NULL; batch->list.tail->next = NULL; break; + } default: GPR_UNREACHABLE_CODE(return 0); } @@ -694,48 +737,102 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *c, return r; } -typedef struct cancel_closure { +typedef struct termination_closure { grpc_closure closure; grpc_call *call; grpc_status_code status; -} cancel_closure; + gpr_slice optional_message; + grpc_closure *op_closure; + enum { TC_CANCEL, TC_CLOSE } type; +} termination_closure; -static void done_cancel(grpc_exec_ctx *exec_ctx, void *ccp, bool success) { - cancel_closure *cc = ccp; - GRPC_CALL_INTERNAL_UNREF(exec_ctx, cc->call, "cancel"); - gpr_free(cc); +static void done_termination(grpc_exec_ctx *exec_ctx, void *tcp, bool success) { + termination_closure *tc = tcp; + if (tc->type == TC_CANCEL) { + GRPC_CALL_INTERNAL_UNREF(exec_ctx, tc->call, "cancel"); + } + if (tc->type == TC_CLOSE) { + GRPC_CALL_INTERNAL_UNREF(exec_ctx, tc->call, "close"); + } + gpr_slice_unref(tc->optional_message); + if (tc->op_closure != NULL) { + grpc_exec_ctx_enqueue(exec_ctx, tc->op_closure, true, NULL); + } + gpr_free(tc); } -static void send_cancel(grpc_exec_ctx *exec_ctx, void *ccp, bool success) { +static void send_cancel(grpc_exec_ctx *exec_ctx, void *tcp, bool success) { grpc_transport_stream_op op; - cancel_closure *cc = ccp; + termination_closure *tc = tcp; memset(&op, 0, sizeof(op)); - op.cancel_with_status = cc->status; + op.cancel_with_status = tc->status; /* reuse closure to catch completion */ - grpc_closure_init(&cc->closure, done_cancel, cc); - op.on_complete = &cc->closure; - execute_op(exec_ctx, cc->call, &op); + grpc_closure_init(&tc->closure, done_termination, tc); + op.on_complete = &tc->closure; + execute_op(exec_ctx, tc->call, &op); +} + +static void send_close(grpc_exec_ctx *exec_ctx, void *tcp, bool success) { + grpc_transport_stream_op op; + termination_closure *tc = tcp; + memset(&op, 0, sizeof(op)); + tc->optional_message = gpr_slice_ref(tc->optional_message); + grpc_transport_stream_op_add_close(&op, tc->status, &tc->optional_message); + /* reuse closure to catch completion */ + grpc_closure_init(&tc->closure, done_termination, tc); + tc->op_closure = op.on_complete; + op.on_complete = &tc->closure; + execute_op(exec_ctx, tc->call, &op); +} + +static grpc_call_error terminate_with_status(grpc_exec_ctx *exec_ctx, + termination_closure *tc) { + grpc_mdstr *details = NULL; + if (GPR_SLICE_LENGTH(tc->optional_message) > 0) { + tc->optional_message = gpr_slice_ref(tc->optional_message); + details = grpc_mdstr_from_slice(tc->optional_message); + } + + set_status_code(tc->call, STATUS_FROM_API_OVERRIDE, (uint32_t)tc->status); + set_status_details(tc->call, STATUS_FROM_API_OVERRIDE, details); + + if (tc->type == TC_CANCEL) { + grpc_closure_init(&tc->closure, send_cancel, tc); + GRPC_CALL_INTERNAL_REF(tc->call, "cancel"); + } else if (tc->type == TC_CLOSE) { + grpc_closure_init(&tc->closure, send_close, tc); + GRPC_CALL_INTERNAL_REF(tc->call, "close"); + } + grpc_exec_ctx_enqueue(exec_ctx, &tc->closure, true, NULL); + return GRPC_CALL_OK; } static grpc_call_error cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c, grpc_status_code status, const char *description) { - grpc_mdstr *details = - description ? grpc_mdstr_from_string(description) : NULL; - cancel_closure *cc = gpr_malloc(sizeof(*cc)); - + termination_closure *tc = gpr_malloc(sizeof(*tc)); + memset(tc, 0, sizeof(termination_closure)); + tc->type = TC_CANCEL; + tc->call = c; + tc->optional_message = gpr_slice_from_copied_string(description); GPR_ASSERT(status != GRPC_STATUS_OK); + tc->status = status; - set_status_code(c, STATUS_FROM_API_OVERRIDE, (uint32_t)status); - set_status_details(c, STATUS_FROM_API_OVERRIDE, details); + return terminate_with_status(exec_ctx, tc); +} - grpc_closure_init(&cc->closure, send_cancel, cc); - cc->call = c; - cc->status = status; - GRPC_CALL_INTERNAL_REF(c, "cancel"); - grpc_exec_ctx_enqueue(exec_ctx, &cc->closure, true, NULL); +static grpc_call_error close_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c, + grpc_status_code status, + const char *description) { + termination_closure *tc = gpr_malloc(sizeof(*tc)); + memset(tc, 0, sizeof(termination_closure)); + tc->type = TC_CLOSE; + tc->call = c; + tc->optional_message = gpr_slice_from_copied_string(description); + GPR_ASSERT(status != GRPC_STATUS_OK); + tc->status = status; - return GRPC_CALL_OK; + return terminate_with_status(exec_ctx, tc); } static void execute_op(grpc_exec_ctx *exec_ctx, grpc_call *call, @@ -876,9 +973,9 @@ static grpc_mdelem *recv_initial_filter(void *callp, grpc_mdelem *elem) { if (elem == NULL) { return NULL; } else if (elem->key == GRPC_MDSTR_GRPC_ENCODING) { - GPR_TIMER_BEGIN("compression_algorithm", 0); - set_compression_algorithm(call, decode_compression(elem)); - GPR_TIMER_END("compression_algorithm", 0); + GPR_TIMER_BEGIN("incoming_compression_algorithm", 0); + set_incoming_compression_algorithm(call, decode_compression(elem)); + GPR_TIMER_END("incoming_compression_algorithm", 0); return NULL; } else if (elem->key == GRPC_MDSTR_GRPC_ACCEPT_ENCODING) { GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0); @@ -1041,9 +1138,9 @@ static void process_data_after_md(grpc_exec_ctx *exec_ctx, batch_control *bctl, } else { call->test_only_last_message_flags = call->receiving_stream->flags; if ((call->receiving_stream->flags & GRPC_WRITE_INTERNAL_COMPRESS) && - (call->compression_algorithm > GRPC_COMPRESS_NONE)) { + (call->incoming_compression_algorithm > GRPC_COMPRESS_NONE)) { *call->receiving_buffer = grpc_raw_compressed_byte_buffer_create( - NULL, 0, call->compression_algorithm); + NULL, 0, call->incoming_compression_algorithm); } else { *call->receiving_buffer = grpc_raw_byte_buffer_create(NULL, 0); } @@ -1071,6 +1168,56 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp, } } +static void validate_filtered_metadata(grpc_exec_ctx *exec_ctx, + batch_control *bctl) { + grpc_call *call = bctl->call; + /* validate call->incoming_compression_algorithm */ + if (call->incoming_compression_algorithm != GRPC_COMPRESS_NONE) { + const grpc_compression_algorithm algo = + call->incoming_compression_algorithm; + char *error_msg = NULL; + const grpc_compression_options compression_options = + grpc_channel_compression_options(call->channel); + /* check if algorithm is known */ + if (algo >= GRPC_COMPRESS_ALGORITHMS_COUNT) { + gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.", + algo); + gpr_log(GPR_ERROR, "%s", error_msg); + close_with_status(exec_ctx, call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + } else if (grpc_compression_options_is_algorithm_enabled( + &compression_options, algo) == 0) { + /* check if algorithm is supported by current channel config */ + char *algo_name; + grpc_compression_algorithm_name(algo, &algo_name); + gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.", + algo_name); + gpr_log(GPR_ERROR, "%s", error_msg); + close_with_status(exec_ctx, call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + } else { + call->incoming_compression_algorithm = algo; + } + gpr_free(error_msg); + } + + /* make sure the received grpc-encoding is amongst the ones listed in + * grpc-accept-encoding */ + GPR_ASSERT(call->encodings_accepted_by_peer != 0); + if (!GPR_BITGET(call->encodings_accepted_by_peer, + call->incoming_compression_algorithm)) { + extern int grpc_compression_trace; + if (grpc_compression_trace) { + char *algo_name; + grpc_compression_algorithm_name(call->incoming_compression_algorithm, + &algo_name); + gpr_log(GPR_ERROR, + "Compression algorithm (grpc-encoding = '%s') not present in " + "the bitset of accepted encodings (grpc-accept-encodings: " + "'0x%x')", + algo_name, call->encodings_accepted_by_peer); + } + } +} + static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *bctlp, bool success) { batch_control *bctl = bctlp; @@ -1085,24 +1232,10 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx, &call->metadata_batch[1 /* is_receiving */][0 /* is_trailing */]; grpc_metadata_batch_filter(md, recv_initial_filter, call); - /* make sure the received grpc-encoding is amongst the ones listed in - * grpc-accept-encoding */ - - GPR_ASSERT(call->encodings_accepted_by_peer != 0); - if (!GPR_BITGET(call->encodings_accepted_by_peer, - call->compression_algorithm)) { - extern int grpc_compression_trace; - if (grpc_compression_trace) { - char *algo_name; - grpc_compression_algorithm_name(call->compression_algorithm, - &algo_name); - gpr_log(GPR_ERROR, - "Compression algorithm (grpc-encoding = '%s') not present in " - "the bitset of accepted encodings (grpc-accept-encodings: " - "'0x%x')", - algo_name, call->encodings_accepted_by_peer); - } - } + GPR_TIMER_BEGIN("validate_filtered_metadata", 0); + validate_filtered_metadata(exec_ctx, bctl); + GPR_TIMER_END("validate_filtered_metadata", 0); + if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) != 0 && !call->is_client) { @@ -1245,7 +1378,40 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; goto done_with_error; } - if (op->data.send_initial_metadata.count > INT_MAX) { + /* process compression level */ + grpc_metadata compression_md; + memset(&compression_md, 0, sizeof(grpc_metadata)); + size_t additional_metadata_count = 0; + grpc_compression_level effective_compression_level; + bool level_set = false; + if (op->data.send_initial_metadata.maybe_compression_level.is_set) { + effective_compression_level = + op->data.send_initial_metadata.maybe_compression_level.level; + level_set = true; + } else { + const grpc_compression_options copts = + grpc_channel_compression_options(call->channel); + level_set = copts.default_level.is_set; + if (level_set) { + effective_compression_level = copts.default_level.level; + } + } + if (level_set && !call->is_client) { + const grpc_compression_algorithm calgo = + compression_algorithm_for_level_locked( + call, effective_compression_level); + char *calgo_name; + grpc_compression_algorithm_name(calgo, &calgo_name); + // the following will be picked up by the compress filter and used as + // the call's compression algorithm. + compression_md.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; + compression_md.value = calgo_name; + compression_md.value_length = strlen(calgo_name); + additional_metadata_count++; + } + + if (op->data.send_initial_metadata.count + additional_metadata_count > + INT_MAX) { error = GRPC_CALL_ERROR_INVALID_METADATA; goto done_with_error; } @@ -1253,7 +1419,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, call->sent_initial_metadata = 1; if (!prepare_application_metadata( call, (int)op->data.send_initial_metadata.count, - op->data.send_initial_metadata.metadata, 0, call->is_client)) { + op->data.send_initial_metadata.metadata, 0, call->is_client, + &compression_md, (int)additional_metadata_count)) { error = GRPC_CALL_ERROR_INVALID_METADATA; goto done_with_error; } @@ -1341,7 +1508,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, if (!prepare_application_metadata( call, (int)op->data.send_status_from_server.trailing_metadata_count, - op->data.send_status_from_server.trailing_metadata, 1, 1)) { + op->data.send_status_from_server.trailing_metadata, 1, 1, NULL, + 0)) { error = GRPC_CALL_ERROR_INVALID_METADATA; goto done_with_error; } @@ -1530,9 +1698,10 @@ uint8_t grpc_call_is_client(grpc_call *call) { return call->is_client; } grpc_compression_algorithm grpc_call_compression_for_level( grpc_call *call, grpc_compression_level level) { gpr_mu_lock(&call->mu); - const uint32_t accepted_encodings = call->encodings_accepted_by_peer; + grpc_compression_algorithm algo = + compression_algorithm_for_level_locked(call, level); gpr_mu_unlock(&call->mu); - return grpc_compression_algorithm_for_level(level, accepted_encodings); + return algo; } const char *grpc_call_error_to_string(grpc_call_error error) { diff --git a/src/core/lib/surface/call_log_batch.c b/src/core/lib/surface/call_log_batch.c index a6d1d5149f1..31c074f15dc 100644 --- a/src/core/lib/surface/call_log_batch.c +++ b/src/core/lib/surface/call_log_batch.c @@ -112,7 +112,7 @@ void grpc_call_log_batch(char *file, int line, gpr_log_severity severity, size_t i; for (i = 0; i < nops; i++) { tmp = grpc_op_string(&ops[i]); - gpr_log(file, line, severity, "ops[%d]: %s", i, tmp); + gpr_log(file, line, severity, "ops[%" PRIuPTR "]: %s", i, tmp); gpr_free(tmp); } } diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index a7ea6fa1f08..f0b3c2e15d1 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -36,16 +36,17 @@ #include #include +#include #include #include #include +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel_init.h" -#include "src/core/lib/surface/init.h" #include "src/core/lib/transport/static_metadata.h" /** Cache grpc-status: X mdelems for X = 0..NUM_CACHED_STATUS_ELEMS. @@ -64,10 +65,12 @@ typedef struct registered_call { struct grpc_channel { int is_client; uint32_t max_message_length; + grpc_compression_options compression_options; grpc_mdelem *default_authority; gpr_mu registered_call_mu; registered_call *registered_calls; + char *target; }; @@ -111,6 +114,7 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, channel->registered_calls = NULL; channel->max_message_length = DEFAULT_MAX_MESSAGE_LENGTH; + grpc_compression_options_init(&channel->compression_options); if (args) { for (size_t i = 0; i < args->num_args; i++) { if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_MESSAGE_LENGTH)) { @@ -151,6 +155,27 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, ":authority", args->args[i].value.string); } } + } else if (0 == strcmp(args->args[i].key, + GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) { + channel->compression_options.default_level.is_set = true; + GPR_ASSERT(args->args[i].value.integer >= 0 && + args->args[i].value.integer < GRPC_COMPRESS_LEVEL_COUNT); + channel->compression_options.default_level.level = + (grpc_compression_level)args->args[i].value.integer; + } else if (0 == strcmp(args->args[i].key, + GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM)) { + channel->compression_options.default_algorithm.is_set = true; + GPR_ASSERT(args->args[i].value.integer >= 0 && + args->args[i].value.integer < + GRPC_COMPRESS_ALGORITHMS_COUNT); + channel->compression_options.default_algorithm.algorithm = + (grpc_compression_algorithm)args->args[i].value.integer; + } else if (0 == + strcmp(args->args[i].key, + GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET)) { + channel->compression_options.enabled_algorithms_bitset = + (uint32_t)args->args[i].value.integer | + 0x1; /* always support no compression */ } } grpc_channel_args_destroy(args); @@ -324,6 +349,11 @@ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel) { return CHANNEL_STACK_FROM_CHANNEL(channel); } +grpc_compression_options grpc_channel_compression_options( + const grpc_channel *channel) { + return channel->compression_options; +} + grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_channel *channel, int i) { char tmp[GPR_LTOA_MIN_BUFSIZE]; switch (i) { diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index ff3debc31f2..7eff7b88836 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -76,4 +76,8 @@ void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, grpc_channel_internal_unref(exec_ctx, channel) #endif +/** Return the channel's compression options. */ +grpc_compression_options grpc_channel_compression_options( + const grpc_channel *channel); + #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */ diff --git a/src/core/lib/transport/metadata.c b/src/core/lib/transport/metadata.c index 82c8e239f68..0677f297660 100644 --- a/src/core/lib/transport/metadata.c +++ b/src/core/lib/transport/metadata.c @@ -129,7 +129,10 @@ typedef struct mdtab_shard { internal_metadata **elems; size_t count; size_t capacity; - size_t free; + /** Estimate of the number of unreferenced mdelems in the hash table. + This will eventually converge to the exact number, but it's instantaneous + accuracy is not guaranteed */ + gpr_atm free_estimate; } mdtab_shard; #define LOG2_STRTAB_SHARD_COUNT 5 @@ -217,7 +220,7 @@ void grpc_mdctx_global_init(void) { mdtab_shard *shard = &g_mdtab_shard[i]; gpr_mu_init(&shard->mu); shard->count = 0; - shard->free = 0; + gpr_atm_no_barrier_store(&shard->free_estimate, 0); shard->capacity = INITIAL_MDTAB_CAPACITY; shard->elems = gpr_malloc(sizeof(*shard->elems) * shard->capacity); memset(shard->elems, 0, sizeof(*shard->elems) * shard->capacity); @@ -232,7 +235,7 @@ void grpc_mdctx_global_shutdown(void) { gc_mdtab(shard); /* TODO(ctiller): GPR_ASSERT(shard->count == 0); */ if (shard->count != 0) { - gpr_log(GPR_DEBUG, "WARNING: %d metadata elements were leaked", + gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata elements were leaked", shard->count); if (grpc_iomgr_abort_on_leaks()) { abort(); @@ -245,7 +248,7 @@ void grpc_mdctx_global_shutdown(void) { gpr_mu_destroy(&shard->mu); /* TODO(ctiller): GPR_ASSERT(shard->count == 0); */ if (shard->count != 0) { - gpr_log(GPR_DEBUG, "WARNING: %d metadata strings were leaked", + gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata strings were leaked", shard->count); for (size_t j = 0; j < shard->capacity; j++) { for (internal_string *s = shard->strs[j]; s; s = s->bucket_next) { @@ -281,10 +284,8 @@ static void ref_md_locked(mdtab_shard *shard, grpc_mdstr_as_c_string((grpc_mdstr *)md->key), grpc_mdstr_as_c_string((grpc_mdstr *)md->value)); #endif - if (0 == gpr_atm_no_barrier_fetch_add(&md->refcnt, 2)) { - shard->free--; - } else { - GPR_ASSERT(1 != gpr_atm_no_barrier_fetch_add(&md->refcnt, -1)); + if (0 == gpr_atm_no_barrier_fetch_add(&md->refcnt, 1)) { + gpr_atm_no_barrier_fetch_add(&shard->free_estimate, -1); } } @@ -447,6 +448,7 @@ static void gc_mdtab(mdtab_shard *shard) { size_t i; internal_metadata **prev_next; internal_metadata *md, *next; + gpr_atm num_freed = 0; GPR_TIMER_BEGIN("gc_mdtab", 0); for (i = 0; i < shard->capacity; i++) { @@ -463,13 +465,14 @@ static void gc_mdtab(mdtab_shard *shard) { } gpr_free(md); *prev_next = next; - shard->free--; + num_freed++; shard->count--; } else { prev_next = &md->bucket_next; } } } + gpr_atm_no_barrier_fetch_add(&shard->free_estimate, -num_freed); GPR_TIMER_END("gc_mdtab", 0); } @@ -504,7 +507,8 @@ static void grow_mdtab(mdtab_shard *shard) { } static void rehash_mdtab(mdtab_shard *shard) { - if (shard->free > shard->capacity / 4) { + if (gpr_atm_no_barrier_load(&shard->free_estimate) > + (gpr_atm)(shard->capacity / 4)) { gc_mdtab(shard); } else { grow_mdtab(shard); @@ -553,7 +557,7 @@ grpc_mdelem *grpc_mdelem_from_metadata_strings(grpc_mdstr *mkey, /* not found: create a new pair */ md = gpr_malloc(sizeof(internal_metadata)); - gpr_atm_rel_store(&md->refcnt, 2); + gpr_atm_rel_store(&md->refcnt, 1); md->key = key; md->value = value; md->user_data = 0; @@ -645,7 +649,7 @@ grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *gmd DEBUG_ARGS) { this function - meaning that no adjustment to mdtab_free is necessary, simplifying the logic here to be just an atomic increment */ /* use C assert to have this removed in opt builds */ - assert(gpr_atm_no_barrier_load(&md->refcnt) >= 2); + assert(gpr_atm_no_barrier_load(&md->refcnt) >= 1); gpr_atm_no_barrier_fetch_add(&md->refcnt, 1); return gmd; } @@ -662,18 +666,13 @@ void grpc_mdelem_unref(grpc_mdelem *gmd DEBUG_ARGS) { grpc_mdstr_as_c_string((grpc_mdstr *)md->key), grpc_mdstr_as_c_string((grpc_mdstr *)md->value)); #endif - if (2 == gpr_atm_full_fetch_add(&md->refcnt, -1)) { - uint32_t hash = GRPC_MDSTR_KV_HASH(md->key->hash, md->value->hash); + uint32_t hash = GRPC_MDSTR_KV_HASH(md->key->hash, md->value->hash); + if (1 == gpr_atm_full_fetch_add(&md->refcnt, -1)) { + /* once the refcount hits zero, some other thread can come along and + free md at any time: it's unsafe from this point on to access it */ mdtab_shard *shard = &g_mdtab_shard[SHARD_IDX(hash, LOG2_MDTAB_SHARD_COUNT)]; - GPR_TIMER_BEGIN("grpc_mdelem_unref.to_zero", 0); - gpr_mu_lock(&shard->mu); - if (1 == gpr_atm_no_barrier_load(&md->refcnt)) { - shard->free++; - gpr_atm_no_barrier_store(&md->refcnt, 0); - } - gpr_mu_unlock(&shard->mu); - GPR_TIMER_END("grpc_mdelem_unref.to_zero", 0); + gpr_atm_no_barrier_fetch_add(&shard->free_estimate, 1); } } diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 32c7794ade7..d3e5ce0c4a6 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -33,15 +33,14 @@ #include -#include -#include -#include #include #include #include #include -#include "src/core/lib/channel/compress_filter.h" +#include +#include +#include namespace grpc { @@ -112,7 +111,7 @@ void ClientContext::set_compression_algorithm( abort(); } GPR_ASSERT(algorithm_name != nullptr); - AddMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); + AddMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name); } void ClientContext::TryCancel() { diff --git a/src/cpp/client/create_channel_posix.cc b/src/cpp/client/create_channel_posix.cc new file mode 100644 index 00000000000..60cfed3d623 --- /dev/null +++ b/src/cpp/client/create_channel_posix.cc @@ -0,0 +1,56 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include + +#include "src/cpp/client/create_channel_internal.h" + +namespace grpc { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +std::shared_ptr CreateInsecureChannelFromFd(const grpc::string& target, + int fd) { + internal::GrpcLibrary init_lib; + init_lib.init(); + return CreateChannelInternal( + "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr)); +} + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index 8e8d42eb294..cc35aa69bab 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -31,7 +31,7 @@ * */ -#include "src/cpp/common/core_codegen.h" +#include #include diff --git a/src/cpp/ext/proto_server_reflection.cc b/src/cpp/ext/proto_server_reflection.cc new file mode 100644 index 00000000000..348a035f0f3 --- /dev/null +++ b/src/cpp/ext/proto_server_reflection.cc @@ -0,0 +1,227 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include + +#include "src/cpp/ext/proto_server_reflection.h" + +using grpc::Status; +using grpc::StatusCode; +using grpc::reflection::v1alpha::ServerReflectionRequest; +using grpc::reflection::v1alpha::ExtensionRequest; +using grpc::reflection::v1alpha::ServerReflectionResponse; +using grpc::reflection::v1alpha::ListServiceResponse; +using grpc::reflection::v1alpha::ServiceResponse; +using grpc::reflection::v1alpha::ExtensionNumberResponse; +using grpc::reflection::v1alpha::ErrorResponse; +using grpc::reflection::v1alpha::FileDescriptorResponse; + +namespace grpc { + +ProtoServerReflection::ProtoServerReflection() + : descriptor_pool_(protobuf::DescriptorPool::generated_pool()) {} + +void ProtoServerReflection::SetServiceList( + const std::vector* services) { + services_ = services; +} + +Status ProtoServerReflection::ServerReflectionInfo( + ServerContext* context, + ServerReaderWriter* + stream) { + ServerReflectionRequest request; + ServerReflectionResponse response; + Status status; + while (stream->Read(&request)) { + switch (request.message_request_case()) { + case ServerReflectionRequest::MessageRequestCase::kFileByFilename: + status = GetFileByName(context, request.file_by_filename(), &response); + break; + case ServerReflectionRequest::MessageRequestCase::kFileContainingSymbol: + status = GetFileContainingSymbol( + context, request.file_containing_symbol(), &response); + break; + case ServerReflectionRequest::MessageRequestCase:: + kFileContainingExtension: + status = GetFileContainingExtension( + context, &request.file_containing_extension(), &response); + break; + case ServerReflectionRequest::MessageRequestCase:: + kAllExtensionNumbersOfType: + status = GetAllExtensionNumbers( + context, request.all_extension_numbers_of_type(), + response.mutable_all_extension_numbers_response()); + break; + case ServerReflectionRequest::MessageRequestCase::kListServices: + status = + ListService(context, response.mutable_list_services_response()); + break; + default: + status = Status(StatusCode::UNIMPLEMENTED, ""); + } + + if (!status.ok()) { + FillErrorResponse(status, response.mutable_error_response()); + } + response.set_valid_host(request.host()); + response.set_allocated_original_request( + new ServerReflectionRequest(request)); + stream->Write(response); + } + + return Status::OK; +} + +void ProtoServerReflection::FillErrorResponse(const Status& status, + ErrorResponse* error_response) { + error_response->set_error_code(status.error_code()); + error_response->set_error_message(status.error_message()); +} + +Status ProtoServerReflection::ListService(ServerContext* context, + ListServiceResponse* response) { + if (services_ == nullptr) { + return Status(StatusCode::NOT_FOUND, "Services not found."); + } + for (auto it = services_->begin(); it != services_->end(); ++it) { + ServiceResponse* service_response = response->add_service(); + service_response->set_name(*it); + } + return Status::OK; +} + +Status ProtoServerReflection::GetFileByName( + ServerContext* context, const grpc::string& filename, + ServerReflectionResponse* response) { + if (descriptor_pool_ == nullptr) { + return Status::CANCELLED; + } + + const protobuf::FileDescriptor* file_desc = + descriptor_pool_->FindFileByName(filename); + if (file_desc == nullptr) { + return Status(StatusCode::NOT_FOUND, "File not found."); + } + std::unordered_set seen_files; + FillFileDescriptorResponse(file_desc, response, &seen_files); + return Status::OK; +} + +Status ProtoServerReflection::GetFileContainingSymbol( + ServerContext* context, const grpc::string& symbol, + ServerReflectionResponse* response) { + if (descriptor_pool_ == nullptr) { + return Status::CANCELLED; + } + + const protobuf::FileDescriptor* file_desc = + descriptor_pool_->FindFileContainingSymbol(symbol); + if (file_desc == nullptr) { + return Status(StatusCode::NOT_FOUND, "Symbol not found."); + } + std::unordered_set seen_files; + FillFileDescriptorResponse(file_desc, response, &seen_files); + return Status::OK; +} + +Status ProtoServerReflection::GetFileContainingExtension( + ServerContext* context, const ExtensionRequest* request, + ServerReflectionResponse* response) { + if (descriptor_pool_ == nullptr) { + return Status::CANCELLED; + } + + const protobuf::Descriptor* desc = + descriptor_pool_->FindMessageTypeByName(request->containing_type()); + if (desc == nullptr) { + return Status(StatusCode::NOT_FOUND, "Type not found."); + } + + const protobuf::FieldDescriptor* field_desc = + descriptor_pool_->FindExtensionByNumber(desc, + request->extension_number()); + if (field_desc == nullptr) { + return Status(StatusCode::NOT_FOUND, "Extension not found."); + } + std::unordered_set seen_files; + FillFileDescriptorResponse(field_desc->file(), response, &seen_files); + return Status::OK; +} + +Status ProtoServerReflection::GetAllExtensionNumbers( + ServerContext* context, const grpc::string& type, + ExtensionNumberResponse* response) { + if (descriptor_pool_ == nullptr) { + return Status::CANCELLED; + } + + const protobuf::Descriptor* desc = + descriptor_pool_->FindMessageTypeByName(type); + if (desc == nullptr) { + return Status(StatusCode::NOT_FOUND, "Type not found."); + } + + std::vector extensions; + descriptor_pool_->FindAllExtensions(desc, &extensions); + for (auto extension : extensions) { + response->add_extension_number(extension->number()); + } + response->set_base_type_name(type); + return Status::OK; +} + +void ProtoServerReflection::FillFileDescriptorResponse( + const protobuf::FileDescriptor* file_desc, + ServerReflectionResponse* response, + std::unordered_set* seen_files) { + if (seen_files->find(file_desc->name()) != seen_files->end()) { + return; + } + seen_files->insert(file_desc->name()); + + protobuf::FileDescriptorProto file_desc_proto; + grpc::string data; + file_desc->CopyTo(&file_desc_proto); + file_desc_proto.SerializeToString(&data); + response->mutable_file_descriptor_response()->add_file_descriptor_proto(data); + + for (int i = 0; i < file_desc->dependency_count(); ++i) { + FillFileDescriptorResponse(file_desc->dependency(i), response, seen_files); + } +} + +} // namespace grpc diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h new file mode 100644 index 00000000000..23c130513d1 --- /dev/null +++ b/src/cpp/ext/proto_server_reflection.h @@ -0,0 +1,94 @@ +/* + * + * 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 GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H +#define GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H + +#include +#include + +#include +#include + +namespace grpc { + +class ProtoServerReflection GRPC_FINAL + : public reflection::v1alpha::ServerReflection::Service { + public: + ProtoServerReflection(); + + // Add the full names of registered services + void SetServiceList(const std::vector* services); + + // implementation of ServerReflectionInfo(stream ServerReflectionRequest) rpc + // in ServerReflection service + Status ServerReflectionInfo( + ServerContext* context, + ServerReaderWriter* stream) + GRPC_OVERRIDE; + + private: + Status ListService(ServerContext* context, + reflection::v1alpha::ListServiceResponse* response); + + Status GetFileByName(ServerContext* context, const grpc::string& file_name, + reflection::v1alpha::ServerReflectionResponse* response); + + Status GetFileContainingSymbol( + ServerContext* context, const grpc::string& symbol, + reflection::v1alpha::ServerReflectionResponse* response); + + Status GetFileContainingExtension( + ServerContext* context, + const reflection::v1alpha::ExtensionRequest* request, + reflection::v1alpha::ServerReflectionResponse* response); + + Status GetAllExtensionNumbers( + ServerContext* context, const grpc::string& type, + reflection::v1alpha::ExtensionNumberResponse* response); + + void FillFileDescriptorResponse( + const protobuf::FileDescriptor* file_desc, + reflection::v1alpha::ServerReflectionResponse* response, + std::unordered_set* seen_files); + + void FillErrorResponse(const Status& status, + reflection::v1alpha::ErrorResponse* error_response); + + const protobuf::DescriptorPool* descriptor_pool_; + const std::vector* services_; +}; + +} // namespace grpc + +#endif // GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H diff --git a/src/cpp/ext/proto_server_reflection_plugin.cc b/src/cpp/ext/proto_server_reflection_plugin.cc new file mode 100644 index 00000000000..f31d102a9e6 --- /dev/null +++ b/src/cpp/ext/proto_server_reflection_plugin.cc @@ -0,0 +1,97 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include + +#include "src/cpp/ext/proto_server_reflection.h" + +namespace grpc { +namespace reflection { + +ProtoServerReflectionPlugin::ProtoServerReflectionPlugin() + : reflection_service_(new grpc::ProtoServerReflection()) {} + +grpc::string ProtoServerReflectionPlugin::name() { + return "proto_server_reflection"; +} + +void ProtoServerReflectionPlugin::InitServer(grpc::ServerInitializer* si) { + si->RegisterService(reflection_service_); +} + +void ProtoServerReflectionPlugin::Finish(grpc::ServerInitializer* si) { + reflection_service_->SetServiceList(si->GetServiceList()); +} + +void ProtoServerReflectionPlugin::ChangeArguments(const grpc::string& name, + void* value) {} + +bool ProtoServerReflectionPlugin::has_sync_methods() const { + if (reflection_service_ != nullptr) { + return reflection_service_->has_synchronous_methods(); + } + return false; +} + +bool ProtoServerReflectionPlugin::has_async_methods() const { + if (reflection_service_ != nullptr) { + return reflection_service_->has_async_methods(); + } + return false; +} + +static std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { + return std::unique_ptr<::grpc::ServerBuilderPlugin>( + new ProtoServerReflectionPlugin()); +} + +void InitProtoReflectionServerBuilderPlugin() { + static bool already_here = false; + if (already_here) return; + already_here = true; + ::grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection); +} + +// Force InitProtoReflectionServerBuilderPlugin() to be called at static +// initialization time. +struct StaticProtoReflectionPluginInitializer { + StaticProtoReflectionPluginInitializer() { + InitProtoReflectionServerBuilderPlugin(); + } +} static_proto_reflection_plugin_initializer; + +} // namespace reflection +} // namespace grpc diff --git a/src/cpp/ext/reflection.grpc.pb.cc b/src/cpp/ext/reflection.grpc.pb.cc new file mode 100644 index 00000000000..b046dfc1b8b --- /dev/null +++ b/src/cpp/ext/reflection.grpc.pb.cc @@ -0,0 +1,97 @@ +/* + * + * 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 the gRPC protobuf plugin. +// If you make any local change, they will be lost. +// source: reflection.proto + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +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 + diff --git a/src/cpp/ext/reflection.pb.cc b/src/cpp/ext/reflection.pb.cc new file mode 100644 index 00000000000..b73a65d0a02 --- /dev/null +++ b/src/cpp/ext/reflection.pb.cc @@ -0,0 +1,3946 @@ +/* + * + * 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 the protocol buffer compiler. DO NOT EDIT! +// source: reflection.proto + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace grpc { +namespace reflection { +namespace v1alpha { + +namespace { + +const ::google::protobuf::Descriptor* ServerReflectionRequest_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ServerReflectionRequest_reflection_ = NULL; +struct ServerReflectionRequestOneofInstance { + ::google::protobuf::internal::ArenaStringPtr file_by_filename_; + ::google::protobuf::internal::ArenaStringPtr file_containing_symbol_; + const ::grpc::reflection::v1alpha::ExtensionRequest* file_containing_extension_; + ::google::protobuf::internal::ArenaStringPtr all_extension_numbers_of_type_; + ::google::protobuf::internal::ArenaStringPtr list_services_; +}* ServerReflectionRequest_default_oneof_instance_ = NULL; +const ::google::protobuf::Descriptor* ExtensionRequest_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ExtensionRequest_reflection_ = NULL; +const ::google::protobuf::Descriptor* ServerReflectionResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ServerReflectionResponse_reflection_ = NULL; +struct ServerReflectionResponseOneofInstance { + const ::grpc::reflection::v1alpha::FileDescriptorResponse* file_descriptor_response_; + const ::grpc::reflection::v1alpha::ExtensionNumberResponse* all_extension_numbers_response_; + const ::grpc::reflection::v1alpha::ListServiceResponse* list_services_response_; + const ::grpc::reflection::v1alpha::ErrorResponse* error_response_; +}* ServerReflectionResponse_default_oneof_instance_ = NULL; +const ::google::protobuf::Descriptor* FileDescriptorResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + FileDescriptorResponse_reflection_ = NULL; +const ::google::protobuf::Descriptor* ExtensionNumberResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ExtensionNumberResponse_reflection_ = NULL; +const ::google::protobuf::Descriptor* ListServiceResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ListServiceResponse_reflection_ = NULL; +const ::google::protobuf::Descriptor* ServiceResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ServiceResponse_reflection_ = NULL; +const ::google::protobuf::Descriptor* ErrorResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ErrorResponse_reflection_ = NULL; + +} // namespace + + +void protobuf_AssignDesc_reflection_2eproto() { + protobuf_AddDesc_reflection_2eproto(); + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( + "reflection.proto"); + GOOGLE_CHECK(file != NULL); + ServerReflectionRequest_descriptor_ = file->message_type(0); + static const int ServerReflectionRequest_offsets_[7] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionRequest, host_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionRequest_default_oneof_instance_, file_by_filename_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionRequest_default_oneof_instance_, file_containing_symbol_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionRequest_default_oneof_instance_, file_containing_extension_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionRequest_default_oneof_instance_, all_extension_numbers_of_type_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionRequest_default_oneof_instance_, list_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionRequest, message_request_), + }; + ServerReflectionRequest_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ServerReflectionRequest_descriptor_, + ServerReflectionRequest::default_instance_, + ServerReflectionRequest_offsets_, + -1, + -1, + -1, + ServerReflectionRequest_default_oneof_instance_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionRequest, _oneof_case_[0]), + sizeof(ServerReflectionRequest), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionRequest, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionRequest, _is_default_instance_)); + ExtensionRequest_descriptor_ = file->message_type(1); + static const int ExtensionRequest_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionRequest, containing_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionRequest, extension_number_), + }; + ExtensionRequest_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ExtensionRequest_descriptor_, + ExtensionRequest::default_instance_, + ExtensionRequest_offsets_, + -1, + -1, + -1, + sizeof(ExtensionRequest), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionRequest, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionRequest, _is_default_instance_)); + ServerReflectionResponse_descriptor_ = file->message_type(2); + static const int ServerReflectionResponse_offsets_[7] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionResponse, valid_host_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionResponse, original_request_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionResponse_default_oneof_instance_, file_descriptor_response_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionResponse_default_oneof_instance_, all_extension_numbers_response_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionResponse_default_oneof_instance_, list_services_response_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ServerReflectionResponse_default_oneof_instance_, error_response_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionResponse, message_response_), + }; + ServerReflectionResponse_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ServerReflectionResponse_descriptor_, + ServerReflectionResponse::default_instance_, + ServerReflectionResponse_offsets_, + -1, + -1, + -1, + ServerReflectionResponse_default_oneof_instance_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionResponse, _oneof_case_[0]), + sizeof(ServerReflectionResponse), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerReflectionResponse, _is_default_instance_)); + FileDescriptorResponse_descriptor_ = file->message_type(3); + static const int FileDescriptorResponse_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorResponse, file_descriptor_proto_), + }; + FileDescriptorResponse_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + FileDescriptorResponse_descriptor_, + FileDescriptorResponse::default_instance_, + FileDescriptorResponse_offsets_, + -1, + -1, + -1, + sizeof(FileDescriptorResponse), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorResponse, _is_default_instance_)); + ExtensionNumberResponse_descriptor_ = file->message_type(4); + static const int ExtensionNumberResponse_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionNumberResponse, base_type_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionNumberResponse, extension_number_), + }; + ExtensionNumberResponse_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ExtensionNumberResponse_descriptor_, + ExtensionNumberResponse::default_instance_, + ExtensionNumberResponse_offsets_, + -1, + -1, + -1, + sizeof(ExtensionNumberResponse), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionNumberResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExtensionNumberResponse, _is_default_instance_)); + ListServiceResponse_descriptor_ = file->message_type(5); + static const int ListServiceResponse_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListServiceResponse, service_), + }; + ListServiceResponse_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ListServiceResponse_descriptor_, + ListServiceResponse::default_instance_, + ListServiceResponse_offsets_, + -1, + -1, + -1, + sizeof(ListServiceResponse), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListServiceResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListServiceResponse, _is_default_instance_)); + ServiceResponse_descriptor_ = file->message_type(6); + static const int ServiceResponse_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceResponse, name_), + }; + ServiceResponse_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ServiceResponse_descriptor_, + ServiceResponse::default_instance_, + ServiceResponse_offsets_, + -1, + -1, + -1, + sizeof(ServiceResponse), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceResponse, _is_default_instance_)); + ErrorResponse_descriptor_ = file->message_type(7); + static const int ErrorResponse_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ErrorResponse, error_code_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ErrorResponse, error_message_), + }; + ErrorResponse_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + ErrorResponse_descriptor_, + ErrorResponse::default_instance_, + ErrorResponse_offsets_, + -1, + -1, + -1, + sizeof(ErrorResponse), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ErrorResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ErrorResponse, _is_default_instance_)); +} + +namespace { + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +inline void protobuf_AssignDescriptorsOnce() { + ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, + &protobuf_AssignDesc_reflection_2eproto); +} + +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ServerReflectionRequest_descriptor_, &ServerReflectionRequest::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ExtensionRequest_descriptor_, &ExtensionRequest::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ServerReflectionResponse_descriptor_, &ServerReflectionResponse::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + FileDescriptorResponse_descriptor_, &FileDescriptorResponse::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ExtensionNumberResponse_descriptor_, &ExtensionNumberResponse::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ListServiceResponse_descriptor_, &ListServiceResponse::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ServiceResponse_descriptor_, &ServiceResponse::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ErrorResponse_descriptor_, &ErrorResponse::default_instance()); +} + +} // namespace + +void protobuf_ShutdownFile_reflection_2eproto() { + delete ServerReflectionRequest::default_instance_; + delete ServerReflectionRequest_default_oneof_instance_; + delete ServerReflectionRequest_reflection_; + delete ExtensionRequest::default_instance_; + delete ExtensionRequest_reflection_; + delete ServerReflectionResponse::default_instance_; + delete ServerReflectionResponse_default_oneof_instance_; + delete ServerReflectionResponse_reflection_; + delete FileDescriptorResponse::default_instance_; + delete FileDescriptorResponse_reflection_; + delete ExtensionNumberResponse::default_instance_; + delete ExtensionNumberResponse_reflection_; + delete ListServiceResponse::default_instance_; + delete ListServiceResponse_reflection_; + delete ServiceResponse::default_instance_; + delete ServiceResponse_reflection_; + delete ErrorResponse::default_instance_; + delete ErrorResponse_reflection_; +} + +void protobuf_AddDesc_reflection_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + "\n\020reflection.proto\022\027grpc.reflection.v1al" + "pha\"\212\002\n\027ServerReflectionRequest\022\014\n\004host\030" + "\001 \001(\t\022\032\n\020file_by_filename\030\003 \001(\tH\000\022 \n\026fil" + "e_containing_symbol\030\004 \001(\tH\000\022N\n\031file_cont" + "aining_extension\030\005 \001(\0132).grpc.reflection" + ".v1alpha.ExtensionRequestH\000\022\'\n\035all_exten" + "sion_numbers_of_type\030\006 \001(\tH\000\022\027\n\rlist_ser" + "vices\030\007 \001(\tH\000B\021\n\017message_request\"E\n\020Exte" + "nsionRequest\022\027\n\017containing_type\030\001 \001(\t\022\030\n" + "\020extension_number\030\002 \001(\005\"\321\003\n\030ServerReflec" + "tionResponse\022\022\n\nvalid_host\030\001 \001(\t\022J\n\020orig" + "inal_request\030\002 \001(\01320.grpc.reflection.v1a" + "lpha.ServerReflectionRequest\022S\n\030file_des" + "criptor_response\030\004 \001(\0132/.grpc.reflection" + ".v1alpha.FileDescriptorResponseH\000\022Z\n\036all" + "_extension_numbers_response\030\005 \001(\01320.grpc" + ".reflection.v1alpha.ExtensionNumberRespo" + "nseH\000\022N\n\026list_services_response\030\006 \001(\0132,." + "grpc.reflection.v1alpha.ListServiceRespo" + "nseH\000\022@\n\016error_response\030\007 \001(\0132&.grpc.ref" + "lection.v1alpha.ErrorResponseH\000B\022\n\020messa" + "ge_response\"7\n\026FileDescriptorResponse\022\035\n" + "\025file_descriptor_proto\030\001 \003(\014\"K\n\027Extensio" + "nNumberResponse\022\026\n\016base_type_name\030\001 \001(\t\022" + "\030\n\020extension_number\030\002 \003(\005\"P\n\023ListService" + "Response\0229\n\007service\030\001 \003(\0132(.grpc.reflect" + "ion.v1alpha.ServiceResponse\"\037\n\017ServiceRe" + "sponse\022\014\n\004name\030\001 \001(\t\":\n\rErrorResponse\022\022\n" + "\nerror_code\030\001 \001(\005\022\025\n\rerror_message\030\002 \001(\t" + "2\223\001\n\020ServerReflection\022\177\n\024ServerReflectio" + "nInfo\0220.grpc.reflection.v1alpha.ServerRe" + "flectionRequest\0321.grpc.reflection.v1alph" + "a.ServerReflectionResponse(\0010\001b\006proto3", 1318); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "reflection.proto", &protobuf_RegisterTypes); + ServerReflectionRequest::default_instance_ = new ServerReflectionRequest(); + ServerReflectionRequest_default_oneof_instance_ = new ServerReflectionRequestOneofInstance(); + ExtensionRequest::default_instance_ = new ExtensionRequest(); + ServerReflectionResponse::default_instance_ = new ServerReflectionResponse(); + ServerReflectionResponse_default_oneof_instance_ = new ServerReflectionResponseOneofInstance(); + FileDescriptorResponse::default_instance_ = new FileDescriptorResponse(); + ExtensionNumberResponse::default_instance_ = new ExtensionNumberResponse(); + ListServiceResponse::default_instance_ = new ListServiceResponse(); + ServiceResponse::default_instance_ = new ServiceResponse(); + ErrorResponse::default_instance_ = new ErrorResponse(); + ServerReflectionRequest::default_instance_->InitAsDefaultInstance(); + ExtensionRequest::default_instance_->InitAsDefaultInstance(); + ServerReflectionResponse::default_instance_->InitAsDefaultInstance(); + FileDescriptorResponse::default_instance_->InitAsDefaultInstance(); + ExtensionNumberResponse::default_instance_->InitAsDefaultInstance(); + ListServiceResponse::default_instance_->InitAsDefaultInstance(); + ServiceResponse::default_instance_->InitAsDefaultInstance(); + ErrorResponse::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_reflection_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_reflection_2eproto { + StaticDescriptorInitializer_reflection_2eproto() { + protobuf_AddDesc_reflection_2eproto(); + } +} static_descriptor_initializer_reflection_2eproto_; + +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD; +static void MergeFromFail(int line) { + GOOGLE_CHECK(false) << __FILE__ << ":" << line; +} + +} // namespace + + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ServerReflectionRequest::kHostFieldNumber; +const int ServerReflectionRequest::kFileByFilenameFieldNumber; +const int ServerReflectionRequest::kFileContainingSymbolFieldNumber; +const int ServerReflectionRequest::kFileContainingExtensionFieldNumber; +const int ServerReflectionRequest::kAllExtensionNumbersOfTypeFieldNumber; +const int ServerReflectionRequest::kListServicesFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ServerReflectionRequest::ServerReflectionRequest() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ServerReflectionRequest) +} + +void ServerReflectionRequest::InitAsDefaultInstance() { + _is_default_instance_ = true; + ServerReflectionRequest_default_oneof_instance_->file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ServerReflectionRequest_default_oneof_instance_->file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ServerReflectionRequest_default_oneof_instance_->file_containing_extension_ = const_cast< ::grpc::reflection::v1alpha::ExtensionRequest*>(&::grpc::reflection::v1alpha::ExtensionRequest::default_instance()); + ServerReflectionRequest_default_oneof_instance_->all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ServerReflectionRequest_default_oneof_instance_->list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +ServerReflectionRequest::ServerReflectionRequest(const ServerReflectionRequest& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ServerReflectionRequest) +} + +void ServerReflectionRequest::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + host_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); +} + +ServerReflectionRequest::~ServerReflectionRequest() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ServerReflectionRequest) + SharedDtor(); +} + +void ServerReflectionRequest::SharedDtor() { + host_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (has_message_request()) { + clear_message_request(); + } + if (this != default_instance_) { + } +} + +void ServerReflectionRequest::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ServerReflectionRequest::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ServerReflectionRequest_descriptor_; +} + +const ServerReflectionRequest& ServerReflectionRequest::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ServerReflectionRequest* ServerReflectionRequest::default_instance_ = NULL; + +ServerReflectionRequest* ServerReflectionRequest::New(::google::protobuf::Arena* arena) const { + ServerReflectionRequest* n = new ServerReflectionRequest; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ServerReflectionRequest::clear_message_request() { +// @@protoc_insertion_point(one_of_clear_start:grpc.reflection.v1alpha.ServerReflectionRequest) + switch(message_request_case()) { + case kFileByFilename: { + message_request_.file_by_filename_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + break; + } + case kFileContainingSymbol: { + message_request_.file_containing_symbol_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + break; + } + case kFileContainingExtension: { + delete message_request_.file_containing_extension_; + break; + } + case kAllExtensionNumbersOfType: { + message_request_.all_extension_numbers_of_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + break; + } + case kListServices: { + message_request_.list_services_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + break; + } + case MESSAGE_REQUEST_NOT_SET: { + break; + } + } + _oneof_case_[0] = MESSAGE_REQUEST_NOT_SET; +} + + +void ServerReflectionRequest::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ServerReflectionRequest) + host_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_message_request(); +} + +bool ServerReflectionRequest::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ServerReflectionRequest) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string host = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_host())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->host().data(), this->host().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServerReflectionRequest.host")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(26)) goto parse_file_by_filename; + break; + } + + // optional string file_by_filename = 3; + case 3: { + if (tag == 26) { + parse_file_by_filename: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_file_by_filename())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->file_by_filename().data(), this->file_by_filename().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(34)) goto parse_file_containing_symbol; + break; + } + + // optional string file_containing_symbol = 4; + case 4: { + if (tag == 34) { + parse_file_containing_symbol: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_file_containing_symbol())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->file_containing_symbol().data(), this->file_containing_symbol().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(42)) goto parse_file_containing_extension; + break; + } + + // optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; + case 5: { + if (tag == 42) { + parse_file_containing_extension: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_file_containing_extension())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(50)) goto parse_all_extension_numbers_of_type; + break; + } + + // optional string all_extension_numbers_of_type = 6; + case 6: { + if (tag == 50) { + parse_all_extension_numbers_of_type: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_all_extension_numbers_of_type())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->all_extension_numbers_of_type().data(), this->all_extension_numbers_of_type().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(58)) goto parse_list_services; + break; + } + + // optional string list_services = 7; + case 7: { + if (tag == 58) { + parse_list_services: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_list_services())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->list_services().data(), this->list_services().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServerReflectionRequest.list_services")); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ServerReflectionRequest) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ServerReflectionRequest) + return false; +#undef DO_ +} + +void ServerReflectionRequest::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ServerReflectionRequest) + // optional string host = 1; + if (this->host().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->host().data(), this->host().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.host"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->host(), output); + } + + // optional string file_by_filename = 3; + if (has_file_by_filename()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->file_by_filename().data(), this->file_by_filename().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 3, this->file_by_filename(), output); + } + + // optional string file_containing_symbol = 4; + if (has_file_containing_symbol()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->file_containing_symbol().data(), this->file_containing_symbol().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 4, this->file_containing_symbol(), output); + } + + // optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; + if (has_file_containing_extension()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 5, *message_request_.file_containing_extension_, output); + } + + // optional string all_extension_numbers_of_type = 6; + if (has_all_extension_numbers_of_type()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->all_extension_numbers_of_type().data(), this->all_extension_numbers_of_type().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 6, this->all_extension_numbers_of_type(), output); + } + + // optional string list_services = 7; + if (has_list_services()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->list_services().data(), this->list_services().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.list_services"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 7, this->list_services(), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ServerReflectionRequest) +} + +::google::protobuf::uint8* ServerReflectionRequest::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ServerReflectionRequest) + // optional string host = 1; + if (this->host().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->host().data(), this->host().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.host"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->host(), target); + } + + // optional string file_by_filename = 3; + if (has_file_by_filename()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->file_by_filename().data(), this->file_by_filename().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 3, this->file_by_filename(), target); + } + + // optional string file_containing_symbol = 4; + if (has_file_containing_symbol()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->file_containing_symbol().data(), this->file_containing_symbol().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 4, this->file_containing_symbol(), target); + } + + // optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; + if (has_file_containing_extension()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 5, *message_request_.file_containing_extension_, target); + } + + // optional string all_extension_numbers_of_type = 6; + if (has_all_extension_numbers_of_type()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->all_extension_numbers_of_type().data(), this->all_extension_numbers_of_type().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 6, this->all_extension_numbers_of_type(), target); + } + + // optional string list_services = 7; + if (has_list_services()) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->list_services().data(), this->list_services().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionRequest.list_services"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 7, this->list_services(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ServerReflectionRequest) + return target; +} + +int ServerReflectionRequest::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ServerReflectionRequest) + int total_size = 0; + + // optional string host = 1; + if (this->host().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->host()); + } + + switch (message_request_case()) { + // optional string file_by_filename = 3; + case kFileByFilename: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->file_by_filename()); + break; + } + // optional string file_containing_symbol = 4; + case kFileContainingSymbol: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->file_containing_symbol()); + break; + } + // optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; + case kFileContainingExtension: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *message_request_.file_containing_extension_); + break; + } + // optional string all_extension_numbers_of_type = 6; + case kAllExtensionNumbersOfType: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->all_extension_numbers_of_type()); + break; + } + // optional string list_services = 7; + case kListServices: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->list_services()); + break; + } + case MESSAGE_REQUEST_NOT_SET: { + break; + } + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ServerReflectionRequest::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ServerReflectionRequest) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServerReflectionRequest* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ServerReflectionRequest) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ServerReflectionRequest) + MergeFrom(*source); + } +} + +void ServerReflectionRequest::MergeFrom(const ServerReflectionRequest& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ServerReflectionRequest) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + switch (from.message_request_case()) { + case kFileByFilename: { + set_file_by_filename(from.file_by_filename()); + break; + } + case kFileContainingSymbol: { + set_file_containing_symbol(from.file_containing_symbol()); + break; + } + case kFileContainingExtension: { + mutable_file_containing_extension()->::grpc::reflection::v1alpha::ExtensionRequest::MergeFrom(from.file_containing_extension()); + break; + } + case kAllExtensionNumbersOfType: { + set_all_extension_numbers_of_type(from.all_extension_numbers_of_type()); + break; + } + case kListServices: { + set_list_services(from.list_services()); + break; + } + case MESSAGE_REQUEST_NOT_SET: { + break; + } + } + if (from.host().size() > 0) { + + host_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.host_); + } +} + +void ServerReflectionRequest::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ServerReflectionRequest) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ServerReflectionRequest::CopyFrom(const ServerReflectionRequest& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ServerReflectionRequest) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ServerReflectionRequest::IsInitialized() const { + + return true; +} + +void ServerReflectionRequest::Swap(ServerReflectionRequest* other) { + if (other == this) return; + InternalSwap(other); +} +void ServerReflectionRequest::InternalSwap(ServerReflectionRequest* other) { + host_.Swap(&other->host_); + std::swap(message_request_, other->message_request_); + std::swap(_oneof_case_[0], other->_oneof_case_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ServerReflectionRequest::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ServerReflectionRequest_descriptor_; + metadata.reflection = ServerReflectionRequest_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ServerReflectionRequest + +// optional string host = 1; +void ServerReflectionRequest::clear_host() { + host_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + const ::std::string& ServerReflectionRequest::host() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.host) + return host_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ServerReflectionRequest::set_host(const ::std::string& value) { + + host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} + void ServerReflectionRequest::set_host(const char* value) { + + host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} + void ServerReflectionRequest::set_host(const char* value, size_t size) { + + host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} + ::std::string* ServerReflectionRequest::mutable_host() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.host) + return host_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServerReflectionRequest::release_host() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.host) + + return host_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ServerReflectionRequest::set_allocated_host(::std::string* host) { + if (host != NULL) { + + } else { + + } + host_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), host); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.host) +} + +// optional string file_by_filename = 3; +bool ServerReflectionRequest::has_file_by_filename() const { + return message_request_case() == kFileByFilename; +} +void ServerReflectionRequest::set_has_file_by_filename() { + _oneof_case_[0] = kFileByFilename; +} +void ServerReflectionRequest::clear_file_by_filename() { + if (has_file_by_filename()) { + message_request_.file_by_filename_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} + const ::std::string& ServerReflectionRequest::file_by_filename() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + if (has_file_by_filename()) { + return message_request_.file_by_filename_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} + void ServerReflectionRequest::set_file_by_filename(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_by_filename_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} + void ServerReflectionRequest::set_file_by_filename(const char* value) { + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_by_filename_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} + void ServerReflectionRequest::set_file_by_filename(const char* value, size_t size) { + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_by_filename_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} + ::std::string* ServerReflectionRequest::mutable_file_by_filename() { + if (!has_file_by_filename()) { + clear_message_request(); + set_has_file_by_filename(); + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + return message_request_.file_by_filename_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServerReflectionRequest::release_file_by_filename() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) + if (has_file_by_filename()) { + clear_has_message_request(); + return message_request_.file_by_filename_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} + void ServerReflectionRequest::set_allocated_file_by_filename(::std::string* file_by_filename) { + if (!has_file_by_filename()) { + message_request_.file_by_filename_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (file_by_filename != NULL) { + set_has_file_by_filename(); + message_request_.file_by_filename_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + file_by_filename); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.file_by_filename) +} + +// optional string file_containing_symbol = 4; +bool ServerReflectionRequest::has_file_containing_symbol() const { + return message_request_case() == kFileContainingSymbol; +} +void ServerReflectionRequest::set_has_file_containing_symbol() { + _oneof_case_[0] = kFileContainingSymbol; +} +void ServerReflectionRequest::clear_file_containing_symbol() { + if (has_file_containing_symbol()) { + message_request_.file_containing_symbol_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} + const ::std::string& ServerReflectionRequest::file_containing_symbol() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + if (has_file_containing_symbol()) { + return message_request_.file_containing_symbol_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} + void ServerReflectionRequest::set_file_containing_symbol(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_containing_symbol_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} + void ServerReflectionRequest::set_file_containing_symbol(const char* value) { + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_containing_symbol_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} + void ServerReflectionRequest::set_file_containing_symbol(const char* value, size_t size) { + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.file_containing_symbol_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} + ::std::string* ServerReflectionRequest::mutable_file_containing_symbol() { + if (!has_file_containing_symbol()) { + clear_message_request(); + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + return message_request_.file_containing_symbol_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServerReflectionRequest::release_file_containing_symbol() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) + if (has_file_containing_symbol()) { + clear_has_message_request(); + return message_request_.file_containing_symbol_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} + void ServerReflectionRequest::set_allocated_file_containing_symbol(::std::string* file_containing_symbol) { + if (!has_file_containing_symbol()) { + message_request_.file_containing_symbol_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (file_containing_symbol != NULL) { + set_has_file_containing_symbol(); + message_request_.file_containing_symbol_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + file_containing_symbol); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_symbol) +} + +// optional .grpc.reflection.v1alpha.ExtensionRequest file_containing_extension = 5; +bool ServerReflectionRequest::has_file_containing_extension() const { + return message_request_case() == kFileContainingExtension; +} +void ServerReflectionRequest::set_has_file_containing_extension() { + _oneof_case_[0] = kFileContainingExtension; +} +void ServerReflectionRequest::clear_file_containing_extension() { + if (has_file_containing_extension()) { + delete message_request_.file_containing_extension_; + clear_has_message_request(); + } +} + const ::grpc::reflection::v1alpha::ExtensionRequest& ServerReflectionRequest::file_containing_extension() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) + return has_file_containing_extension() + ? *message_request_.file_containing_extension_ + : ::grpc::reflection::v1alpha::ExtensionRequest::default_instance(); +} +::grpc::reflection::v1alpha::ExtensionRequest* ServerReflectionRequest::mutable_file_containing_extension() { + if (!has_file_containing_extension()) { + clear_message_request(); + set_has_file_containing_extension(); + message_request_.file_containing_extension_ = new ::grpc::reflection::v1alpha::ExtensionRequest; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) + return message_request_.file_containing_extension_; +} +::grpc::reflection::v1alpha::ExtensionRequest* ServerReflectionRequest::release_file_containing_extension() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) + if (has_file_containing_extension()) { + clear_has_message_request(); + ::grpc::reflection::v1alpha::ExtensionRequest* temp = message_request_.file_containing_extension_; + message_request_.file_containing_extension_ = NULL; + return temp; + } else { + return NULL; + } +} +void ServerReflectionRequest::set_allocated_file_containing_extension(::grpc::reflection::v1alpha::ExtensionRequest* file_containing_extension) { + clear_message_request(); + if (file_containing_extension) { + set_has_file_containing_extension(); + message_request_.file_containing_extension_ = file_containing_extension; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension) +} + +// optional string all_extension_numbers_of_type = 6; +bool ServerReflectionRequest::has_all_extension_numbers_of_type() const { + return message_request_case() == kAllExtensionNumbersOfType; +} +void ServerReflectionRequest::set_has_all_extension_numbers_of_type() { + _oneof_case_[0] = kAllExtensionNumbersOfType; +} +void ServerReflectionRequest::clear_all_extension_numbers_of_type() { + if (has_all_extension_numbers_of_type()) { + message_request_.all_extension_numbers_of_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} + const ::std::string& ServerReflectionRequest::all_extension_numbers_of_type() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + if (has_all_extension_numbers_of_type()) { + return message_request_.all_extension_numbers_of_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} + void ServerReflectionRequest::set_all_extension_numbers_of_type(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.all_extension_numbers_of_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} + void ServerReflectionRequest::set_all_extension_numbers_of_type(const char* value) { + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.all_extension_numbers_of_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} + void ServerReflectionRequest::set_all_extension_numbers_of_type(const char* value, size_t size) { + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.all_extension_numbers_of_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} + ::std::string* ServerReflectionRequest::mutable_all_extension_numbers_of_type() { + if (!has_all_extension_numbers_of_type()) { + clear_message_request(); + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + return message_request_.all_extension_numbers_of_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServerReflectionRequest::release_all_extension_numbers_of_type() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) + if (has_all_extension_numbers_of_type()) { + clear_has_message_request(); + return message_request_.all_extension_numbers_of_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} + void ServerReflectionRequest::set_allocated_all_extension_numbers_of_type(::std::string* all_extension_numbers_of_type) { + if (!has_all_extension_numbers_of_type()) { + message_request_.all_extension_numbers_of_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (all_extension_numbers_of_type != NULL) { + set_has_all_extension_numbers_of_type(); + message_request_.all_extension_numbers_of_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + all_extension_numbers_of_type); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.all_extension_numbers_of_type) +} + +// optional string list_services = 7; +bool ServerReflectionRequest::has_list_services() const { + return message_request_case() == kListServices; +} +void ServerReflectionRequest::set_has_list_services() { + _oneof_case_[0] = kListServices; +} +void ServerReflectionRequest::clear_list_services() { + if (has_list_services()) { + message_request_.list_services_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message_request(); + } +} + const ::std::string& ServerReflectionRequest::list_services() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + if (has_list_services()) { + return message_request_.list_services_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); +} + void ServerReflectionRequest::set_list_services(const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.list_services_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} + void ServerReflectionRequest::set_list_services(const char* value) { + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.list_services_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} + void ServerReflectionRequest::set_list_services(const char* value, size_t size) { + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + message_request_.list_services_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} + ::std::string* ServerReflectionRequest::mutable_list_services() { + if (!has_list_services()) { + clear_message_request(); + set_has_list_services(); + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + return message_request_.list_services_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServerReflectionRequest::release_list_services() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) + if (has_list_services()) { + clear_has_message_request(); + return message_request_.list_services_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } else { + return NULL; + } +} + void ServerReflectionRequest::set_allocated_list_services(::std::string* list_services) { + if (!has_list_services()) { + message_request_.list_services_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_message_request(); + if (list_services != NULL) { + set_has_list_services(); + message_request_.list_services_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + list_services); + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionRequest.list_services) +} + +bool ServerReflectionRequest::has_message_request() const { + return message_request_case() != MESSAGE_REQUEST_NOT_SET; +} +void ServerReflectionRequest::clear_has_message_request() { + _oneof_case_[0] = MESSAGE_REQUEST_NOT_SET; +} +ServerReflectionRequest::MessageRequestCase ServerReflectionRequest::message_request_case() const { + return ServerReflectionRequest::MessageRequestCase(_oneof_case_[0]); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ExtensionRequest::kContainingTypeFieldNumber; +const int ExtensionRequest::kExtensionNumberFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ExtensionRequest::ExtensionRequest() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ExtensionRequest) +} + +void ExtensionRequest::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +ExtensionRequest::ExtensionRequest(const ExtensionRequest& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ExtensionRequest) +} + +void ExtensionRequest::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + containing_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + extension_number_ = 0; +} + +ExtensionRequest::~ExtensionRequest() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ExtensionRequest) + SharedDtor(); +} + +void ExtensionRequest::SharedDtor() { + containing_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + } +} + +void ExtensionRequest::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ExtensionRequest::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ExtensionRequest_descriptor_; +} + +const ExtensionRequest& ExtensionRequest::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ExtensionRequest* ExtensionRequest::default_instance_ = NULL; + +ExtensionRequest* ExtensionRequest::New(::google::protobuf::Arena* arena) const { + ExtensionRequest* n = new ExtensionRequest; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ExtensionRequest::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ExtensionRequest) + containing_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + extension_number_ = 0; +} + +bool ExtensionRequest::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ExtensionRequest) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string containing_type = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_containing_type())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->containing_type().data(), this->containing_type().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ExtensionRequest.containing_type")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(16)) goto parse_extension_number; + break; + } + + // optional int32 extension_number = 2; + case 2: { + if (tag == 16) { + parse_extension_number: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &extension_number_))); + + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ExtensionRequest) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ExtensionRequest) + return false; +#undef DO_ +} + +void ExtensionRequest::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ExtensionRequest) + // optional string containing_type = 1; + if (this->containing_type().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->containing_type().data(), this->containing_type().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ExtensionRequest.containing_type"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->containing_type(), output); + } + + // optional int32 extension_number = 2; + if (this->extension_number() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->extension_number(), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ExtensionRequest) +} + +::google::protobuf::uint8* ExtensionRequest::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ExtensionRequest) + // optional string containing_type = 1; + if (this->containing_type().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->containing_type().data(), this->containing_type().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ExtensionRequest.containing_type"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->containing_type(), target); + } + + // optional int32 extension_number = 2; + if (this->extension_number() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->extension_number(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ExtensionRequest) + return target; +} + +int ExtensionRequest::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ExtensionRequest) + int total_size = 0; + + // optional string containing_type = 1; + if (this->containing_type().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->containing_type()); + } + + // optional int32 extension_number = 2; + if (this->extension_number() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->extension_number()); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ExtensionRequest::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ExtensionRequest) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ExtensionRequest* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ExtensionRequest) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ExtensionRequest) + MergeFrom(*source); + } +} + +void ExtensionRequest::MergeFrom(const ExtensionRequest& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ExtensionRequest) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.containing_type().size() > 0) { + + containing_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.containing_type_); + } + if (from.extension_number() != 0) { + set_extension_number(from.extension_number()); + } +} + +void ExtensionRequest::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ExtensionRequest) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ExtensionRequest::CopyFrom(const ExtensionRequest& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ExtensionRequest) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ExtensionRequest::IsInitialized() const { + + return true; +} + +void ExtensionRequest::Swap(ExtensionRequest* other) { + if (other == this) return; + InternalSwap(other); +} +void ExtensionRequest::InternalSwap(ExtensionRequest* other) { + containing_type_.Swap(&other->containing_type_); + std::swap(extension_number_, other->extension_number_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ExtensionRequest::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ExtensionRequest_descriptor_; + metadata.reflection = ExtensionRequest_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ExtensionRequest + +// optional string containing_type = 1; +void ExtensionRequest::clear_containing_type() { + containing_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + const ::std::string& ExtensionRequest::containing_type() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionRequest.containing_type) + return containing_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ExtensionRequest::set_containing_type(const ::std::string& value) { + + containing_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} + void ExtensionRequest::set_containing_type(const char* value) { + + containing_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} + void ExtensionRequest::set_containing_type(const char* value, size_t size) { + + containing_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} + ::std::string* ExtensionRequest::mutable_containing_type() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ExtensionRequest.containing_type) + return containing_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ExtensionRequest::release_containing_type() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ExtensionRequest.containing_type) + + return containing_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ExtensionRequest::set_allocated_containing_type(::std::string* containing_type) { + if (containing_type != NULL) { + + } else { + + } + containing_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), containing_type); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ExtensionRequest.containing_type) +} + +// optional int32 extension_number = 2; +void ExtensionRequest::clear_extension_number() { + extension_number_ = 0; +} + ::google::protobuf::int32 ExtensionRequest::extension_number() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionRequest.extension_number) + return extension_number_; +} + void ExtensionRequest::set_extension_number(::google::protobuf::int32 value) { + + extension_number_ = value; + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionRequest.extension_number) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ServerReflectionResponse::kValidHostFieldNumber; +const int ServerReflectionResponse::kOriginalRequestFieldNumber; +const int ServerReflectionResponse::kFileDescriptorResponseFieldNumber; +const int ServerReflectionResponse::kAllExtensionNumbersResponseFieldNumber; +const int ServerReflectionResponse::kListServicesResponseFieldNumber; +const int ServerReflectionResponse::kErrorResponseFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ServerReflectionResponse::ServerReflectionResponse() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ServerReflectionResponse) +} + +void ServerReflectionResponse::InitAsDefaultInstance() { + _is_default_instance_ = true; + original_request_ = const_cast< ::grpc::reflection::v1alpha::ServerReflectionRequest*>(&::grpc::reflection::v1alpha::ServerReflectionRequest::default_instance()); + ServerReflectionResponse_default_oneof_instance_->file_descriptor_response_ = const_cast< ::grpc::reflection::v1alpha::FileDescriptorResponse*>(&::grpc::reflection::v1alpha::FileDescriptorResponse::default_instance()); + ServerReflectionResponse_default_oneof_instance_->all_extension_numbers_response_ = const_cast< ::grpc::reflection::v1alpha::ExtensionNumberResponse*>(&::grpc::reflection::v1alpha::ExtensionNumberResponse::default_instance()); + ServerReflectionResponse_default_oneof_instance_->list_services_response_ = const_cast< ::grpc::reflection::v1alpha::ListServiceResponse*>(&::grpc::reflection::v1alpha::ListServiceResponse::default_instance()); + ServerReflectionResponse_default_oneof_instance_->error_response_ = const_cast< ::grpc::reflection::v1alpha::ErrorResponse*>(&::grpc::reflection::v1alpha::ErrorResponse::default_instance()); +} + +ServerReflectionResponse::ServerReflectionResponse(const ServerReflectionResponse& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ServerReflectionResponse) +} + +void ServerReflectionResponse::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + valid_host_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + original_request_ = NULL; + clear_has_message_response(); +} + +ServerReflectionResponse::~ServerReflectionResponse() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ServerReflectionResponse) + SharedDtor(); +} + +void ServerReflectionResponse::SharedDtor() { + valid_host_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (has_message_response()) { + clear_message_response(); + } + if (this != default_instance_) { + delete original_request_; + } +} + +void ServerReflectionResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ServerReflectionResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ServerReflectionResponse_descriptor_; +} + +const ServerReflectionResponse& ServerReflectionResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ServerReflectionResponse* ServerReflectionResponse::default_instance_ = NULL; + +ServerReflectionResponse* ServerReflectionResponse::New(::google::protobuf::Arena* arena) const { + ServerReflectionResponse* n = new ServerReflectionResponse; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ServerReflectionResponse::clear_message_response() { +// @@protoc_insertion_point(one_of_clear_start:grpc.reflection.v1alpha.ServerReflectionResponse) + switch(message_response_case()) { + case kFileDescriptorResponse: { + delete message_response_.file_descriptor_response_; + break; + } + case kAllExtensionNumbersResponse: { + delete message_response_.all_extension_numbers_response_; + break; + } + case kListServicesResponse: { + delete message_response_.list_services_response_; + break; + } + case kErrorResponse: { + delete message_response_.error_response_; + break; + } + case MESSAGE_RESPONSE_NOT_SET: { + break; + } + } + _oneof_case_[0] = MESSAGE_RESPONSE_NOT_SET; +} + + +void ServerReflectionResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ServerReflectionResponse) + valid_host_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (GetArenaNoVirtual() == NULL && original_request_ != NULL) delete original_request_; + original_request_ = NULL; + clear_message_response(); +} + +bool ServerReflectionResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ServerReflectionResponse) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string valid_host = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_valid_host())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->valid_host().data(), this->valid_host().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServerReflectionResponse.valid_host")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_original_request; + break; + } + + // optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; + case 2: { + if (tag == 18) { + parse_original_request: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_original_request())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(34)) goto parse_file_descriptor_response; + break; + } + + // optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; + case 4: { + if (tag == 34) { + parse_file_descriptor_response: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_file_descriptor_response())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(42)) goto parse_all_extension_numbers_response; + break; + } + + // optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; + case 5: { + if (tag == 42) { + parse_all_extension_numbers_response: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_all_extension_numbers_response())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(50)) goto parse_list_services_response; + break; + } + + // optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; + case 6: { + if (tag == 50) { + parse_list_services_response: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_list_services_response())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(58)) goto parse_error_response; + break; + } + + // optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; + case 7: { + if (tag == 58) { + parse_error_response: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_error_response())); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ServerReflectionResponse) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ServerReflectionResponse) + return false; +#undef DO_ +} + +void ServerReflectionResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ServerReflectionResponse) + // optional string valid_host = 1; + if (this->valid_host().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->valid_host().data(), this->valid_host().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionResponse.valid_host"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->valid_host(), output); + } + + // optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; + if (this->has_original_request()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 2, *this->original_request_, output); + } + + // optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; + if (has_file_descriptor_response()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 4, *message_response_.file_descriptor_response_, output); + } + + // optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; + if (has_all_extension_numbers_response()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 5, *message_response_.all_extension_numbers_response_, output); + } + + // optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; + if (has_list_services_response()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 6, *message_response_.list_services_response_, output); + } + + // optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; + if (has_error_response()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 7, *message_response_.error_response_, output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ServerReflectionResponse) +} + +::google::protobuf::uint8* ServerReflectionResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ServerReflectionResponse) + // optional string valid_host = 1; + if (this->valid_host().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->valid_host().data(), this->valid_host().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServerReflectionResponse.valid_host"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->valid_host(), target); + } + + // optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; + if (this->has_original_request()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 2, *this->original_request_, target); + } + + // optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; + if (has_file_descriptor_response()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 4, *message_response_.file_descriptor_response_, target); + } + + // optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; + if (has_all_extension_numbers_response()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 5, *message_response_.all_extension_numbers_response_, target); + } + + // optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; + if (has_list_services_response()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 6, *message_response_.list_services_response_, target); + } + + // optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; + if (has_error_response()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 7, *message_response_.error_response_, target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ServerReflectionResponse) + return target; +} + +int ServerReflectionResponse::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ServerReflectionResponse) + int total_size = 0; + + // optional string valid_host = 1; + if (this->valid_host().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->valid_host()); + } + + // optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; + if (this->has_original_request()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->original_request_); + } + + switch (message_response_case()) { + // optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; + case kFileDescriptorResponse: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *message_response_.file_descriptor_response_); + break; + } + // optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; + case kAllExtensionNumbersResponse: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *message_response_.all_extension_numbers_response_); + break; + } + // optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; + case kListServicesResponse: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *message_response_.list_services_response_); + break; + } + // optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; + case kErrorResponse: { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *message_response_.error_response_); + break; + } + case MESSAGE_RESPONSE_NOT_SET: { + break; + } + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ServerReflectionResponse::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ServerReflectionResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServerReflectionResponse* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ServerReflectionResponse) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ServerReflectionResponse) + MergeFrom(*source); + } +} + +void ServerReflectionResponse::MergeFrom(const ServerReflectionResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ServerReflectionResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + switch (from.message_response_case()) { + case kFileDescriptorResponse: { + mutable_file_descriptor_response()->::grpc::reflection::v1alpha::FileDescriptorResponse::MergeFrom(from.file_descriptor_response()); + break; + } + case kAllExtensionNumbersResponse: { + mutable_all_extension_numbers_response()->::grpc::reflection::v1alpha::ExtensionNumberResponse::MergeFrom(from.all_extension_numbers_response()); + break; + } + case kListServicesResponse: { + mutable_list_services_response()->::grpc::reflection::v1alpha::ListServiceResponse::MergeFrom(from.list_services_response()); + break; + } + case kErrorResponse: { + mutable_error_response()->::grpc::reflection::v1alpha::ErrorResponse::MergeFrom(from.error_response()); + break; + } + case MESSAGE_RESPONSE_NOT_SET: { + break; + } + } + if (from.valid_host().size() > 0) { + + valid_host_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.valid_host_); + } + if (from.has_original_request()) { + mutable_original_request()->::grpc::reflection::v1alpha::ServerReflectionRequest::MergeFrom(from.original_request()); + } +} + +void ServerReflectionResponse::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ServerReflectionResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ServerReflectionResponse::CopyFrom(const ServerReflectionResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ServerReflectionResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ServerReflectionResponse::IsInitialized() const { + + return true; +} + +void ServerReflectionResponse::Swap(ServerReflectionResponse* other) { + if (other == this) return; + InternalSwap(other); +} +void ServerReflectionResponse::InternalSwap(ServerReflectionResponse* other) { + valid_host_.Swap(&other->valid_host_); + std::swap(original_request_, other->original_request_); + std::swap(message_response_, other->message_response_); + std::swap(_oneof_case_[0], other->_oneof_case_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ServerReflectionResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ServerReflectionResponse_descriptor_; + metadata.reflection = ServerReflectionResponse_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ServerReflectionResponse + +// optional string valid_host = 1; +void ServerReflectionResponse::clear_valid_host() { + valid_host_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + const ::std::string& ServerReflectionResponse::valid_host() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) + return valid_host_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ServerReflectionResponse::set_valid_host(const ::std::string& value) { + + valid_host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} + void ServerReflectionResponse::set_valid_host(const char* value) { + + valid_host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} + void ServerReflectionResponse::set_valid_host(const char* value, size_t size) { + + valid_host_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} + ::std::string* ServerReflectionResponse::mutable_valid_host() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) + return valid_host_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServerReflectionResponse::release_valid_host() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) + + return valid_host_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ServerReflectionResponse::set_allocated_valid_host(::std::string* valid_host) { + if (valid_host != NULL) { + + } else { + + } + valid_host_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), valid_host); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.valid_host) +} + +// optional .grpc.reflection.v1alpha.ServerReflectionRequest original_request = 2; +bool ServerReflectionResponse::has_original_request() const { + return !_is_default_instance_ && original_request_ != NULL; +} +void ServerReflectionResponse::clear_original_request() { + if (GetArenaNoVirtual() == NULL && original_request_ != NULL) delete original_request_; + original_request_ = NULL; +} +const ::grpc::reflection::v1alpha::ServerReflectionRequest& ServerReflectionResponse::original_request() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) + return original_request_ != NULL ? *original_request_ : *default_instance_->original_request_; +} +::grpc::reflection::v1alpha::ServerReflectionRequest* ServerReflectionResponse::mutable_original_request() { + + if (original_request_ == NULL) { + original_request_ = new ::grpc::reflection::v1alpha::ServerReflectionRequest; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) + return original_request_; +} +::grpc::reflection::v1alpha::ServerReflectionRequest* ServerReflectionResponse::release_original_request() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) + + ::grpc::reflection::v1alpha::ServerReflectionRequest* temp = original_request_; + original_request_ = NULL; + return temp; +} +void ServerReflectionResponse::set_allocated_original_request(::grpc::reflection::v1alpha::ServerReflectionRequest* original_request) { + delete original_request_; + original_request_ = original_request; + if (original_request) { + + } else { + + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.original_request) +} + +// optional .grpc.reflection.v1alpha.FileDescriptorResponse file_descriptor_response = 4; +bool ServerReflectionResponse::has_file_descriptor_response() const { + return message_response_case() == kFileDescriptorResponse; +} +void ServerReflectionResponse::set_has_file_descriptor_response() { + _oneof_case_[0] = kFileDescriptorResponse; +} +void ServerReflectionResponse::clear_file_descriptor_response() { + if (has_file_descriptor_response()) { + delete message_response_.file_descriptor_response_; + clear_has_message_response(); + } +} + const ::grpc::reflection::v1alpha::FileDescriptorResponse& ServerReflectionResponse::file_descriptor_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) + return has_file_descriptor_response() + ? *message_response_.file_descriptor_response_ + : ::grpc::reflection::v1alpha::FileDescriptorResponse::default_instance(); +} +::grpc::reflection::v1alpha::FileDescriptorResponse* ServerReflectionResponse::mutable_file_descriptor_response() { + if (!has_file_descriptor_response()) { + clear_message_response(); + set_has_file_descriptor_response(); + message_response_.file_descriptor_response_ = new ::grpc::reflection::v1alpha::FileDescriptorResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) + return message_response_.file_descriptor_response_; +} +::grpc::reflection::v1alpha::FileDescriptorResponse* ServerReflectionResponse::release_file_descriptor_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) + if (has_file_descriptor_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::FileDescriptorResponse* temp = message_response_.file_descriptor_response_; + message_response_.file_descriptor_response_ = NULL; + return temp; + } else { + return NULL; + } +} +void ServerReflectionResponse::set_allocated_file_descriptor_response(::grpc::reflection::v1alpha::FileDescriptorResponse* file_descriptor_response) { + clear_message_response(); + if (file_descriptor_response) { + set_has_file_descriptor_response(); + message_response_.file_descriptor_response_ = file_descriptor_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response) +} + +// optional .grpc.reflection.v1alpha.ExtensionNumberResponse all_extension_numbers_response = 5; +bool ServerReflectionResponse::has_all_extension_numbers_response() const { + return message_response_case() == kAllExtensionNumbersResponse; +} +void ServerReflectionResponse::set_has_all_extension_numbers_response() { + _oneof_case_[0] = kAllExtensionNumbersResponse; +} +void ServerReflectionResponse::clear_all_extension_numbers_response() { + if (has_all_extension_numbers_response()) { + delete message_response_.all_extension_numbers_response_; + clear_has_message_response(); + } +} + const ::grpc::reflection::v1alpha::ExtensionNumberResponse& ServerReflectionResponse::all_extension_numbers_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) + return has_all_extension_numbers_response() + ? *message_response_.all_extension_numbers_response_ + : ::grpc::reflection::v1alpha::ExtensionNumberResponse::default_instance(); +} +::grpc::reflection::v1alpha::ExtensionNumberResponse* ServerReflectionResponse::mutable_all_extension_numbers_response() { + if (!has_all_extension_numbers_response()) { + clear_message_response(); + set_has_all_extension_numbers_response(); + message_response_.all_extension_numbers_response_ = new ::grpc::reflection::v1alpha::ExtensionNumberResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) + return message_response_.all_extension_numbers_response_; +} +::grpc::reflection::v1alpha::ExtensionNumberResponse* ServerReflectionResponse::release_all_extension_numbers_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) + if (has_all_extension_numbers_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::ExtensionNumberResponse* temp = message_response_.all_extension_numbers_response_; + message_response_.all_extension_numbers_response_ = NULL; + return temp; + } else { + return NULL; + } +} +void ServerReflectionResponse::set_allocated_all_extension_numbers_response(::grpc::reflection::v1alpha::ExtensionNumberResponse* all_extension_numbers_response) { + clear_message_response(); + if (all_extension_numbers_response) { + set_has_all_extension_numbers_response(); + message_response_.all_extension_numbers_response_ = all_extension_numbers_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response) +} + +// optional .grpc.reflection.v1alpha.ListServiceResponse list_services_response = 6; +bool ServerReflectionResponse::has_list_services_response() const { + return message_response_case() == kListServicesResponse; +} +void ServerReflectionResponse::set_has_list_services_response() { + _oneof_case_[0] = kListServicesResponse; +} +void ServerReflectionResponse::clear_list_services_response() { + if (has_list_services_response()) { + delete message_response_.list_services_response_; + clear_has_message_response(); + } +} + const ::grpc::reflection::v1alpha::ListServiceResponse& ServerReflectionResponse::list_services_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) + return has_list_services_response() + ? *message_response_.list_services_response_ + : ::grpc::reflection::v1alpha::ListServiceResponse::default_instance(); +} +::grpc::reflection::v1alpha::ListServiceResponse* ServerReflectionResponse::mutable_list_services_response() { + if (!has_list_services_response()) { + clear_message_response(); + set_has_list_services_response(); + message_response_.list_services_response_ = new ::grpc::reflection::v1alpha::ListServiceResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) + return message_response_.list_services_response_; +} +::grpc::reflection::v1alpha::ListServiceResponse* ServerReflectionResponse::release_list_services_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) + if (has_list_services_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::ListServiceResponse* temp = message_response_.list_services_response_; + message_response_.list_services_response_ = NULL; + return temp; + } else { + return NULL; + } +} +void ServerReflectionResponse::set_allocated_list_services_response(::grpc::reflection::v1alpha::ListServiceResponse* list_services_response) { + clear_message_response(); + if (list_services_response) { + set_has_list_services_response(); + message_response_.list_services_response_ = list_services_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response) +} + +// optional .grpc.reflection.v1alpha.ErrorResponse error_response = 7; +bool ServerReflectionResponse::has_error_response() const { + return message_response_case() == kErrorResponse; +} +void ServerReflectionResponse::set_has_error_response() { + _oneof_case_[0] = kErrorResponse; +} +void ServerReflectionResponse::clear_error_response() { + if (has_error_response()) { + delete message_response_.error_response_; + clear_has_message_response(); + } +} + const ::grpc::reflection::v1alpha::ErrorResponse& ServerReflectionResponse::error_response() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) + return has_error_response() + ? *message_response_.error_response_ + : ::grpc::reflection::v1alpha::ErrorResponse::default_instance(); +} +::grpc::reflection::v1alpha::ErrorResponse* ServerReflectionResponse::mutable_error_response() { + if (!has_error_response()) { + clear_message_response(); + set_has_error_response(); + message_response_.error_response_ = new ::grpc::reflection::v1alpha::ErrorResponse; + } + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) + return message_response_.error_response_; +} +::grpc::reflection::v1alpha::ErrorResponse* ServerReflectionResponse::release_error_response() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) + if (has_error_response()) { + clear_has_message_response(); + ::grpc::reflection::v1alpha::ErrorResponse* temp = message_response_.error_response_; + message_response_.error_response_ = NULL; + return temp; + } else { + return NULL; + } +} +void ServerReflectionResponse::set_allocated_error_response(::grpc::reflection::v1alpha::ErrorResponse* error_response) { + clear_message_response(); + if (error_response) { + set_has_error_response(); + message_response_.error_response_ = error_response; + } + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServerReflectionResponse.error_response) +} + +bool ServerReflectionResponse::has_message_response() const { + return message_response_case() != MESSAGE_RESPONSE_NOT_SET; +} +void ServerReflectionResponse::clear_has_message_response() { + _oneof_case_[0] = MESSAGE_RESPONSE_NOT_SET; +} +ServerReflectionResponse::MessageResponseCase ServerReflectionResponse::message_response_case() const { + return ServerReflectionResponse::MessageResponseCase(_oneof_case_[0]); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int FileDescriptorResponse::kFileDescriptorProtoFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +FileDescriptorResponse::FileDescriptorResponse() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.FileDescriptorResponse) +} + +void FileDescriptorResponse::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +FileDescriptorResponse::FileDescriptorResponse(const FileDescriptorResponse& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.FileDescriptorResponse) +} + +void FileDescriptorResponse::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; +} + +FileDescriptorResponse::~FileDescriptorResponse() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.FileDescriptorResponse) + SharedDtor(); +} + +void FileDescriptorResponse::SharedDtor() { + if (this != default_instance_) { + } +} + +void FileDescriptorResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* FileDescriptorResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return FileDescriptorResponse_descriptor_; +} + +const FileDescriptorResponse& FileDescriptorResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +FileDescriptorResponse* FileDescriptorResponse::default_instance_ = NULL; + +FileDescriptorResponse* FileDescriptorResponse::New(::google::protobuf::Arena* arena) const { + FileDescriptorResponse* n = new FileDescriptorResponse; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void FileDescriptorResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.FileDescriptorResponse) + file_descriptor_proto_.Clear(); +} + +bool FileDescriptorResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.FileDescriptorResponse) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated bytes file_descriptor_proto = 1; + case 1: { + if (tag == 10) { + parse_file_descriptor_proto: + DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( + input, this->add_file_descriptor_proto())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(10)) goto parse_file_descriptor_proto; + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.FileDescriptorResponse) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.FileDescriptorResponse) + return false; +#undef DO_ +} + +void FileDescriptorResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.FileDescriptorResponse) + // repeated bytes file_descriptor_proto = 1; + for (int i = 0; i < this->file_descriptor_proto_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteBytes( + 1, this->file_descriptor_proto(i), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.FileDescriptorResponse) +} + +::google::protobuf::uint8* FileDescriptorResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.FileDescriptorResponse) + // repeated bytes file_descriptor_proto = 1; + for (int i = 0; i < this->file_descriptor_proto_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteBytesToArray(1, this->file_descriptor_proto(i), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.FileDescriptorResponse) + return target; +} + +int FileDescriptorResponse::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.FileDescriptorResponse) + int total_size = 0; + + // repeated bytes file_descriptor_proto = 1; + total_size += 1 * this->file_descriptor_proto_size(); + for (int i = 0; i < this->file_descriptor_proto_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::BytesSize( + this->file_descriptor_proto(i)); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void FileDescriptorResponse::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.FileDescriptorResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileDescriptorResponse* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.FileDescriptorResponse) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.FileDescriptorResponse) + MergeFrom(*source); + } +} + +void FileDescriptorResponse::MergeFrom(const FileDescriptorResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.FileDescriptorResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + file_descriptor_proto_.MergeFrom(from.file_descriptor_proto_); +} + +void FileDescriptorResponse::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.FileDescriptorResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void FileDescriptorResponse::CopyFrom(const FileDescriptorResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.FileDescriptorResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool FileDescriptorResponse::IsInitialized() const { + + return true; +} + +void FileDescriptorResponse::Swap(FileDescriptorResponse* other) { + if (other == this) return; + InternalSwap(other); +} +void FileDescriptorResponse::InternalSwap(FileDescriptorResponse* other) { + file_descriptor_proto_.UnsafeArenaSwap(&other->file_descriptor_proto_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata FileDescriptorResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = FileDescriptorResponse_descriptor_; + metadata.reflection = FileDescriptorResponse_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// FileDescriptorResponse + +// repeated bytes file_descriptor_proto = 1; +int FileDescriptorResponse::file_descriptor_proto_size() const { + return file_descriptor_proto_.size(); +} +void FileDescriptorResponse::clear_file_descriptor_proto() { + file_descriptor_proto_.Clear(); +} + const ::std::string& FileDescriptorResponse::file_descriptor_proto(int index) const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_.Get(index); +} + ::std::string* FileDescriptorResponse::mutable_file_descriptor_proto(int index) { + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_.Mutable(index); +} + void FileDescriptorResponse::set_file_descriptor_proto(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + file_descriptor_proto_.Mutable(index)->assign(value); +} + void FileDescriptorResponse::set_file_descriptor_proto(int index, const char* value) { + file_descriptor_proto_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} + void FileDescriptorResponse::set_file_descriptor_proto(int index, const void* value, size_t size) { + file_descriptor_proto_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} + ::std::string* FileDescriptorResponse::add_file_descriptor_proto() { + // @@protoc_insertion_point(field_add_mutable:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_.Add(); +} + void FileDescriptorResponse::add_file_descriptor_proto(const ::std::string& value) { + file_descriptor_proto_.Add()->assign(value); + // @@protoc_insertion_point(field_add:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} + void FileDescriptorResponse::add_file_descriptor_proto(const char* value) { + file_descriptor_proto_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} + void FileDescriptorResponse::add_file_descriptor_proto(const void* value, size_t size) { + file_descriptor_proto_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) +} + const ::google::protobuf::RepeatedPtrField< ::std::string>& +FileDescriptorResponse::file_descriptor_proto() const { + // @@protoc_insertion_point(field_list:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return file_descriptor_proto_; +} + ::google::protobuf::RepeatedPtrField< ::std::string>* +FileDescriptorResponse::mutable_file_descriptor_proto() { + // @@protoc_insertion_point(field_mutable_list:grpc.reflection.v1alpha.FileDescriptorResponse.file_descriptor_proto) + return &file_descriptor_proto_; +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ExtensionNumberResponse::kBaseTypeNameFieldNumber; +const int ExtensionNumberResponse::kExtensionNumberFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ExtensionNumberResponse::ExtensionNumberResponse() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ExtensionNumberResponse) +} + +void ExtensionNumberResponse::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +ExtensionNumberResponse::ExtensionNumberResponse(const ExtensionNumberResponse& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ExtensionNumberResponse) +} + +void ExtensionNumberResponse::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + base_type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +ExtensionNumberResponse::~ExtensionNumberResponse() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ExtensionNumberResponse) + SharedDtor(); +} + +void ExtensionNumberResponse::SharedDtor() { + base_type_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + } +} + +void ExtensionNumberResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ExtensionNumberResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ExtensionNumberResponse_descriptor_; +} + +const ExtensionNumberResponse& ExtensionNumberResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ExtensionNumberResponse* ExtensionNumberResponse::default_instance_ = NULL; + +ExtensionNumberResponse* ExtensionNumberResponse::New(::google::protobuf::Arena* arena) const { + ExtensionNumberResponse* n = new ExtensionNumberResponse; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ExtensionNumberResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + base_type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + extension_number_.Clear(); +} + +bool ExtensionNumberResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string base_type_name = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_base_type_name())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->base_type_name().data(), this->base_type_name().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name")); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_extension_number; + break; + } + + // repeated int32 extension_number = 2; + case 2: { + if (tag == 18) { + parse_extension_number: + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, this->mutable_extension_number()))); + } else if (tag == 16) { + DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + 1, 18, input, this->mutable_extension_number()))); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ExtensionNumberResponse) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ExtensionNumberResponse) + return false; +#undef DO_ +} + +void ExtensionNumberResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + // optional string base_type_name = 1; + if (this->base_type_name().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->base_type_name().data(), this->base_type_name().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->base_type_name(), output); + } + + // repeated int32 extension_number = 2; + if (this->extension_number_size() > 0) { + ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); + output->WriteVarint32(_extension_number_cached_byte_size_); + } + for (int i = 0; i < this->extension_number_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( + this->extension_number(i), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ExtensionNumberResponse) +} + +::google::protobuf::uint8* ExtensionNumberResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + // optional string base_type_name = 1; + if (this->base_type_name().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->base_type_name().data(), this->base_type_name().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->base_type_name(), target); + } + + // repeated int32 extension_number = 2; + if (this->extension_number_size() > 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( + 2, + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, + target); + target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( + _extension_number_cached_byte_size_, target); + } + for (int i = 0; i < this->extension_number_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteInt32NoTagToArray(this->extension_number(i), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ExtensionNumberResponse) + return target; +} + +int ExtensionNumberResponse::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + int total_size = 0; + + // optional string base_type_name = 1; + if (this->base_type_name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->base_type_name()); + } + + // repeated int32 extension_number = 2; + { + int data_size = 0; + for (int i = 0; i < this->extension_number_size(); i++) { + data_size += ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->extension_number(i)); + } + if (data_size > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _extension_number_cached_byte_size_ = data_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + total_size += data_size; + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ExtensionNumberResponse::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ExtensionNumberResponse* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ExtensionNumberResponse) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ExtensionNumberResponse) + MergeFrom(*source); + } +} + +void ExtensionNumberResponse::MergeFrom(const ExtensionNumberResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + extension_number_.MergeFrom(from.extension_number_); + if (from.base_type_name().size() > 0) { + + base_type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.base_type_name_); + } +} + +void ExtensionNumberResponse::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ExtensionNumberResponse::CopyFrom(const ExtensionNumberResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ExtensionNumberResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ExtensionNumberResponse::IsInitialized() const { + + return true; +} + +void ExtensionNumberResponse::Swap(ExtensionNumberResponse* other) { + if (other == this) return; + InternalSwap(other); +} +void ExtensionNumberResponse::InternalSwap(ExtensionNumberResponse* other) { + base_type_name_.Swap(&other->base_type_name_); + extension_number_.UnsafeArenaSwap(&other->extension_number_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ExtensionNumberResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ExtensionNumberResponse_descriptor_; + metadata.reflection = ExtensionNumberResponse_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ExtensionNumberResponse + +// optional string base_type_name = 1; +void ExtensionNumberResponse::clear_base_type_name() { + base_type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + const ::std::string& ExtensionNumberResponse::base_type_name() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) + return base_type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ExtensionNumberResponse::set_base_type_name(const ::std::string& value) { + + base_type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} + void ExtensionNumberResponse::set_base_type_name(const char* value) { + + base_type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} + void ExtensionNumberResponse::set_base_type_name(const char* value, size_t size) { + + base_type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} + ::std::string* ExtensionNumberResponse::mutable_base_type_name() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) + return base_type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ExtensionNumberResponse::release_base_type_name() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) + + return base_type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ExtensionNumberResponse::set_allocated_base_type_name(::std::string* base_type_name) { + if (base_type_name != NULL) { + + } else { + + } + base_type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), base_type_name); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ExtensionNumberResponse.base_type_name) +} + +// repeated int32 extension_number = 2; +int ExtensionNumberResponse::extension_number_size() const { + return extension_number_.size(); +} +void ExtensionNumberResponse::clear_extension_number() { + extension_number_.Clear(); +} + ::google::protobuf::int32 ExtensionNumberResponse::extension_number(int index) const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) + return extension_number_.Get(index); +} + void ExtensionNumberResponse::set_extension_number(int index, ::google::protobuf::int32 value) { + extension_number_.Set(index, value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) +} + void ExtensionNumberResponse::add_extension_number(::google::protobuf::int32 value) { + extension_number_.Add(value); + // @@protoc_insertion_point(field_add:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) +} + const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +ExtensionNumberResponse::extension_number() const { + // @@protoc_insertion_point(field_list:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) + return extension_number_; +} + ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +ExtensionNumberResponse::mutable_extension_number() { + // @@protoc_insertion_point(field_mutable_list:grpc.reflection.v1alpha.ExtensionNumberResponse.extension_number) + return &extension_number_; +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ListServiceResponse::kServiceFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ListServiceResponse::ListServiceResponse() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ListServiceResponse) +} + +void ListServiceResponse::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +ListServiceResponse::ListServiceResponse(const ListServiceResponse& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ListServiceResponse) +} + +void ListServiceResponse::SharedCtor() { + _is_default_instance_ = false; + _cached_size_ = 0; +} + +ListServiceResponse::~ListServiceResponse() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ListServiceResponse) + SharedDtor(); +} + +void ListServiceResponse::SharedDtor() { + if (this != default_instance_) { + } +} + +void ListServiceResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ListServiceResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ListServiceResponse_descriptor_; +} + +const ListServiceResponse& ListServiceResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ListServiceResponse* ListServiceResponse::default_instance_ = NULL; + +ListServiceResponse* ListServiceResponse::New(::google::protobuf::Arena* arena) const { + ListServiceResponse* n = new ListServiceResponse; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ListServiceResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ListServiceResponse) + service_.Clear(); +} + +bool ListServiceResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ListServiceResponse) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; + case 1: { + if (tag == 10) { + DO_(input->IncrementRecursionDepth()); + parse_loop_service: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_service())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(10)) goto parse_loop_service; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ListServiceResponse) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ListServiceResponse) + return false; +#undef DO_ +} + +void ListServiceResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ListServiceResponse) + // repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; + for (unsigned int i = 0, n = this->service_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, this->service(i), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ListServiceResponse) +} + +::google::protobuf::uint8* ListServiceResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ListServiceResponse) + // repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; + for (unsigned int i = 0, n = this->service_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 1, this->service(i), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ListServiceResponse) + return target; +} + +int ListServiceResponse::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ListServiceResponse) + int total_size = 0; + + // repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; + total_size += 1 * this->service_size(); + for (int i = 0; i < this->service_size(); i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->service(i)); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ListServiceResponse::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ListServiceResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ListServiceResponse* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ListServiceResponse) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ListServiceResponse) + MergeFrom(*source); + } +} + +void ListServiceResponse::MergeFrom(const ListServiceResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ListServiceResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + service_.MergeFrom(from.service_); +} + +void ListServiceResponse::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ListServiceResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ListServiceResponse::CopyFrom(const ListServiceResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ListServiceResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ListServiceResponse::IsInitialized() const { + + return true; +} + +void ListServiceResponse::Swap(ListServiceResponse* other) { + if (other == this) return; + InternalSwap(other); +} +void ListServiceResponse::InternalSwap(ListServiceResponse* other) { + service_.UnsafeArenaSwap(&other->service_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ListServiceResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ListServiceResponse_descriptor_; + metadata.reflection = ListServiceResponse_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ListServiceResponse + +// repeated .grpc.reflection.v1alpha.ServiceResponse service = 1; +int ListServiceResponse::service_size() const { + return service_.size(); +} +void ListServiceResponse::clear_service() { + service_.Clear(); +} +const ::grpc::reflection::v1alpha::ServiceResponse& ListServiceResponse::service(int index) const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_.Get(index); +} +::grpc::reflection::v1alpha::ServiceResponse* ListServiceResponse::mutable_service(int index) { + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_.Mutable(index); +} +::grpc::reflection::v1alpha::ServiceResponse* ListServiceResponse::add_service() { + // @@protoc_insertion_point(field_add:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_.Add(); +} +::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse >* +ListServiceResponse::mutable_service() { + // @@protoc_insertion_point(field_mutable_list:grpc.reflection.v1alpha.ListServiceResponse.service) + return &service_; +} +const ::google::protobuf::RepeatedPtrField< ::grpc::reflection::v1alpha::ServiceResponse >& +ListServiceResponse::service() const { + // @@protoc_insertion_point(field_list:grpc.reflection.v1alpha.ListServiceResponse.service) + return service_; +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ServiceResponse::kNameFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ServiceResponse::ServiceResponse() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ServiceResponse) +} + +void ServiceResponse::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +ServiceResponse::ServiceResponse(const ServiceResponse& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ServiceResponse) +} + +void ServiceResponse::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +ServiceResponse::~ServiceResponse() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ServiceResponse) + SharedDtor(); +} + +void ServiceResponse::SharedDtor() { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + } +} + +void ServiceResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ServiceResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ServiceResponse_descriptor_; +} + +const ServiceResponse& ServiceResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ServiceResponse* ServiceResponse::default_instance_ = NULL; + +ServiceResponse* ServiceResponse::New(::google::protobuf::Arena* arena) const { + ServiceResponse* n = new ServiceResponse; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ServiceResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ServiceResponse) + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +bool ServiceResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ServiceResponse) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string name = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_name())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ServiceResponse.name")); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ServiceResponse) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ServiceResponse) + return false; +#undef DO_ +} + +void ServiceResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ServiceResponse) + // optional string name = 1; + if (this->name().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServiceResponse.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->name(), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ServiceResponse) +} + +::google::protobuf::uint8* ServiceResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ServiceResponse) + // optional string name = 1; + if (this->name().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ServiceResponse.name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->name(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ServiceResponse) + return target; +} + +int ServiceResponse::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ServiceResponse) + int total_size = 0; + + // optional string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ServiceResponse::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ServiceResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServiceResponse* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ServiceResponse) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ServiceResponse) + MergeFrom(*source); + } +} + +void ServiceResponse::MergeFrom(const ServiceResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ServiceResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.name().size() > 0) { + + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } +} + +void ServiceResponse::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ServiceResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ServiceResponse::CopyFrom(const ServiceResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ServiceResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ServiceResponse::IsInitialized() const { + + return true; +} + +void ServiceResponse::Swap(ServiceResponse* other) { + if (other == this) return; + InternalSwap(other); +} +void ServiceResponse::InternalSwap(ServiceResponse* other) { + name_.Swap(&other->name_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ServiceResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ServiceResponse_descriptor_; + metadata.reflection = ServiceResponse_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ServiceResponse + +// optional string name = 1; +void ServiceResponse::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + const ::std::string& ServiceResponse::name() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ServiceResponse.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ServiceResponse::set_name(const ::std::string& value) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ServiceResponse.name) +} + void ServiceResponse::set_name(const char* value) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ServiceResponse.name) +} + void ServiceResponse::set_name(const char* value, size_t size) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ServiceResponse.name) +} + ::std::string* ServiceResponse::mutable_name() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ServiceResponse.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ServiceResponse::release_name() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ServiceResponse.name) + + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ServiceResponse::set_allocated_name(::std::string* name) { + if (name != NULL) { + + } else { + + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ServiceResponse.name) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ErrorResponse::kErrorCodeFieldNumber; +const int ErrorResponse::kErrorMessageFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ErrorResponse::ErrorResponse() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:grpc.reflection.v1alpha.ErrorResponse) +} + +void ErrorResponse::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +ErrorResponse::ErrorResponse(const ErrorResponse& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:grpc.reflection.v1alpha.ErrorResponse) +} + +void ErrorResponse::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + error_code_ = 0; + error_message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +ErrorResponse::~ErrorResponse() { + // @@protoc_insertion_point(destructor:grpc.reflection.v1alpha.ErrorResponse) + SharedDtor(); +} + +void ErrorResponse::SharedDtor() { + error_message_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + } +} + +void ErrorResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ErrorResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ErrorResponse_descriptor_; +} + +const ErrorResponse& ErrorResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_reflection_2eproto(); + return *default_instance_; +} + +ErrorResponse* ErrorResponse::default_instance_ = NULL; + +ErrorResponse* ErrorResponse::New(::google::protobuf::Arena* arena) const { + ErrorResponse* n = new ErrorResponse; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void ErrorResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:grpc.reflection.v1alpha.ErrorResponse) + error_code_ = 0; + error_message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +bool ErrorResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:grpc.reflection.v1alpha.ErrorResponse) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 error_code = 1; + case 1: { + if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &error_code_))); + + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_error_message; + break; + } + + // optional string error_message = 2; + case 2: { + if (tag == 18) { + parse_error_message: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_error_message())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->error_message().data(), this->error_message().length(), + ::google::protobuf::internal::WireFormatLite::PARSE, + "grpc.reflection.v1alpha.ErrorResponse.error_message")); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:grpc.reflection.v1alpha.ErrorResponse) + return true; +failure: + // @@protoc_insertion_point(parse_failure:grpc.reflection.v1alpha.ErrorResponse) + return false; +#undef DO_ +} + +void ErrorResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:grpc.reflection.v1alpha.ErrorResponse) + // optional int32 error_code = 1; + if (this->error_code() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->error_code(), output); + } + + // optional string error_message = 2; + if (this->error_message().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->error_message().data(), this->error_message().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ErrorResponse.error_message"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 2, this->error_message(), output); + } + + // @@protoc_insertion_point(serialize_end:grpc.reflection.v1alpha.ErrorResponse) +} + +::google::protobuf::uint8* ErrorResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:grpc.reflection.v1alpha.ErrorResponse) + // optional int32 error_code = 1; + if (this->error_code() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->error_code(), target); + } + + // optional string error_message = 2; + if (this->error_message().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->error_message().data(), this->error_message().length(), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "grpc.reflection.v1alpha.ErrorResponse.error_message"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 2, this->error_message(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:grpc.reflection.v1alpha.ErrorResponse) + return target; +} + +int ErrorResponse::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:grpc.reflection.v1alpha.ErrorResponse) + int total_size = 0; + + // optional int32 error_code = 1; + if (this->error_code() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->error_code()); + } + + // optional string error_message = 2; + if (this->error_message().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->error_message()); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ErrorResponse::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:grpc.reflection.v1alpha.ErrorResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ErrorResponse* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:grpc.reflection.v1alpha.ErrorResponse) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:grpc.reflection.v1alpha.ErrorResponse) + MergeFrom(*source); + } +} + +void ErrorResponse::MergeFrom(const ErrorResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:grpc.reflection.v1alpha.ErrorResponse) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.error_code() != 0) { + set_error_code(from.error_code()); + } + if (from.error_message().size() > 0) { + + error_message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_message_); + } +} + +void ErrorResponse::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:grpc.reflection.v1alpha.ErrorResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ErrorResponse::CopyFrom(const ErrorResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpc.reflection.v1alpha.ErrorResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ErrorResponse::IsInitialized() const { + + return true; +} + +void ErrorResponse::Swap(ErrorResponse* other) { + if (other == this) return; + InternalSwap(other); +} +void ErrorResponse::InternalSwap(ErrorResponse* other) { + std::swap(error_code_, other->error_code_); + error_message_.Swap(&other->error_message_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ErrorResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ErrorResponse_descriptor_; + metadata.reflection = ErrorResponse_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ErrorResponse + +// optional int32 error_code = 1; +void ErrorResponse::clear_error_code() { + error_code_ = 0; +} + ::google::protobuf::int32 ErrorResponse::error_code() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ErrorResponse.error_code) + return error_code_; +} + void ErrorResponse::set_error_code(::google::protobuf::int32 value) { + + error_code_ = value; + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ErrorResponse.error_code) +} + +// optional string error_message = 2; +void ErrorResponse::clear_error_message() { + error_message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + const ::std::string& ErrorResponse::error_message() const { + // @@protoc_insertion_point(field_get:grpc.reflection.v1alpha.ErrorResponse.error_message) + return error_message_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ErrorResponse::set_error_message(const ::std::string& value) { + + error_message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:grpc.reflection.v1alpha.ErrorResponse.error_message) +} + void ErrorResponse::set_error_message(const char* value) { + + error_message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:grpc.reflection.v1alpha.ErrorResponse.error_message) +} + void ErrorResponse::set_error_message(const char* value, size_t size) { + + error_message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:grpc.reflection.v1alpha.ErrorResponse.error_message) +} + ::std::string* ErrorResponse::mutable_error_message() { + + // @@protoc_insertion_point(field_mutable:grpc.reflection.v1alpha.ErrorResponse.error_message) + return error_message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* ErrorResponse::release_error_message() { + // @@protoc_insertion_point(field_release:grpc.reflection.v1alpha.ErrorResponse.error_message) + + return error_message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void ErrorResponse::set_allocated_error_message(::std::string* error_message) { + if (error_message != NULL) { + + } else { + + } + error_message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), error_message); + // @@protoc_insertion_point(field_set_allocated:grpc.reflection.v1alpha.ErrorResponse.error_message) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// @@protoc_insertion_point(namespace_scope) + +} // namespace v1alpha +} // namespace reflection +} // namespace grpc + +// @@protoc_insertion_point(global_scope) diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index f6c3e5747c9..50fc4733a16 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -329,6 +329,10 @@ void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) { g_callbacks.reset(callbacks); } +grpc_server* Server::c_server() { return server_; } + +CompletionQueue* Server::completion_queue() { return &cq_; } + static grpc_server_register_method_payload_handling PayloadHandlingForMethod( RpcServiceMethod* method) { switch (method->method_type()) { diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 54feac39825..279981744ad 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -37,6 +37,8 @@ #include #include #include + +#include "include/grpc/support/useful.h" #include "src/cpp/server/thread_pool_interface.h" namespace grpc { @@ -52,12 +54,18 @@ static void do_plugin_list_init(void) { ServerBuilder::ServerBuilder() : max_message_size_(-1), generic_service_(nullptr) { - grpc_compression_options_init(&compression_options_); gpr_once_init(&once_init_plugin_list, do_plugin_list_init); for (auto factory : (*g_plugin_factory_list)) { std::unique_ptr plugin = factory(); plugins_[plugin->name()] = std::move(plugin); } + // all compression algorithms enabled by default. + enabled_compression_algorithms_bitset_ = + (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; + memset(&maybe_default_compression_level_, 0, + sizeof(maybe_default_compression_level_)); + memset(&maybe_default_compression_algorithm_, 0, + sizeof(maybe_default_compression_algorithm_)); } std::unique_ptr ServerBuilder::AddCompletionQueue( @@ -67,35 +75,65 @@ std::unique_ptr ServerBuilder::AddCompletionQueue( return std::unique_ptr(cq); } -void ServerBuilder::RegisterService(Service* service) { +ServerBuilder& ServerBuilder::RegisterService(Service* service) { services_.emplace_back(new NamedService(service)); + return *this; } -void ServerBuilder::RegisterService(const grpc::string& addr, - Service* service) { +ServerBuilder& ServerBuilder::RegisterService(const grpc::string& addr, + Service* service) { services_.emplace_back(new NamedService(addr, service)); + return *this; } -void ServerBuilder::RegisterAsyncGenericService(AsyncGenericService* service) { +ServerBuilder& ServerBuilder::RegisterAsyncGenericService( + AsyncGenericService* service) { if (generic_service_) { gpr_log(GPR_ERROR, "Adding multiple AsyncGenericService is unsupported for now. " "Dropping the service %p", service); - return; + } else { + generic_service_ = service; } - generic_service_ = service; + return *this; } -void ServerBuilder::SetOption(std::unique_ptr option) { +ServerBuilder& ServerBuilder::SetOption( + std::unique_ptr option) { options_.push_back(std::move(option)); + return *this; +} + +ServerBuilder& ServerBuilder::SetCompressionAlgorithmSupportStatus( + grpc_compression_algorithm algorithm, bool enabled) { + if (enabled) { + GPR_BITSET(&enabled_compression_algorithms_bitset_, algorithm); + } else { + GPR_BITCLEAR(&enabled_compression_algorithms_bitset_, algorithm); + } + return *this; } -void ServerBuilder::AddListeningPort(const grpc::string& addr, - std::shared_ptr creds, - int* selected_port) { +ServerBuilder& ServerBuilder::SetDefaultCompressionLevel( + grpc_compression_level level) { + maybe_default_compression_level_.level = level; + return *this; +} + +ServerBuilder& ServerBuilder::SetDefaultCompressionAlgorithm( + grpc_compression_algorithm algorithm) { + maybe_default_compression_algorithm_.is_set = true; + maybe_default_compression_algorithm_.algorithm = algorithm; + return *this; +} + +ServerBuilder& ServerBuilder::AddListeningPort( + const grpc::string& addr, std::shared_ptr creds, + int* selected_port) { Port port = {addr, creds, selected_port}; ports_.push_back(port); + return *this; } std::unique_ptr ServerBuilder::BuildAndStart() { @@ -128,7 +166,15 @@ std::unique_ptr ServerBuilder::BuildAndStart() { args.SetInt(GRPC_ARG_MAX_MESSAGE_LENGTH, max_message_size_); } args.SetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET, - compression_options_.enabled_algorithms_bitset); + enabled_compression_algorithms_bitset_); + if (maybe_default_compression_level_.is_set) { + args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL, + maybe_default_compression_level_.level); + } + if (maybe_default_compression_algorithm_.is_set) { + args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, + maybe_default_compression_algorithm_.algorithm); + } std::unique_ptr server( new Server(thread_pool.release(), true, max_message_size_, &args)); ServerInitializer* initializer = server->initializer(); diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 204fef1b09e..43117fd1e95 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -42,7 +42,6 @@ #include #include -#include "src/core/lib/channel/compress_filter.h" #include "src/core/lib/surface/call.h" namespace grpc { @@ -196,6 +195,9 @@ bool ServerContext::IsCancelled() const { } void ServerContext::set_compression_level(grpc_compression_level level) { + // TODO(dgq): get rid of grpc_call_compression_for_level and propagate the + // compression level by adding a new argument to + // CallOpSendInitialMetadata::SendInitialMetadata. const grpc_compression_algorithm algorithm_for_level = grpc_call_compression_for_level(call_, level); set_compression_algorithm(algorithm_for_level); @@ -210,7 +212,7 @@ void ServerContext::set_compression_algorithm( abort(); } GPR_ASSERT(algorithm_name != NULL); - AddInitialMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); + AddInitialMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name); } grpc::string ServerContext::peer() const { diff --git a/src/cpp/server/server_posix.cc b/src/cpp/server/server_posix.cc new file mode 100644 index 00000000000..c3aa2adc60e --- /dev/null +++ b/src/cpp/server/server_posix.cc @@ -0,0 +1,49 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +namespace grpc { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +void AddInsecureChannelFromFd(Server* server, int fd) { + grpc_server_add_insecure_channel_from_fd( + server->c_server(), server->completion_queue()->cq(), fd); +} + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs index 81897f8c772..98e27a17a1d 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs @@ -224,7 +224,7 @@ namespace Grpc.Core.Internal.Tests fakeCall.UnaryResponseClientHandler(true, new ClientSideStatus(new Status(StatusCode.OutOfRange, ""), new Metadata()), - null, + CreateResponsePayload(), new Metadata()); AssertUnaryResponseError(asyncCall, fakeCall, resultTask, StatusCode.OutOfRange); diff --git a/src/csharp/Grpc.Core.Tests/ServerTest.cs b/src/csharp/Grpc.Core.Tests/ServerTest.cs index fa693162ada..3b51aa63300 100644 --- a/src/csharp/Grpc.Core.Tests/ServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ServerTest.cs @@ -93,5 +93,20 @@ namespace Grpc.Core.Tests server.ShutdownAsync().Wait(); } + + [Test] + public void UnstartedServerCanBeShutdown() + { + var server = new Server(); + server.ShutdownAsync().Wait(); + Assert.Throws(typeof(InvalidOperationException), () => server.Start()); + } + + [Test] + public void UnstartedServerDoesNotPreventShutdown() + { + // just create a server, don't start it, and make sure it doesn't prevent shutdown. + var server = new Server(); + } } } diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index a8b7b5f00d9..a796911b99f 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -136,6 +136,8 @@ + + diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs index 0359d9092a7..e9e4cb4cbb3 100644 --- a/src/csharp/Grpc.Core/GrpcEnvironment.cs +++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs @@ -47,6 +47,7 @@ namespace Grpc.Core /// public class GrpcEnvironment { + const LogLevel DefaultLogLevel = LogLevel.Info; const int MinDefaultThreadPoolSize = 4; static object staticLock = new object(); @@ -57,7 +58,7 @@ namespace Grpc.Core static readonly HashSet registeredChannels = new HashSet(); static readonly HashSet registeredServers = new HashSet(); - static ILogger logger = new ConsoleLogger(); + static ILogger logger = new LogLevelFilterLogger(new ConsoleLogger(), DefaultLogLevel); readonly object myLock = new object(); readonly GrpcThreadPool threadPool; diff --git a/src/csharp/Grpc.Core/IAsyncStreamReader.cs b/src/csharp/Grpc.Core/IAsyncStreamReader.cs index 49e1ea78325..aa3b802a50f 100644 --- a/src/csharp/Grpc.Core/IAsyncStreamReader.cs +++ b/src/csharp/Grpc.Core/IAsyncStreamReader.cs @@ -41,10 +41,24 @@ namespace Grpc.Core { /// /// A stream of messages to be read. + /// Messages can be awaited await reader.MoveNext(), that returns true + /// if there is a message available and false if there are no more messages + /// (i.e. the stream has been closed). + /// + /// On the client side, the last invocation of MoveNext() either returns false + /// if the call has finished successfully or throws RpcException if call finished + /// with an error. Once the call finishes, subsequent invocations of MoveNext() will + /// continue yielding the same result (returning false or throwing an exception). + /// + /// + /// On the server side, MoveNext() does not throw exceptions. + /// In case of a failure, the request stream will appear to be finished + /// (MoveNext will return false) and the CancellationToken + /// associated with the call will be cancelled to signal the failure. + /// /// /// The message type. public interface IAsyncStreamReader : IAsyncEnumerator { - // TODO(jtattermusch): consider just using IAsyncEnumerator instead of this interface. } } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 895be690a59..f549c528762 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -267,7 +267,7 @@ namespace Grpc.Core.Internal halfcloseRequested = true; return Task.FromResult(null); } - call.StartSendCloseFromClient(HandleSendCloseFromClientFinished); + call.StartSendCloseFromClient(HandleSendFinished); halfcloseRequested = true; streamingWriteTcs = new TaskCompletionSource(); diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index cb8366c2166..eb9c3ea62d1 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -248,7 +248,7 @@ namespace Grpc.Core.Internal } /// - /// Handles send completion. + /// Handles send completion (including SendCloseFromClient). /// protected void HandleSendFinished(bool success) { @@ -271,31 +271,6 @@ namespace Grpc.Core.Internal } } - /// - /// Handles halfclose (send close from client) completion. - /// - protected void HandleSendCloseFromClientFinished(bool success) - { - TaskCompletionSource origTcs = null; - lock (myLock) - { - origTcs = streamingWriteTcs; - streamingWriteTcs = null; - - ReleaseResourcesIfPossible(); - } - - if (!success) - { - // TODO(jtattermusch): this method is same as HandleSendFinished (only the error message differs). - origTcs.SetException(new InvalidOperationException("Sending close from client has failed.")); - } - else - { - origTcs.SetResult(null); - } - } - /// /// Handles send status from server completion. /// diff --git a/src/csharp/Grpc.Core/Logging/LogLevel.cs b/src/csharp/Grpc.Core/Logging/LogLevel.cs new file mode 100644 index 00000000000..d64e1f5fd0f --- /dev/null +++ b/src/csharp/Grpc.Core/Logging/LogLevel.cs @@ -0,0 +1,59 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; + +namespace Grpc.Core.Logging +{ + /// Standard logging levels. + public enum LogLevel + { + /// + /// Debug severity. + /// + Debug = 0, + /// + /// Info severity. + /// + Info, + /// + /// Warning severity. + /// + Warning, + /// + /// Error severity. + /// + Error + } +} diff --git a/src/csharp/Grpc.Core/Logging/LogLevelFilterLogger.cs b/src/csharp/Grpc.Core/Logging/LogLevelFilterLogger.cs new file mode 100644 index 00000000000..4eeb79c783d --- /dev/null +++ b/src/csharp/Grpc.Core/Logging/LogLevelFilterLogger.cs @@ -0,0 +1,160 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using Grpc.Core.Utils; + +namespace Grpc.Core.Logging +{ + /// Logger that filters out messages below certain log level. + public class LogLevelFilterLogger : ILogger + { + readonly ILogger innerLogger; + readonly LogLevel logLevel; + + /// + /// Creates and instance of LogLevelFilter. + /// + public LogLevelFilterLogger(ILogger logger, LogLevel logLevel) + { + this.innerLogger = GrpcPreconditions.CheckNotNull(logger); + this.logLevel = logLevel; + } + + /// + /// Returns a logger associated with the specified type. + /// + public virtual ILogger ForType() + { + var newInnerLogger = innerLogger.ForType(); + if (object.ReferenceEquals(this.innerLogger, newInnerLogger)) + { + return this; + } + return new LogLevelFilterLogger(newInnerLogger, logLevel); + } + + /// Logs a message with severity Debug. + public void Debug(string message) + { + if (logLevel <= LogLevel.Debug) + { + innerLogger.Debug(message); + } + } + + /// Logs a formatted message with severity Debug. + public void Debug(string format, params object[] formatArgs) + { + if (logLevel <= LogLevel.Debug) + { + innerLogger.Debug(format, formatArgs); + } + } + + /// Logs a message with severity Info. + public void Info(string message) + { + if (logLevel <= LogLevel.Info) + { + innerLogger.Info(message); + } + } + + /// Logs a formatted message with severity Info. + public void Info(string format, params object[] formatArgs) + { + if (logLevel <= LogLevel.Info) + { + innerLogger.Info(format, formatArgs); + } + } + + /// Logs a message with severity Warning. + public void Warning(string message) + { + if (logLevel <= LogLevel.Warning) + { + innerLogger.Warning(message); + } + } + + /// Logs a formatted message with severity Warning. + public void Warning(string format, params object[] formatArgs) + { + if (logLevel <= LogLevel.Warning) + { + innerLogger.Warning(format, formatArgs); + } + } + + /// Logs a message and an associated exception with severity Warning. + public void Warning(Exception exception, string message) + { + if (logLevel <= LogLevel.Warning) + { + innerLogger.Warning(exception, message); + } + } + + /// Logs a message with severity Error. + public void Error(string message) + { + if (logLevel <= LogLevel.Error) + { + innerLogger.Error(message); + } + } + + /// Logs a formatted message with severity Error. + public void Error(string format, params object[] formatArgs) + { + if (logLevel <= LogLevel.Error) + { + innerLogger.Error(format, formatArgs); + } + } + + /// Logs a message and an associated exception with severity Error. + public void Error(Exception exception, string message) + { + if (logLevel <= LogLevel.Error) + { + innerLogger.Error(exception, message); + } + } + } +} diff --git a/src/csharp/Grpc.Core/Metadata.cs b/src/csharp/Grpc.Core/Metadata.cs index e982fa0c486..f73f720094a 100644 --- a/src/csharp/Grpc.Core/Metadata.cs +++ b/src/csharp/Grpc.Core/Metadata.cs @@ -95,6 +95,7 @@ namespace Grpc.Core public void Insert(int index, Metadata.Entry item) { + GrpcPreconditions.CheckNotNull(item); CheckWriteable(); entries.Insert(index, item); } @@ -114,6 +115,7 @@ namespace Grpc.Core set { + GrpcPreconditions.CheckNotNull(value); CheckWriteable(); entries[index] = value; } @@ -121,6 +123,7 @@ namespace Grpc.Core public void Add(Metadata.Entry item) { + GrpcPreconditions.CheckNotNull(item); CheckWriteable(); entries.Add(item); } @@ -187,7 +190,7 @@ namespace Grpc.Core /// /// Metadata entry /// - public struct Entry + public class Entry { private static readonly Encoding Encoding = Encoding.ASCII; private static readonly Regex ValidKeyRegex = new Regex("^[a-z0-9_-]+$"); diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index ae7a8c9a9a1..3b554e5e87e 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -140,6 +140,7 @@ namespace Grpc.Core lock (myLock) { GrpcPreconditions.CheckState(!startRequested); + GrpcPreconditions.CheckState(!shutdownRequested); startRequested = true; handle.Start(); @@ -203,7 +204,6 @@ namespace Grpc.Core { lock (myLock) { - GrpcPreconditions.CheckState(startRequested); GrpcPreconditions.CheckState(!shutdownRequested); shutdownRequested = true; } @@ -215,7 +215,6 @@ namespace Grpc.Core { handle.CancelAllCalls(); } - await ShutdownCompleteOrEnvironmentDeadAsync().ConfigureAwait(false); DisposeHandle(); diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 2a243b94cbd..4782654250c 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -503,6 +503,7 @@ grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx, grpc_metadata_array *initial_metadata, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[6]; + memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; grpcsharp_metadata_array_move(&(ctx->send_initial_metadata), initial_metadata); @@ -555,6 +556,7 @@ grpcsharp_call_start_client_streaming(grpc_call *call, grpc_metadata_array *initial_metadata) { /* TODO: don't use magic number */ grpc_op ops[4]; + memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; grpcsharp_metadata_array_move(&(ctx->send_initial_metadata), initial_metadata); @@ -596,6 +598,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( size_t send_buffer_len, grpc_metadata_array *initial_metadata, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; + memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; grpcsharp_metadata_array_move(&(ctx->send_initial_metadata), initial_metadata); @@ -638,6 +641,7 @@ grpcsharp_call_start_duplex_streaming(grpc_call *call, grpc_metadata_array *initial_metadata) { /* TODO: don't use magic number */ grpc_op ops[2]; + memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; grpcsharp_metadata_array_move(&(ctx->send_initial_metadata), initial_metadata); @@ -684,6 +688,7 @@ grpcsharp_call_send_message(grpc_call *call, grpcsharp_batch_context *ctx, int32_t send_empty_initial_metadata) { /* TODO: don't use magic number */ grpc_op ops[2]; + memset(ops, 0, sizeof(ops)); size_t nops = send_empty_initial_metadata ? 2 : 1; ops[0].op = GRPC_OP_SEND_MESSAGE; ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len); @@ -691,8 +696,6 @@ grpcsharp_call_send_message(grpc_call *call, grpcsharp_batch_context *ctx, ops[0].flags = write_flags; ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_INITIAL_METADATA; - ops[1].data.send_initial_metadata.count = 0; - ops[1].data.send_initial_metadata.metadata = NULL; ops[1].flags = 0; ops[1].reserved = NULL; @@ -719,6 +722,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( size_t optional_send_buffer_len, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[3]; + memset(ops, 0, sizeof(ops)); size_t nops = 1; ops[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER; ops[0].data.send_status_from_server.status = status_code; @@ -743,8 +747,6 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( } if (send_empty_initial_metadata) { ops[nops].op = GRPC_OP_SEND_INITIAL_METADATA; - ops[nops].data.send_initial_metadata.count = 0; - ops[nops].data.send_initial_metadata.metadata = NULL; ops[nops].flags = 0; ops[nops].reserved = NULL; nops++; @@ -784,6 +786,7 @@ grpcsharp_call_send_initial_metadata(grpc_call *call, grpc_metadata_array *initial_metadata) { /* TODO: don't use magic number */ grpc_op ops[1]; + memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; grpcsharp_metadata_array_move(&(ctx->send_initial_metadata), initial_metadata); diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 7a77ae60b6a..b9e741dfa8f 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -220,6 +220,8 @@ extern id const kGRPCTrailersKey; * messages to the response side of the call indefinitely (depending on the semantics of the * specific remote method called). * To finish a call right away, invoke cancel. + * host parameter should not contain the scheme (http:// or https://), only the name or IP addr + * and the port number, for example @"localhost:5050". */ - (instancetype)initWithHost:(NSString *)host path:(NSString *)path diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 16e5bff7ff7..a3fa5938cdd 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -72,6 +72,8 @@ _op.op = GRPC_OP_SEND_INITIAL_METADATA; _op.data.send_initial_metadata.count = metadata.count; _op.data.send_initial_metadata.metadata = metadata.grpc_metadataArray; + _op.data.send_initial_metadata.maybe_compression_level.is_set = false; + _op.data.send_initial_metadata.maybe_compression_level.level = 0; _handler = handler; } return self; diff --git a/src/objective-c/ProtoRPC/ProtoMethod.h b/src/objective-c/ProtoRPC/ProtoMethod.h index a0ed2cf98a5..f9fdbb35ffd 100644 --- a/src/objective-c/ProtoRPC/ProtoMethod.h +++ b/src/objective-c/ProtoRPC/ProtoMethod.h @@ -37,6 +37,7 @@ * A fully-qualified proto service method name. Full qualification is needed because a gRPC endpoint * can implement multiple services. */ +__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod : NSObject @property(nonatomic, readonly) NSString *package; @property(nonatomic, readonly) NSString *service; @@ -48,3 +49,11 @@ service:(NSString *)service method:(NSString *)method; @end + +/** + * This subclass is empty now. Eventually we'll remove ProtoMethod class + * to avoid potential naming conflict + */ +@interface GRPCProtoMethod : ProtoMethod + +@end diff --git a/src/objective-c/ProtoRPC/ProtoMethod.m b/src/objective-c/ProtoRPC/ProtoMethod.m index 4b7ed63123c..e9978f38afe 100644 --- a/src/objective-c/ProtoRPC/ProtoMethod.m +++ b/src/objective-c/ProtoRPC/ProtoMethod.m @@ -53,3 +53,7 @@ } } @end + +@implementation GRPCProtoMethod + +@end diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index bd926b73287..5f91f6bce1e 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -36,13 +36,26 @@ #import "ProtoMethod.h" +__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC : GRPCCall +/** + * host parameter should not contain the scheme (http:// or https://), only the name or IP addr + * and the port number, for example @"localhost:5050". + */ - (instancetype)initWithHost:(NSString *)host - method:(ProtoMethod *)method + method:(GRPCProtoMethod *)method requestsWriter:(GRXWriter *)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable NS_DESIGNATED_INITIALIZER; - (void)start; @end + +/** + * This subclass is empty now. Eventually we'll remove ProtoRPC class + * to avoid potential naming conflict + */ +@interface GRPCProtoCall : ProtoRPC + +@end diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 9bf66f347ac..fb0b566f199 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -70,7 +70,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing // Designated initializer - (instancetype)initWithHost:(NSString *)host - method:(ProtoMethod *)method + method:(GRPCProtoMethod *)method requestsWriter:(GRXWriter *)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable { @@ -117,3 +117,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing _responseWriteable = nil; } @end + +@implementation GRPCProtoCall + +@end diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 2e8cb33696b..87d06e1ae59 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -33,17 +33,28 @@ #import -@class ProtoRPC; +@class GRPCProtoCall; @protocol GRXWriteable; @class GRXWriter; + +__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService : NSObject - (instancetype)initWithHost:(NSString *)host packageName:(NSString *)packageName serviceName:(NSString *)serviceName NS_DESIGNATED_INITIALIZER; -- (ProtoRPC *)RPCToMethod:(NSString *)method +- (GRPCProtoCall *)RPCToMethod:(NSString *)method requestsWriter:(GRXWriter *)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable; @end + + +/** + * This subclass is empty now. Eventually we'll remove ProtoService class + * to avoid potential naming conflict + */ +@interface GRPCProtoService : ProtoService + +@end diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index fccc6aadc9c..597c3cf0fed 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -79,3 +79,7 @@ responsesWriteable:responsesWriteable]; } @end + +@implementation GRPCProtoService + +@end diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 508641d681a..a7a88a3b9df 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -1,32 +1,36 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' -pod 'Protobuf', :path => "../../../third_party/protobuf" -pod 'BoringSSL', :podspec => ".." -pod 'CronetFramework', :podspec => ".." -pod 'gRPC', :path => "../../.." -pod 'RemoteTest', :path => "RemoteTestClient" - -link_with 'AllTests', - 'RxLibraryUnitTests', - 'InteropTests', - 'InteropTestsLocalSSL', - 'InteropTestsLocalCleartext' +install! 'cocoapods', :deterministic_uuids => false + +def shared_pods + pod 'Protobuf', :path => "../../../third_party/protobuf" + pod 'BoringSSL', :podspec => ".." + pod 'CronetFramework', :podspec => ".." + pod 'gRPC', :path => "../../.." + pod 'RemoteTest', :path => "RemoteTestClient" +end target 'Tests' do + shared_pods end target 'AllTests' do + shared_pods end target 'RxLibraryUnitTests' do + shared_pods end target 'InteropTestsRemote' do + shared_pods end target 'InteropTestsLocalSSL' do + shared_pods end target 'InteropTestsLocalCleartext' do + shared_pods end diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 6ecef0593b7..e1fd9910389 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -2,6 +2,10 @@ Pod::Spec.new do |s| s.name = "RemoteTest" s.version = "0.0.1" s.license = "New BSD" + s.authors = { 'gRPC contributors' => 'grpc-io@googlegroups.com' } + s.homepage = "http://www.grpc.io/" + s.summary = "RemoteTest example" + s.source = { :git => 'https://github.com/grpc/grpc.git' } s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index b0429617c01..89e0ea60b9e 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -7,33 +7,34 @@ objects = { /* Begin PBXBuildFile section */ - 036D953EE34B1FD523647ACD /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */; }; - 08A8BB02D19A53D902B214B8 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */; }; - 50267643BA114A2A724D4FDF /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */; }; + 0F9232F984C08643FD40C34F /* libPods-InteropTestsRemote.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */; }; + 16A9E77B6E336B3C0B9BA6E0 /* libPods-InteropTestsLocalSSL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */; }; + 20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */; }; + 333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */; }; + 3D7C85F6AA68C4A205E3BA16 /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */; }; 6312AE4E1B1BF49B00341DEE /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; 63423F4A1B150A5F006CF63C /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; 635697CD1B14FC11007A7283 /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635697CC1B14FC11007A7283 /* Tests.m */; }; 635ED2EC1B1A3BC400FDE5C3 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; 63715F561B780C020029CB0B /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; - 6379CC4D1BE1662A001BC0A1 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; settings = {ASSET_TAGS = (); }; }; - 6379CC4E1BE1662B001BC0A1 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; settings = {ASSET_TAGS = (); }; }; - 6379CC501BE16703001BC0A1 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; settings = {ASSET_TAGS = (); }; }; - 6379CC511BE1683B001BC0A1 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; settings = {ASSET_TAGS = (); }; }; - 6379CC531BE17709001BC0A1 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; settings = {ASSET_TAGS = (); }; }; - 63DC84181BE15179000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; settings = {ASSET_TAGS = (); }; }; - 63DC841E1BE15180000708E8 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; settings = {ASSET_TAGS = (); }; }; - 63DC84281BE15267000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; settings = {ASSET_TAGS = (); }; }; - 63DC842E1BE15278000708E8 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; settings = {ASSET_TAGS = (); }; }; - 63DC842F1BE1527D000708E8 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; settings = {ASSET_TAGS = (); }; }; - 63DC84391BE15294000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; settings = {ASSET_TAGS = (); }; }; - 63DC84481BE152B5000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; settings = {ASSET_TAGS = (); }; }; - 63DC844E1BE15350000708E8 /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; settings = {ASSET_TAGS = (); }; }; - 63DC844F1BE15353000708E8 /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; settings = {ASSET_TAGS = (); }; }; - 63DC84501BE153AA000708E8 /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; settings = {ASSET_TAGS = (); }; }; + 6379CC4D1BE1662A001BC0A1 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; + 6379CC4E1BE1662B001BC0A1 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; + 6379CC501BE16703001BC0A1 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; + 6379CC511BE1683B001BC0A1 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; + 6379CC531BE17709001BC0A1 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; + 63DC84181BE15179000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; + 63DC841E1BE15180000708E8 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; }; + 63DC84281BE15267000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; + 63DC842E1BE15278000708E8 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; }; + 63DC842F1BE1527D000708E8 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; + 63DC84391BE15294000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; + 63DC84481BE152B5000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; + 63DC844E1BE15350000708E8 /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; + 63DC844F1BE15353000708E8 /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; + 63DC84501BE153AA000708E8 /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; 63E240CE1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 63E240D01B6C63DC005F3B0E /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 7D8A186224D39101F90230F6 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */; }; - DCFAE001609CCBFE69DFA6A1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */; }; + F15EF7852DC70770EFDB1D2C /* libPods-AllTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -87,8 +88,15 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.debug.xcconfig"; sourceTree = ""; }; + 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.debug.xcconfig"; sourceTree = ""; }; 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.release.xcconfig"; sourceTree = ""; }; + 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.release.xcconfig"; sourceTree = ""; }; + 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.debug.xcconfig"; sourceTree = ""; }; + 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.release.xcconfig"; sourceTree = ""; }; 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRPCClientTests.m; sourceTree = ""; }; 63423F441B150A5F006CF63C /* AllTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AllTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; @@ -105,6 +113,17 @@ 63E240CC1B6C4D3A005F3B0E /* InteropTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InteropTests.h; sourceTree = ""; }; 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsLocalSSL.m; sourceTree = ""; }; 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TestCertificates.bundle; sourceTree = ""; }; + 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = ""; }; + A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RxLibraryUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.debug.xcconfig"; sourceTree = ""; }; + CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemote.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSL.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.debug.xcconfig"; sourceTree = ""; }; + E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.debug.xcconfig"; sourceTree = ""; }; + E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.release.xcconfig"; sourceTree = ""; }; + E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = ""; }; + FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartext.a"; sourceTree = BUILT_PRODUCTS_DIR; }; FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -114,7 +133,7 @@ buildActionMask = 2147483647; files = ( 63423F4A1B150A5F006CF63C /* libTests.a in Frameworks */, - 7D8A186224D39101F90230F6 /* libPods.a in Frameworks */, + F15EF7852DC70770EFDB1D2C /* libPods-AllTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -122,6 +141,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 3D7C85F6AA68C4A205E3BA16 /* libPods-Tests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -130,7 +150,7 @@ buildActionMask = 2147483647; files = ( 63DC84181BE15179000708E8 /* libTests.a in Frameworks */, - 036D953EE34B1FD523647ACD /* libPods.a in Frameworks */, + 20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -139,7 +159,7 @@ buildActionMask = 2147483647; files = ( 63DC84281BE15267000708E8 /* libTests.a in Frameworks */, - DCFAE001609CCBFE69DFA6A1 /* libPods.a in Frameworks */, + 0F9232F984C08643FD40C34F /* libPods-InteropTestsRemote.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -148,7 +168,7 @@ buildActionMask = 2147483647; files = ( 63DC84391BE15294000708E8 /* libTests.a in Frameworks */, - 08A8BB02D19A53D902B214B8 /* libPods.a in Frameworks */, + 16A9E77B6E336B3C0B9BA6E0 /* libPods-InteropTestsLocalSSL.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -157,7 +177,7 @@ buildActionMask = 2147483647; files = ( 63DC84481BE152B5000708E8 /* libTests.a in Frameworks */, - 50267643BA114A2A724D4FDF /* libPods.a in Frameworks */, + 333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -168,6 +188,12 @@ isa = PBXGroup; children = ( 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */, + CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */, + FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */, + DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */, + DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */, + A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */, + 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */, ); name = Frameworks; sourceTree = ""; @@ -177,6 +203,18 @@ children = ( FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */, 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */, + B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */, + 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */, + E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */, + 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */, + 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */, + 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */, + DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */, + E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */, + 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */, + 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */, + 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */, + E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -236,12 +274,12 @@ isa = PBXNativeTarget; buildConfigurationList = 63423F4D1B150A5F006CF63C /* Build configuration list for PBXNativeTarget "AllTests" */; buildPhases = ( - 914ADDD7106BA9BB8A7E569F /* Check Pods Manifest.lock */, + 914ADDD7106BA9BB8A7E569F /* 📦 Check Pods Manifest.lock */, 63423F401B150A5F006CF63C /* Sources */, 63423F411B150A5F006CF63C /* Frameworks */, 63423F421B150A5F006CF63C /* Resources */, - A441F71824DCB9D0CA297748 /* Copy Pods Resources */, - 5F14F59509E10C2852014F9E /* Embed Pods Frameworks */, + A441F71824DCB9D0CA297748 /* 📦 Copy Pods Resources */, + 5F14F59509E10C2852014F9E /* 📦 Embed Pods Frameworks */, ); buildRules = ( ); @@ -257,9 +295,11 @@ isa = PBXNativeTarget; buildConfigurationList = 635697DB1B14FC11007A7283 /* Build configuration list for PBXNativeTarget "Tests" */; buildPhases = ( + 796680C7599CB4ED736DD62A /* 📦 Check Pods Manifest.lock */, 635697C31B14FC11007A7283 /* Sources */, 635697C41B14FC11007A7283 /* Frameworks */, 635697C51B14FC11007A7283 /* CopyFiles */, + AEEBFC914CBAEE347382E8C4 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -274,12 +314,12 @@ isa = PBXNativeTarget; buildConfigurationList = 63DC841B1BE15179000708E8 /* Build configuration list for PBXNativeTarget "RxLibraryUnitTests" */; buildPhases = ( - B2986CEEE8CDD4901C97598B /* Check Pods Manifest.lock */, + B2986CEEE8CDD4901C97598B /* 📦 Check Pods Manifest.lock */, 63DC840F1BE15179000708E8 /* Sources */, 63DC84101BE15179000708E8 /* Frameworks */, 63DC84111BE15179000708E8 /* Resources */, - 4F5690DC0E6AD6663FE78B8B /* Embed Pods Frameworks */, - C977426A8727267BBAC7D48E /* Copy Pods Resources */, + 4F5690DC0E6AD6663FE78B8B /* 📦 Embed Pods Frameworks */, + C977426A8727267BBAC7D48E /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -295,12 +335,12 @@ isa = PBXNativeTarget; buildConfigurationList = 63DC842B1BE15267000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsRemote" */; buildPhases = ( - 4C406327D3907A5E5FBA8AC9 /* Check Pods Manifest.lock */, + 4C406327D3907A5E5FBA8AC9 /* 📦 Check Pods Manifest.lock */, 63DC841F1BE15267000708E8 /* Sources */, 63DC84201BE15267000708E8 /* Frameworks */, 63DC84211BE15267000708E8 /* Resources */, - 900B6EDD4D16BE7D765C3885 /* Embed Pods Frameworks */, - C2E09DC4BD239F71160F0CC1 /* Copy Pods Resources */, + 900B6EDD4D16BE7D765C3885 /* 📦 Embed Pods Frameworks */, + C2E09DC4BD239F71160F0CC1 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -316,12 +356,12 @@ isa = PBXNativeTarget; buildConfigurationList = 63DC843C1BE15294000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSL" */; buildPhases = ( - 5C20DCCB71C3991E6FE78C22 /* Check Pods Manifest.lock */, + 5C20DCCB71C3991E6FE78C22 /* 📦 Check Pods Manifest.lock */, 63DC84301BE15294000708E8 /* Sources */, 63DC84311BE15294000708E8 /* Frameworks */, 63DC84321BE15294000708E8 /* Resources */, - C591129ACE9F6CC5EE03FCDE /* Embed Pods Frameworks */, - 693DD0B453431D64EA24FD66 /* Copy Pods Resources */, + C591129ACE9F6CC5EE03FCDE /* 📦 Embed Pods Frameworks */, + 693DD0B453431D64EA24FD66 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -337,12 +377,12 @@ isa = PBXNativeTarget; buildConfigurationList = 63DC844B1BE152B5000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartext" */; buildPhases = ( - 7418AC7B3844B29E48D24FC7 /* Check Pods Manifest.lock */, + 7418AC7B3844B29E48D24FC7 /* 📦 Check Pods Manifest.lock */, 63DC843F1BE152B5000708E8 /* Sources */, 63DC84401BE152B5000708E8 /* Frameworks */, 63DC84411BE152B5000708E8 /* Resources */, - A8E3AC66DF770B774114A30E /* Embed Pods Frameworks */, - 8AD3130D3C58A0FB32FF2A36 /* Copy Pods Resources */, + A8E3AC66DF770B774114A30E /* 📦 Embed Pods Frameworks */, + 8AD3130D3C58A0FB32FF2A36 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -446,14 +486,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 4C406327D3907A5E5FBA8AC9 /* Check Pods Manifest.lock */ = { + 4C406327D3907A5E5FBA8AC9 /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -461,29 +501,29 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 4F5690DC0E6AD6663FE78B8B /* Embed Pods Frameworks */ = { + 4F5690DC0E6AD6663FE78B8B /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 5C20DCCB71C3991E6FE78C22 /* Check Pods Manifest.lock */ = { + 5C20DCCB71C3991E6FE78C22 /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -491,44 +531,44 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 5F14F59509E10C2852014F9E /* Embed Pods Frameworks */ = { + 5F14F59509E10C2852014F9E /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 693DD0B453431D64EA24FD66 /* Copy Pods Resources */ = { + 693DD0B453431D64EA24FD66 /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 7418AC7B3844B29E48D24FC7 /* Check Pods Manifest.lock */ = { + 7418AC7B3844B29E48D24FC7 /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -536,44 +576,59 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 8AD3130D3C58A0FB32FF2A36 /* Copy Pods Resources */ = { + 796680C7599CB4ED736DD62A /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 8AD3130D3C58A0FB32FF2A36 /* 📦 Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "📦 Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 900B6EDD4D16BE7D765C3885 /* Embed Pods Frameworks */ = { + 900B6EDD4D16BE7D765C3885 /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 914ADDD7106BA9BB8A7E569F /* Check Pods Manifest.lock */ = { + 914ADDD7106BA9BB8A7E569F /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -581,44 +636,59 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - A441F71824DCB9D0CA297748 /* Copy Pods Resources */ = { + A441F71824DCB9D0CA297748 /* 📦 Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "📦 Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + A8E3AC66DF770B774114A30E /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - A8E3AC66DF770B774114A30E /* Embed Pods Frameworks */ = { + AEEBFC914CBAEE347382E8C4 /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - B2986CEEE8CDD4901C97598B /* Check Pods Manifest.lock */ = { + B2986CEEE8CDD4901C97598B /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -626,49 +696,49 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - C2E09DC4BD239F71160F0CC1 /* Copy Pods Resources */ = { + C2E09DC4BD239F71160F0CC1 /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh\"\n"; showEnvVarsInLog = 0; }; - C591129ACE9F6CC5EE03FCDE /* Embed Pods Frameworks */ = { + C591129ACE9F6CC5EE03FCDE /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - C977426A8727267BBAC7D48E /* Copy Pods Resources */ = { + C977426A8727267BBAC7D48E /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -764,7 +834,7 @@ /* Begin XCBuildConfiguration section */ 63423F4E1B150A5F006CF63C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */; + baseConfigurationReference = B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", @@ -782,7 +852,7 @@ }; 63423F4F1B150A5F006CF63C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */; + baseConfigurationReference = 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", @@ -874,6 +944,7 @@ }; 635697DC1B14FC11007A7283 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -882,6 +953,7 @@ }; 635697DD1B14FC11007A7283 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -890,7 +962,7 @@ }; 63DC841C1BE15179000708E8 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */; + baseConfigurationReference = 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; @@ -904,7 +976,7 @@ }; 63DC841D1BE15179000708E8 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */; + baseConfigurationReference = 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */; buildSettings = { INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -916,7 +988,7 @@ }; 63DC842C1BE15267000708E8 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */; + baseConfigurationReference = DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; @@ -930,7 +1002,7 @@ }; 63DC842D1BE15267000708E8 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */; + baseConfigurationReference = E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */; buildSettings = { INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -942,7 +1014,7 @@ }; 63DC843D1BE15294000708E8 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */; + baseConfigurationReference = 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; @@ -956,7 +1028,7 @@ }; 63DC843E1BE15294000708E8 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */; + baseConfigurationReference = 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */; buildSettings = { INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -968,7 +1040,7 @@ }; 63DC844C1BE152B5000708E8 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */; + baseConfigurationReference = E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; @@ -982,7 +1054,7 @@ }; 63DC844D1BE152B5000708E8 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */; + baseConfigurationReference = 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */; buildSettings = { INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; diff --git a/src/objective-c/tests/build_tests.sh b/src/objective-c/tests/build_tests.sh index e7ad31e4031..8547bfd3a83 100755 --- a/src/objective-c/tests/build_tests.sh +++ b/src/objective-c/tests/build_tests.sh @@ -33,6 +33,9 @@ set -e +# CocoaPods requires the terminal to be using UTF-8 encoding. +export LANG=en_US.UTF-8 + cd $(dirname $0) hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; } diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index 884130e7d4f..0ec502262de 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -292,6 +292,7 @@ PHP_METHOD(Call, startBatch) { grpc_metadata_array_init(&recv_trailing_metadata); MAKE_STD_ZVAL(result); object_init(result); + memset(ops, 0, sizeof(ops)); /* "a" == 1 array */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) { diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php index 712af91eb28..c86d2988055 100644 --- a/src/php/lib/Grpc/AbstractCall.php +++ b/src/php/lib/Grpc/AbstractCall.php @@ -39,6 +39,7 @@ abstract class AbstractCall protected $call; protected $deserialize; protected $metadata; + protected $trailing_metadata; /** * Create a new Call wrapper object. @@ -66,6 +67,7 @@ abstract class AbstractCall $this->call = new Call($channel, $method, $deadline); $this->deserialize = $deserialize; $this->metadata = null; + $this->trailing_metadata = null; if (isset($options['call_credentials_callback']) && is_callable($call_credentials_callback = $options['call_credentials_callback'])) { @@ -83,6 +85,14 @@ abstract class AbstractCall return $this->metadata; } + /** + * @return The trailing metadata sent by the server. + */ + public function getTrailingMetadata() + { + return $this->trailing_metadata; + } + /** * @return string The URI of the endpoint. */ diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index 2de1b337e53..70644fac872 100755 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -52,8 +52,9 @@ class BaseStub * - 'update_metadata': (optional) a callback function which takes in a * metadata array, and returns an updated metadata array * - 'grpc.primary_user_agent': (optional) a user-agent string + * @param $channel Channel An already created Channel object */ - public function __construct($hostname, $opts) + public function __construct($hostname, $opts, $channel = null) { $this->hostname = $hostname; $this->update_metadata = null; @@ -77,7 +78,15 @@ class BaseStub 'required. Please see one of the '. 'ChannelCredentials::create methods'); } - $this->channel = new Channel($hostname, $opts); + if ($channel) { + if (!is_a($channel, 'Channel')) { + throw new \Exception("The channel argument is not a". + "Channel object"); + } + $this->channel = $channel; + } else { + $this->channel = new Channel($hostname, $opts); + } } /** diff --git a/src/php/lib/Grpc/BidiStreamingCall.php b/src/php/lib/Grpc/BidiStreamingCall.php index bf813c12e76..95e51c5088d 100644 --- a/src/php/lib/Grpc/BidiStreamingCall.php +++ b/src/php/lib/Grpc/BidiStreamingCall.php @@ -112,6 +112,7 @@ class BidiStreamingCall extends AbstractCall OP_RECV_STATUS_ON_CLIENT => true, ]); + $this->trailing_metadata = $status_event->status->metadata; return $status_event->status; } } diff --git a/src/php/lib/Grpc/ClientStreamingCall.php b/src/php/lib/Grpc/ClientStreamingCall.php index 500cfe0d7a0..315a406735f 100644 --- a/src/php/lib/Grpc/ClientStreamingCall.php +++ b/src/php/lib/Grpc/ClientStreamingCall.php @@ -86,6 +86,8 @@ class ClientStreamingCall extends AbstractCall ]); $this->metadata = $event->metadata; - return [$this->deserializeResponse($event->message), $event->status]; + $status = $event->status; + $this->trailing_metadata = $status->metadata; + return [$this->deserializeResponse($event->message), $status]; } } diff --git a/src/php/lib/Grpc/ServerStreamingCall.php b/src/php/lib/Grpc/ServerStreamingCall.php index da48523717e..53599fe4ae8 100644 --- a/src/php/lib/Grpc/ServerStreamingCall.php +++ b/src/php/lib/Grpc/ServerStreamingCall.php @@ -91,6 +91,7 @@ class ServerStreamingCall extends AbstractCall OP_RECV_STATUS_ON_CLIENT => true, ]); + $this->trailing_metadata = $status_event->status->metadata; return $status_event->status; } } diff --git a/src/php/lib/Grpc/UnaryCall.php b/src/php/lib/Grpc/UnaryCall.php index b57903d6d07..b114b771b84 100644 --- a/src/php/lib/Grpc/UnaryCall.php +++ b/src/php/lib/Grpc/UnaryCall.php @@ -75,6 +75,8 @@ class UnaryCall extends AbstractCall OP_RECV_STATUS_ON_CLIENT => true, ]); - return [$this->deserializeResponse($event->message), $event->status]; + $status = $event->status; + $this->trailing_metadata = $status->metadata; + return [$this->deserializeResponse($event->message), $status]; } } diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 565bfce74f7..c5bb7c490e2 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -477,7 +477,8 @@ function _makeStub($args) return $stub; } -function interop_main($args, $stub = false) { +function interop_main($args, $stub = false) +{ if (!$stub) { $stub = _makeStub($args); } diff --git a/src/php/tests/interop/metrics_client.php b/src/php/tests/interop/metrics_client.php index 46f4212f773..19510dc5d82 100644 --- a/src/php/tests/interop/metrics_client.php +++ b/src/php/tests/interop/metrics_client.php @@ -39,11 +39,11 @@ $server_port = (count($parts) == 2) ? $parts[1] : ''; $socket = socket_create(AF_INET, SOCK_STREAM, 0); if (@!socket_connect($socket, $server_host, $server_port)) { - echo "Cannot connect to merics server...\n"; - exit(1); + echo "Cannot connect to merics server...\n"; + exit(1); } socket_write($socket, 'qps'); while ($out = socket_read($socket, 1024)) { - echo "$out\n"; + echo "$out\n"; } socket_close($socket); diff --git a/src/php/tests/interop/stress_client.php b/src/php/tests/interop/stress_client.php index 2339f0d105d..419ef5be438 100644 --- a/src/php/tests/interop/stress_client.php +++ b/src/php/tests/interop/stress_client.php @@ -32,50 +32,52 @@ * */ -include_once('interop_client.php'); +include_once 'interop_client.php'; -function stress_main($args) { - mt_srand(); - set_time_limit(0); +function stress_main($args) +{ + mt_srand(); + set_time_limit(0); - // open socket to listen as metrics server - $socket = socket_create(AF_INET, SOCK_STREAM, 0); - socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1); - if (@!socket_bind($socket, 'localhost', $args['metrics_port'])) { - echo "Cannot create socket for metrics server...\n"; - exit(1); - } - socket_listen($socket); - socket_set_nonblock($socket); + // open socket to listen as metrics server + $socket = socket_create(AF_INET, SOCK_STREAM, 0); + socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1); + if (@!socket_bind($socket, 'localhost', $args['metrics_port'])) { + echo "Cannot create socket for metrics server...\n"; + exit(1); + } + socket_listen($socket); + socket_set_nonblock($socket); - $start_time = microtime(true); - $count = 0; - $deadline = $args['test_duration_secs'] ? - ($start_time + $args['test_duration_secs']) : false; - $num_test_cases = count($args['test_cases']); - $stub = false; + $start_time = microtime(true); + $count = 0; + $deadline = $args['test_duration_secs'] ? + ($start_time + $args['test_duration_secs']) : false; + $num_test_cases = count($args['test_cases']); + $stub = false; - while (true) { - $current_time = microtime(true); - if ($deadline && $current_time > $deadline) { - break; - } - if ($client_connection = socket_accept($socket)) { - // there is an incoming request, respond with qps metrics - $input = socket_read($client_connection, 1024); - $qps = round($count / ($current_time - $start_time)); - socket_write($client_connection, "qps: $qps"); - socket_close($client_connection); - } else { - // do actual work, run one interop test case - $args['test_case'] = - $args['test_cases'][mt_rand(0, $num_test_cases - 1)]; - $stub = @interop_main($args, $stub); - $count++; + while (true) { + $current_time = microtime(true); + if ($deadline && $current_time > $deadline) { + break; + } + if ($client_connection = socket_accept($socket)) { + // there is an incoming request, respond with qps metrics + $input = socket_read($client_connection, 1024); + $qps = round($count / ($current_time - $start_time)); + socket_write($client_connection, "qps: $qps"); + socket_close($client_connection); + } else { + // do actual work, run one interop test case + $args['test_case'] = + $args['test_cases'][mt_rand(0, $num_test_cases - 1)]; + $stub = @interop_main($args, $stub); + ++$count; + } } - } - socket_close($socket); - echo "Number of interop tests run in $args[test_duration_secs] seconds: $count.\n"; + socket_close($socket); + echo "Number of interop tests run in $args[test_duration_secs] ". + "seconds: $count.\n"; } // process command line arguments @@ -85,31 +87,32 @@ $raw_args = getopt('', 'metrics_port::', 'test_duration_secs::', 'num_channels_per_server::', - 'num_stubs_per_channel::']); + 'num_stubs_per_channel::', + ]); $args = []; if (empty($raw_args['server_addresses'])) { - $args['server_host'] = 'localhost'; - $args['server_port'] = '8080'; + $args['server_host'] = 'localhost'; + $args['server_port'] = '8080'; } else { - $parts = explode(':', $raw_args['server_addresses']); - $args['server_host'] = $parts[0]; - $args['server_port'] = (count($parts) == 2) ? $parts[1] : ''; + $parts = explode(':', $raw_args['server_addresses']); + $args['server_host'] = $parts[0]; + $args['server_port'] = (count($parts) == 2) ? $parts[1] : ''; } $args['metrics_port'] = empty($raw_args['metrics_port']) ? - '8081' : $args['metrics_port']; + '8081' : $args['metrics_port']; $args['test_duration_secs'] = empty($raw_args['test_duration_secs']) || - $raw_args['test_duration_secs'] == -1 ? - false : $raw_args['test_duration_secs']; + $raw_args['test_duration_secs'] == -1 ? + false : $raw_args['test_duration_secs']; $test_cases = []; $test_case_strs = explode(',', $raw_args['test_cases']); foreach ($test_case_strs as $test_case_str) { - $parts = explode(':', $test_case_str); - $test_cases = array_merge($test_cases, array_fill(0, $parts[1], $parts[0])); + $parts = explode(':', $test_case_str); + $test_cases = array_merge($test_cases, array_fill(0, $parts[1], $parts[0])); } $args['test_cases'] = $test_cases; diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py index 295dab2d274..3e974eba0a3 100644 --- a/src/python/grpcio/commands.py +++ b/src/python/grpcio/commands.py @@ -191,7 +191,7 @@ class BuildProtoModules(setuptools.Command): except subprocess.CalledProcessError as e: sys.stderr.write( 'warning: Command:\n{}\nMessage:\n{}\nOutput:\n{}'.format( - command, e.message, e.output)) + command, str(e), e.output)) # Generated proto directories dont include __init__.py, but # these are needed for python package resolution diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 5ba5a4e1fdd..1cc0c3a2505 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -900,6 +900,102 @@ class Server(six.with_metaclass(abc.ABCMeta)): ################################# Functions ################################ +def unary_unary_rpc_method_handler( + behavior, request_deserializer=None, response_serializer=None): + """Creates an RpcMethodHandler for a unary-unary RPC method. + + Args: + behavior: The implementation of an RPC method as a callable behavior taking + a single request value and returning a single response value. + request_deserializer: An optional request deserialization behavior. + response_serializer: An optional response serialization behavior. + + Returns: + An RpcMethodHandler for a unary-unary RPC method constructed from the given + parameters. + """ + from grpc import _utilities + return _utilities.RpcMethodHandler( + False, False, request_deserializer, response_serializer, behavior, None, + None, None) + + +def unary_stream_rpc_method_handler( + behavior, request_deserializer=None, response_serializer=None): + """Creates an RpcMethodHandler for a unary-stream RPC method. + + Args: + behavior: The implementation of an RPC method as a callable behavior taking + a single request value and returning an iterator of response values. + request_deserializer: An optional request deserialization behavior. + response_serializer: An optional response serialization behavior. + + Returns: + An RpcMethodHandler for a unary-stream RPC method constructed from the + given parameters. + """ + from grpc import _utilities + return _utilities.RpcMethodHandler( + False, True, request_deserializer, response_serializer, None, behavior, + None, None) + + +def stream_unary_rpc_method_handler( + behavior, request_deserializer=None, response_serializer=None): + """Creates an RpcMethodHandler for a stream-unary RPC method. + + Args: + behavior: The implementation of an RPC method as a callable behavior taking + an iterator of request values and returning a single response value. + request_deserializer: An optional request deserialization behavior. + response_serializer: An optional response serialization behavior. + + Returns: + An RpcMethodHandler for a stream-unary RPC method constructed from the + given parameters. + """ + from grpc import _utilities + return _utilities.RpcMethodHandler( + True, False, request_deserializer, response_serializer, None, None, + behavior, None) + + +def stream_stream_rpc_method_handler( + behavior, request_deserializer=None, response_serializer=None): + """Creates an RpcMethodHandler for a stream-stream RPC method. + + Args: + behavior: The implementation of an RPC method as a callable behavior taking + an iterator of request values and returning an iterator of response + values. + request_deserializer: An optional request deserialization behavior. + response_serializer: An optional response serialization behavior. + + Returns: + An RpcMethodHandler for a stream-stream RPC method constructed from the + given parameters. + """ + from grpc import _utilities + return _utilities.RpcMethodHandler( + True, True, request_deserializer, response_serializer, None, None, None, + behavior) + + +def method_handlers_generic_handler(service, method_handlers): + """Creates a grpc.GenericRpcHandler from RpcMethodHandlers. + + Args: + service: A service name to be used for the given method handlers. + method_handlers: A dictionary from method name to RpcMethodHandler + implementing the named method. + + Returns: + A GenericRpcHandler constructed from the given parameters. + """ + from grpc import _utilities + return _utilities.DictionaryGenericHandler(service, method_handlers) + + def ssl_channel_credentials( root_certificates=None, private_key=None, certificate_chain=None): """Creates a ChannelCredentials for use with an SSL-enabled Channel. @@ -1059,7 +1155,7 @@ def insecure_channel(target, options=None): A Channel to the target through which RPCs may be conducted. """ from grpc import _channel - return _channel.Channel(target, None, options) + return _channel.Channel(target, options, None) def secure_channel(target, credentials, options=None): @@ -1075,7 +1171,7 @@ def secure_channel(target, credentials, options=None): A Channel to the target through which RPCs may be conducted. """ from grpc import _channel - return _channel.Channel(target, credentials, options) + return _channel.Channel(target, options, credentials) def server(generic_rpc_handlers, thread_pool, options=None): @@ -1097,3 +1193,49 @@ def server(generic_rpc_handlers, thread_pool, options=None): """ from grpc import _server return _server.Server(generic_rpc_handlers, thread_pool) + + +################################### __all__ ################################# + + +__all__ = ( + 'FutureTimeoutError', + 'FutureCancelledError', + 'Future', + 'ChannelConnectivity', + 'StatusCode', + 'RpcError', + 'RpcContext', + 'Call', + 'ChannelCredentials', + 'CallCredentials', + 'AuthMetadataContext', + 'AuthMetadataPluginCallback', + 'AuthMetadataPlugin', + 'ServerCredentials', + 'UnaryUnaryMultiCallable', + 'UnaryStreamMultiCallable', + 'StreamUnaryMultiCallable', + 'StreamStreamMultiCallable', + 'Channel', + 'ServicerContext', + 'RpcMethodHandler', + 'HandlerCallDetails', + 'GenericRpcHandler', + 'Server', + 'unary_unary_rpc_method_handler', + 'unary_stream_rpc_method_handler', + 'stream_unary_rpc_method_handler', + 'stream_stream_rpc_method_handler', + 'method_handlers_generic_handler', + 'ssl_channel_credentials', + 'metadata_call_credentials', + 'access_token_call_credentials', + 'composite_call_credentials', + 'composite_channel_credentials', + 'ssl_server_credentials', + 'channel_ready_future', + 'insecure_channel', + 'secure_channel', + 'server', +) diff --git a/src/python/grpcio/grpc/_auth.py b/src/python/grpcio/grpc/_auth.py index 3ae00ca23a7..dea3221c9d8 100644 --- a/src/python/grpcio/grpc/_auth.py +++ b/src/python/grpcio/grpc/_auth.py @@ -29,6 +29,7 @@ """GRPCAuthMetadataPlugins for standard authentication.""" +import inspect from concurrent import futures import grpc @@ -46,9 +47,21 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin): self._credentials = credentials self._pool = futures.ThreadPoolExecutor(max_workers=1) + # Hack to determine if these are JWT creds and we need to pass + # additional_claims when getting a token + if 'additional_claims' in inspect.getargspec( + credentials.get_access_token).args: + self._is_jwt = True + else: + self._is_jwt = False + def __call__(self, context, callback): # MetadataPlugins cannot block (see grpc.beta.interfaces.py) - future = self._pool.submit(self._credentials.get_access_token) + if self._is_jwt: + future = self._pool.submit(self._credentials.get_access_token, + additional_claims={'aud': context.service_url}) + else: + future = self._pool.submit(self._credentials.get_access_token) future.add_done_callback(lambda x: self._get_token_callback(callback, x)) def _get_token_callback(self, callback, future): diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index d9eb5a4b770..d9315d2e6cd 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -85,7 +85,7 @@ def _deadline(timeout): def _unknown_code_details(unknown_cygrpc_code, details): - return b'Server sent unknown code {} and details "{}"'.format( + return 'Server sent unknown code {} and details "{}"'.format( unknown_cygrpc_code, details) @@ -134,19 +134,19 @@ def _handle_event(event, state, response_deserializer): for batch_operation in event.batch_operations: operation_type = batch_operation.type state.due.remove(operation_type) - if operation_type is cygrpc.OperationType.receive_initial_metadata: + if operation_type == cygrpc.OperationType.receive_initial_metadata: state.initial_metadata = batch_operation.received_metadata - elif operation_type is cygrpc.OperationType.receive_message: + elif operation_type == cygrpc.OperationType.receive_message: serialized_response = batch_operation.received_message.bytes() if serialized_response is not None: response = _common.deserialize( serialized_response, response_deserializer) if response is None: - details = b'Exception deserializing response!' + details = 'Exception deserializing response!' _abort(state, grpc.StatusCode.INTERNAL, details) else: state.response = response - elif operation_type is cygrpc.OperationType.receive_status_on_client: + elif operation_type == cygrpc.OperationType.receive_status_on_client: state.trailing_metadata = batch_operation.received_metadata if state.code is None: code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE.get( @@ -186,7 +186,7 @@ def _consume_request_iterator( if state.code is None and not state.cancelled: if serialized_request is None: call.cancel() - details = b'Exception serializing request!' + details = 'Exception serializing request!' _abort(state, grpc.StatusCode.INTERNAL, details) return else: @@ -230,7 +230,7 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): if self._state.code is None: self._call.cancel() self._state.cancelled = True - _abort(self._state, grpc.StatusCode.CANCELLED, b'Cancelled!') + _abort(self._state, grpc.StatusCode.CANCELLED, 'Cancelled!') self._state.condition.notify_all() return False @@ -402,7 +402,7 @@ def _start_unary_request(request, timeout, request_serializer): if serialized_request is None: state = _RPCState( (), _EMPTY_METADATA, _EMPTY_METADATA, grpc.StatusCode.INTERNAL, - b'Exception serializing request!') + 'Exception serializing request!') rendezvous = _Rendezvous(state, None, None, deadline) return deadline, deadline_timespec, None, rendezvous else: diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index a3fb66cd077..1fd1704f18b 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -30,6 +30,8 @@ """Shared implementation.""" import logging +import threading +import time import six @@ -97,3 +99,56 @@ def serialize(message, serializer): def deserialize(serialized_message, deserializer): return _transform(serialized_message, deserializer, 'Exception deserializing message!') + + +def _encode(s): + if isinstance(s, bytes): + return s + else: + return s.encode('ascii') + + +def fully_qualified_method(group, method): + group = _encode(group) + method = _encode(method) + return b'/' + group + b'/' + method + + +class CleanupThread(threading.Thread): + """A threading.Thread subclass supporting custom behavior on join(). + + On Python Interpreter exit, Python will attempt to join outstanding threads + prior to garbage collection. We may need to do additional cleanup, and + we accomplish this by overriding the join() method. + """ + + def __init__(self, behavior, group=None, target=None, name=None, + args=(), kwargs={}): + """Constructor. + + Args: + behavior (function): Function called on join() with a single + argument, timeout, indicating the maximum duration of + `behavior`, or None indicating `behavior` has no deadline. + `behavior` must be idempotent. + group (None): should be None. Reseved for future extensions + when ThreadGroup is implemented. + target (function): The function to invoke when this thread is + run. Defaults to None. + name (str): The name of this thread. Defaults to None. + args (tuple[object]): A tuple of arguments to pass to `target`. + kwargs (dict[str,object]): A dictionary of keyword arguments to + pass to `target`. + """ + super(CleanupThread, self).__init__(group=group, target=target, + name=name, args=args, kwargs=kwargs) + self._behavior = behavior + + def join(self, timeout=None): + start_time = time.time() + self._behavior(timeout) + end_time = time.time() + if timeout is not None: + timeout -= end_time - start_time + timeout = max(timeout, 0) + super(CleanupThread, self).join(timeout) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi index 1bfe6344e07..a09bbc75fe6 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi @@ -55,6 +55,7 @@ cdef class Call: def cancel( self, grpc_status_code error_code=GRPC_STATUS__DO_NOT_USE, details=None): + details = str_to_bytes(details) if not self.is_valid: raise ValueError("invalid call object cannot be used from Python") if (details is None) != (error_code == GRPC_STATUS__DO_NOT_USE): @@ -63,12 +64,6 @@ cdef class Call: cdef grpc_call_error result cdef char *c_details = NULL if error_code != GRPC_STATUS__DO_NOT_USE: - if isinstance(details, bytes): - pass - elif isinstance(details, basestring): - details = details.encode() - else: - raise TypeError("expected details to be str or bytes") self.references.append(details) c_details = details with nogil: diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index c26bc083cf3..866cff0d019 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -34,18 +34,13 @@ cdef class Channel: def __cinit__(self, target, ChannelArgs arguments=None, ChannelCredentials channel_credentials=None): + target = str_to_bytes(target) cdef grpc_channel_args *c_arguments = NULL cdef char *c_target = NULL self.c_channel = NULL self.references = [] if arguments is not None: c_arguments = &arguments.c_args - if isinstance(target, bytes): - pass - elif isinstance(target, basestring): - target = target.encode() - else: - raise TypeError("expected target to be str or bytes") c_target = target if channel_credentials is None: with nogil: @@ -62,25 +57,14 @@ cdef class Channel: def create_call(self, Call parent, int flags, CompletionQueue queue not None, method, host, Timespec deadline not None): + method = str_to_bytes(method) + host = str_to_bytes(host) if queue.is_shutting_down: raise ValueError("queue must not be shutting down or shutdown") - if isinstance(method, bytes): - pass - elif isinstance(method, basestring): - method = method.encode() - else: - raise TypeError("expected method to be str or bytes") cdef char *method_c_string = method cdef char *host_c_string = NULL - if host is None: - pass - elif isinstance(host, bytes): + if host is not None: host_c_string = host - elif isinstance(host, basestring): - host = host.encode() - host_c_string = host - else: - raise TypeError("expected host to be str, bytes, or None") cdef Call operation_call = Call() operation_call.references = [self, method, host, queue] cdef grpc_call *parent_call = NULL diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi index a67c9636843..01089c3dc0b 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi @@ -31,9 +31,6 @@ cdef class CompletionQueue: cdef grpc_completion_queue *c_completion_queue - cdef object pluck_condition - cdef int num_plucking - cdef int num_polling cdef bint is_shutting_down cdef bint is_shutdown diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi index cdae39d5194..90266516fed 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi @@ -32,6 +32,8 @@ cimport cpython import threading import time +cdef int _INTERRUPT_CHECK_PERIOD_MS = 200 + cdef class CompletionQueue: @@ -40,9 +42,6 @@ cdef class CompletionQueue: self.c_completion_queue = grpc_completion_queue_create(NULL) self.is_shutting_down = False self.is_shutdown = False - self.pluck_condition = threading.Condition() - self.num_plucking = 0 - self.num_polling = 0 cdef _interpret_event(self, grpc_event event): cdef OperationTag tag = None @@ -83,45 +82,27 @@ cdef class CompletionQueue: def poll(self, Timespec deadline=None): # We name this 'poll' to avoid problems with CPython's expectations for # 'special' methods (like next and __next__). + cdef gpr_timespec c_increment + cdef gpr_timespec c_timeout cdef gpr_timespec c_deadline with nogil: + c_increment = gpr_time_from_millis(_INTERRUPT_CHECK_PERIOD_MS, GPR_TIMESPAN) c_deadline = gpr_inf_future(GPR_CLOCK_REALTIME) - if deadline is not None: - c_deadline = deadline.c_time - cdef grpc_event event - - # Poll within a critical section to detect contention - with self.pluck_condition: - assert self.num_plucking == 0, 'cannot simultaneously pluck and poll' - self.num_polling += 1 - with nogil: - event = grpc_completion_queue_next( - self.c_completion_queue, c_deadline, NULL) - with self.pluck_condition: - self.num_polling -= 1 - return self._interpret_event(event) - - def pluck(self, OperationTag tag, Timespec deadline=None): - # Plucking a 'None' tag is equivalent to passing control to GRPC core until - # the deadline. - cdef gpr_timespec c_deadline = gpr_inf_future( - GPR_CLOCK_REALTIME) - if deadline is not None: - c_deadline = deadline.c_time - cdef grpc_event event - - # Pluck within a critical section to detect contention - with self.pluck_condition: - assert self.num_polling == 0, 'cannot simultaneously pluck and poll' - assert self.num_plucking < GRPC_MAX_COMPLETION_QUEUE_PLUCKERS, ( - 'cannot pluck more than {} times simultaneously'.format( - GRPC_MAX_COMPLETION_QUEUE_PLUCKERS)) - self.num_plucking += 1 - with nogil: - event = grpc_completion_queue_pluck( - self.c_completion_queue, tag, c_deadline, NULL) - with self.pluck_condition: - self.num_plucking -= 1 + if deadline is not None: + c_deadline = deadline.c_time + + while True: + c_timeout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c_increment) + if gpr_time_cmp(c_timeout, c_deadline) > 0: + c_timeout = c_deadline + event = grpc_completion_queue_next( + self.c_completion_queue, c_timeout, NULL) + if event.type != GRPC_QUEUE_TIMEOUT or gpr_time_cmp(c_timeout, c_deadline) == 0: + break; + + # Handle any signals + with gil: + cpython.PyErr_CheckSignals() return self._interpret_event(event) def shutdown(self): diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi index 19a59e08f3f..d377a675200 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi @@ -54,7 +54,7 @@ cdef class ServerCredentials: cdef class CredentialsMetadataPlugin: cdef object plugin_callback - cdef str plugin_name + cdef bytes plugin_name cdef grpc_metadata_credentials_plugin make_c_plugin(self) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index 1ba86457af5..470382d6091 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -82,7 +82,7 @@ cdef class ServerCredentials: cdef class CredentialsMetadataPlugin: - def __cinit__(self, object plugin_callback, str name): + def __cinit__(self, object plugin_callback, name): """ Args: plugin_callback (callable): Callback accepting a service URL (str/bytes) @@ -93,6 +93,7 @@ cdef class CredentialsMetadataPlugin: successful). name (str): Plugin name. """ + name = str_to_bytes(name) if not callable(plugin_callback): raise ValueError('expected callable plugin_callback') self.plugin_callback = plugin_callback @@ -129,7 +130,8 @@ cdef void plugin_get_metadata( grpc_credentials_plugin_metadata_cb cb, void *user_data) with gil: def python_callback( Metadata metadata, grpc_status_code status, - const char *error_details): + error_details): + error_details = str_to_bytes(error_details) cb(user_data, metadata.c_metadata_array.metadata, metadata.c_metadata_array.count, status, error_details) cdef CredentialsMetadataPlugin self = state @@ -148,14 +150,7 @@ def channel_credentials_google_default(): def channel_credentials_ssl(pem_root_certificates, SslPemKeyCertPair ssl_pem_key_cert_pair): - if pem_root_certificates is None: - pass - elif isinstance(pem_root_certificates, bytes): - pass - elif isinstance(pem_root_certificates, basestring): - pem_root_certificates = pem_root_certificates.encode() - else: - raise TypeError("expected str or bytes for pem_root_certificates") + pem_root_certificates = str_to_bytes(pem_root_certificates) cdef ChannelCredentials credentials = ChannelCredentials() cdef const char *c_pem_root_certificates = NULL if pem_root_certificates is not None: @@ -207,12 +202,7 @@ def call_credentials_google_compute_engine(): def call_credentials_service_account_jwt_access( json_key, Timespec token_lifetime not None): - if isinstance(json_key, bytes): - pass - elif isinstance(json_key, basestring): - json_key = json_key.encode() - else: - raise TypeError("expected json_key to be str or bytes") + json_key = str_to_bytes(json_key) cdef CallCredentials credentials = CallCredentials() cdef char *json_key_c_string = json_key with nogil: @@ -223,12 +213,7 @@ def call_credentials_service_account_jwt_access( return credentials def call_credentials_google_refresh_token(json_refresh_token): - if isinstance(json_refresh_token, bytes): - pass - elif isinstance(json_refresh_token, basestring): - json_refresh_token = json_refresh_token.encode() - else: - raise TypeError("expected json_refresh_token to be str or bytes") + json_refresh_token = str_to_bytes(json_refresh_token) cdef CallCredentials credentials = CallCredentials() cdef char *json_refresh_token_c_string = json_refresh_token with nogil: @@ -238,18 +223,8 @@ def call_credentials_google_refresh_token(json_refresh_token): return credentials def call_credentials_google_iam(authorization_token, authority_selector): - if isinstance(authorization_token, bytes): - pass - elif isinstance(authorization_token, basestring): - authorization_token = authorization_token.encode() - else: - raise TypeError("expected authorization_token to be str or bytes") - if isinstance(authority_selector, bytes): - pass - elif isinstance(authority_selector, basestring): - authority_selector = authority_selector.encode() - else: - raise TypeError("expected authority_selector to be str or bytes") + authorization_token = str_to_bytes(authorization_token) + authority_selector = str_to_bytes(authority_selector) cdef CallCredentials credentials = CallCredentials() cdef char *authorization_token_c_string = authorization_token cdef char *authority_selector_c_string = authority_selector @@ -272,16 +247,10 @@ def call_credentials_metadata_plugin(CredentialsMetadataPlugin plugin): def server_credentials_ssl(pem_root_certs, pem_key_cert_pairs, bint force_client_auth): + pem_root_certs = str_to_bytes(pem_root_certs) cdef char *c_pem_root_certs = NULL - if pem_root_certs is None: - pass - elif isinstance(pem_root_certs, bytes): - c_pem_root_certs = pem_root_certs - elif isinstance(pem_root_certs, basestring): - pem_root_certs = pem_root_certs.encode() + if pem_root_certs is not None: c_pem_root_certs = pem_root_certs - else: - raise TypeError("expected pem_root_certs to be str or bytes") pem_key_cert_pairs = list(pem_key_cert_pairs) for pair in pem_key_cert_pairs: if not isinstance(pair, SslPemKeyCertPair): diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 05b8886df73..168b9751aa2 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -80,6 +80,12 @@ cdef extern from "grpc/_cython/loader.h": gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock) nogil + gpr_timespec gpr_time_from_millis(int64_t ms, gpr_clock_type type) nogil + + gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) nogil + + int gpr_time_cmp(gpr_timespec a, gpr_timespec b) nogil + ctypedef enum grpc_status_code: GRPC_STATUS_OK GRPC_STATUS_CANCELLED diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi new file mode 100644 index 00000000000..274f038e0ac --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi @@ -0,0 +1,39 @@ +# 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. + + +# This function will ascii encode unicode string inputs if neccesary. +# In Python3, unicode strings are the default str type. +cdef bytes str_to_bytes(object s): + if s is None or isinstance(s, bytes): + return s + elif isinstance(s, unicode): + return s.encode('ascii') + else: + raise TypeError('Expected bytes, str, or unicode, not {}'.format(type(s))) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index e0219b00865..2e52953c0a3 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -235,18 +235,13 @@ cdef class ByteBuffer: if data is None: self.c_byte_buffer = NULL return - if isinstance(data, bytes): - pass - elif isinstance(data, basestring): - data = data.encode() - elif isinstance(data, ByteBuffer): + if isinstance(data, ByteBuffer): data = (data).bytes() if data is None: self.c_byte_buffer = NULL return else: - raise TypeError("expected value to be of type str, bytes, or " - "ByteBuffer, not {}".format(type(data))) + data = str_to_bytes(data) cdef char *c_data = data cdef gpr_slice data_slice @@ -302,19 +297,8 @@ cdef class ByteBuffer: cdef class SslPemKeyCertPair: def __cinit__(self, private_key, certificate_chain): - if isinstance(private_key, bytes): - self.private_key = private_key - elif isinstance(private_key, basestring): - self.private_key = private_key.encode() - else: - raise TypeError("expected private_key to be of type str or bytes") - if isinstance(certificate_chain, bytes): - self.certificate_chain = certificate_chain - elif isinstance(certificate_chain, basestring): - self.certificate_chain = certificate_chain.encode() - else: - raise TypeError("expected certificate_chain to be of type str or bytes " - "or int") + self.private_key = str_to_bytes(private_key) + self.certificate_chain = str_to_bytes(certificate_chain) self.c_pair.private_key = self.private_key self.c_pair.certificate_chain = self.certificate_chain @@ -322,27 +306,16 @@ cdef class SslPemKeyCertPair: cdef class ChannelArg: def __cinit__(self, key, value): - if isinstance(key, bytes): - self.key = key - elif isinstance(key, basestring): - self.key = key.encode() - else: - raise TypeError("expected key to be of type str or bytes") - if isinstance(value, bytes): - self.value = value - self.c_arg.type = GRPC_ARG_STRING - self.c_arg.value.string = self.value - elif isinstance(value, basestring): - self.value = value.encode() - self.c_arg.type = GRPC_ARG_STRING - self.c_arg.value.string = self.value - elif isinstance(value, int): + self.key = str_to_bytes(key) + self.c_arg.key = self.key + if isinstance(value, int): self.value = int(value) self.c_arg.type = GRPC_ARG_INTEGER self.c_arg.value.integer = self.value else: - raise TypeError("expected value to be of type str or bytes or int") - self.c_arg.key = self.key + self.value = str_to_bytes(value) + self.c_arg.type = GRPC_ARG_STRING + self.c_arg.value.string = self.value cdef class ChannelArgs: @@ -375,18 +348,8 @@ cdef class ChannelArgs: cdef class Metadatum: def __cinit__(self, key, value): - if isinstance(key, bytes): - self._key = key - elif isinstance(key, basestring): - self._key = key.encode() - else: - raise TypeError("expected key to be of type str or bytes") - if isinstance(value, bytes): - self._value = value - elif isinstance(value, basestring): - self._value = value.encode() - else: - raise TypeError("expected value to be of type str or bytes") + self._key = str_to_bytes(key) + self._value = str_to_bytes(value) self.c_metadata.key = self._key self.c_metadata.value = self._value self.c_metadata.value_length = len(self._value) @@ -601,12 +564,7 @@ def operation_send_close_from_client(int flags): def operation_send_status_from_server( Metadata metadata, grpc_status_code code, details, int flags): - if isinstance(details, bytes): - pass - elif isinstance(details, basestring): - details = details.encode() - else: - raise TypeError("expected a str or bytes object for details") + details = str_to_bytes(details) cdef Operation op = Operation() op.c_op.type = GRPC_OP_SEND_STATUS_FROM_SERVER op.c_op.flags = flags diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi index 55948755b2f..42afeb84987 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi @@ -99,16 +99,11 @@ cdef class Server: with nogil: grpc_server_start(self.c_server) # Ensure the core has gotten a chance to do the start-up work - self.backup_shutdown_queue.pluck(None, Timespec(None)) + self.backup_shutdown_queue.poll(Timespec(None)) def add_http2_port(self, address, ServerCredentials server_credentials=None): - if isinstance(address, bytes): - pass - elif isinstance(address, basestring): - address = address.encode() - else: - raise TypeError("expected address to be a str or bytes") + address = str_to_bytes(address) self.references.append(address) cdef int result cdef char *address_c_string = address diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index 8823ea5ef5e..cf146f5a048 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -35,6 +35,7 @@ import sys # TODO(atash): figure out why the coverage tool gets confused about the Cython # coverage plugin when the following files don't have a '.pxi' suffix. +include "grpc/_cython/_cygrpc/grpc_string.pyx.pxi" include "grpc/_cython/_cygrpc/call.pyx.pxi" include "grpc/_cython/_cygrpc/channel.pyx.pxi" include "grpc/_cython/_cygrpc/credentials.pyx.pxi" diff --git a/src/python/grpcio/grpc/_cython/imports.generated.c b/src/python/grpcio/grpc/_cython/imports.generated.c index c80ee66c061..5c49f6cf3e9 100644 --- a/src/python/grpcio/grpc/_cython/imports.generated.c +++ b/src/python/grpcio/grpc/_cython/imports.generated.c @@ -126,6 +126,8 @@ grpc_header_key_is_legal_type grpc_header_key_is_legal_import; grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import; grpc_is_binary_header_type grpc_is_binary_header_import; grpc_call_error_to_string_type grpc_call_error_to_string_import; +grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import; +grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import; grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import; grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import; @@ -397,6 +399,8 @@ void pygrpc_load_imports(HMODULE library) { grpc_header_nonbin_value_is_legal_import = (grpc_header_nonbin_value_is_legal_type) GetProcAddress(library, "grpc_header_nonbin_value_is_legal"); grpc_is_binary_header_import = (grpc_is_binary_header_type) GetProcAddress(library, "grpc_is_binary_header"); grpc_call_error_to_string_import = (grpc_call_error_to_string_type) GetProcAddress(library, "grpc_call_error_to_string"); + grpc_insecure_channel_create_from_fd_import = (grpc_insecure_channel_create_from_fd_type) GetProcAddress(library, "grpc_insecure_channel_create_from_fd"); + grpc_server_add_insecure_channel_from_fd_import = (grpc_server_add_insecure_channel_from_fd_type) GetProcAddress(library, "grpc_server_add_insecure_channel_from_fd"); grpc_auth_property_iterator_next_import = (grpc_auth_property_iterator_next_type) GetProcAddress(library, "grpc_auth_property_iterator_next"); grpc_auth_context_property_iterator_import = (grpc_auth_context_property_iterator_type) GetProcAddress(library, "grpc_auth_context_property_iterator"); grpc_auth_context_peer_identity_import = (grpc_auth_context_peer_identity_type) GetProcAddress(library, "grpc_auth_context_peer_identity"); diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h index 7b8e98d9bf7..62865f8a0e9 100644 --- a/src/python/grpcio/grpc/_cython/imports.generated.h +++ b/src/python/grpcio/grpc/_cython/imports.generated.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -328,6 +329,12 @@ extern grpc_is_binary_header_type grpc_is_binary_header_import; typedef const char *(*grpc_call_error_to_string_type)(grpc_call_error error); extern grpc_call_error_to_string_type grpc_call_error_to_string_import; #define grpc_call_error_to_string grpc_call_error_to_string_import +typedef grpc_channel *(*grpc_insecure_channel_create_from_fd_type)(const char *target, int fd, const grpc_channel_args *args); +extern grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import; +#define grpc_insecure_channel_create_from_fd grpc_insecure_channel_create_from_fd_import +typedef void(*grpc_server_add_insecure_channel_from_fd_type)(grpc_server *server, grpc_completion_queue *cq, int fd); +extern grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import; +#define grpc_server_add_insecure_channel_from_fd grpc_server_add_insecure_channel_from_fd_import typedef const grpc_auth_property *(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator *it); extern grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; #define grpc_auth_property_iterator_next grpc_auth_property_iterator_next_import @@ -475,7 +482,7 @@ extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_impo typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader); extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; #define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import -typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...); +typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); extern gpr_log_type gpr_log_import; #define gpr_log gpr_log_import typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); @@ -814,7 +821,7 @@ extern gpr_format_message_type gpr_format_message_import; typedef char *(*gpr_strdup_type)(const char *src); extern gpr_strdup_type gpr_strdup_import; #define gpr_strdup gpr_strdup_import -typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...); +typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(2, 3); extern gpr_asprintf_type gpr_asprintf_import; #define gpr_asprintf gpr_asprintf_import typedef const char *(*gpr_subprocess_binary_extension_type)(); diff --git a/src/python/grpcio/grpc/_links/service.py b/src/python/grpcio/grpc/_links/service.py index 11310e22409..5fc4994ca0e 100644 --- a/src/python/grpcio/grpc/_links/service.py +++ b/src/python/grpcio/grpc/_links/service.py @@ -33,6 +33,7 @@ import abc import enum import logging import threading +import six import time from grpc._adapter import _intermediary_low @@ -177,7 +178,10 @@ class _Kernel(object): call = service_acceptance.call call.accept(self._completion_queue, call) try: - group, method = service_acceptance.method.split(b'/')[1:3] + service_method = service_acceptance.method + if six.PY3: + service_method = service_method.decode('latin1') + group, method = service_method.split('/')[1:3] except ValueError: logging.info('Illegal path "%s"!', service_acceptance.method) return diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index aae9f48ae6c..bf20f15f729 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -60,6 +60,8 @@ _CANCELLED = 'cancelled' _EMPTY_FLAGS = 0 _EMPTY_METADATA = cygrpc.Metadata(()) +_UNEXPECTED_EXIT_SERVER_GRACE = 1.0 + def _serialized_request(request_event): return request_event.batch_operations[0].received_message.bytes() @@ -85,7 +87,7 @@ def _abortion_code(state, code): def _details(state): - return b'' if state.details is None else state.details + return '' if state.details is None else state.details class _HandlerCallDetails( @@ -189,7 +191,7 @@ def _receive_message(state, call, request_deserializer): if request is None: _abort( state, call, cygrpc.StatusCode.internal, - b'Exception deserializing request!') + 'Exception deserializing request!') else: state.request = request state.condition.notify_all() @@ -254,7 +256,7 @@ class _Context(grpc.ServicerContext): else: if self._state.initial_metadata_allowed: operation = cygrpc.operation_send_initial_metadata( - cygrpc.Metadata(initial_metadata), _EMPTY_FLAGS) + _common.metadata(initial_metadata), _EMPTY_FLAGS) self._rpc_event.operation_call.start_batch( cygrpc.Operations((operation,)), _send_initial_metadata(self._state)) @@ -340,12 +342,11 @@ def _unary_request(rpc_event, state, request_deserializer): state.condition.wait() if state.request is None: if state.client is _CLOSED: - details = b'"{}" requires exactly one request message.'.format( + details = '"{}" requires exactly one request message.'.format( rpc_event.request_call_details.method) - # TODO(5992#issuecomment-220761992): really, what status code? _abort( state, rpc_event.operation_call, - cygrpc.StatusCode.unavailable, details) + cygrpc.StatusCode.unimplemented, details) return None elif state.client is _CANCELLED: return None @@ -363,7 +364,7 @@ def _call_behavior(rpc_event, state, behavior, argument, request_deserializer): except Exception as e: # pylint: disable=broad-except with state.condition: if e not in state.rpc_errors: - details = b'Exception calling application: {}'.format(e) + details = 'Exception calling application: {}'.format(e) logging.exception(details) _abort( state, rpc_event.operation_call, cygrpc.StatusCode.unknown, details) @@ -378,7 +379,7 @@ def _take_response_from_response_iterator(rpc_event, state, response_iterator): except Exception as e: # pylint: disable=broad-except with state.condition: if e not in state.rpc_errors: - details = b'Exception iterating responses: {}'.format(e) + details = 'Exception iterating responses: {}'.format(e) logging.exception(details) _abort( state, rpc_event.operation_call, cygrpc.StatusCode.unknown, details) @@ -391,7 +392,7 @@ def _serialize_response(rpc_event, state, response, response_serializer): with state.condition: _abort( state, rpc_event.operation_call, cygrpc.StatusCode.internal, - b'Failed to serialize response!') + 'Failed to serialize response!') return None else: return serialized_response @@ -544,7 +545,7 @@ def _handle_unrecognized_method(rpc_event): cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS), cygrpc.operation_send_status_from_server( _EMPTY_METADATA, cygrpc.StatusCode.unimplemented, - b'Method not found!', _EMPTY_FLAGS), + 'Method not found!', _EMPTY_FLAGS), ) rpc_state = _RPCState() rpc_event.operation_call.start_batch( @@ -670,17 +671,6 @@ def _serve(state): return -def _start(state): - with state.lock: - if state.stage is not _ServerStage.STOPPED: - raise ValueError('Cannot start already-started server!') - state.server.start() - state.stage = _ServerStage.STARTED - _request_call(state) - thread = threading.Thread(target=_serve, args=(state,)) - thread.start() - - def _stop(state, grace): with state.lock: if state.stage is _ServerStage.STOPPED: @@ -719,6 +709,24 @@ def _stop(state, grace): return shutdown_event +def _start(state): + with state.lock: + if state.stage is not _ServerStage.STOPPED: + raise ValueError('Cannot start already-started server!') + state.server.start() + state.stage = _ServerStage.STARTED + _request_call(state) + def cleanup_server(timeout): + if timeout is None: + _stop(state, _UNEXPECTED_EXIT_SERVER_GRACE).wait() + else: + _stop(state, timeout).wait() + + thread = _common.CleanupThread( + cleanup_server, target=_serve, args=(state,)) + thread.start() + + class Server(grpc.Server): def __init__(self, generic_handlers, thread_pool): diff --git a/src/python/grpcio/grpc/_utilities.py b/src/python/grpcio/grpc/_utilities.py index a4ca9b7282c..4850967fbc7 100644 --- a/src/python/grpcio/grpc/_utilities.py +++ b/src/python/grpcio/grpc/_utilities.py @@ -29,16 +29,41 @@ """Internal utilities for gRPC Python.""" +import collections import threading import time +import six + import grpc +from grpc import _common from grpc.framework.foundation import callable_util _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE = ( 'Exception calling connectivity future "done" callback!') +class RpcMethodHandler( + collections.namedtuple( + '_RpcMethodHandler', + ('request_streaming', 'response_streaming', 'request_deserializer', + 'response_serializer', 'unary_unary', 'unary_stream', 'stream_unary', + 'stream_stream',)), + grpc.RpcMethodHandler): + pass + + +class DictionaryGenericHandler(grpc.GenericRpcHandler): + + def __init__(self, service, method_handlers): + self._method_handlers = { + _common.fully_qualified_method(service, method): method_handler + for method, method_handler in six.iteritems(method_handlers)} + + def service(self, handler_call_details): + return self._method_handlers.get(handler_call_details.method) + + class _ChannelReadyFuture(grpc.Future): def __init__(self, channel): @@ -144,4 +169,3 @@ def channel_ready_future(channel): ready_future = _ChannelReadyFuture(channel) ready_future.start() return ready_future - diff --git a/src/python/grpcio/grpc/beta/_client_adaptations.py b/src/python/grpcio/grpc/beta/_client_adaptations.py index 621fcf2174f..024808c5404 100644 --- a/src/python/grpcio/grpc/beta/_client_adaptations.py +++ b/src/python/grpcio/grpc/beta/_client_adaptations.py @@ -30,6 +30,7 @@ """Translates gRPC's client-side API into gRPC's client-side Beta API.""" import grpc +from grpc import _common from grpc._cython import cygrpc from grpc.beta import interfaces from grpc.framework.common import cardinality @@ -48,10 +49,6 @@ _STATUS_CODE_TO_ABORTION_KIND_AND_ABORTION_ERROR_CLASS = { } -def _fully_qualified_method(group, method): - return b'/{}/{}'.format(group, method) - - def _effective_metadata(metadata, metadata_transformer): non_none_metadata = () if metadata is None else metadata if metadata_transformer is None: @@ -184,7 +181,7 @@ def _blocking_unary_unary( metadata_transformer, request, request_serializer, response_deserializer): try: multi_callable = channel.unary_unary( - _fully_qualified_method(group, method), + _common.fully_qualified_method(group, method), request_serializer=request_serializer, response_deserializer=response_deserializer) effective_metadata = _effective_metadata(metadata, metadata_transformer) @@ -205,7 +202,7 @@ def _future_unary_unary( channel, group, method, timeout, protocol_options, metadata, metadata_transformer, request, request_serializer, response_deserializer): multi_callable = channel.unary_unary( - _fully_qualified_method(group, method), + _common.fully_qualified_method(group, method), request_serializer=request_serializer, response_deserializer=response_deserializer) effective_metadata = _effective_metadata(metadata, metadata_transformer) @@ -219,7 +216,7 @@ def _unary_stream( channel, group, method, timeout, protocol_options, metadata, metadata_transformer, request, request_serializer, response_deserializer): multi_callable = channel.unary_stream( - _fully_qualified_method(group, method), + _common.fully_qualified_method(group, method), request_serializer=request_serializer, response_deserializer=response_deserializer) effective_metadata = _effective_metadata(metadata, metadata_transformer) @@ -235,7 +232,7 @@ def _blocking_stream_unary( response_deserializer): try: multi_callable = channel.stream_unary( - _fully_qualified_method(group, method), + _common.fully_qualified_method(group, method), request_serializer=request_serializer, response_deserializer=response_deserializer) effective_metadata = _effective_metadata(metadata, metadata_transformer) @@ -257,7 +254,7 @@ def _future_stream_unary( metadata_transformer, request_iterator, request_serializer, response_deserializer): multi_callable = channel.stream_unary( - _fully_qualified_method(group, method), + _common.fully_qualified_method(group, method), request_serializer=request_serializer, response_deserializer=response_deserializer) effective_metadata = _effective_metadata(metadata, metadata_transformer) @@ -272,7 +269,7 @@ def _stream_stream( metadata_transformer, request_iterator, request_serializer, response_deserializer): multi_callable = channel.stream_stream( - _fully_qualified_method(group, method), + _common.fully_qualified_method(group, method), request_serializer=request_serializer, response_deserializer=response_deserializer) effective_metadata = _effective_metadata(metadata, metadata_transformer) diff --git a/src/python/grpcio/grpc/beta/_server_adaptations.py b/src/python/grpcio/grpc/beta/_server_adaptations.py index 52eadf23158..79e6ca87eb5 100644 --- a/src/python/grpcio/grpc/beta/_server_adaptations.py +++ b/src/python/grpcio/grpc/beta/_server_adaptations.py @@ -33,6 +33,7 @@ import collections import threading import grpc +from grpc import _common from grpc.beta import interfaces from grpc.framework.common import cardinality from grpc.framework.common import style @@ -287,36 +288,43 @@ def _simple_method_handler( None, _adapt_stream_stream_event(implementation.stream_stream_event)) +def _flatten_method_pair_map(method_pair_map): + method_pair_map = method_pair_map or {} + flat_map = {} + for method_pair in method_pair_map: + method = _common.fully_qualified_method(method_pair[0], method_pair[1]) + flat_map[method] = method_pair_map[method_pair] + return flat_map + + class _GenericRpcHandler(grpc.GenericRpcHandler): def __init__( self, method_implementations, multi_method_implementation, request_deserializers, response_serializers): - self._method_implementations = method_implementations + self._method_implementations = _flatten_method_pair_map( + method_implementations) + self._request_deserializers = _flatten_method_pair_map( + request_deserializers) + self._response_serializers = _flatten_method_pair_map( + response_serializers) self._multi_method_implementation = multi_method_implementation - self._request_deserializers = request_deserializers or {} - self._response_serializers = response_serializers or {} def service(self, handler_call_details): - try: - group_name, method_name = handler_call_details.method.split(b'/')[1:3] - except ValueError: + method_implementation = self._method_implementations.get( + handler_call_details.method) + if method_implementation is not None: + return _simple_method_handler( + method_implementation, + self._request_deserializers.get(handler_call_details.method), + self._response_serializers.get(handler_call_details.method)) + elif self._multi_method_implementation is None: return None else: - method_implementation = self._method_implementations.get( - (group_name, method_name,)) - if method_implementation is not None: - return _simple_method_handler( - method_implementation, - self._request_deserializers.get((group_name, method_name,)), - self._response_serializers.get((group_name, method_name,))) - elif self._multi_method_implementation is None: + try: + return None #TODO(nathaniel): call the multimethod. + except face.NoSuchMethodError: return None - else: - try: - return None #TODO(nathaniel): call the multimethod. - except face.NoSuchMethodError: - return None class _Server(interfaces.Server): diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index b83c82cb926..2a5229434c9 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -84,7 +84,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/connected_channel.c', 'src/core/lib/channel/http_client_filter.c', 'src/core/lib/channel/http_server_filter.c', - 'src/core/lib/compression/compression_algorithm.c', + 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', 'src/core/lib/http/format_request.c', @@ -161,6 +161,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/transport/transport.c', 'src/core/lib/transport/transport_op_string.c', 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c', + 'src/core/ext/transport/chttp2/transport/bin_decoder.c', 'src/core/ext/transport/chttp2/transport/bin_encoder.c', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c', 'src/core/ext/transport/chttp2/transport/chttp2_transport.c', @@ -231,7 +232,9 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/subchannel_index.c', 'src/core/ext/client_config/uri_parser.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', + 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c', + 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'third_party/nanopb/pb_common.c', diff --git a/src/python/grpcio/tests/interop/client.py b/src/python/grpcio/tests/interop/client.py index e3d5545a020..8aa1ce30c1a 100644 --- a/src/python/grpcio/tests/interop/client.py +++ b/src/python/grpcio/tests/interop/client.py @@ -76,6 +76,9 @@ def _stub(args): creds = oauth2client_client.GoogleCredentials.get_application_default() scoped_creds = creds.create_scoped([args.oauth_scope]) call_creds = implementations.google_call_credentials(scoped_creds) + elif args.test_case == 'jwt_token_creds': + creds = oauth2client_client.GoogleCredentials.get_application_default() + call_creds = implementations.google_call_credentials(creds) else: call_creds = None if args.use_tls: diff --git a/src/python/grpcio/tests/interop/methods.py b/src/python/grpcio/tests/interop/methods.py index d5ef0c68bb9..7eac5115258 100644 --- a/src/python/grpcio/tests/interop/methods.py +++ b/src/python/grpcio/tests/interop/methods.py @@ -310,6 +310,16 @@ def _oauth2_auth_token(stub, args): (response.oauth_scope, args.oauth_scope)) +def _jwt_token_creds(stub, args): + json_key_filename = os.environ[ + oauth2client_client.GOOGLE_APPLICATION_CREDENTIALS] + wanted_email = json.load(open(json_key_filename, 'rb'))['client_email'] + response = _large_unary_common_behavior(stub, True, False) + if wanted_email != response.username: + raise ValueError( + 'expected username %s, got %s' % (wanted_email, response.username)) + + def _per_rpc_creds(stub, args): json_key_filename = os.environ[ oauth2client_client.GOOGLE_APPLICATION_CREDENTIALS] @@ -338,6 +348,7 @@ class TestCase(enum.Enum): EMPTY_STREAM = 'empty_stream' COMPUTE_ENGINE_CREDS = 'compute_engine_creds' OAUTH2_AUTH_TOKEN = 'oauth2_auth_token' + JWT_TOKEN_CREDS = 'jwt_token_creds' PER_RPC_CREDS = 'per_rpc_creds' TIMEOUT_ON_SLEEPING_SERVER = 'timeout_on_sleeping_server' @@ -364,6 +375,8 @@ class TestCase(enum.Enum): _compute_engine_creds(stub, args) elif self is TestCase.OAUTH2_AUTH_TOKEN: _oauth2_auth_token(stub, args) + elif self is TestCase.JWT_TOKEN_CREDS: + _jwt_token_creds(stub, args) elif self is TestCase.PER_RPC_CREDS: _per_rpc_creds(stub, args) else: diff --git a/src/python/grpcio/tests/protoc_plugin/_python_plugin_test.py b/src/python/grpcio/tests/protoc_plugin/_python_plugin_test.py new file mode 100644 index 00000000000..1c9cbb0d0c3 --- /dev/null +++ b/src/python/grpcio/tests/protoc_plugin/_python_plugin_test.py @@ -0,0 +1,583 @@ +# 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. + +import collections +from concurrent import futures +import contextlib +import distutils.spawn +import errno +import os +import shutil +import subprocess +import sys +import tempfile +import threading +import unittest + +from six import moves + +import grpc +from tests.unit.framework.common import test_constants + +# Identifiers of entities we expect to find in the generated module. +STUB_IDENTIFIER = 'TestServiceStub' +SERVICER_IDENTIFIER = 'TestServiceServicer' +ADD_SERVICER_TO_SERVER_IDENTIFIER = 'add_TestServiceServicer_to_server' + + +class _ServicerMethods(object): + + def __init__(self, response_pb2, payload_pb2): + self._condition = threading.Condition() + self._paused = False + self._fail = False + self._response_pb2 = response_pb2 + self._payload_pb2 = payload_pb2 + + @contextlib.contextmanager + def pause(self): # pylint: disable=invalid-name + with self._condition: + self._paused = True + yield + with self._condition: + self._paused = False + self._condition.notify_all() + + @contextlib.contextmanager + def fail(self): # pylint: disable=invalid-name + with self._condition: + self._fail = True + yield + with self._condition: + self._fail = False + + def _control(self): # pylint: disable=invalid-name + with self._condition: + if self._fail: + raise ValueError() + while self._paused: + self._condition.wait() + + def UnaryCall(self, request, unused_rpc_context): + response = self._response_pb2.SimpleResponse() + response.payload.payload_type = self._payload_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * request.response_size + self._control() + return response + + def StreamingOutputCall(self, request, unused_rpc_context): + for parameter in request.response_parameters: + response = self._response_pb2.StreamingOutputCallResponse() + response.payload.payload_type = self._payload_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * parameter.size + self._control() + yield response + + def StreamingInputCall(self, request_iter, unused_rpc_context): + response = self._response_pb2.StreamingInputCallResponse() + aggregated_payload_size = 0 + for request in request_iter: + aggregated_payload_size += len(request.payload.payload_compressable) + response.aggregated_payload_size = aggregated_payload_size + self._control() + return response + + def FullDuplexCall(self, request_iter, unused_rpc_context): + for request in request_iter: + for parameter in request.response_parameters: + response = self._response_pb2.StreamingOutputCallResponse() + response.payload.payload_type = self._payload_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * parameter.size + self._control() + yield response + + def HalfDuplexCall(self, request_iter, unused_rpc_context): + responses = [] + for request in request_iter: + for parameter in request.response_parameters: + response = self._response_pb2.StreamingOutputCallResponse() + response.payload.payload_type = self._payload_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * parameter.size + self._control() + responses.append(response) + for response in responses: + yield response + + +class _Service( + collections.namedtuple( + '_Service', ('servicer_methods', 'server', 'stub',))): + """A live and running service. + + Attributes: + servicer_methods: The _ServicerMethods servicing RPCs. + server: The grpc.Server servicing RPCs. + stub: A stub on which to invoke RPCs. + """ + + +def _CreateService(service_pb2, response_pb2, payload_pb2): + """Provides a servicer backend and a stub. + + Args: + service_pb2: The service_pb2 module generated by this test. + response_pb2: The response_pb2 module generated by this test. + payload_pb2: The payload_pb2 module generated by this test. + + Returns: + A _Service with which to test RPCs. + """ + servicer_methods = _ServicerMethods(response_pb2, payload_pb2) + + class Servicer(getattr(service_pb2, SERVICER_IDENTIFIER)): + + def UnaryCall(self, request, context): + return servicer_methods.UnaryCall(request, context) + + def StreamingOutputCall(self, request, context): + return servicer_methods.StreamingOutputCall(request, context) + + def StreamingInputCall(self, request_iter, context): + return servicer_methods.StreamingInputCall(request_iter, context) + + def FullDuplexCall(self, request_iter, context): + return servicer_methods.FullDuplexCall(request_iter, context) + + def HalfDuplexCall(self, request_iter, context): + return servicer_methods.HalfDuplexCall(request_iter, context) + + server = grpc.server( + (), futures.ThreadPoolExecutor(max_workers=test_constants.POOL_SIZE)) + getattr(service_pb2, ADD_SERVICER_TO_SERVER_IDENTIFIER)(Servicer(), server) + port = server.add_insecure_port('[::]:0') + server.start() + channel = grpc.insecure_channel('localhost:{}'.format(port)) + stub = getattr(service_pb2, STUB_IDENTIFIER)(channel) + return _Service(servicer_methods, server, stub) + + +def _CreateIncompleteService(service_pb2): + """Provides a servicer backend that fails to implement methods and its stub. + + Args: + service_pb2: The service_pb2 module generated by this test. + + Returns: + A _Service with which to test RPCs. The returned _Service's + servicer_methods implements none of the methods required of it. + """ + + class Servicer(getattr(service_pb2, SERVICER_IDENTIFIER)): + pass + + server = grpc.server( + (), futures.ThreadPoolExecutor(max_workers=test_constants.POOL_SIZE)) + getattr(service_pb2, ADD_SERVICER_TO_SERVER_IDENTIFIER)(Servicer(), server) + port = server.add_insecure_port('[::]:0') + server.start() + channel = grpc.insecure_channel('localhost:{}'.format(port)) + stub = getattr(service_pb2, STUB_IDENTIFIER)(channel) + return _Service(None, server, stub) + + +def _streaming_input_request_iterator(request_pb2, payload_pb2): + for _ in range(3): + request = request_pb2.StreamingInputCallRequest() + request.payload.payload_type = payload_pb2.COMPRESSABLE + request.payload.payload_compressable = 'a' + yield request + + +def _streaming_output_request(request_pb2): + request = request_pb2.StreamingOutputCallRequest() + sizes = [1, 2, 3] + request.response_parameters.add(size=sizes[0], interval_us=0) + request.response_parameters.add(size=sizes[1], interval_us=0) + request.response_parameters.add(size=sizes[2], interval_us=0) + return request + + +def _full_duplex_request_iterator(request_pb2): + request = request_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + request = request_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=2, interval_us=0) + request.response_parameters.add(size=3, interval_us=0) + yield request + + +class PythonPluginTest(unittest.TestCase): + """Test case for the gRPC Python protoc-plugin. + + While reading these tests, remember that the futures API + (`stub.method.future()`) only gives futures for the *response-unary* + methods and does not exist for response-streaming methods. + """ + + def setUp(self): + # Assume that the appropriate protoc and grpc_python_plugins are on the + # path. + protoc_command = 'protoc' + protoc_plugin_filename = distutils.spawn.find_executable( + 'grpc_python_plugin') + if not os.path.isfile(protoc_command): + # Assume that if we haven't built protoc that it's on the system. + protoc_command = 'protoc' + + # Ensure that the output directory exists. + self.outdir = tempfile.mkdtemp() + + # Find all proto files + paths = [] + root_dir = os.path.dirname(os.path.realpath(__file__)) + proto_dir = os.path.join(root_dir, 'protos') + for walk_root, _, filenames in os.walk(proto_dir): + for filename in filenames: + if filename.endswith('.proto'): + path = os.path.join(walk_root, filename) + paths.append(path) + + # Invoke protoc with the plugin. + cmd = [ + protoc_command, + '--plugin=protoc-gen-python-grpc=%s' % protoc_plugin_filename, + '-I %s' % root_dir, + '--python_out=%s' % self.outdir, + '--python-grpc_out=%s' % self.outdir + ] + paths + subprocess.check_call(' '.join(cmd), shell=True, env=os.environ, + cwd=os.path.dirname(os.path.realpath(__file__))) + + # Generated proto directories dont include __init__.py, but + # these are needed for python package resolution + for walk_root, _, _ in os.walk(os.path.join(self.outdir, 'protos')): + path = os.path.join(walk_root, '__init__.py') + open(path, 'a').close() + + sys.path.insert(0, self.outdir) + + import protos.payload.test_payload_pb2 as payload_pb2 + import protos.requests.r.test_requests_pb2 as request_pb2 + import protos.responses.test_responses_pb2 as response_pb2 + import protos.service.test_service_pb2 as service_pb2 + self._payload_pb2 = payload_pb2 + self._request_pb2 = request_pb2 + self._response_pb2 = response_pb2 + self._service_pb2 = service_pb2 + + def tearDown(self): + try: + shutil.rmtree(self.outdir) + except OSError as exc: + if exc.errno != errno.ENOENT: + raise + sys.path.remove(self.outdir) + + def testImportAttributes(self): + # check that we can access the generated module and its members. + self.assertIsNotNone( + getattr(self._service_pb2, STUB_IDENTIFIER, None)) + self.assertIsNotNone( + getattr(self._service_pb2, SERVICER_IDENTIFIER, None)) + self.assertIsNotNone( + getattr(self._service_pb2, ADD_SERVICER_TO_SERVER_IDENTIFIER, None)) + + def testUpDown(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + self.assertIsNotNone(service.servicer_methods) + self.assertIsNotNone(service.server) + self.assertIsNotNone(service.stub) + + def testIncompleteServicer(self): + service = _CreateIncompleteService(self._service_pb2) + request = self._request_pb2.SimpleRequest(response_size=13) + with self.assertRaises(grpc.RpcError) as exception_context: + service.stub.UnaryCall(request) + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.UNIMPLEMENTED) + + def testUnaryCall(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = self._request_pb2.SimpleRequest(response_size=13) + response = service.stub.UnaryCall(request) + expected_response = service.servicer_methods.UnaryCall( + request, 'not a real context!') + self.assertEqual(expected_response, response) + + def testUnaryCallFuture(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = self._request_pb2.SimpleRequest(response_size=13) + # Check that the call does not block waiting for the server to respond. + with service.servicer_methods.pause(): + response_future = service.stub.UnaryCall.future(request) + response = response_future.result() + expected_response = service.servicer_methods.UnaryCall( + request, 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testUnaryCallFutureExpired(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = self._request_pb2.SimpleRequest(response_size=13) + with service.servicer_methods.pause(): + response_future = service.stub.UnaryCall.future( + request, timeout=test_constants.SHORT_TIMEOUT) + with self.assertRaises(grpc.RpcError) as exception_context: + response_future.result() + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.DEADLINE_EXCEEDED) + self.assertIs(response_future.code(), grpc.StatusCode.DEADLINE_EXCEEDED) + + def testUnaryCallFutureCancelled(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = self._request_pb2.SimpleRequest(response_size=13) + with service.servicer_methods.pause(): + response_future = service.stub.UnaryCall.future(request) + response_future.cancel() + self.assertTrue(response_future.cancelled()) + self.assertIs(response_future.code(), grpc.StatusCode.CANCELLED) + + def testUnaryCallFutureFailed(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = self._request_pb2.SimpleRequest(response_size=13) + with service.servicer_methods.fail(): + response_future = service.stub.UnaryCall.future(request) + self.assertIsNotNone(response_future.exception()) + self.assertIs(response_future.code(), grpc.StatusCode.UNKNOWN) + + def testStreamingOutputCall(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = _streaming_output_request(self._request_pb2) + responses = service.stub.StreamingOutputCall(request) + expected_responses = service.servicer_methods.StreamingOutputCall( + request, 'not a real RpcContext!') + for expected_response, response in moves.zip_longest( + expected_responses, responses): + self.assertEqual(expected_response, response) + + def testStreamingOutputCallExpired(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = _streaming_output_request(self._request_pb2) + with service.servicer_methods.pause(): + responses = service.stub.StreamingOutputCall( + request, timeout=test_constants.SHORT_TIMEOUT) + with self.assertRaises(grpc.RpcError) as exception_context: + list(responses) + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.DEADLINE_EXCEEDED) + + def testStreamingOutputCallCancelled(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = _streaming_output_request(self._request_pb2) + responses = service.stub.StreamingOutputCall(request) + next(responses) + responses.cancel() + with self.assertRaises(grpc.RpcError) as exception_context: + next(responses) + self.assertIs(responses.code(), grpc.StatusCode.CANCELLED) + + def testStreamingOutputCallFailed(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request = _streaming_output_request(self._request_pb2) + with service.servicer_methods.fail(): + responses = service.stub.StreamingOutputCall(request) + self.assertIsNotNone(responses) + with self.assertRaises(grpc.RpcError) as exception_context: + next(responses) + self.assertIs(exception_context.exception.code(), grpc.StatusCode.UNKNOWN) + + def testStreamingInputCall(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + response = service.stub.StreamingInputCall( + _streaming_input_request_iterator( + self._request_pb2, self._payload_pb2)) + expected_response = service.servicer_methods.StreamingInputCall( + _streaming_input_request_iterator(self._request_pb2, self._payload_pb2), + 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testStreamingInputCallFuture(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with service.servicer_methods.pause(): + response_future = service.stub.StreamingInputCall.future( + _streaming_input_request_iterator( + self._request_pb2, self._payload_pb2)) + response = response_future.result() + expected_response = service.servicer_methods.StreamingInputCall( + _streaming_input_request_iterator(self._request_pb2, self._payload_pb2), + 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testStreamingInputCallFutureExpired(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with service.servicer_methods.pause(): + response_future = service.stub.StreamingInputCall.future( + _streaming_input_request_iterator( + self._request_pb2, self._payload_pb2), + timeout=test_constants.SHORT_TIMEOUT) + with self.assertRaises(grpc.RpcError) as exception_context: + response_future.result() + self.assertIsInstance(response_future.exception(), grpc.RpcError) + self.assertIs( + response_future.exception().code(), grpc.StatusCode.DEADLINE_EXCEEDED) + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.DEADLINE_EXCEEDED) + + def testStreamingInputCallFutureCancelled(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with service.servicer_methods.pause(): + response_future = service.stub.StreamingInputCall.future( + _streaming_input_request_iterator( + self._request_pb2, self._payload_pb2)) + response_future.cancel() + self.assertTrue(response_future.cancelled()) + with self.assertRaises(grpc.FutureCancelledError): + response_future.result() + + def testStreamingInputCallFutureFailed(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with service.servicer_methods.fail(): + response_future = service.stub.StreamingInputCall.future( + _streaming_input_request_iterator( + self._request_pb2, self._payload_pb2)) + self.assertIsNotNone(response_future.exception()) + self.assertIs(response_future.code(), grpc.StatusCode.UNKNOWN) + + def testFullDuplexCall(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + responses = service.stub.FullDuplexCall( + _full_duplex_request_iterator(self._request_pb2)) + expected_responses = service.servicer_methods.FullDuplexCall( + _full_duplex_request_iterator(self._request_pb2), + 'not a real RpcContext!') + for expected_response, response in moves.zip_longest( + expected_responses, responses): + self.assertEqual(expected_response, response) + + def testFullDuplexCallExpired(self): + request_iterator = _full_duplex_request_iterator(self._request_pb2) + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with service.servicer_methods.pause(): + responses = service.stub.FullDuplexCall( + request_iterator, timeout=test_constants.SHORT_TIMEOUT) + with self.assertRaises(grpc.RpcError) as exception_context: + list(responses) + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.DEADLINE_EXCEEDED) + + def testFullDuplexCallCancelled(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + request_iterator = _full_duplex_request_iterator(self._request_pb2) + responses = service.stub.FullDuplexCall(request_iterator) + next(responses) + responses.cancel() + with self.assertRaises(grpc.RpcError) as exception_context: + next(responses) + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.CANCELLED) + + def testFullDuplexCallFailed(self): + request_iterator = _full_duplex_request_iterator(self._request_pb2) + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with service.servicer_methods.fail(): + responses = service.stub.FullDuplexCall(request_iterator) + with self.assertRaises(grpc.RpcError) as exception_context: + next(responses) + self.assertIs(exception_context.exception.code(), grpc.StatusCode.UNKNOWN) + + def testHalfDuplexCall(self): + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + def half_duplex_request_iterator(): + request = self._request_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + request = self._request_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=2, interval_us=0) + request.response_parameters.add(size=3, interval_us=0) + yield request + responses = service.stub.HalfDuplexCall(half_duplex_request_iterator()) + expected_responses = service.servicer_methods.HalfDuplexCall( + half_duplex_request_iterator(), 'not a real RpcContext!') + for expected_response, response in moves.zip_longest( + expected_responses, responses): + self.assertEqual(expected_response, response) + + def testHalfDuplexCallWedged(self): + condition = threading.Condition() + wait_cell = [False] + @contextlib.contextmanager + def wait(): # pylint: disable=invalid-name + # Where's Python 3's 'nonlocal' statement when you need it? + with condition: + wait_cell[0] = True + yield + with condition: + wait_cell[0] = False + condition.notify_all() + def half_duplex_request_iterator(): + request = self._request_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + with condition: + while wait_cell[0]: + condition.wait() + service = _CreateService( + self._service_pb2, self._response_pb2, self._payload_pb2) + with wait(): + responses = service.stub.HalfDuplexCall( + half_duplex_request_iterator(), timeout=test_constants.SHORT_TIMEOUT) + # half-duplex waits for the client to send all info + with self.assertRaises(grpc.RpcError) as exception_context: + next(responses) + self.assertIs( + exception_context.exception.code(), grpc.StatusCode.DEADLINE_EXCEEDED) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio/tests/qps/benchmark_client.py b/src/python/grpcio/tests/qps/benchmark_client.py index b372ea01ade..1b100bb168d 100644 --- a/src/python/grpcio/tests/qps/benchmark_client.py +++ b/src/python/grpcio/tests/qps/benchmark_client.py @@ -31,12 +31,9 @@ import abc import time -try: - import Queue as queue # Python 2.x -except ImportError: - import queue # Python 3 from concurrent import futures +from six.moves import queue from grpc.beta import implementations from grpc.framework.interfaces.face import face @@ -82,6 +79,7 @@ class BenchmarkClient: self._response_callbacks = [] def add_response_callback(self, callback): + """callback will be invoked as callback(client, query_time)""" self._response_callbacks.append(callback) @abc.abstractmethod @@ -95,10 +93,10 @@ class BenchmarkClient: def stop(self): pass - def _handle_response(self, query_time): + def _handle_response(self, client, query_time): self._hist.add(query_time * 1e9) # Report times in nanoseconds for callback in self._response_callbacks: - callback(query_time) + callback(client, query_time) class UnarySyncBenchmarkClient(BenchmarkClient): @@ -121,7 +119,7 @@ class UnarySyncBenchmarkClient(BenchmarkClient): start_time = time.time() self._stub.UnaryCall(self._request, _TIMEOUT) end_time = time.time() - self._handle_response(end_time - start_time) + self._handle_response(self, end_time - start_time) class UnaryAsyncBenchmarkClient(BenchmarkClient): @@ -136,19 +134,20 @@ class UnaryAsyncBenchmarkClient(BenchmarkClient): def _response_received(self, start_time, resp): resp.result() end_time = time.time() - self._handle_response(end_time - start_time) + self._handle_response(self, end_time - start_time) def stop(self): self._stub = None -class StreamingSyncBenchmarkClient(BenchmarkClient): +class _SyncStream(object): - def __init__(self, server, config, hist): - super(StreamingSyncBenchmarkClient, self).__init__(server, config, hist) + def __init__(self, stub, generic, request, handle_response): + self._stub = stub + self._generic = generic + self._request = request + self._handle_response = handle_response self._is_streaming = False - self._pool = futures.ThreadPoolExecutor(max_workers=1) - # Use a thread-safe queue to put requests on the stream self._request_queue = queue.Queue() self._send_time_queue = queue.Queue() @@ -157,15 +156,6 @@ class StreamingSyncBenchmarkClient(BenchmarkClient): self._request_queue.put(self._request) def start(self): - self._is_streaming = True - self._pool.submit(self._request_stream) - - def stop(self): - self._is_streaming = False - self._pool.shutdown(wait=True) - self._stub = None - - def _request_stream(self): self._is_streaming = True if self._generic: stream_callable = self._stub.stream_stream( @@ -175,8 +165,11 @@ class StreamingSyncBenchmarkClient(BenchmarkClient): response_stream = stream_callable(self._request_generator(), _TIMEOUT) for _ in response_stream: - end_time = time.time() - self._handle_response(end_time - self._send_time_queue.get_nowait()) + self._handle_response( + self, time.time() - self._send_time_queue.get_nowait()) + + def stop(self): + self._is_streaming = False def _request_generator(self): while self._is_streaming: @@ -187,46 +180,28 @@ class StreamingSyncBenchmarkClient(BenchmarkClient): pass -class AsyncReceiver(face.ResponseReceiver): - """Receiver for async stream responses.""" - - def __init__(self, send_time_queue, response_handler): - self._send_time_queue = send_time_queue - self._response_handler = response_handler - - def initial_metadata(self, initial_mdetadata): - pass - - def response(self, response): - end_time = time.time() - self._response_handler(end_time - self._send_time_queue.get_nowait()) - - def complete(self, terminal_metadata, code, details): - pass - - -class StreamingAsyncBenchmarkClient(BenchmarkClient): +class StreamingSyncBenchmarkClient(BenchmarkClient): def __init__(self, server, config, hist): - super(StreamingAsyncBenchmarkClient, self).__init__(server, config, hist) - self._send_time_queue = queue.Queue() - self._receiver = AsyncReceiver(self._send_time_queue, self._handle_response) - self._rendezvous = None + super(StreamingSyncBenchmarkClient, self).__init__(server, config, hist) + self._pool = futures.ThreadPoolExecutor( + max_workers=config.outstanding_rpcs_per_channel) + self._streams = [_SyncStream(self._stub, self._generic, + self._request, self._handle_response) + for _ in xrange(config.outstanding_rpcs_per_channel)] + self._curr_stream = 0 def send_request(self): - if self._rendezvous is not None: - self._send_time_queue.put(time.time()) - self._rendezvous.consume(self._request) + # Use a round_robin scheduler to determine what stream to send on + self._streams[self._curr_stream].send_request() + self._curr_stream = (self._curr_stream + 1) % len(self._streams) def start(self): - if self._generic: - stream_callable = self._stub.stream_stream( - 'grpc.testing.BenchmarkService', 'StreamingCall') - else: - stream_callable = self._stub.StreamingCall - self._rendezvous = stream_callable.event( - self._receiver, lambda *args: None, _TIMEOUT) + for stream in self._streams: + self._pool.submit(stream.start) def stop(self): - self._rendezvous.terminate() - self._rendezvous = None + for stream in self._streams: + stream.stop() + self._pool.shutdown(wait=True) + self._stub = None diff --git a/src/python/grpcio/tests/qps/client_runner.py b/src/python/grpcio/tests/qps/client_runner.py index 1ede7d2af1b..1fd58687ad4 100644 --- a/src/python/grpcio/tests/qps/client_runner.py +++ b/src/python/grpcio/tests/qps/client_runner.py @@ -34,7 +34,7 @@ ClientRunner invokes either periodically or in response to some event. """ import abc -import thread +import threading import time @@ -61,15 +61,18 @@ class OpenLoopClientRunner(ClientRunner): super(OpenLoopClientRunner, self).__init__(client) self._is_running = False self._interval_generator = interval_generator + self._dispatch_thread = threading.Thread( + target=self._dispatch_requests, args=()) def start(self): self._is_running = True self._client.start() - thread.start_new_thread(self._dispatch_requests, ()) - + self._dispatch_thread.start() + def stop(self): self._is_running = False self._client.stop() + self._dispatch_thread.join() self._client = None def _dispatch_requests(self): @@ -98,7 +101,6 @@ class ClosedLoopClientRunner(ClientRunner): self._client.stop() self._client = None - def _send_request(self, response_time): + def _send_request(self, client, response_time): if self._is_running: - self._client.send_request() - + client.send_request() diff --git a/src/python/grpcio/tests/qps/qps_worker.py b/src/python/grpcio/tests/qps/qps_worker.py index 3dda718638e..16926379a5b 100644 --- a/src/python/grpcio/tests/qps/qps_worker.py +++ b/src/python/grpcio/tests/qps/qps_worker.py @@ -43,9 +43,7 @@ def run_worker_server(port): server.add_insecure_port('[::]:{}'.format(port)) server.start() servicer.wait_for_quit() - # Drain outstanding requests for clean exit - time.sleep(2) - server.stop(0) + server.stop(2) if __name__ == '__main__': diff --git a/src/python/grpcio/tests/qps/worker_server.py b/src/python/grpcio/tests/qps/worker_server.py index 1f9af5482cc..d41f8377c2a 100644 --- a/src/python/grpcio/tests/qps/worker_server.py +++ b/src/python/grpcio/tests/qps/worker_server.py @@ -153,9 +153,8 @@ class WorkerServer(services_pb2.BetaWorkerServiceServicer): if config.rpc_type == control_pb2.UNARY: client = benchmark_client.UnaryAsyncBenchmarkClient( server, config, qps_data) - elif config.rpc_type == control_pb2.STREAMING: - client = benchmark_client.StreamingAsyncBenchmarkClient( - server, config, qps_data) + else: + raise Exception('Async streaming client not supported') else: raise Exception('Unsupported client type {}'.format(config.client_type)) diff --git a/src/python/grpcio/tests/stress/client.py b/src/python/grpcio/tests/stress/client.py index e2e016760c8..0de2532cd88 100644 --- a/src/python/grpcio/tests/stress/client.py +++ b/src/python/grpcio/tests/stress/client.py @@ -30,10 +30,10 @@ """Entry point for running stress tests.""" import argparse -import Queue import threading from grpc.beta import implementations +from six.moves import queue from src.proto.grpc.testing import metrics_pb2 from src.proto.grpc.testing import test_pb2 @@ -94,7 +94,7 @@ def run_test(args): test_cases = _parse_weighted_test_cases(args.test_cases) test_servers = args.server_addresses.split(',') # Propagate any client exceptions with a queue - exception_queue = Queue.Queue() + exception_queue = queue.Queue() stop_event = threading.Event() hist = histogram.Histogram(1, 1) runners = [] @@ -121,7 +121,7 @@ def run_test(args): if timeout_secs < 0: timeout_secs = None raise exception_queue.get(block=True, timeout=timeout_secs) - except Queue.Empty: + except queue.Empty: # No exceptions thrown, success pass finally: diff --git a/src/python/grpcio/tests/tests.json b/src/python/grpcio/tests/tests.json index 8dc47bf69dd..f1d813930d0 100644 --- a/src/python/grpcio/tests/tests.json +++ b/src/python/grpcio/tests/tests.json @@ -1,4 +1,5 @@ [ + "_api_test.AllTest", "_auth_test.AccessTokenCallCredentialsTest", "_auth_test.GoogleCallCredentialsTest", "_base_interface_test.AsyncEasyTest", @@ -28,6 +29,7 @@ "_crust_over_core_over_links_face_interface_test.GenericInvokerFutureInvocationAsynchronousEventServiceTest", "_crust_over_core_over_links_face_interface_test.MultiCallableInvokerBlockingInvocationInlineServiceTest", "_crust_over_core_over_links_face_interface_test.MultiCallableInvokerFutureInvocationAsynchronousEventServiceTest", + "_empty_message_test.EmptyMessageTest", "_face_interface_test.DynamicInvokerBlockingInvocationInlineServiceTest", "_face_interface_test.DynamicInvokerFutureInvocationAsynchronousEventServiceTest", "_face_interface_test.GenericInvokerBlockingInvocationInlineServiceTest", @@ -47,11 +49,14 @@ "_lonely_invocation_link_test.LonelyInvocationLinkTest", "_low_test.HangingServerShutdown", "_low_test.InsecureServerInsecureClient", + "_metadata_test.MetadataTest", "_not_found_test.NotFoundTest", + "_python_plugin_test.PythonPluginTest", "_read_some_but_not_all_responses_test.ReadSomeButNotAllResponsesTest", "_rpc_test.RPCTest", "_sanity_test.Sanity", "_secure_interop_test.SecureInteropTest", + "_thread_cleanup_test.CleanupThreadTest", "_transmission_test.RoundTripTest", "_transmission_test.TransmissionTest", "_utilities_test.ChannelConnectivityTest", diff --git a/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py b/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py index 22d4b019c7f..09ebdeff335 100644 --- a/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py +++ b/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py @@ -164,15 +164,15 @@ class EchoTest(unittest.TestCase): self.assertIsNotNone(service_accepted) self.assertIs(service_accepted.kind, _low.Event.Kind.SERVICE_ACCEPTED) self.assertIs(service_accepted.tag, service_tag) - self.assertEqual(method, service_accepted.service_acceptance.method) - self.assertEqual(self.host, service_accepted.service_acceptance.host) + self.assertEqual(method.encode(), service_accepted.service_acceptance.method) + self.assertEqual(self.host.encode(), service_accepted.service_acceptance.host) self.assertIsNotNone(service_accepted.service_acceptance.call) metadata = dict(service_accepted.metadata) - self.assertIn(client_metadata_key, metadata) - self.assertEqual(client_metadata_value, metadata[client_metadata_key]) - self.assertIn(client_binary_metadata_key, metadata) + self.assertIn(client_metadata_key.encode(), metadata) + self.assertEqual(client_metadata_value.encode(), metadata[client_metadata_key.encode()]) + self.assertIn(client_binary_metadata_key.encode(), metadata) self.assertEqual(client_binary_metadata_value, - metadata[client_binary_metadata_key]) + metadata[client_binary_metadata_key.encode()]) server_call = service_accepted.service_acceptance.call server_call.accept(self.server_completion_queue, finish_tag) server_call.add_metadata(server_leading_metadata_key, @@ -186,12 +186,12 @@ class EchoTest(unittest.TestCase): self.assertEqual(_low.Event.Kind.METADATA_ACCEPTED, metadata_accepted.kind) self.assertEqual(metadata_tag, metadata_accepted.tag) metadata = dict(metadata_accepted.metadata) - self.assertIn(server_leading_metadata_key, metadata) - self.assertEqual(server_leading_metadata_value, - metadata[server_leading_metadata_key]) - self.assertIn(server_leading_binary_metadata_key, metadata) + self.assertIn(server_leading_metadata_key.encode(), metadata) + self.assertEqual(server_leading_metadata_value.encode(), + metadata[server_leading_metadata_key.encode()]) + self.assertIn(server_leading_binary_metadata_key.encode(), metadata) self.assertEqual(server_leading_binary_metadata_value, - metadata[server_leading_binary_metadata_key]) + metadata[server_leading_binary_metadata_key.encode()]) for datum in test_data: client_call.write(datum, write_tag, _low.WriteFlags.WRITE_NO_COMPRESS) @@ -277,17 +277,17 @@ class EchoTest(unittest.TestCase): self.assertIsNone(read_accepted.bytes) self.assertEqual(_low.Event.Kind.FINISH, finish_accepted.kind) self.assertEqual(finish_tag, finish_accepted.tag) - self.assertEqual(_low.Status(_low.Code.OK, details), finish_accepted.status) + self.assertEqual(_low.Status(_low.Code.OK, details.encode()), finish_accepted.status) metadata = dict(finish_accepted.metadata) - self.assertIn(server_trailing_metadata_key, metadata) - self.assertEqual(server_trailing_metadata_value, - metadata[server_trailing_metadata_key]) - self.assertIn(server_trailing_binary_metadata_key, metadata) + self.assertIn(server_trailing_metadata_key.encode(), metadata) + self.assertEqual(server_trailing_metadata_value.encode(), + metadata[server_trailing_metadata_key.encode()]) + self.assertIn(server_trailing_binary_metadata_key.encode(), metadata) self.assertEqual(server_trailing_binary_metadata_value, - metadata[server_trailing_binary_metadata_key]) + metadata[server_trailing_binary_metadata_key.encode()]) self.assertSetEqual(set(key for key, _ in finish_accepted.metadata), - set((server_trailing_metadata_key, - server_trailing_binary_metadata_key,))) + set((server_trailing_metadata_key.encode(), + server_trailing_binary_metadata_key.encode(),))) self.assertSequenceEqual(test_data, server_data) self.assertSequenceEqual(test_data, client_data) @@ -302,7 +302,8 @@ class EchoTest(unittest.TestCase): self._perform_echo_test([_BYTE_SEQUENCE]) def testManyOneByteEchoes(self): - self._perform_echo_test(_BYTE_SEQUENCE) + self._perform_echo_test( + [_BYTE_SEQUENCE[i:i+1] for i in range(len(_BYTE_SEQUENCE))]) def testManyManyByteEchoes(self): self._perform_echo_test(_BYTE_SEQUENCE_SEQUENCE) @@ -409,7 +410,7 @@ class CancellationTest(unittest.TestCase): finish_event = self.client_events.get() self.assertEqual(_low.Event.Kind.FINISH, finish_event.kind) - self.assertEqual(_low.Status(_low.Code.CANCELLED, 'Cancelled'), + self.assertEqual(_low.Status(_low.Code.CANCELLED, b'Cancelled'), finish_event.status) self.assertSequenceEqual(test_data, server_data) diff --git a/src/python/grpcio/tests/unit/_adapter/_low_test.py b/src/python/grpcio/tests/unit/_adapter/_low_test.py index ec46617996b..e09a1f2564f 100644 --- a/src/python/grpcio/tests/unit/_adapter/_low_test.py +++ b/src/python/grpcio/tests/unit/_adapter/_low_test.py @@ -148,11 +148,11 @@ class InsecureServerInsecureClient(unittest.TestCase): # Check that Python's user agent string is a part of the full user agent # string received_initial_metadata_dict = dict(received_initial_metadata) - self.assertIn('user-agent', received_initial_metadata_dict) - self.assertIn('Python-gRPC-{}'.format(_grpcio_metadata.__version__), - received_initial_metadata_dict['user-agent']) - self.assertEqual(method, request_event.call_details.method) - self.assertEqual(host, request_event.call_details.host) + self.assertIn(b'user-agent', received_initial_metadata_dict) + self.assertIn('Python-gRPC-{}'.format(_grpcio_metadata.__version__).encode(), + received_initial_metadata_dict[b'user-agent']) + self.assertEqual(method.encode(), request_event.call_details.method) + self.assertEqual(host.encode(), request_event.call_details.host) self.assertLess(abs(deadline - request_event.call_details.deadline), deadline_tolerance) @@ -198,12 +198,12 @@ class InsecureServerInsecureClient(unittest.TestCase): test_common.metadata_transmitted(server_initial_metadata, client_result.initial_metadata)) elif client_result.type == _types.OpType.RECV_MESSAGE: - self.assertEqual(response, client_result.message) + self.assertEqual(response.encode(), client_result.message) elif client_result.type == _types.OpType.RECV_STATUS_ON_CLIENT: self.assertTrue( test_common.metadata_transmitted(server_trailing_metadata, client_result.trailing_metadata)) - self.assertEqual(server_status_details, client_result.status.details) + self.assertEqual(server_status_details.encode(), client_result.status.details) self.assertEqual(server_status_code, client_result.status.code) self.assertEqual(set([ _types.OpType.SEND_INITIAL_METADATA, @@ -220,7 +220,7 @@ class InsecureServerInsecureClient(unittest.TestCase): self.assertNotIn(client_result.type, found_server_op_types) found_server_op_types.add(server_result.type) if server_result.type == _types.OpType.RECV_MESSAGE: - self.assertEqual(request, server_result.message) + self.assertEqual(request.encode(), server_result.message) elif server_result.type == _types.OpType.RECV_CLOSE_ON_SERVER: self.assertFalse(server_result.cancelled) self.assertEqual(set([ diff --git a/src/python/grpcio/tests/unit/_api_test.py b/src/python/grpcio/tests/unit/_api_test.py new file mode 100644 index 00000000000..1d724c3ed4f --- /dev/null +++ b/src/python/grpcio/tests/unit/_api_test.py @@ -0,0 +1,90 @@ +# 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. + +"""Test of gRPC Python's application-layer API.""" + +import unittest + +import six + +from tests.unit import _from_grpc_import_star + + +class AllTest(unittest.TestCase): + + def testAll(self): + expected_grpc_code_elements = ( + 'FutureTimeoutError', + 'FutureCancelledError', + 'Future', + 'ChannelConnectivity', + 'StatusCode', + 'RpcError', + 'RpcContext', + 'Call', + 'ChannelCredentials', + 'CallCredentials', + 'AuthMetadataContext', + 'AuthMetadataPluginCallback', + 'AuthMetadataPlugin', + 'ServerCredentials', + 'UnaryUnaryMultiCallable', + 'UnaryStreamMultiCallable', + 'StreamUnaryMultiCallable', + 'StreamStreamMultiCallable', + 'Channel', + 'ServicerContext', + 'RpcMethodHandler', + 'HandlerCallDetails', + 'GenericRpcHandler', + 'Server', + 'unary_unary_rpc_method_handler', + 'unary_stream_rpc_method_handler', + 'stream_unary_rpc_method_handler', + 'stream_stream_rpc_method_handler', + 'method_handlers_generic_handler', + 'ssl_channel_credentials', + 'metadata_call_credentials', + 'access_token_call_credentials', + 'composite_call_credentials', + 'composite_channel_credentials', + 'ssl_server_credentials', + 'channel_ready_future', + 'insecure_channel', + 'secure_channel', + 'server', + ) + + six.assertCountEqual( + self, expected_grpc_code_elements, + _from_grpc_import_star.GRPC_ELEMENTS) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio/tests/unit/_cython/cygrpc_test.py b/src/python/grpcio/tests/unit/_cython/cygrpc_test.py index 0a511101f0d..a006a20ce3f 100644 --- a/src/python/grpcio/tests/unit/_cython/cygrpc_test.py +++ b/src/python/grpcio/tests/unit/_cython/cygrpc_test.py @@ -37,7 +37,7 @@ from tests.unit import test_common from tests.unit import resources -_SSL_HOST_OVERRIDE = 'foo.test.google.fr' +_SSL_HOST_OVERRIDE = b'foo.test.google.fr' _CALL_CREDENTIALS_METADATA_KEY = 'call-creds-key' _CALL_CREDENTIALS_METADATA_VALUE = 'call-creds-value' _EMPTY_FLAGS = 0 @@ -143,22 +143,60 @@ class TypeSmokeTest(unittest.TestCase): del completion_queue -class InsecureServerInsecureClient(unittest.TestCase): +class ServerClientMixin(object): - def setUp(self): + def setUpMixin(self, server_credentials, client_credentials, host_override): self.server_completion_queue = cygrpc.CompletionQueue() self.server = cygrpc.Server() self.server.register_completion_queue(self.server_completion_queue) - self.port = self.server.add_http2_port('[::]:0') + if server_credentials: + self.port = self.server.add_http2_port('[::]:0', server_credentials) + else: + self.port = self.server.add_http2_port('[::]:0') self.server.start() self.client_completion_queue = cygrpc.CompletionQueue() - self.client_channel = cygrpc.Channel('localhost:{}'.format(self.port)) - - def tearDown(self): + if client_credentials: + client_channel_arguments = cygrpc.ChannelArgs([ + cygrpc.ChannelArg(cygrpc.ChannelArgKey.ssl_target_name_override, + host_override)]) + self.client_channel = cygrpc.Channel( + 'localhost:{}'.format(self.port), client_channel_arguments, + client_credentials) + else: + self.client_channel = cygrpc.Channel('localhost:{}'.format(self.port)) + if host_override: + self.host_argument = None # default host + self.expected_host = host_override + else: + # arbitrary host name necessitating no further identification + self.host_argument = b'hostess' + self.expected_host = self.host_argument + + def tearDownMixin(self): del self.server del self.client_completion_queue del self.server_completion_queue + def _perform_operations(self, operations, call, queue, deadline, description): + """Perform the list of operations with given call, queue, and deadline. + + Invocation errors are reported with as an exception with `description` in + the message. Performs the operations asynchronously, returning a future. + """ + def performer(): + tag = object() + try: + call_result = call.start_batch(cygrpc.Operations(operations), tag) + self.assertEqual(cygrpc.CallError.ok, call_result) + event = queue.poll(deadline) + self.assertEqual(cygrpc.CompletionType.operation_complete, event.type) + self.assertTrue(event.success) + self.assertIs(tag, event.tag) + except Exception as error: + raise Exception("Error in '{}': {}".format(description, error.message)) + return event + return test_utilities.SimpleFuture(performer) + def testEcho(self): DEADLINE = time.time()+5 DEADLINE_TOLERANCE = 0.25 @@ -175,7 +213,6 @@ class InsecureServerInsecureClient(unittest.TestCase): REQUEST = b'in death a member of project mayhem has a name' RESPONSE = b'his name is robert paulson' METHOD = b'twinkies' - HOST = b'hostess' cygrpc_deadline = cygrpc.Timespec(DEADLINE) @@ -188,7 +225,8 @@ class InsecureServerInsecureClient(unittest.TestCase): client_call_tag = object() client_call = self.client_channel.create_call( - None, 0, self.client_completion_queue, METHOD, HOST, cygrpc_deadline) + None, 0, self.client_completion_queue, METHOD, self.host_argument, + cygrpc_deadline) client_initial_metadata = cygrpc.Metadata([ cygrpc.Metadatum(CLIENT_METADATA_ASCII_KEY, CLIENT_METADATA_ASCII_VALUE), @@ -216,7 +254,8 @@ class InsecureServerInsecureClient(unittest.TestCase): test_common.metadata_transmitted(client_initial_metadata, request_event.request_metadata)) self.assertEqual(METHOD, request_event.request_call_details.method) - self.assertEqual(HOST, request_event.request_call_details.host) + self.assertEqual(self.expected_host, + request_event.request_call_details.host) self.assertLess( abs(DEADLINE - float(request_event.request_call_details.deadline)), DEADLINE_TOLERANCE) @@ -292,172 +331,101 @@ class InsecureServerInsecureClient(unittest.TestCase): del client_call del server_call - -class SecureServerSecureClient(unittest.TestCase): - - def setUp(self): - server_credentials = cygrpc.server_credentials_ssl( - None, [cygrpc.SslPemKeyCertPair(resources.private_key(), - resources.certificate_chain())], False) - channel_credentials = cygrpc.channel_credentials_ssl( - resources.test_root_certificates(), None) - self.server_completion_queue = cygrpc.CompletionQueue() - self.server = cygrpc.Server() - self.server.register_completion_queue(self.server_completion_queue) - self.port = self.server.add_http2_port('[::]:0', server_credentials) - self.server.start() - self.client_completion_queue = cygrpc.CompletionQueue() - client_channel_arguments = cygrpc.ChannelArgs([ - cygrpc.ChannelArg(cygrpc.ChannelArgKey.ssl_target_name_override, - _SSL_HOST_OVERRIDE)]) - self.client_channel = cygrpc.Channel( - 'localhost:{}'.format(self.port), client_channel_arguments, - channel_credentials) - - def tearDown(self): - del self.server - del self.client_completion_queue - del self.server_completion_queue - - def testEcho(self): + def test6522(self): DEADLINE = time.time()+5 DEADLINE_TOLERANCE = 0.25 - CLIENT_METADATA_ASCII_KEY = b'key' - CLIENT_METADATA_ASCII_VALUE = b'val' - CLIENT_METADATA_BIN_KEY = b'key-bin' - CLIENT_METADATA_BIN_VALUE = b'\0'*1000 - SERVER_INITIAL_METADATA_KEY = b'init_me_me_me' - SERVER_INITIAL_METADATA_VALUE = b'whodawha?' - SERVER_TRAILING_METADATA_KEY = b'california_is_in_a_drought' - SERVER_TRAILING_METADATA_VALUE = b'zomg it is' - SERVER_STATUS_CODE = cygrpc.StatusCode.ok - SERVER_STATUS_DETAILS = b'our work is never over' - REQUEST = b'in death a member of project mayhem has a name' - RESPONSE = b'his name is robert paulson' - METHOD = b'/twinkies' - HOST = None # Default host + METHOD = b'twinkies' cygrpc_deadline = cygrpc.Timespec(DEADLINE) + empty_metadata = cygrpc.Metadata([]) server_request_tag = object() - request_call_result = self.server.request_call( + self.server.request_call( self.server_completion_queue, self.server_completion_queue, server_request_tag) + client_call = self.client_channel.create_call( + None, 0, self.client_completion_queue, METHOD, self.host_argument, + cygrpc_deadline) - self.assertEqual(cygrpc.CallError.ok, request_call_result) - - plugin = cygrpc.CredentialsMetadataPlugin(_metadata_plugin_callback, '') - call_credentials = cygrpc.call_credentials_metadata_plugin(plugin) + # Prologue + def perform_client_operations(operations, description): + return self._perform_operations( + operations, client_call, + self.client_completion_queue, cygrpc_deadline, description) - client_call_tag = object() - client_call = self.client_channel.create_call( - None, 0, self.client_completion_queue, METHOD, HOST, cygrpc_deadline) - client_call.set_credentials(call_credentials) - client_initial_metadata = cygrpc.Metadata([ - cygrpc.Metadatum(CLIENT_METADATA_ASCII_KEY, - CLIENT_METADATA_ASCII_VALUE), - cygrpc.Metadatum(CLIENT_METADATA_BIN_KEY, CLIENT_METADATA_BIN_VALUE)]) - client_start_batch_result = client_call.start_batch(cygrpc.Operations([ - cygrpc.operation_send_initial_metadata(client_initial_metadata, - _EMPTY_FLAGS), - cygrpc.operation_send_message(REQUEST, _EMPTY_FLAGS), - cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), - cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS), - cygrpc.operation_receive_message(_EMPTY_FLAGS), - cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS) - ]), client_call_tag) - self.assertEqual(cygrpc.CallError.ok, client_start_batch_result) - client_event_future = test_utilities.CompletionQueuePollFuture( - self.client_completion_queue, cygrpc_deadline) + client_event_future = perform_client_operations([ + cygrpc.operation_send_initial_metadata(empty_metadata, + _EMPTY_FLAGS), + cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS), + ], "Client prologue") request_event = self.server_completion_queue.poll(cygrpc_deadline) - self.assertEqual(cygrpc.CompletionType.operation_complete, - request_event.type) - self.assertIsInstance(request_event.operation_call, cygrpc.Call) - self.assertIs(server_request_tag, request_event.tag) - self.assertEqual(0, len(request_event.batch_operations)) - client_metadata_with_credentials = list(client_initial_metadata) + [ - (_CALL_CREDENTIALS_METADATA_KEY, _CALL_CREDENTIALS_METADATA_VALUE)] - self.assertTrue( - test_common.metadata_transmitted(client_metadata_with_credentials, - request_event.request_metadata)) - self.assertEqual(METHOD, request_event.request_call_details.method) - self.assertEqual(_SSL_HOST_OVERRIDE, - request_event.request_call_details.host) - self.assertLess( - abs(DEADLINE - float(request_event.request_call_details.deadline)), - DEADLINE_TOLERANCE) - - server_call_tag = object() server_call = request_event.operation_call - server_initial_metadata = cygrpc.Metadata([ - cygrpc.Metadatum(SERVER_INITIAL_METADATA_KEY, - SERVER_INITIAL_METADATA_VALUE)]) - server_trailing_metadata = cygrpc.Metadata([ - cygrpc.Metadatum(SERVER_TRAILING_METADATA_KEY, - SERVER_TRAILING_METADATA_VALUE)]) - server_start_batch_result = server_call.start_batch([ - cygrpc.operation_send_initial_metadata(server_initial_metadata, - _EMPTY_FLAGS), - cygrpc.operation_receive_message(_EMPTY_FLAGS), - cygrpc.operation_send_message(RESPONSE, _EMPTY_FLAGS), - cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS), - cygrpc.operation_send_status_from_server( - server_trailing_metadata, SERVER_STATUS_CODE, - SERVER_STATUS_DETAILS, _EMPTY_FLAGS) - ], server_call_tag) - self.assertEqual(cygrpc.CallError.ok, server_start_batch_result) - client_event = client_event_future.result() - server_event = self.server_completion_queue.poll(cygrpc_deadline) + def perform_server_operations(operations, description): + return self._perform_operations( + operations, server_call, + self.server_completion_queue, cygrpc_deadline, description) - self.assertEqual(6, len(client_event.batch_operations)) - found_client_op_types = set() - for client_result in client_event.batch_operations: - # we expect each op type to be unique - self.assertNotIn(client_result.type, found_client_op_types) - found_client_op_types.add(client_result.type) - if client_result.type == cygrpc.OperationType.receive_initial_metadata: - self.assertTrue( - test_common.metadata_transmitted(server_initial_metadata, - client_result.received_metadata)) - elif client_result.type == cygrpc.OperationType.receive_message: - self.assertEqual(RESPONSE, client_result.received_message.bytes()) - elif client_result.type == cygrpc.OperationType.receive_status_on_client: - self.assertTrue( - test_common.metadata_transmitted(server_trailing_metadata, - client_result.received_metadata)) - self.assertEqual(SERVER_STATUS_DETAILS, - client_result.received_status_details) - self.assertEqual(SERVER_STATUS_CODE, client_result.received_status_code) - self.assertEqual(set([ - cygrpc.OperationType.send_initial_metadata, - cygrpc.OperationType.send_message, - cygrpc.OperationType.send_close_from_client, - cygrpc.OperationType.receive_initial_metadata, - cygrpc.OperationType.receive_message, - cygrpc.OperationType.receive_status_on_client - ]), found_client_op_types) + server_event_future = perform_server_operations([ + cygrpc.operation_send_initial_metadata(empty_metadata, + _EMPTY_FLAGS), + ], "Server prologue") - self.assertEqual(5, len(server_event.batch_operations)) - found_server_op_types = set() - for server_result in server_event.batch_operations: - self.assertNotIn(client_result.type, found_server_op_types) - found_server_op_types.add(server_result.type) - if server_result.type == cygrpc.OperationType.receive_message: - self.assertEqual(REQUEST, server_result.received_message.bytes()) - elif server_result.type == cygrpc.OperationType.receive_close_on_server: - self.assertFalse(server_result.received_cancelled) - self.assertEqual(set([ - cygrpc.OperationType.send_initial_metadata, - cygrpc.OperationType.receive_message, - cygrpc.OperationType.send_message, - cygrpc.OperationType.receive_close_on_server, - cygrpc.OperationType.send_status_from_server - ]), found_server_op_types) + client_event_future.result() # force completion + server_event_future.result() - del client_call - del server_call + # Messaging + for _ in range(10): + client_event_future = perform_client_operations([ + cygrpc.operation_send_message(b'', _EMPTY_FLAGS), + cygrpc.operation_receive_message(_EMPTY_FLAGS), + ], "Client message") + server_event_future = perform_server_operations([ + cygrpc.operation_send_message(b'', _EMPTY_FLAGS), + cygrpc.operation_receive_message(_EMPTY_FLAGS), + ], "Server receive") + + client_event_future.result() # force completion + server_event_future.result() + + # Epilogue + client_event_future = perform_client_operations([ + cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), + cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS) + ], "Client epilogue") + + server_event_future = perform_server_operations([ + cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS), + cygrpc.operation_send_status_from_server( + empty_metadata, cygrpc.StatusCode.ok, b'', _EMPTY_FLAGS) + ], "Server epilogue") + + client_event_future.result() # force completion + server_event_future.result() + + +class InsecureServerInsecureClient(unittest.TestCase, ServerClientMixin): + + def setUp(self): + self.setUpMixin(None, None, None) + + def tearDown(self): + self.tearDownMixin() + + +class SecureServerSecureClient(unittest.TestCase, ServerClientMixin): + + def setUp(self): + server_credentials = cygrpc.server_credentials_ssl( + None, [cygrpc.SslPemKeyCertPair(resources.private_key(), + resources.certificate_chain())], False) + client_credentials = cygrpc.channel_credentials_ssl( + resources.test_root_certificates(), None) + self.setUpMixin(server_credentials, client_credentials, _SSL_HOST_OVERRIDE) + + def tearDown(self): + self.tearDownMixin() if __name__ == '__main__': diff --git a/src/python/grpcio/tests/unit/_cython/test_utilities.py b/src/python/grpcio/tests/unit/_cython/test_utilities.py index 6a097396431..6280ce74c47 100644 --- a/src/python/grpcio/tests/unit/_cython/test_utilities.py +++ b/src/python/grpcio/tests/unit/_cython/test_utilities.py @@ -32,15 +32,35 @@ import threading from grpc._cython import cygrpc -class CompletionQueuePollFuture: +class SimpleFuture(object): + """A simple future mechanism.""" - def __init__(self, completion_queue, deadline): - def poller_function(): - self._event_result = completion_queue.poll(deadline) - self._event_result = None - self._thread = threading.Thread(target=poller_function) + def __init__(self, function, *args, **kwargs): + def wrapped_function(): + try: + self._result = function(*args, **kwargs) + except Exception as error: + self._error = error + self._result = None + self._error = None + self._thread = threading.Thread(target=wrapped_function) self._thread.start() def result(self): + """The resulting value of this future. + + Re-raises any exceptions. + """ self._thread.join() - return self._event_result + if self._error: + # TODO(atash): re-raise exceptions in a way that preserves tracebacks + raise self._error + return self._result + + +class CompletionQueuePollFuture(SimpleFuture): + + def __init__(self, completion_queue, deadline): + super(CompletionQueuePollFuture, self).__init__( + lambda: completion_queue.poll(deadline)) + diff --git a/src/python/grpcio/tests/unit/_empty_message_test.py b/src/python/grpcio/tests/unit/_empty_message_test.py new file mode 100644 index 00000000000..f324f6216b7 --- /dev/null +++ b/src/python/grpcio/tests/unit/_empty_message_test.py @@ -0,0 +1,137 @@ +# 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. + +import unittest + +import grpc +from grpc.framework.foundation import logging_pool + +from tests.unit.framework.common import test_constants + +_REQUEST = b'' +_RESPONSE = b'' + +_UNARY_UNARY = b'/test/UnaryUnary' +_UNARY_STREAM = b'/test/UnaryStream' +_STREAM_UNARY = b'/test/StreamUnary' +_STREAM_STREAM = b'/test/StreamStream' + + +def handle_unary_unary(request, servicer_context): + return _RESPONSE + + +def handle_unary_stream(request, servicer_context): + for _ in range(test_constants.STREAM_LENGTH): + yield _RESPONSE + + +def handle_stream_unary(request_iterator, servicer_context): + for request in request_iterator: + pass + return _RESPONSE + + +def handle_stream_stream(request_iterator, servicer_context): + for request in request_iterator: + yield _RESPONSE + + +class _MethodHandler(grpc.RpcMethodHandler): + + def __init__(self, request_streaming, response_streaming): + self.request_streaming = request_streaming + self.response_streaming = response_streaming + self.request_deserializer = None + self.response_serializer = None + self.unary_unary = None + self.unary_stream = None + self.stream_unary = None + self.stream_stream = None + if self.request_streaming and self.response_streaming: + self.stream_stream = handle_stream_stream + elif self.request_streaming: + self.stream_unary = handle_stream_unary + elif self.response_streaming: + self.unary_stream = handle_unary_stream + else: + self.unary_unary = handle_unary_unary + + +class _GenericHandler(grpc.GenericRpcHandler): + + def service(self, handler_call_details): + if handler_call_details.method == _UNARY_UNARY: + return _MethodHandler(False, False) + elif handler_call_details.method == _UNARY_STREAM: + return _MethodHandler(False, True) + elif handler_call_details.method == _STREAM_UNARY: + return _MethodHandler(True, False) + elif handler_call_details.method == _STREAM_STREAM: + return _MethodHandler(True, True) + else: + return None + + +class EmptyMessageTest(unittest.TestCase): + + def setUp(self): + self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY) + self._server = grpc.server((_GenericHandler(),), self._server_pool) + port = self._server.add_insecure_port('[::]:0') + self._server.start() + self._channel = grpc.insecure_channel('localhost:%d' % port) + + def tearDown(self): + self._server.stop(0) + + def testUnaryUnary(self): + response = self._channel.unary_unary(_UNARY_UNARY)(_REQUEST) + self.assertEqual(_RESPONSE, response) + + def testUnaryStream(self): + response_iterator = self._channel.unary_stream(_UNARY_STREAM)(_REQUEST) + self.assertSequenceEqual( + [_RESPONSE] * test_constants.STREAM_LENGTH, list(response_iterator)) + + def testStreamUnary(self): + response = self._channel.stream_unary(_STREAM_UNARY)( + [_REQUEST] * test_constants.STREAM_LENGTH) + self.assertEqual(_RESPONSE, response) + + def testStreamStream(self): + response_iterator = self._channel.stream_stream(_STREAM_STREAM)( + [_REQUEST] * test_constants.STREAM_LENGTH) + self.assertSequenceEqual( + [_RESPONSE] * test_constants.STREAM_LENGTH, list(response_iterator)) + + +if __name__ == '__main__': + unittest.main(verbosity=2) + diff --git a/src/python/grpcio/tests/unit/_from_grpc_import_star.py b/src/python/grpcio/tests/unit/_from_grpc_import_star.py new file mode 100644 index 00000000000..78d2fb7dc56 --- /dev/null +++ b/src/python/grpcio/tests/unit/_from_grpc_import_star.py @@ -0,0 +1,38 @@ +# 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. + +_BEFORE_IMPORT = tuple(globals()) + +from grpc import * + +_AFTER_IMPORT = tuple(globals()) + +GRPC_ELEMENTS = tuple( + element for element in _AFTER_IMPORT + if element not in _BEFORE_IMPORT and element != '_BEFORE_IMPORT') diff --git a/src/python/grpcio/tests/unit/_links/_transmission_test.py b/src/python/grpcio/tests/unit/_links/_transmission_test.py index 888684d197d..1f6edd18ca7 100644 --- a/src/python/grpcio/tests/unit/_links/_transmission_test.py +++ b/src/python/grpcio/tests/unit/_links/_transmission_test.py @@ -153,7 +153,7 @@ class RoundTripTest(unittest.TestCase): invocation_mate.tickets()[-1].termination, links.Ticket.Termination.COMPLETION) self.assertIs(invocation_mate.tickets()[-1].code, test_code) - self.assertEqual(invocation_mate.tickets()[-1].message, test_message) + self.assertEqual(invocation_mate.tickets()[-1].message, test_message.encode()) def _perform_scenario_test(self, scenario): test_operation_id = object() diff --git a/src/python/grpcio/tests/unit/_metadata_test.py b/src/python/grpcio/tests/unit/_metadata_test.py new file mode 100644 index 00000000000..77b39012619 --- /dev/null +++ b/src/python/grpcio/tests/unit/_metadata_test.py @@ -0,0 +1,216 @@ +# 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. +"""Tests server and client side metadata API.""" + +import unittest +import weakref + +import grpc +from grpc import _grpcio_metadata +from grpc.framework.foundation import logging_pool + +from tests.unit import test_common +from tests.unit.framework.common import test_constants + +_CHANNEL_ARGS = (('grpc.primary_user_agent', 'primary-agent'), + ('grpc.secondary_user_agent', 'secondary-agent')) + +_REQUEST = b'\x00\x00\x00' +_RESPONSE = b'\x00\x00\x00' + +_UNARY_UNARY = b'/test/UnaryUnary' +_UNARY_STREAM = b'/test/UnaryStream' +_STREAM_UNARY = b'/test/StreamUnary' +_STREAM_STREAM = b'/test/StreamStream' + +_USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__) + +_CLIENT_METADATA = ( + (b'client-md-key', b'client-md-key'), + (b'client-md-key-bin', b'\x00\x01') +) + +_SERVER_INITIAL_METADATA = ( + (b'server-initial-md-key', b'server-initial-md-value'), + (b'server-initial-md-key-bin', b'\x00\x02') +) + +_SERVER_TRAILING_METADATA = ( + (b'server-trailing-md-key', b'server-trailing-md-value'), + (b'server-trailing-md-key-bin', b'\x00\x03') +) + + +def user_agent(metadata): + for key, val in metadata: + if key == b'user-agent': + return val.decode('ascii') + raise KeyError('No user agent!') + + +def validate_client_metadata(test, servicer_context): + test.assertTrue(test_common.metadata_transmitted( + _CLIENT_METADATA, servicer_context.invocation_metadata())) + test.assertTrue(user_agent(servicer_context.invocation_metadata()) + .startswith('primary-agent ' + _USER_AGENT)) + test.assertTrue(user_agent(servicer_context.invocation_metadata()) + .endswith('secondary-agent')) + + +def handle_unary_unary(test, request, servicer_context): + validate_client_metadata(test, servicer_context) + servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA) + servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA) + return _RESPONSE + + +def handle_unary_stream(test, request, servicer_context): + validate_client_metadata(test, servicer_context) + servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA) + servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA) + for _ in range(test_constants.STREAM_LENGTH): + yield _RESPONSE + + +def handle_stream_unary(test, request_iterator, servicer_context): + validate_client_metadata(test, servicer_context) + servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA) + servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA) + # TODO(issue:#6891) We should be able to remove this loop + for request in request_iterator: + pass + return _RESPONSE + + +def handle_stream_stream(test, request_iterator, servicer_context): + validate_client_metadata(test, servicer_context) + servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA) + servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA) + # TODO(issue:#6891) We should be able to remove this loop, + # and replace with return; yield + for request in request_iterator: + yield _RESPONSE + + +class _MethodHandler(grpc.RpcMethodHandler): + + def __init__(self, test, request_streaming, response_streaming): + self.request_streaming = request_streaming + self.response_streaming = response_streaming + self.request_deserializer = None + self.response_serializer = None + self.unary_unary = None + self.unary_stream = None + self.stream_unary = None + self.stream_stream = None + if self.request_streaming and self.response_streaming: + self.stream_stream = lambda x, y: handle_stream_stream(test, x, y) + elif self.request_streaming: + self.stream_unary = lambda x, y: handle_stream_unary(test, x, y) + elif self.response_streaming: + self.unary_stream = lambda x, y: handle_unary_stream(test, x, y) + else: + self.unary_unary = lambda x, y: handle_unary_unary(test, x, y) + + +class _GenericHandler(grpc.GenericRpcHandler): + + def __init__(self, test): + self._test = test + + def service(self, handler_call_details): + if handler_call_details.method == _UNARY_UNARY: + return _MethodHandler(self._test, False, False) + elif handler_call_details.method == _UNARY_STREAM: + return _MethodHandler(self._test, False, True) + elif handler_call_details.method == _STREAM_UNARY: + return _MethodHandler(self._test, True, False) + elif handler_call_details.method == _STREAM_STREAM: + return _MethodHandler(self._test, True, True) + else: + return None + + +class MetadataTest(unittest.TestCase): + + def setUp(self): + self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY) + self._server = grpc.server((_GenericHandler(weakref.proxy(self)),), + self._server_pool) + port = self._server.add_insecure_port('[::]:0') + self._server.start() + self._channel = grpc.insecure_channel('localhost:%d' % port, + options=_CHANNEL_ARGS) + + def tearDown(self): + self._server.stop(0) + + def testUnaryUnary(self): + multi_callable = self._channel.unary_unary(_UNARY_UNARY) + unused_response, call = multi_callable( + _REQUEST, metadata=_CLIENT_METADATA, with_call=True) + self.assertTrue(test_common.metadata_transmitted( + _SERVER_INITIAL_METADATA, call.initial_metadata())) + self.assertTrue(test_common.metadata_transmitted( + _SERVER_TRAILING_METADATA, call.trailing_metadata())) + + def testUnaryStream(self): + multi_callable = self._channel.unary_stream(_UNARY_STREAM) + call = multi_callable(_REQUEST, metadata=_CLIENT_METADATA) + self.assertTrue(test_common.metadata_transmitted( + _SERVER_INITIAL_METADATA, call.initial_metadata())) + for _ in call: + pass + self.assertTrue(test_common.metadata_transmitted( + _SERVER_TRAILING_METADATA, call.trailing_metadata())) + + def testStreamUnary(self): + multi_callable = self._channel.stream_unary(_STREAM_UNARY) + unused_response, call = multi_callable( + [_REQUEST] * test_constants.STREAM_LENGTH, + metadata=_CLIENT_METADATA, with_call=True) + self.assertTrue(test_common.metadata_transmitted( + _SERVER_INITIAL_METADATA, call.initial_metadata())) + self.assertTrue(test_common.metadata_transmitted( + _SERVER_TRAILING_METADATA, call.trailing_metadata())) + + def testStreamStream(self): + multi_callable = self._channel.stream_stream(_STREAM_STREAM) + call = multi_callable([_REQUEST] * test_constants.STREAM_LENGTH, + metadata=_CLIENT_METADATA) + self.assertTrue(test_common.metadata_transmitted( + _SERVER_INITIAL_METADATA, call.initial_metadata())) + for _ in call: + pass + self.assertTrue(test_common.metadata_transmitted( + _SERVER_TRAILING_METADATA, call.trailing_metadata())) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio/tests/unit/_rpc_test.py b/src/python/grpcio/tests/unit/_rpc_test.py index 1c7a14c5d01..8407593c86d 100644 --- a/src/python/grpcio/tests/unit/_rpc_test.py +++ b/src/python/grpcio/tests/unit/_rpc_test.py @@ -41,9 +41,9 @@ from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_control _SERIALIZE_REQUEST = lambda bytestring: bytestring * 2 -_DESERIALIZE_REQUEST = lambda bytestring: bytestring[len(bytestring) / 2:] +_DESERIALIZE_REQUEST = lambda bytestring: bytestring[len(bytestring) // 2:] _SERIALIZE_RESPONSE = lambda bytestring: bytestring * 3 -_DESERIALIZE_RESPONSE = lambda bytestring: bytestring[:len(bytestring) / 3] +_DESERIALIZE_RESPONSE = lambda bytestring: bytestring[:len(bytestring) // 3] _UNARY_UNARY = b'/test/UnaryUnary' _UNARY_STREAM = b'/test/UnaryStream' @@ -189,14 +189,7 @@ class RPCTest(unittest.TestCase): self._server.add_generic_rpc_handlers((_GenericHandler(self._handler),)) self._server.start() - self._channel = grpc.insecure_channel(b'localhost:%d' % port) - - # TODO(nathaniel): Why is this necessary, and only in some development - # environments? - def tearDown(self): - del self._channel - del self._server - del self._server_pool + self._channel = grpc.insecure_channel('localhost:%d' % port) def testUnrecognizedMethod(self): request = b'abc' diff --git a/src/python/grpcio/tests/unit/_thread_cleanup_test.py b/src/python/grpcio/tests/unit/_thread_cleanup_test.py new file mode 100644 index 00000000000..3e4f317edcd --- /dev/null +++ b/src/python/grpcio/tests/unit/_thread_cleanup_test.py @@ -0,0 +1,117 @@ +# 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. +"""Tests for CleanupThread.""" + +import threading +import time +import unittest + +from grpc import _common + +_SHORT_TIME = 0.5 +_LONG_TIME = 2.0 +_EPSILON = 0.1 + + +def cleanup(timeout): + if timeout is not None: + time.sleep(timeout) + else: + time.sleep(_LONG_TIME) + + +def slow_cleanup(timeout): + # Don't respect timeout + time.sleep(_LONG_TIME) + + +class CleanupThreadTest(unittest.TestCase): + + def testTargetInvocation(self): + event = threading.Event() + def target(arg1, arg2, arg3=None): + self.assertEqual('arg1', arg1) + self.assertEqual('arg2', arg2) + self.assertEqual('arg3', arg3) + event.set() + + cleanup_thread = _common.CleanupThread(behavior=lambda x: None, + target=target, name='test-name', + args=('arg1', 'arg2'), kwargs={'arg3': 'arg3'}) + cleanup_thread.start() + cleanup_thread.join() + self.assertEqual(cleanup_thread.name, 'test-name') + self.assertTrue(event.is_set()) + + def testJoinNoTimeout(self): + cleanup_thread = _common.CleanupThread(behavior=cleanup) + cleanup_thread.start() + start_time = time.time() + cleanup_thread.join() + end_time = time.time() + self.assertAlmostEqual(_LONG_TIME, end_time - start_time, delta=_EPSILON) + + def testJoinTimeout(self): + cleanup_thread = _common.CleanupThread(behavior=cleanup) + cleanup_thread.start() + start_time = time.time() + cleanup_thread.join(_SHORT_TIME) + end_time = time.time() + self.assertAlmostEqual(_SHORT_TIME, end_time - start_time, delta=_EPSILON) + + def testJoinTimeoutSlowBehavior(self): + cleanup_thread = _common.CleanupThread(behavior=slow_cleanup) + cleanup_thread.start() + start_time = time.time() + cleanup_thread.join(_SHORT_TIME) + end_time = time.time() + self.assertAlmostEqual(_LONG_TIME, end_time - start_time, delta=_EPSILON) + + def testJoinTimeoutSlowTarget(self): + event = threading.Event() + def target(): + event.wait(_LONG_TIME) + cleanup_thread = _common.CleanupThread(behavior=cleanup, target=target) + cleanup_thread.start() + start_time = time.time() + cleanup_thread.join(_SHORT_TIME) + end_time = time.time() + self.assertAlmostEqual(_SHORT_TIME, end_time - start_time, delta=_EPSILON) + event.set() + + def testJoinZeroTimeout(self): + cleanup_thread = _common.CleanupThread(behavior=cleanup) + cleanup_thread.start() + start_time = time.time() + cleanup_thread.join(0) + end_time = time.time() + self.assertAlmostEqual(0, end_time - start_time, delta=_EPSILON) + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio/tests/unit/beta/_beta_features_test.py b/src/python/grpcio/tests/unit/beta/_beta_features_test.py index bb2893a21b9..3a9701b8ebe 100644 --- a/src/python/grpcio/tests/unit/beta/_beta_features_test.py +++ b/src/python/grpcio/tests/unit/beta/_beta_features_test.py @@ -42,8 +42,8 @@ from tests.unit.framework.common import test_constants _SERVER_HOST_OVERRIDE = 'foo.test.google.fr' -_PER_RPC_CREDENTIALS_METADATA_KEY = 'my-call-credentials-metadata-key' -_PER_RPC_CREDENTIALS_METADATA_VALUE = 'my-call-credentials-metadata-value' +_PER_RPC_CREDENTIALS_METADATA_KEY = b'my-call-credentials-metadata-key' +_PER_RPC_CREDENTIALS_METADATA_VALUE = b'my-call-credentials-metadata-value' _GROUP = 'group' _UNARY_UNARY = 'unary-unary' diff --git a/src/python/grpcio/tests/unit/beta/_not_found_test.py b/src/python/grpcio/tests/unit/beta/_not_found_test.py index 44fcd1e13c2..37b8c49120f 100644 --- a/src/python/grpcio/tests/unit/beta/_not_found_test.py +++ b/src/python/grpcio/tests/unit/beta/_not_found_test.py @@ -61,7 +61,7 @@ class NotFoundTest(unittest.TestCase): def test_future_stream_unary_not_found(self): rpc_future = self._generic_stub.future_stream_unary( - 'grupe', 'mevvod', b'def', test_constants.LONG_TIMEOUT) + 'grupe', 'mevvod', [b'def'], test_constants.LONG_TIMEOUT) with self.assertRaises(face.LocalError) as exception_assertion_context: rpc_future.result() self.assertIs( diff --git a/src/python/grpcio/tests/unit/beta/test_utilities.py b/src/python/grpcio/tests/unit/beta/test_utilities.py index 66b5f72897c..e374b203ce9 100644 --- a/src/python/grpcio/tests/unit/beta/test_utilities.py +++ b/src/python/grpcio/tests/unit/beta/test_utilities.py @@ -50,6 +50,6 @@ def not_really_secure_channel( """ target = '%s:%d' % (host, port) channel = grpc.secure_channel( - target, ((b'grpc.ssl_target_name_override', server_host_override,),), - channel_credentials._credentials) + target, channel_credentials._credentials, + ((b'grpc.ssl_target_name_override', server_host_override,),)) return implementations.Channel(channel) diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py index 4f8e26c9a26..5d16bf98be3 100644 --- a/src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py +++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py @@ -29,6 +29,8 @@ """Tests of the base interface of RPC Framework.""" +from __future__ import division + import logging import random import threading @@ -54,13 +56,13 @@ class _Serialization(test_interfaces.Serialization): return request + request def deserialize_request(self, serialized_request): - return serialized_request[:len(serialized_request) / 2] + return serialized_request[:len(serialized_request) // 2] def serialize_response(self, response): return response * 3 def deserialize_response(self, serialized_response): - return serialized_response[2 * len(serialized_response) / 3:] + return serialized_response[2 * len(serialized_response) // 3:] def _advance(quadruples, operator, controller): diff --git a/src/python/grpcio/tests/unit/test_common.py b/src/python/grpcio/tests/unit/test_common.py index 7b4d20dccbe..b779f65e7e9 100644 --- a/src/python/grpcio/tests/unit/test_common.py +++ b/src/python/grpcio/tests/unit/test_common.py @@ -61,6 +61,10 @@ def metadata_transmitted(original_metadata, transmitted_metadata): original = collections.defaultdict(list) for key_value_pair in original_metadata: key, value = tuple(key_value_pair) + if not isinstance(key, bytes): + key = key.encode() + if not isinstance(value, bytes): + value = value.encode() original[key].append(value) transmitted = collections.defaultdict(list) for key_value_pair in transmitted_metadata: diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index f76462649d2..c13d1a00d74 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -126,6 +126,8 @@ grpc_header_key_is_legal_type grpc_header_key_is_legal_import; grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import; grpc_is_binary_header_type grpc_is_binary_header_import; grpc_call_error_to_string_type grpc_call_error_to_string_import; +grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import; +grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import; grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import; grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import; @@ -393,6 +395,8 @@ void grpc_rb_load_imports(HMODULE library) { grpc_header_nonbin_value_is_legal_import = (grpc_header_nonbin_value_is_legal_type) GetProcAddress(library, "grpc_header_nonbin_value_is_legal"); grpc_is_binary_header_import = (grpc_is_binary_header_type) GetProcAddress(library, "grpc_is_binary_header"); grpc_call_error_to_string_import = (grpc_call_error_to_string_type) GetProcAddress(library, "grpc_call_error_to_string"); + grpc_insecure_channel_create_from_fd_import = (grpc_insecure_channel_create_from_fd_type) GetProcAddress(library, "grpc_insecure_channel_create_from_fd"); + grpc_server_add_insecure_channel_from_fd_import = (grpc_server_add_insecure_channel_from_fd_type) GetProcAddress(library, "grpc_server_add_insecure_channel_from_fd"); grpc_auth_property_iterator_next_import = (grpc_auth_property_iterator_next_type) GetProcAddress(library, "grpc_auth_property_iterator_next"); grpc_auth_context_property_iterator_import = (grpc_auth_context_property_iterator_type) GetProcAddress(library, "grpc_auth_context_property_iterator"); grpc_auth_context_peer_identity_import = (grpc_auth_context_peer_identity_type) GetProcAddress(library, "grpc_auth_context_peer_identity"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 5d690a915d8..e9845cd7e25 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -328,6 +329,12 @@ extern grpc_is_binary_header_type grpc_is_binary_header_import; typedef const char *(*grpc_call_error_to_string_type)(grpc_call_error error); extern grpc_call_error_to_string_type grpc_call_error_to_string_import; #define grpc_call_error_to_string grpc_call_error_to_string_import +typedef grpc_channel *(*grpc_insecure_channel_create_from_fd_type)(const char *target, int fd, const grpc_channel_args *args); +extern grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import; +#define grpc_insecure_channel_create_from_fd grpc_insecure_channel_create_from_fd_import +typedef void(*grpc_server_add_insecure_channel_from_fd_type)(grpc_server *server, grpc_completion_queue *cq, int fd); +extern grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import; +#define grpc_server_add_insecure_channel_from_fd grpc_server_add_insecure_channel_from_fd_import typedef const grpc_auth_property *(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator *it); extern grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; #define grpc_auth_property_iterator_next grpc_auth_property_iterator_next_import @@ -475,7 +482,7 @@ extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_impo typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader); extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; #define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import -typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...); +typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); extern gpr_log_type gpr_log_import; #define gpr_log gpr_log_import typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); @@ -814,7 +821,7 @@ extern gpr_format_message_type gpr_format_message_import; typedef char *(*gpr_strdup_type)(const char *src); extern gpr_strdup_type gpr_strdup_import; #define gpr_strdup gpr_strdup_import -typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...); +typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(2, 3); extern gpr_asprintf_type gpr_asprintf_import; #define gpr_asprintf gpr_asprintf_import typedef const char *(*gpr_subprocess_binary_extension_type)(); diff --git a/templates/composer.json.template b/templates/composer.json.template index 275b4655ced..7d2029c218f 100644 --- a/templates/composer.json.template +++ b/templates/composer.json.template @@ -4,7 +4,6 @@ "name": "grpc/grpc", "type": "library", "description": "gRPC library for PHP", - "version": "${settings.php_version.php()}", "keywords": ["rpc"], "homepage": "http://grpc.io", "license": "BSD-3-Clause", diff --git a/templates/package.xml.template b/templates/package.xml.template index 85f9a7d19ea..a620a2d6a50 100644 --- a/templates/package.xml.template +++ b/templates/package.xml.template @@ -200,20 +200,5 @@ - Updated functions with TSRM macros for ZTS support #6607 - - - ${settings.php_version.php()} - ${settings.php_version.php()} - - - beta - beta - - 2016-05-19 - BSD - - - TBD - - diff --git a/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template b/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template index c11cefd283b..e39537975bf 100644 --- a/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template @@ -34,6 +34,12 @@ <%include file="../../apt_get_basic.include"/> <%include file="../../cxx_deps.include"/> <%include file="../../run_tests_addons.include"/> + + # The clang-3.6 symlink for the default clang version was added + # to Ubuntu 16.04 recently, so make sure it's installed. + # Also install clang3.7. + RUN apt-get update && apt-get -y install clang-3.6 clang-3.7 && apt-get clean + # Define the default command. CMD ["bash"] \ No newline at end of file diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.c index b7d329cb741..ded5f17d4ab 100644 --- a/test/core/bad_client/tests/large_metadata.c +++ b/test/core/bad_client/tests/large_metadata.c @@ -163,6 +163,7 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server, meta.value_length = metadata_value_size; grpc_op op; + memset(&op, 0, sizeof(op)); op.op = GRPC_OP_SEND_INITIAL_METADATA; op.data.send_initial_metadata.count = 1; op.data.send_initial_metadata.metadata = &meta; diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index c4ae212ec29..bb06ab0bb96 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -84,6 +84,7 @@ static void run_test(const char *target, size_t nops) { "/foo", "foo.test.google.fr:1234", deadline, NULL); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c index c2fc05095aa..8ef1bff22e7 100644 --- a/test/core/channel/channel_args_test.c +++ b/test/core/channel/channel_args_test.c @@ -136,8 +136,10 @@ static void test_compression_algorithm_states(void) { int main(int argc, char **argv) { grpc_test_init(argc, argv); + grpc_init(); test_create(); test_set_compression_algorithm(); test_compression_algorithm_states(); + grpc_shutdown(); return 0; } diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index b5476c8f6a8..2d77bc5bd4a 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -124,7 +124,7 @@ static void test_create_channel_stack(void) { channel_stack = gpr_malloc(grpc_channel_stack_size(&filters, 1)); grpc_channel_stack_init(&exec_ctx, 1, free_channel, channel_stack, &filters, - 1, &chan_args, "test", channel_stack); + 1, &chan_args, NULL, "test", channel_stack); GPR_ASSERT(channel_stack->count == 1); channel_elem = grpc_channel_stack_element(channel_stack, 0); channel_data = (int *)channel_elem->channel_data; diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c index 2ec46124a89..3160312db6f 100644 --- a/test/core/client_config/lb_policies_test.c +++ b/test/core/client_config/lb_policies_test.c @@ -135,7 +135,7 @@ static void drain_cq(grpc_completion_queue *cq) { } static void kill_server(const servers_fixture *f, size_t i) { - gpr_log(GPR_INFO, "KILLING SERVER %d", i); + gpr_log(GPR_INFO, "KILLING SERVER %" PRIuPTR, i); GPR_ASSERT(f->servers[i] != NULL); grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); GPR_ASSERT( @@ -157,7 +157,7 @@ typedef struct request_data { static void revive_server(const servers_fixture *f, request_data *rdata, size_t i) { int got_port; - gpr_log(GPR_INFO, "RAISE AGAIN SERVER %d", i); + gpr_log(GPR_INFO, "RAISE AGAIN SERVER %" PRIuPTR, i); GPR_ASSERT(f->servers[i] == NULL); gpr_log(GPR_DEBUG, "revive: %s", f->servers_hostports[i]); @@ -275,6 +275,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, GPR_ASSERT(c); completed_client = 0; + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -310,7 +311,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, .type != GRPC_QUEUE_TIMEOUT) { GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); read_tag = ((int)(intptr_t)ev.tag); - gpr_log(GPR_DEBUG, "EVENT: success:%d, type:%d, tag:%d iter:%d", + gpr_log(GPR_DEBUG, "EVENT: success:%d, type:%d, tag:%d iter:%" PRIuPTR, ev.success, ev.type, read_tag, iter_num); if (ev.success && read_tag >= 1000) { GPR_ASSERT(s_idx == -1); /* only one server must reply */ @@ -327,6 +328,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, } if (s_idx >= 0) { + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -415,6 +417,7 @@ static grpc_call **perform_multirequest(servers_fixture *f, kill_server(f, i); } + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -640,7 +643,8 @@ static void print_failed_expectations(const int *expected_connection_sequence, const size_t num_iters) { size_t i; for (i = 0; i < num_iters; i++) { - gpr_log(GPR_ERROR, "FAILURE: Iter, expected, actual:%d (%d, %d)", i, + gpr_log(GPR_ERROR, + "FAILURE: Iter (expected, actual): %" PRIuPTR " (%d, %d)", i, expected_connection_sequence[i % expected_seq_length], actual_connection_sequence[i]); } @@ -664,8 +668,6 @@ static void verify_vanilla_round_robin(const servers_fixture *f, const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -692,24 +694,21 @@ static void verify_vanishing_floor_round_robin( memcpy(expected_connection_sequence, actual_connection_sequence + 2, expected_seq_length * sizeof(int)); - /* first three elements of the sequence should be [<1st>, -1] */ - if (actual_connection_sequence[0] != expected_connection_sequence[0]) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", - expected_connection_sequence[0], actual_connection_sequence[0], 0); - print_failed_expectations(expected_connection_sequence, - actual_connection_sequence, expected_seq_length, - 1u); - abort(); - } - + /* first two elements of the sequence should be [0 (1st server), -1 (failure)] + */ + GPR_ASSERT(actual_connection_sequence[0] == 0); GPR_ASSERT(actual_connection_sequence[1] == -1); + /* the next two element must be [3, 0], repeating from that point: the 3 is + * brought forth by servers 1 and 2 disappearing after the intial pick of 0 */ + GPR_ASSERT(actual_connection_sequence[2] == 3); + GPR_ASSERT(actual_connection_sequence[3] == 0); + + /* make sure that the expectation obliges */ for (i = 2; i < num_iters; i++) { const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -728,8 +727,8 @@ static void verify_total_carnage_round_robin( const int actual = actual_connection_sequence[i]; const int expected = -1; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); + gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %" PRIuPTR, + expected, actual, i); abort(); } } @@ -757,8 +756,6 @@ static void verify_partial_carnage_round_robin( const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -856,8 +853,6 @@ static void verify_rebirth_round_robin(const servers_fixture *f, const int expected = expected_connection_sequence[j++ % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -887,7 +882,8 @@ int main(int argc, char **argv) { GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, NULL, NULL) == NULL); spec = test_spec_create(NUM_ITERS, NUM_SERVERS); - /* everything is fine, all servers stay up the whole time and life's peachy */ + /* everything is fine, all servers stay up the whole time and life's peachy + */ spec->verifier = verify_vanilla_round_robin; spec->description = "test_all_server_up"; run_spec(spec); diff --git a/test/core/client_config/set_initial_connect_string_test.c b/test/core/client_config/set_initial_connect_string_test.c index 5390c4ab986..63371a6b341 100644 --- a/test/core/client_config/set_initial_connect_string_test.c +++ b/test/core/client_config/set_initial_connect_string_test.c @@ -69,7 +69,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) { GPR_ASSERT(success); gpr_slice_buffer_move_into(&state.temp_incoming_buffer, &state.incoming_buffer); - gpr_log(GPR_DEBUG, "got %d bytes, magic is %d bytes", + gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, magic is %" PRIuPTR " bytes", state.incoming_buffer.length, strlen(magic_connect_string)); if (state.incoming_buffer.length > strlen(magic_connect_string)) { gpr_atm_rel_store(&state.done_atm, 1); @@ -136,6 +136,7 @@ static void start_rpc(int use_creds, int target_port) { state.call = grpc_channel_create_call( state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, "/Service/Method", "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + memset(&state.op, 0, sizeof(state.op)); state.op.op = GRPC_OP_SEND_INITIAL_METADATA; state.op.data.send_initial_metadata.count = 0; state.op.flags = 0; @@ -172,8 +173,8 @@ static void actually_poll_server(void *arg) { bool done = gpr_atm_acq_load(&state.done_atm) != 0; gpr_timespec time_left = gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%d.%09d", done, time_left.tv_sec, - time_left.tv_nsec); + gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09" PRId32, done, + time_left.tv_sec, time_left.tv_nsec); if (done || gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) < 0) { break; } diff --git a/test/core/client_config/uri_fuzzer_test.c b/test/core/client_config/uri_fuzzer_test.c index eb976fc9f53..f297140559c 100644 --- a/test/core/client_config/uri_fuzzer_test.c +++ b/test/core/client_config/uri_fuzzer_test.c @@ -31,6 +31,7 @@ * */ +#include #include #include @@ -38,6 +39,9 @@ #include "src/core/ext/client_config/uri_parser.h" +bool squelch = true; +bool leak_check = true; + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char *s = gpr_malloc(size + 1); memcpy(s, data, size); diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index 1a93903346f..47ecf72e08e 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -66,13 +66,14 @@ static void assert_passthrough(gpr_slice value, char *algorithm_name; GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algorithm_name) != 0); - gpr_log(GPR_INFO, - "assert_passthrough: value_length=%d value_hash=0x%08x " - "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", - GPR_SLICE_LENGTH(value), gpr_murmur_hash3(GPR_SLICE_START_PTR(value), - GPR_SLICE_LENGTH(value), 0), - algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), - grpc_slice_split_mode_name(compressed_split_mode)); + gpr_log( + GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR + " value_hash=0x%08x " + "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", + GPR_SLICE_LENGTH(value), + gpr_murmur_hash3(GPR_SLICE_START_PTR(value), GPR_SLICE_LENGTH(value), 0), + algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), + grpc_slice_split_mode_name(compressed_split_mode)); gpr_slice_buffer_init(&input); gpr_slice_buffer_init(&compressed_raw); diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 77afe588d79..8e9fa70b0ec 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -284,6 +284,6 @@ static expectation *add(cq_verifier *v, grpc_completion_type type, void *tag) { return e; } -void cq_expect_completion(cq_verifier *v, void *tag, int success) { +void cq_expect_completion(cq_verifier *v, void *tag, bool success) { add(v, GRPC_OP_COMPLETE, tag)->success = success; } diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index b3e07c45a58..8c9a85c2187 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -34,6 +34,8 @@ #ifndef GRPC_TEST_CORE_END2END_CQ_VERIFIER_H #define GRPC_TEST_CORE_END2END_CQ_VERIFIER_H +#include + #include #include "test/core/util/test_config.h" @@ -57,7 +59,7 @@ void cq_verify_empty(cq_verifier *v); Any functions taking ... expect a NULL terminated list of key/value pairs (each pair using two parameter slots) of metadata that MUST be present in the event. */ -void cq_expect_completion(cq_verifier *v, void *tag, int success); +void cq_expect_completion(cq_verifier *v, void *tag, bool success); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); int contains_metadata(grpc_metadata_array *array, const char *key, diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 202fb3b6a86..46e060e4fe9 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -167,6 +167,7 @@ void test_connect(const char *server_host, const char *client_host, int port, "/foo", "foo.test.google.fr", deadline, NULL); GPR_ASSERT(c); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -201,6 +202,7 @@ void test_connect(const char *server_host, const char *client_host, int port, cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.c new file mode 100644 index 00000000000..e938fe77301 --- /dev/null +++ b/test/core/end2end/fixtures/h2_fd.c @@ -0,0 +1,128 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/core/end2end/end2end_tests.h" + +#include +#include + +#include +#include +#include +#include +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/socket_utils_posix.h" +#include "src/core/lib/iomgr/unix_sockets_posix.h" +#include "test/core/util/test_config.h" + +typedef struct { int fd_pair[2]; } sp_fixture_data; + +static void create_sockets(int sv[2]) { + int flags; + grpc_create_socketpair_if_unix(sv); + flags = fcntl(sv[0], F_GETFL, 0); + GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0); + flags = fcntl(sv[1], F_GETFL, 0); + GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0); + GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[0])); + GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[1])); +} + +static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( + grpc_channel_args *client_args, grpc_channel_args *server_args) { + sp_fixture_data *fixture_data = gpr_malloc(sizeof(*fixture_data)); + + grpc_end2end_test_fixture f; + memset(&f, 0, sizeof(f)); + f.fixture_data = fixture_data; + f.cq = grpc_completion_queue_create(NULL); + + create_sockets(fixture_data->fd_pair); + + return f; +} + +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + sp_fixture_data *sfd = f->fixture_data; + + GPR_ASSERT(!f->client); + f->client = grpc_insecure_channel_create_from_fd( + "fixture_client", sfd->fd_pair[0], client_args); + GPR_ASSERT(f->client); + + grpc_exec_ctx_finish(&exec_ctx); +} + +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + sp_fixture_data *sfd = f->fixture_data; + GPR_ASSERT(!f->server); + f->server = grpc_server_create(server_args, NULL); + GPR_ASSERT(f->server); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + grpc_server_start(f->server); + + grpc_server_add_insecure_channel_from_fd(f->server, f->cq, sfd->fd_pair[1]); + + grpc_exec_ctx_finish(&exec_ctx); +} + +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { + gpr_free(f->fixture_data); +} + +/* All test configurations */ +static grpc_end2end_test_config configs[] = { + {"chttp2/fd", 0, chttp2_create_fixture_socketpair, + chttp2_init_client_socketpair, chttp2_init_server_socketpair, + chttp2_tear_down_socketpair}, +}; + +int main(int argc, char **argv) { + size_t i; + + grpc_test_init(argc, argv); + grpc_end2end_tests_pre_init(); + grpc_init(); + + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(argc, argv, configs[i]); + } + + grpc_shutdown(); + + return 0; +} diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index 0fa525175ba..b476bf5516d 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -321,6 +321,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, NULL); GPR_ASSERT(c); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index 7f10649fa69..beed80df819 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -170,6 +170,7 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) { grpc_op op; grpc_call_error err; + memset(&op, 0, sizeof(op)); if (!pc->proxy->shutdown) { op.op = GRPC_OP_SEND_INITIAL_METADATA; op.flags = 0; @@ -329,6 +330,7 @@ static void on_new_call(void *arg, int success) { if (success) { grpc_op op; + memset(&op, 0, sizeof(op)); proxy_call *pc = gpr_malloc(sizeof(*pc)); memset(pc, 0, sizeof(*pc)); pc->proxy = proxy; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 6bcddbd7699..dd93c4a817f 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -50,7 +50,8 @@ //////////////////////////////////////////////////////////////////////////////// // logging -static const bool squelch = true; +bool squelch = true; +bool leak_check = true; static void dont_log(gpr_log_func_args *args) {} @@ -739,6 +740,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { break; } grpc_op *ops = gpr_malloc(sizeof(grpc_op) * num_ops); + memset(ops, 0, sizeof(grpc_op) * num_ops); bool ok = true; size_t i; grpc_op *op; diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0e79b68aa8b9c336f0bbf9029928c53079711423 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0e79b68aa8b9c336f0bbf9029928c53079711423 new file mode 100644 index 00000000000..5b16d9d759a Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/0e79b68aa8b9c336f0bbf9029928c53079711423 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1560af88445d6c1e8b1300047f33056dce198e02 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1560af88445d6c1e8b1300047f33056dce198e02 new file mode 100644 index 00000000000..008dcac29ab Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/1560af88445d6c1e8b1300047f33056dce198e02 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/48caf755ddcc6c45d3416ba6ab44709f360eb82b b/test/core/end2end/fuzzers/api_fuzzer_corpus/48caf755ddcc6c45d3416ba6ab44709f360eb82b new file mode 100644 index 00000000000..f29e9a7983b Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/48caf755ddcc6c45d3416ba6ab44709f360eb82b differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7030cb2c62b289459e459bc54bd84c8d7e6f5a98 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7030cb2c62b289459e459bc54bd84c8d7e6f5a98 new file mode 100644 index 00000000000..035f23e8997 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/7030cb2c62b289459e459bc54bd84c8d7e6f5a98 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/81f8c545d77d93e6cb8239e9e4a4d7f8f8beeee9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/81f8c545d77d93e6cb8239e9e4a4d7f8f8beeee9 new file mode 100644 index 00000000000..a16874c5415 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/81f8c545d77d93e6cb8239e9e4a4d7f8f8beeee9 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b7d02f4d12cd0b5442a04675e69f98fbdabc775a b/test/core/end2end/fuzzers/api_fuzzer_corpus/b7d02f4d12cd0b5442a04675e69f98fbdabc775a new file mode 100644 index 00000000000..6f1edf58514 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/b7d02f4d12cd0b5442a04675e69f98fbdabc775a differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ce6a90cb7d395fea7aa54ee9f7061cc45f5494d7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ce6a90cb7d395fea7aa54ee9f7061cc45f5494d7 new file mode 100644 index 00000000000..c5c9c279383 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/ce6a90cb7d395fea7aa54ee9f7061cc45f5494d7 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-482e9bdce0e13df2a77eef75a1c07d38ee28f4ab b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-482e9bdce0e13df2a77eef75a1c07d38ee28f4ab new file mode 100644 index 00000000000..b83e382f18c Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-482e9bdce0e13df2a77eef75a1c07d38ee28f4ab differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e94428d78182060ff6309dd626cf6b3ebeed88d6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e94428d78182060ff6309dd626cf6b3ebeed88d6 new file mode 100644 index 00000000000..570de0eef1a Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/e94428d78182060ff6309dd626cf6b3ebeed88d6 differ diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index afcf7638f72..79b23d78569 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -39,7 +41,8 @@ #include "test/core/util/memory_counters.h" #include "test/core/util/mock_endpoint.h" -static const bool squelch = true; +bool squelch = true; +bool leak_check = true; static void discard_write(gpr_slice slice) {} @@ -51,7 +54,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_test_only_set_metadata_hash_seed(0); struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); - grpc_memory_counters_init(); + if (leak_check) grpc_memory_counters_init(); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -78,6 +81,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { size_t details_capacity = 0; grpc_op ops[6]; + memset(ops, 0, sizeof(ops)); grpc_op *op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -153,8 +157,10 @@ done: grpc_byte_buffer_destroy(response_payload_recv); } grpc_shutdown(); - counters = grpc_memory_counters_snapshot(); - grpc_memory_counters_destroy(); - GPR_ASSERT(counters.total_size_relative == 0); + if (leak_check) { + counters = grpc_memory_counters_snapshot(); + grpc_memory_counters_destroy(); + GPR_ASSERT(counters.total_size_relative == 0); + } return 0; } diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index 0a7d6d92aac..80f568ac927 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -38,7 +38,8 @@ #include "test/core/util/memory_counters.h" #include "test/core/util/mock_endpoint.h" -static const bool squelch = true; +bool squelch = true; +bool leak_check = true; static void discard_write(gpr_slice slice) {} @@ -51,7 +52,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_test_only_set_metadata_hash_seed(0); struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); - grpc_memory_counters_init(); + if (leak_check) grpc_memory_counters_init(); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -120,8 +121,10 @@ done: grpc_server_destroy(server); grpc_completion_queue_destroy(cq); grpc_shutdown(); - counters = grpc_memory_counters_snapshot(); - grpc_memory_counters_destroy(); - GPR_ASSERT(counters.total_size_relative == 0); + if (leak_check) { + counters = grpc_memory_counters_snapshot(); + grpc_memory_counters_destroy(); + GPR_ASSERT(counters.total_size_relative == 0); + } return 0; } diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/05551028437699c8650f5d08eb5f95ee25adf436 b/test/core/end2end/fuzzers/server_fuzzer_corpus/05551028437699c8650f5d08eb5f95ee25adf436 new file mode 100644 index 00000000000..c61aff87e99 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/05551028437699c8650f5d08eb5f95ee25adf436 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/06285b50669cc16463db009ac821f99cf1ec2e24 b/test/core/end2end/fuzzers/server_fuzzer_corpus/06285b50669cc16463db009ac821f99cf1ec2e24 new file mode 100644 index 00000000000..d480552344b Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/06285b50669cc16463db009ac821f99cf1ec2e24 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/23c582f6e23c7bbc9ae7b039b3b4e2ccdea3d5d2 b/test/core/end2end/fuzzers/server_fuzzer_corpus/23c582f6e23c7bbc9ae7b039b3b4e2ccdea3d5d2 new file mode 100644 index 00000000000..20b4cf800c7 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/23c582f6e23c7bbc9ae7b039b3b4e2ccdea3d5d2 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/23f261e44d54a2736f6e288128d98db9e5015206 b/test/core/end2end/fuzzers/server_fuzzer_corpus/23f261e44d54a2736f6e288128d98db9e5015206 new file mode 100644 index 00000000000..1452256ec7f Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/23f261e44d54a2736f6e288128d98db9e5015206 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/395aea4fcfea081fc0d2733fff2d14405439fa72 b/test/core/end2end/fuzzers/server_fuzzer_corpus/395aea4fcfea081fc0d2733fff2d14405439fa72 new file mode 100644 index 00000000000..c83226294aa Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/395aea4fcfea081fc0d2733fff2d14405439fa72 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/404e234751b01dd0b51f9e7610f787253b074528 b/test/core/end2end/fuzzers/server_fuzzer_corpus/404e234751b01dd0b51f9e7610f787253b074528 new file mode 100644 index 00000000000..56a2f93726c Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/404e234751b01dd0b51f9e7610f787253b074528 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/4123bd764c04385191342ea64918408140313714 b/test/core/end2end/fuzzers/server_fuzzer_corpus/4123bd764c04385191342ea64918408140313714 new file mode 100644 index 00000000000..18d908f6ab3 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/4123bd764c04385191342ea64918408140313714 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/4f96a5fba4d11401eb22d4b1e365fbbb2d684f24 b/test/core/end2end/fuzzers/server_fuzzer_corpus/4f96a5fba4d11401eb22d4b1e365fbbb2d684f24 new file mode 100644 index 00000000000..cc5d4987b94 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/4f96a5fba4d11401eb22d4b1e365fbbb2d684f24 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/552199651d942e7220141a93ec33dd8256210a18 b/test/core/end2end/fuzzers/server_fuzzer_corpus/552199651d942e7220141a93ec33dd8256210a18 new file mode 100644 index 00000000000..c8c54f443d7 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/552199651d942e7220141a93ec33dd8256210a18 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/609706c57e848ea58d7ca14fe6cc253322f3e8ce b/test/core/end2end/fuzzers/server_fuzzer_corpus/609706c57e848ea58d7ca14fe6cc253322f3e8ce new file mode 100644 index 00000000000..1ac7cc9036d Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/609706c57e848ea58d7ca14fe6cc253322f3e8ce differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/7a946bf3cd91b63001f2cf3f40c515c747f2ecde b/test/core/end2end/fuzzers/server_fuzzer_corpus/7a946bf3cd91b63001f2cf3f40c515c747f2ecde new file mode 100644 index 00000000000..8ef1b0ad7e9 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/7a946bf3cd91b63001f2cf3f40c515c747f2ecde differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/7d25c28298fb4d0fe41209d0d14307e4aa67c59e b/test/core/end2end/fuzzers/server_fuzzer_corpus/7d25c28298fb4d0fe41209d0d14307e4aa67c59e new file mode 100644 index 00000000000..a323f7a1abd Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/7d25c28298fb4d0fe41209d0d14307e4aa67c59e differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/8138b18a9a743659befc2f2b23d23cb9c3086a09 b/test/core/end2end/fuzzers/server_fuzzer_corpus/8138b18a9a743659befc2f2b23d23cb9c3086a09 new file mode 100644 index 00000000000..2bcef177a33 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/8138b18a9a743659befc2f2b23d23cb9c3086a09 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/89cd90fb47bb9eb289e8126b26021ee00d572d95 b/test/core/end2end/fuzzers/server_fuzzer_corpus/89cd90fb47bb9eb289e8126b26021ee00d572d95 new file mode 100644 index 00000000000..17b8d7db661 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/89cd90fb47bb9eb289e8126b26021ee00d572d95 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/925011abb99fd56bb0f425ae5e0d92e6d341f804 b/test/core/end2end/fuzzers/server_fuzzer_corpus/925011abb99fd56bb0f425ae5e0d92e6d341f804 new file mode 100644 index 00000000000..948d5fafa33 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/925011abb99fd56bb0f425ae5e0d92e6d341f804 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/99a1acc96512c1155f91afa378e2345726d307c3 b/test/core/end2end/fuzzers/server_fuzzer_corpus/99a1acc96512c1155f91afa378e2345726d307c3 new file mode 100644 index 00000000000..a82790db500 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/99a1acc96512c1155f91afa378e2345726d307c3 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-c1f66840627e3bfdedf2e4c225bc4de0c267ed37 b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-c1f66840627e3bfdedf2e4c225bc4de0c267ed37 new file mode 100644 index 00000000000..a7fa57e78e8 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-c1f66840627e3bfdedf2e4c225bc4de0c267ed37 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-ccf36bef9318fe6d5e5e1560c5485cdc87d0a701 b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-ccf36bef9318fe6d5e5e1560c5485cdc87d0a701 new file mode 100644 index 00000000000..8bc2de908a8 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-ccf36bef9318fe6d5e5e1560c5485cdc87d0a701 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/d6bed9cc3c10338a8c5f41064ff8bec0bbc267ce b/test/core/end2end/fuzzers/server_fuzzer_corpus/d6bed9cc3c10338a8c5f41064ff8bec0bbc267ce new file mode 100644 index 00000000000..2b3424a332f Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/d6bed9cc3c10338a8c5f41064ff8bec0bbc267ce differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/dda9643679f8c8b796e64232a7d153e447d64991 b/test/core/end2end/fuzzers/server_fuzzer_corpus/dda9643679f8c8b796e64232a7d153e447d64991 new file mode 100644 index 00000000000..b8ba07b16bf Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/dda9643679f8c8b796e64232a7d153e447d64991 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/e7b08e36420fa107f0aee652e62158af85a4ef15 b/test/core/end2end/fuzzers/server_fuzzer_corpus/e7b08e36420fa107f0aee652e62158af85a4ef15 new file mode 100644 index 00000000000..523c785612e Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/e7b08e36420fa107f0aee652e62158af85a4ef15 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/ec4949487fa84f0cead39521b51f837af9dc784a b/test/core/end2end/fuzzers/server_fuzzer_corpus/ec4949487fa84f0cead39521b51f837af9dc784a new file mode 100644 index 00000000000..e6ea5327d88 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/ec4949487fa84f0cead39521b51f837af9dc784a differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-0292270056246b7a4ccd2e7d0356665cef307ef2 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-0292270056246b7a4ccd2e7d0356665cef307ef2 new file mode 100644 index 00000000000..e3eab9eab39 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-0292270056246b7a4ccd2e7d0356665cef307ef2 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-098ec93ded3a20e6043d11e9cc6066351e257f8e b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-098ec93ded3a20e6043d11e9cc6066351e257f8e new file mode 100644 index 00000000000..b8fa2c077ed Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-098ec93ded3a20e6043d11e9cc6066351e257f8e differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-1dc659f500e7bee41a4fee4423ade8332c162cc0 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-1dc659f500e7bee41a4fee4423ade8332c162cc0 new file mode 100644 index 00000000000..54411c45e4d Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-1dc659f500e7bee41a4fee4423ade8332c162cc0 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-350b5da741597222c98fe86768432507850317f5 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-350b5da741597222c98fe86768432507850317f5 new file mode 100644 index 00000000000..4364289907f Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-350b5da741597222c98fe86768432507850317f5 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-395aea4fcfea081fc0d2733fff2d14405439fa72 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-395aea4fcfea081fc0d2733fff2d14405439fa72 new file mode 100644 index 00000000000..c83226294aa Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-395aea4fcfea081fc0d2733fff2d14405439fa72 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-45cf8ac5faa9c7b15baf9281e8d7e0b4e103f0e0 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-45cf8ac5faa9c7b15baf9281e8d7e0b4e103f0e0 new file mode 100644 index 00000000000..70b2eecbd63 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-45cf8ac5faa9c7b15baf9281e8d7e0b4e103f0e0 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-60a9f77951c5059616764894e1963d83d478edfe b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-60a9f77951c5059616764894e1963d83d478edfe new file mode 100644 index 00000000000..0063c63f733 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-60a9f77951c5059616764894e1963d83d478edfe differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-97a338fa892093ed5013a76b96b35dd112df3342 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-97a338fa892093ed5013a76b96b35dd112df3342 new file mode 100644 index 00000000000..3a231db3e4b Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-97a338fa892093ed5013a76b96b35dd112df3342 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a1b2cfcf0997acb13a32fc5c004f57d9e9bc4275 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a1b2cfcf0997acb13a32fc5c004f57d9e9bc4275 new file mode 100644 index 00000000000..1a213469dda Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a1b2cfcf0997acb13a32fc5c004f57d9e9bc4275 differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a1ed26e6f82ca0e81e3f415bd8b0b8b520d3927b b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a1ed26e6f82ca0e81e3f415bd8b0b8b520d3927b new file mode 100644 index 00000000000..c00d51de994 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a1ed26e6f82ca0e81e3f415bd8b0b8b520d3927b differ diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-f412afea6b01aa53da919a41a65ffbf9885f2d65 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-f412afea6b01aa53da919a41a65ffbf9885f2d65 new file mode 100644 index 00000000000..171446cb1e0 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-f412afea6b01aa53da919a41a65ffbf9885f2d65 differ diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index cf1ba7c68ee..3d3bec1a69e 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -45,6 +45,8 @@ default_unsecure_fixture_options = FixtureOptions( socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False) default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True) uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix']) +fd_unsecure_fixture_options = default_unsecure_fixture_options._replace( + dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix']) # maps fixture name to whether it requires the security library @@ -52,6 +54,7 @@ END2END_FIXTURES = { 'h2_compress': default_unsecure_fixture_options, 'h2_census': default_unsecure_fixture_options, 'h2_fakesec': default_secure_fixture_options._replace(ci_mac=False), + 'h2_fd': fd_unsecure_fixture_options, 'h2_full': default_unsecure_fixture_options, 'h2_full+pipe': default_unsecure_fixture_options._replace( platforms=['linux']), @@ -73,7 +76,8 @@ END2END_FIXTURES = { } TestOptions = collections.namedtuple( - 'TestOptions', 'needs_fullstack needs_dns proxyable secure traceable cpu_cost') + 'TestOptions', + 'needs_fullstack needs_dns proxyable secure traceable cpu_cost') default_test_options = TestOptions(False, False, True, False, True, 1.0) connectivity_test_options = default_test_options._replace(needs_fullstack=True) @@ -90,8 +94,10 @@ END2END_TESTS = { 'cancel_before_invoke': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_in_a_vacuum': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_with_status': default_test_options._replace(cpu_cost=LOWCPU), - 'compressed_payload': default_test_options._replace(proxyable=False, cpu_cost=LOWCPU), - 'connectivity': connectivity_test_options._replace(proxyable=False, cpu_cost=LOWCPU), + 'compressed_payload': default_test_options._replace(proxyable=False, + cpu_cost=LOWCPU), + 'connectivity': connectivity_test_options._replace(proxyable=False, + cpu_cost=LOWCPU), 'default_host': default_test_options._replace(needs_fullstack=True, needs_dns=True), 'disappearing_server': connectivity_test_options, @@ -117,7 +123,8 @@ END2END_TESTS = { 'server_finishes_request': default_test_options, 'shutdown_finishes_calls': default_test_options, 'shutdown_finishes_tags': default_test_options, - 'simple_delayed_request': connectivity_test_options._replace(cpu_cost=LOWCPU), + 'simple_delayed_request': connectivity_test_options._replace( + cpu_cost=LOWCPU), 'simple_metadata': default_test_options, 'simple_request': default_test_options, 'trailing_metadata': default_test_options, diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c index 5f8c2641e76..3266793137c 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -132,6 +132,7 @@ int main(int argc, char **argv) { chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1", GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL); /* send initial metadata to probe connectivity */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -142,6 +143,7 @@ int main(int argc, char **argv) { (size_t)(op - ops), tag(0x101), NULL)); /* and receive status to probe termination */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1; @@ -183,6 +185,7 @@ int main(int argc, char **argv) { tag(0x9999)); /* listen for close on the server call to probe for finishing */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled1; @@ -205,6 +208,7 @@ int main(int argc, char **argv) { chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1", GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL); /* send initial metadata to probe connectivity */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -215,6 +219,7 @@ int main(int argc, char **argv) { (size_t)(op - ops), tag(0x201), NULL)); /* and receive status to probe termination */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2; @@ -249,6 +254,7 @@ int main(int argc, char **argv) { cq_verify(cqv); /* listen for close on the server call to probe for finishing */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled2; diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index cf42e92a1a3..35456607012 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -30,11 +30,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +#include +#include + #include #include #include #include -#include + #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -74,6 +78,7 @@ static void prepare_test(int is_client) { g_state.cqv = cq_verifier_create(g_state.cq); g_state.details = NULL; g_state.details_capacity = 0; + memset(g_state.ops, 0, sizeof(g_state.ops)); if (is_client) { /* create a call, channel to a non existant server */ diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 7a5cd2335f1..08af3821971 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -31,9 +31,12 @@ * */ +#include + #include #include #include + #include "test/core/end2end/cq_verifier.h" #include "test/core/util/test_config.h" @@ -65,6 +68,7 @@ int main(int argc, char **argv) { call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/Foo", "nonexistant", deadline, NULL); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index 3cb9b3d4b12..c9663c2155e 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -123,6 +123,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 994c3bf1dd2..3dd26120777 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -157,6 +157,7 @@ static void test_request_response_with_metadata_and_payload( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -201,6 +202,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -219,6 +221,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 5c6791f6f78..694a0aa9ef4 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -193,6 +193,7 @@ static void request_response_with_payload_and_call_creds( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -248,6 +249,7 @@ static void request_response_with_payload_and_call_creds( /* Cannot set creds on the server call object. */ GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -265,6 +267,7 @@ static void request_response_with_payload_and_call_creds( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; @@ -410,6 +413,7 @@ static void test_request_with_server_rejecting_client_creds( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index fc2a64a6c18..51c13da3b1e 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -136,6 +136,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; @@ -174,6 +175,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(2), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &request_payload_recv; diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 3bafa8c85fd..2b5a409deef 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -136,6 +136,7 @@ static void test_cancel_after_accept_and_writes_closed( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; @@ -178,6 +179,7 @@ static void test_cancel_after_accept_and_writes_closed( cq_expect_completion(cqv, tag(2), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &request_payload_recv; diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index fc2751af8e1..85fbe9de7bb 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -131,6 +131,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 33005db9e45..d99062c6082 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -131,6 +131,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index c3ee4a6a0ee..673c7051ad1 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -112,7 +112,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { char *details = NULL; size_t details_capacity = 0; - gpr_log(GPR_DEBUG, "test with %d ops", num_ops); + gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, @@ -122,6 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 589bc314f8e..ec5c012238e 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -38,13 +38,15 @@ #include #include +#include #include #include +#include #include #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/compress_filter.h" +#include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" @@ -102,12 +104,12 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void request_with_payload_template( +static void request_for_disabled_algorithm( grpc_end2end_test_config config, const char *test_name, uint32_t send_flags_bitmask, - grpc_compression_algorithm requested_compression_algorithm, - grpc_compression_algorithm expected_compression_algorithm, - grpc_metadata *client_metadata) { + grpc_compression_algorithm algorithm_to_disable, + grpc_compression_algorithm requested_client_compression_algorithm, + grpc_status_code expected_error, grpc_metadata *client_metadata) { grpc_call *c; grpc_call *s; gpr_slice request_payload_slice; @@ -137,9 +139,11 @@ static void request_with_payload_template( request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); client_args = grpc_channel_args_set_compression_algorithm( - NULL, requested_compression_algorithm); - server_args = grpc_channel_args_set_compression_algorithm( - NULL, requested_compression_algorithm); + NULL, requested_client_compression_algorithm); + server_args = + grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_NONE); + server_args = grpc_channel_args_compression_algorithm_set_state( + &server_args, algorithm_to_disable, false); f = begin_test(config, test_name, client_args, server_args); cqv = cq_verifier_create(f.cq); @@ -153,6 +157,7 @@ static void request_with_payload_template( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; if (client_metadata != NULL) { @@ -193,11 +198,174 @@ static void request_with_payload_template( grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion(cqv, tag(101), 1); + cq_expect_completion(cqv, tag(101), true); + cq_verify(cqv); + + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(102), false); + + op = ops; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(103), true); + cq_expect_completion(cqv, tag(1), true); cq_verify(cqv); - GPR_ASSERT( - GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer(s)) == 3); + /* call was cancelled (closed) ... */ + GPR_ASSERT(was_cancelled != 0); + /* with a certain error */ + GPR_ASSERT(status == expected_error); + + char *algo_name = NULL; + GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name)); + char *expected_details = NULL; + gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.", + algo_name); + /* and we expect a specific reason for it */ + GPR_ASSERT(0 == strcmp(details, expected_details)); + gpr_free(expected_details); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + grpc_call_destroy(c); + grpc_call_destroy(s); + + cq_verifier_destroy(cqv); + + gpr_slice_unref(request_payload_slice); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(request_payload_recv); + + grpc_channel_args_destroy(client_args); + grpc_channel_args_destroy(server_args); + + end_test(&f); + config.tear_down_data(&f); +} + +static void request_with_payload_template( + grpc_end2end_test_config config, const char *test_name, + uint32_t client_send_flags_bitmask, + grpc_compression_algorithm default_client_channel_compression_algorithm, + grpc_compression_algorithm default_server_channel_compression_algorithm, + grpc_compression_algorithm expected_algorithm_from_client, + grpc_compression_algorithm expected_algorithm_from_server, + grpc_metadata *client_init_metadata, bool set_server_level, + grpc_compression_level server_compression_level) { + grpc_call *c; + grpc_call *s; + gpr_slice request_payload_slice; + grpc_byte_buffer *request_payload; + gpr_timespec deadline = five_seconds_time(); + grpc_channel_args *client_args; + grpc_channel_args *server_args; + grpc_end2end_test_fixture f; + grpc_op ops[6]; + grpc_op *op; + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_metadata_array request_metadata_recv; + grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer *response_payload; + grpc_byte_buffer *response_payload_recv; + grpc_call_details call_details; + grpc_status_code status; + grpc_call_error error; + char *details = NULL; + size_t details_capacity = 0; + int was_cancelled = 2; + cq_verifier *cqv; + char request_str[1024]; + char response_str[1024]; + + memset(request_str, 'x', 1023); + request_str[1023] = '\0'; + + memset(response_str, 'y', 1023); + response_str[1023] = '\0'; + + request_payload_slice = gpr_slice_from_copied_string(request_str); + gpr_slice response_payload_slice = gpr_slice_from_copied_string(response_str); + + client_args = grpc_channel_args_set_compression_algorithm( + NULL, default_client_channel_compression_algorithm); + server_args = grpc_channel_args_set_compression_algorithm( + NULL, default_server_channel_compression_algorithm); + + f = begin_test(config, test_name, client_args, server_args); + cqv = cq_verifier_create(f.cq); + + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); + + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + if (client_init_metadata != NULL) { + op->data.send_initial_metadata.count = 1; + op->data.send_initial_metadata.metadata = client_init_metadata; + } else { + op->data.send_initial_metadata.count = 0; + } + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.status_details_capacity = &details_capacity; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(100)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(100), true); + cq_verify(cqv); + + GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer( + s)) == GRPC_COMPRESS_ALGORITHMS_COUNT); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_NONE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), @@ -205,29 +373,107 @@ static void request_with_payload_template( GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_GZIP) != 0); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; + if (set_server_level) { + op->data.send_initial_metadata.maybe_compression_level.is_set = true; + op->data.send_initial_metadata.maybe_compression_level.level = + server_compression_level; + } op->flags = 0; op->reserved = NULL; op++; - op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion(cqv, tag(102), 1); - cq_verify(cqv); + for (int i = 0; i < 2; i++) { + request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); + response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = request_payload; + op->flags = client_send_flags_bitmask; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &response_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); + + GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, request_str)); + GPR_ASSERT(request_payload_recv->data.raw.compression == + expected_algorithm_from_client); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = response_payload; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(2), 1); + cq_verify(cqv); + + GPR_ASSERT(response_payload_recv->type == GRPC_BB_RAW); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, response_str)); + if (server_compression_level > GRPC_COMPRESS_LEVEL_NONE) { + const grpc_compression_algorithm algo_for_server_level = + grpc_call_compression_for_level(s, server_compression_level); + GPR_ASSERT(response_payload_recv->data.raw.compression == + algo_for_server_level); + } else { + GPR_ASSERT(response_payload_recv->data.raw.compression == + expected_algorithm_from_server); + } + + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + } + + gpr_slice_unref(request_payload_slice); + gpr_slice_unref(response_payload_slice); + memset(ops, 0, sizeof(ops)); op = ops; - op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; - op->data.recv_close_on_server.cancelled = &was_cancelled; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; op->reserved = NULL; op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + memset(ops, 0, sizeof(ops)); + op = ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; op->data.send_status_from_server.status = GRPC_STATUS_OK; @@ -235,11 +481,13 @@ static void request_with_payload_template( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion(cqv, tag(103), 1); cq_expect_completion(cqv, tag(1), 1); + cq_expect_completion(cqv, tag(3), 1); + cq_expect_completion(cqv, tag(101), 1); + cq_expect_completion(cqv, tag(104), 1); cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); @@ -248,12 +496,6 @@ static void request_with_payload_template( GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); GPR_ASSERT(was_cancelled == 0); - GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW); - GPR_ASSERT(request_payload_recv->data.raw.compression == - expected_compression_algorithm); - - GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, str)); - gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); @@ -265,10 +507,6 @@ static void request_with_payload_template( cq_verifier_destroy(cqv); - gpr_slice_unref(request_payload_slice); - grpc_byte_buffer_destroy(request_payload); - grpc_byte_buffer_destroy(request_payload_recv); - grpc_channel_args_destroy(client_args); grpc_channel_args_destroy(server_args); @@ -280,61 +518,90 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_exceptionally_uncompressed_payload", - GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, NULL); + GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, NULL, false, + /* ignored */ GRPC_COMPRESS_LEVEL_NONE); } static void test_invoke_request_with_uncompressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_uncompressed_payload", 0, - GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, NULL); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE); } static void test_invoke_request_with_compressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, NULL); + GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE); +} + +static void test_invoke_request_with_server_level( + grpc_end2end_test_config config) { + request_with_payload_template( + config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */, + NULL, true, GRPC_COMPRESS_LEVEL_HIGH); } static void test_invoke_request_with_compressed_payload_md_override( grpc_end2end_test_config config) { grpc_metadata gzip_compression_override; - grpc_metadata none_compression_override; + grpc_metadata identity_compression_override; - gzip_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY; + gzip_compression_override.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; gzip_compression_override.value = "gzip"; - gzip_compression_override.value_length = 4; + gzip_compression_override.value_length = + strlen(gzip_compression_override.value); memset(&gzip_compression_override.internal_data, 0, sizeof(gzip_compression_override.internal_data)); - none_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY; - none_compression_override.value = "identity"; - none_compression_override.value_length = 4; - memset(&none_compression_override.internal_data, 0, - sizeof(none_compression_override.internal_data)); + identity_compression_override.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; + identity_compression_override.value = "identity"; + identity_compression_override.value_length = + strlen(identity_compression_override.value); + memset(&identity_compression_override.internal_data, 0, + sizeof(identity_compression_override.internal_data)); /* Channel default NONE (aka IDENTITY), call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_1", 0, - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, &gzip_compression_override); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_NONE, &gzip_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); /* Channel default DEFLATE, call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_2", 0, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP, &gzip_compression_override); + GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_NONE, &gzip_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); /* Channel default DEFLATE, call override to NONE (aka IDENTITY) */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_3", 0, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override); + GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, &identity_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); +} + +static void test_invoke_request_with_disabled_algorithm( + grpc_end2end_test_config config) { + request_for_disabled_algorithm( + config, "test_invoke_request_with_disabled_algorithm", 0, + GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_STATUS_UNIMPLEMENTED, NULL); } void compressed_payload(grpc_end2end_test_config config) { test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); + test_invoke_request_with_server_level(config); test_invoke_request_with_compressed_payload_md_override(config); + test_invoke_request_with_disabled_algorithm(config); } void compressed_payload_pre_init(void) {} diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 44384a783ec..728ee597b50 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -131,6 +131,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -173,6 +174,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { gpr_log(GPR_DEBUG, "client_peer=%s", peer); gpr_free(peer); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 03d1ded04cf..536fbd0d8a8 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -108,6 +108,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -145,6 +146,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, - and still complete the request */ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 29244d94287..e6edb213cc9 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -134,6 +134,7 @@ static void test_request(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 26198f3bdfc..f527b8617d9 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -122,6 +122,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -160,6 +161,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); cq_verify_empty(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 374606dcb73..50e3c9cb898 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -128,6 +128,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -161,6 +162,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 07d5d387b4c..ee889b77a1c 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -323,6 +323,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = GPR_ARRAY_SIZE(extra_metadata); @@ -357,6 +358,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index e53f3b2aaa8..dfedcfebee8 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -132,6 +132,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -174,6 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { gpr_log(GPR_DEBUG, "client_peer=%s", peer); gpr_free(peer); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 6410305451a..9c9ca951293 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -138,6 +138,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -181,6 +182,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -198,6 +200,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index ae1f68a2b45..1f278960196 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -142,6 +142,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); // Client: send request. op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -183,6 +184,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); // Server: send initial metadata and receive request. op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -201,6 +203,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); // Server: receive close and send status. This should trigger // completion of request on client. op = ops; diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 1bb53073cb0..41de74ff874 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -124,6 +124,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -157,6 +158,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -270,6 +272,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { f.server, &s1, &call_details, &request_metadata_recv, f.cq, f.cq, tag(101))); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -283,6 +286,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1; @@ -300,6 +304,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -313,6 +318,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2; @@ -354,6 +360,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { } GPR_ASSERT(live_call == 300 || live_call == 400); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -388,6 +395,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(201), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 4f572789d95..08d326ab4d6 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -143,6 +143,7 @@ static void test_max_message_length(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -181,6 +182,7 @@ static void test_max_message_length(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 03e57a90f6f..dff7992f63b 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -112,7 +112,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { char *details = NULL; size_t details_capacity = 0; - gpr_log(GPR_DEBUG, "test with %d ops", num_ops); + gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, @@ -122,6 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index bdfb1354068..443d85eecc4 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -131,6 +131,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -174,6 +175,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -191,6 +193,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 15e1c6e338a..1d2f7943c1d 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -135,6 +135,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -164,6 +165,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(100), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -182,6 +184,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = request_payload; @@ -196,6 +199,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &request_payload_recv; @@ -207,6 +211,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = response_payload; @@ -228,6 +233,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, gpr_slice_unref(request_payload_slice); gpr_slice_unref(response_payload_slice); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; @@ -236,6 +242,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 3c4edbae7dc..ece6250ea13 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -125,6 +125,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -158,6 +159,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index f5a8d4d60cf..b5d398bba9f 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -131,6 +131,7 @@ static void test_invoke_request_with_flags( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 77064040909..d94267e09cf 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -130,6 +130,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -167,6 +168,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -184,6 +186,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index a4f5319e5b4..a723c6fd2ca 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -126,6 +126,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -155,6 +156,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 80287cd507a..abb6b26a875 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -115,6 +115,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -149,6 +150,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 400b3a00274..e1fcc035bbd 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -117,6 +117,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -152,6 +153,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 707b3c9512c..c9b1a03da52 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -141,6 +141,7 @@ static void test_request_response_with_metadata_and_payload( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -185,6 +186,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -203,6 +205,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 42108425e6f..a8014e6894c 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -132,6 +132,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -174,6 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { gpr_log(GPR_DEBUG, "client_peer=%s", peer); gpr_free(peer); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 4dd8c12cba9..41e0f009113 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -144,6 +144,7 @@ static void test_request_response_with_metadata_and_payload( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -188,6 +189,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -206,6 +208,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 81562277ec0..123f2b5bbed 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -65,6 +65,7 @@ static void init_ping_pong_request(void) { grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; diff --git a/test/core/http/fuzzer.c b/test/core/http/fuzzer.c index 7e4f4eb993d..c3c634f2813 100644 --- a/test/core/http/fuzzer.c +++ b/test/core/http/fuzzer.c @@ -31,6 +31,7 @@ * */ +#include #include #include @@ -38,6 +39,9 @@ #include "src/core/lib/http/parser.h" +bool squelch = true; +bool leak_check = true; + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_http_parser parser; grpc_http_parser_init(&parser); diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index 52082c3c6b7..6d15ecf141d 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -188,13 +188,15 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_endpoint_test_fixture f = begin_test(config, "read_and_write_test", slice_size); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_DEBUG, "num_bytes=%d write_size=%d slice_size=%d shutdown=%d", + gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR + " slice_size=%" PRIuPTR " shutdown=%d", num_bytes, write_size, slice_size, shutdown); if (shutdown) { gpr_log(GPR_INFO, "Start read and write shutdown test"); } else { - gpr_log(GPR_INFO, "Start read and write test with %d bytes, slice size %d", + gpr_log(GPR_INFO, "Start read and write test with %" PRIuPTR + " bytes, slice size %" PRIuPTR, num_bytes, slice_size); } diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c index f97f33712eb..24ba474680f 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -52,6 +52,7 @@ #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/iomgr/socket_utils_posix.h" #include "test/core/util/test_config.h" static gpr_mu *g_mu; @@ -68,17 +69,15 @@ static void create_test_socket(int port, int *socket_fd, struct sockaddr_in *sin) { int fd; int one = 1; - int buf_size = BUF_SIZE; + int buffer_size_bytes = BUF_SIZE; int flags; fd = socket(AF_INET, SOCK_STREAM, 0); setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); /* Reset the size of socket send buffer to the minimal value to facilitate buffer filling up and triggering notify_on_write */ - GPR_ASSERT( - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size)) != -1); - GPR_ASSERT( - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size)) != -1); + GPR_ASSERT(grpc_set_socket_sndbuf(fd, buffer_size_bytes)); + GPR_ASSERT(grpc_set_socket_rcvbuf(fd, buffer_size_bytes)); /* Make fd non-blocking */ flags = fcntl(fd, F_GETFL, 0); GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); @@ -399,7 +398,7 @@ static void test_grpc_fd(void) { client_wait_and_shutdown(&cl); server_wait_and_shutdown(&sv); GPR_ASSERT(sv.read_bytes_total == cl.write_bytes_total); - gpr_log(GPR_INFO, "Total read bytes %d", sv.read_bytes_total); + gpr_log(GPR_INFO, "Total read bytes %" PRIdPTR, sv.read_bytes_total); } typedef struct fd_change_data { diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 7a98fa0e506..19ba258303e 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -151,7 +151,7 @@ static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data, bool success) { read_bytes = count_slices(state->incoming.slices, state->incoming.count, ¤t_data); state->read_bytes += read_bytes; - gpr_log(GPR_INFO, "Read %d bytes of %d", read_bytes, + gpr_log(GPR_INFO, "Read %" PRIuPTR " bytes of %" PRIuPTR, read_bytes, state->target_read_bytes); if (state->read_bytes >= state->target_read_bytes) { gpr_mu_unlock(g_mu); @@ -170,8 +170,8 @@ static void read_test(size_t num_bytes, size_t slice_size) { gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_INFO, "Read test of size %d, slice size %d", num_bytes, - slice_size); + gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR, + num_bytes, slice_size); create_sockets(sv); @@ -179,7 +179,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset); written_bytes = fill_socket_partial(sv[0], num_bytes); - gpr_log(GPR_INFO, "Wrote %d bytes", written_bytes); + gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes); state.ep = ep; state.read_bytes = 0; @@ -216,7 +216,7 @@ static void large_read_test(size_t slice_size) { gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_INFO, "Start large read test, slice size %d", slice_size); + gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size); create_sockets(sv); @@ -225,7 +225,7 @@ static void large_read_test(size_t slice_size) { grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset); written_bytes = fill_socket(sv[0]); - gpr_log(GPR_INFO, "Wrote %d bytes", written_bytes); + gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes); state.ep = ep; state.read_bytes = 0; @@ -344,8 +344,9 @@ static void write_test(size_t num_bytes, size_t slice_size) { gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_INFO, "Start write test with %d bytes, slice size %d", num_bytes, - slice_size); + gpr_log(GPR_INFO, + "Start write test with %" PRIuPTR " bytes, slice size %" PRIuPTR, + num_bytes, slice_size); create_sockets(sv); @@ -404,8 +405,9 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { int fd_released_done = 0; grpc_closure_init(&fd_released_cb, &on_fd_released, &fd_released_done); - gpr_log(GPR_INFO, "Release fd read_test of size %d, slice size %d", num_bytes, - slice_size); + gpr_log(GPR_INFO, + "Release fd read_test of size %" PRIuPTR ", slice size %" PRIuPTR, + num_bytes, slice_size); create_sockets(sv); @@ -414,7 +416,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset); written_bytes = fill_socket_partial(sv[0], num_bytes); - gpr_log(GPR_INFO, "Wrote %d bytes", written_bytes); + gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes); state.ep = ep; state.read_bytes = 0; diff --git a/test/core/json/fuzzer.c b/test/core/json/fuzzer.c index e94b41ca999..26c5c25caf1 100644 --- a/test/core/json/fuzzer.c +++ b/test/core/json/fuzzer.c @@ -31,6 +31,7 @@ * */ +#include #include #include @@ -40,6 +41,9 @@ #include "src/core/lib/json/json.h" #include "test/core/util/memory_counters.h" +bool squelch = true; +bool leak_check = true; + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char *s; struct grpc_memory_counters counters; diff --git a/test/core/nanopb/fuzzer_response.c b/test/core/nanopb/fuzzer_response.c index b4e386020a7..21a5d7b9685 100644 --- a/test/core/nanopb/fuzzer_response.c +++ b/test/core/nanopb/fuzzer_response.c @@ -38,6 +38,9 @@ #include "src/core/ext/lb_policy/grpclb/load_balancer_api.h" +bool squelch = true; +bool leak_check = true; + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); grpc_grpclb_response *response; diff --git a/test/core/nanopb/fuzzer_serverlist.c b/test/core/nanopb/fuzzer_serverlist.c index d4ec74f0e79..df2044d9077 100644 --- a/test/core/nanopb/fuzzer_serverlist.c +++ b/test/core/nanopb/fuzzer_serverlist.c @@ -38,6 +38,9 @@ #include "src/core/ext/lb_policy/grpclb/load_balancer_api.h" +bool squelch = true; +bool leak_check = true; + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); grpc_grpclb_serverlist *serverlist; diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c index 2df38376a9f..0da483a3216 100644 --- a/test/core/support/slice_test.c +++ b/test/core/support/slice_test.c @@ -164,7 +164,7 @@ static void test_slice_split_head_works(size_t length) { size_t i; LOG_TEST_NAME("test_slice_split_head_works"); - gpr_log(GPR_INFO, "length=%d", length); + gpr_log(GPR_INFO, "length=%" PRIuPTR, length); /* Create a slice in which each byte is equal to the distance from it to the beginning of the slice. */ @@ -192,7 +192,7 @@ static void test_slice_split_tail_works(size_t length) { size_t i; LOG_TEST_NAME("test_slice_split_tail_works"); - gpr_log(GPR_INFO, "length=%d", length); + gpr_log(GPR_INFO, "length=%" PRIuPTR, length); /* Create a slice in which each byte is equal to the distance from it to the beginning of the slice. */ diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index d5f8107f211..553a824b3fa 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -156,7 +156,7 @@ static void test_asprintf(void) { LOG_TEST_NAME("test_asprintf"); /* Print an empty string. */ - GPR_ASSERT(gpr_asprintf(&buf, "") == 0); + GPR_ASSERT(gpr_asprintf(&buf, "%s", "") == 0); GPR_ASSERT(buf[0] == '\0'); gpr_free(buf); @@ -334,6 +334,38 @@ static void test_int64toa() { GPR_ASSERT(0 == strcmp("-9223372036854775808", buf)); } +static void test_leftpad() { + char *padded; + + padded = gpr_leftpad("foo", ' ', 5); + GPR_ASSERT(0 == strcmp(" foo", padded)); + gpr_free(padded); + + padded = gpr_leftpad("foo", ' ', 4); + GPR_ASSERT(0 == strcmp(" foo", padded)); + gpr_free(padded); + + padded = gpr_leftpad("foo", ' ', 3); + GPR_ASSERT(0 == strcmp("foo", padded)); + gpr_free(padded); + + padded = gpr_leftpad("foo", ' ', 2); + GPR_ASSERT(0 == strcmp("foo", padded)); + gpr_free(padded); + + padded = gpr_leftpad("foo", ' ', 1); + GPR_ASSERT(0 == strcmp("foo", padded)); + gpr_free(padded); + + padded = gpr_leftpad("foo", ' ', 0); + GPR_ASSERT(0 == strcmp("foo", padded)); + gpr_free(padded); + + padded = gpr_leftpad("foo", '0', 5); + GPR_ASSERT(0 == strcmp("00foo", padded)); + gpr_free(padded); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); @@ -346,5 +378,6 @@ int main(int argc, char **argv) { test_strsplit(); test_ltoa(); test_int64toa(); + test_leftpad(); return 0; } diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 49a1fc441f0..2fcd7f5a938 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -348,8 +348,8 @@ static void test_threading(size_t producers, size_t consumers) { size_t total_consumed = 0; static int optid = 101; - gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading", - producers, consumers); + gpr_log(GPR_INFO, "%s: %" PRIuPTR " producers, %" PRIuPTR " consumers", + "test_threading", producers, consumers); /* start all threads: they will wait for phase1 */ for (i = 0; i < producers + consumers; i++) { diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 3286db5b1b8..edd50568d6c 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -115,6 +115,7 @@ int main(int argc, char **argv) { GPR_ASSERT(call); cqv = cq_verifier_create(cq); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -133,6 +134,7 @@ int main(int argc, char **argv) { cq_expect_completion(cqv, tag(1), 0); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/transport/chttp2/bin_decoder_test.c b/test/core/transport/chttp2/bin_decoder_test.c new file mode 100644 index 00000000000..c4e6cd332f0 --- /dev/null +++ b/test/core/transport/chttp2/bin_decoder_test.c @@ -0,0 +1,144 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/ext/transport/chttp2/transport/bin_decoder.h" + +#include + +#include +#include +#include "src/core/ext/transport/chttp2/transport/bin_encoder.h" +#include "src/core/lib/support/string.h" + +static int all_ok = 1; + +static void expect_slice_eq(gpr_slice expected, gpr_slice slice, char *debug, + int line) { + if (0 != gpr_slice_cmp(slice, expected)) { + char *hs = gpr_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *he = gpr_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, + he); + gpr_free(hs); + gpr_free(he); + all_ok = 0; + } + gpr_slice_unref(expected); + gpr_slice_unref(slice); +} + +static gpr_slice base64_encode(const char *s) { + gpr_slice ss = gpr_slice_from_copied_string(s); + gpr_slice out = grpc_chttp2_base64_encode(ss); + gpr_slice_unref(ss); + return out; +} + +static gpr_slice base64_decode(const char *s) { + gpr_slice ss = gpr_slice_from_copied_string(s); + gpr_slice out = grpc_chttp2_base64_decode(ss); + gpr_slice_unref(ss); + return out; +} + +static gpr_slice base64_decode_with_length(const char *s, + size_t output_length) { + gpr_slice ss = gpr_slice_from_copied_string(s); + gpr_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length); + gpr_slice_unref(ss); + return out; +} + +#define EXPECT_SLICE_EQ(expected, slice) \ + expect_slice_eq( \ + gpr_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \ + #slice, __LINE__); + +#define ENCODE_AND_DECODE(s) \ + EXPECT_SLICE_EQ( \ + s, grpc_chttp2_base64_decode_with_length(base64_encode(s), strlen(s))); + +int main(int argc, char **argv) { + /* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which + takes encoded base64 strings without pad chars, but output length is + required. */ + /* Base64 test vectors from RFC 4648 */ + ENCODE_AND_DECODE(""); + ENCODE_AND_DECODE("f"); + ENCODE_AND_DECODE("foo"); + ENCODE_AND_DECODE("fo"); + ENCODE_AND_DECODE("foob"); + ENCODE_AND_DECODE("fooba"); + ENCODE_AND_DECODE("foobar"); + + ENCODE_AND_DECODE("\xc0\xc1\xc2\xc3\xc4\xc5"); + + /* Base64 test vectors from RFC 4648, with pad chars */ + /* BASE64("") = "" */ + EXPECT_SLICE_EQ("", base64_decode("")); + /* BASE64("f") = "Zg==" */ + EXPECT_SLICE_EQ("f", base64_decode("Zg==")); + /* BASE64("fo") = "Zm8=" */ + EXPECT_SLICE_EQ("fo", base64_decode("Zm8=")); + /* BASE64("foo") = "Zm9v" */ + EXPECT_SLICE_EQ("foo", base64_decode("Zm9v")); + /* BASE64("foob") = "Zm9vYg==" */ + EXPECT_SLICE_EQ("foob", base64_decode("Zm9vYg==")); + /* BASE64("fooba") = "Zm9vYmE=" */ + EXPECT_SLICE_EQ("fooba", base64_decode("Zm9vYmE=")); + /* BASE64("foobar") = "Zm9vYmFy" */ + EXPECT_SLICE_EQ("foobar", base64_decode("Zm9vYmFy")); + + EXPECT_SLICE_EQ("\xc0\xc1\xc2\xc3\xc4\xc5", base64_decode("wMHCw8TF")); + + // Test illegal input length in grpc_chttp2_base64_decode + EXPECT_SLICE_EQ("", base64_decode("a")); + EXPECT_SLICE_EQ("", base64_decode("ab")); + EXPECT_SLICE_EQ("", base64_decode("abc")); + + // Test illegal charactors in grpc_chttp2_base64_decode + EXPECT_SLICE_EQ("", base64_decode("Zm:v")); + EXPECT_SLICE_EQ("", base64_decode("Zm=v")); + + // Test output_length longer than max possible output length in + // grpc_chttp2_base64_decode_with_length + EXPECT_SLICE_EQ("", base64_decode_with_length("Zg", 2)); + EXPECT_SLICE_EQ("", base64_decode_with_length("Zm8", 3)); + EXPECT_SLICE_EQ("", base64_decode_with_length("Zm9v", 4)); + + // Test illegal charactors in grpc_chttp2_base64_decode_with_length + EXPECT_SLICE_EQ("", base64_decode_with_length("Zm:v", 3)); + EXPECT_SLICE_EQ("", base64_decode_with_length("Zm=v", 3)); + + return all_ok ? 0 : 1; +} diff --git a/test/core/transport/chttp2/bin_encoder_test.c b/test/core/transport/chttp2/bin_encoder_test.c index 095861e9741..08d10735a5a 100644 --- a/test/core/transport/chttp2/bin_encoder_test.c +++ b/test/core/transport/chttp2/bin_encoder_test.c @@ -88,7 +88,8 @@ static void expect_combined_equiv(const char *s, size_t len, int line) { char *t = gpr_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *e = gpr_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *g = gpr_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_ERROR, "FAILED:%d:\ntest: %s\ngot: %s\nwant: %s", t, g, e); + gpr_log(GPR_ERROR, "FAILED:%d:\ntest: %s\ngot: %s\nwant: %s", line, t, g, + e); gpr_free(t); gpr_free(e); gpr_free(g); diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c b/test/core/transport/chttp2/hpack_parser_fuzzer_test.c index e41eda8653e..1e3d2d39d88 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.c @@ -40,12 +40,15 @@ #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +bool squelch = true; +bool leak_check = true; + static void onhdr(void *ud, grpc_mdelem *md) { GRPC_MDELEM_UNREF(md); } static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_test_only_set_metadata_hash_seed(0); - gpr_set_log_function(dont_log); + if (squelch) gpr_set_log_function(dont_log); grpc_init(); grpc_chttp2_hpack_parser parser; grpc_chttp2_hpack_parser_init(&parser); diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index a4e9694a93e..007892930cf 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -166,7 +166,7 @@ static void test_things_stick_around(void) { grpc_init(); for (i = 0; i < nstrs; i++) { - gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%dx", i); + gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x", i); strs[i] = grpc_mdstr_from_string(buffer); shuf[i] = i; gpr_free(buffer); @@ -188,7 +188,8 @@ static void test_things_stick_around(void) { for (i = 0; i < nstrs; i++) { GRPC_MDSTR_UNREF(strs[shuf[i]]); for (j = i + 1; j < nstrs; j++) { - gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%dx", shuf[j]); + gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x", + shuf[j]); test = grpc_mdstr_from_string(buffer); GPR_ASSERT(test == strs[shuf[j]]); GRPC_MDSTR_UNREF(test); diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.c index 41f9558211a..be32a8a2cf4 100644 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -31,13 +31,20 @@ * */ +#include + #include #include "src/core/lib/support/load_file.h" extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +extern bool squelch; +extern bool leak_check; + int main(int argc, char **argv) { int ok = 0; + squelch = false; + leak_check = false; gpr_slice buffer = gpr_load_file(argv[1], 0, &ok); GPR_ASSERT(ok); LLVMFuzzerTestOneInput(GPR_SLICE_START_PTR(buffer), GPR_SLICE_LENGTH(buffer)); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index b8398015006..8229bda6bf2 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -229,9 +229,10 @@ class TestScenario { credentials_type(creds_type), message_content(content) {} void Log() const { - gpr_log(GPR_INFO, - "Scenario: disable_blocking %d, credentials %s, message size %d", - disable_blocking, credentials_type.c_str(), message_content.size()); + gpr_log( + GPR_INFO, + "Scenario: disable_blocking %d, credentials %s, message size %" PRIuPTR, + disable_blocking, credentials_type.c_str(), message_content.size()); } bool disable_blocking; const grpc::string credentials_type; diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index f52aa52f39f..e3667cf26bd 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1014,6 +1014,16 @@ TEST_P(ProxyEnd2endTest, SimpleRpc) { SendRpc(stub_.get(), 1, false); } +TEST_P(ProxyEnd2endTest, SimpleRpcWithEmptyMessages) { + ResetStub(); + EchoRequest request; + EchoResponse response; + + ClientContext context; + Status s = stub_->Echo(&context, request, &response); + EXPECT_TRUE(s.ok()); +} + TEST_P(ProxyEnd2endTest, MultipleRpcs) { ResetStub(); std::vector threads; diff --git a/test/cpp/end2end/proto_server_reflection_test.cc b/test/cpp/end2end/proto_server_reflection_test.cc new file mode 100644 index 00000000000..f8fc39b5535 --- /dev/null +++ b/test/cpp/end2end/proto_server_reflection_test.cc @@ -0,0 +1,166 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/end2end/test_service_impl.h" +#include "test/cpp/util/proto_reflection_descriptor_database.h" + +namespace grpc { +namespace testing { + +class ProtoServerReflectionTest : public ::testing::Test { + public: + ProtoServerReflectionTest() {} + + void SetUp() GRPC_OVERRIDE { + port_ = grpc_pick_unused_port_or_die(); + ref_desc_pool_ = google::protobuf::DescriptorPool::generated_pool(); + + ServerBuilder builder; + grpc::string server_address = "localhost:" + to_string(port_); + builder.AddListeningPort(server_address, InsecureServerCredentials()); + server_ = builder.BuildAndStart(); + } + + void ResetStub() { + string target = "dns:localhost:" + to_string(port_); + std::shared_ptr channel = + CreateChannel(target, InsecureChannelCredentials()); + stub_ = grpc::testing::EchoTestService::NewStub(channel); + desc_db_.reset(new ProtoReflectionDescriptorDatabase(channel)); + desc_pool_.reset(new google::protobuf::DescriptorPool(desc_db_.get())); + } + + string to_string(const int number) { + std::stringstream strs; + strs << number; + return strs.str(); + } + + void CompareService(const grpc::string& service) { + const google::protobuf::ServiceDescriptor* service_desc = + desc_pool_->FindServiceByName(service); + const google::protobuf::ServiceDescriptor* ref_service_desc = + ref_desc_pool_->FindServiceByName(service); + EXPECT_TRUE(service_desc != nullptr); + EXPECT_TRUE(ref_service_desc != nullptr); + EXPECT_EQ(service_desc->DebugString(), ref_service_desc->DebugString()); + + const google::protobuf::FileDescriptor* file_desc = service_desc->file(); + if (known_files_.find(file_desc->package() + "/" + file_desc->name()) != + known_files_.end()) { + EXPECT_EQ(file_desc->DebugString(), + ref_service_desc->file()->DebugString()); + known_files_.insert(file_desc->package() + "/" + file_desc->name()); + } + + for (int i = 0; i < service_desc->method_count(); ++i) { + CompareMethod(service_desc->method(i)->full_name()); + } + } + + void CompareMethod(const grpc::string& method) { + const google::protobuf::MethodDescriptor* method_desc = + desc_pool_->FindMethodByName(method); + const google::protobuf::MethodDescriptor* ref_method_desc = + ref_desc_pool_->FindMethodByName(method); + EXPECT_TRUE(method_desc != nullptr); + EXPECT_TRUE(ref_method_desc != nullptr); + EXPECT_EQ(method_desc->DebugString(), ref_method_desc->DebugString()); + + CompareType(method_desc->input_type()->full_name()); + CompareType(method_desc->output_type()->full_name()); + } + + void CompareType(const grpc::string& type) { + if (known_types_.find(type) != known_types_.end()) { + return; + } + + const google::protobuf::Descriptor* desc = + desc_pool_->FindMessageTypeByName(type); + const google::protobuf::Descriptor* ref_desc = + ref_desc_pool_->FindMessageTypeByName(type); + EXPECT_TRUE(desc != nullptr); + EXPECT_TRUE(ref_desc != nullptr); + EXPECT_EQ(desc->DebugString(), ref_desc->DebugString()); + } + + protected: + std::unique_ptr server_; + std::unique_ptr stub_; + std::unique_ptr desc_db_; + std::unique_ptr desc_pool_; + std::unordered_set known_files_; + std::unordered_set known_types_; + const google::protobuf::DescriptorPool* ref_desc_pool_; + int port_; + reflection::ProtoServerReflectionPlugin plugin_; +}; + +TEST_F(ProtoServerReflectionTest, CheckResponseWithLocalDescriptorPool) { + ResetStub(); + + std::vector services; + desc_db_->GetServices(&services); + // The service list has at least one service (reflection servcie). + EXPECT_TRUE(services.size() > 0); + + for (auto it = services.begin(); it != services.end(); ++it) { + CompareService(*it); + } +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index 12853a1b985..fdc500e5352 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -101,7 +101,7 @@ class ZookeeperTest : public ::testing::Test { zookeeper_address_ = addr_str; gpr_free(addr); } - gpr_log(GPR_DEBUG, zookeeper_address_.c_str()); + gpr_log(GPR_DEBUG, "%s", zookeeper_address_.c_str()); // Connects to zookeeper server zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 509e8b97aba..b19d4e4a410 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -332,7 +332,7 @@ bool InteropClient::DoClientCompressedUnary() { if (s.error_code() != grpc::StatusCode::INVALID_ARGUMENT) { // The server isn't able to evaluate incoming compression, making the rest // of this test moot. - gpr_log(GPR_DEBUG, "Compressed unary request probe failed %s"); + gpr_log(GPR_DEBUG, "Compressed unary request probe failed"); return false; } gpr_log(GPR_DEBUG, "Compressed unary request probe succeeded. Proceeding."); @@ -452,7 +452,7 @@ bool InteropClient::DoResponseStreaming() { // most likely due to connection failure. gpr_log(GPR_ERROR, "DoResponseStreaming(): Read fewer streams (%d) than " - "response_stream_sizes.size() (%d)", + "response_stream_sizes.size() (%" PRIuPTR ")", i, response_stream_sizes.size()); return TransientFailureOrAbort(); } @@ -489,7 +489,7 @@ bool InteropClient::DoClientCompressedStreaming() { if (s.error_code() != grpc::StatusCode::INVALID_ARGUMENT) { // The server isn't able to evaluate incoming compression, making the rest // of this test moot. - gpr_log(GPR_DEBUG, "Compressed streaming request probe failed %s"); + gpr_log(GPR_DEBUG, "Compressed streaming request probe failed"); return false; } gpr_log(GPR_DEBUG, @@ -579,8 +579,10 @@ bool InteropClient::DoServerCompressedStreaming() { // stream->Read() failed before reading all the expected messages. This // is most likely due to a connection failure. gpr_log(GPR_ERROR, - "%s(): Responses read (k=%d) is " - "less than the expected number of messages (%d)).", + "%s(): Responses read (k=%" PRIuPTR + ") is " + "less than the expected messages (i.e " + "response_stream_sizes.size() (%" PRIuPTR ")).", __func__, k, response_stream_sizes.size()); return TransientFailureOrAbort(); } @@ -666,7 +668,7 @@ bool InteropClient::DoHalfDuplex() { // most likely due to a connection failure gpr_log(GPR_ERROR, "DoHalfDuplex(): Responses read (i=%d) are less than the expected " - "number of messages response_stream_sizes.size() (%d)", + "number of messages response_stream_sizes.size() (%" PRIuPTR ")", i, response_stream_sizes.size()); return TransientFailureOrAbort(); } diff --git a/test/cpp/interop/metrics_client.cc b/test/cpp/interop/metrics_client.cc index c8c2215fab1..7a0cb994df5 100644 --- a/test/cpp/interop/metrics_client.cc +++ b/test/cpp/interop/metrics_client.cc @@ -76,7 +76,7 @@ bool PrintMetrics(std::unique_ptr stub, bool total_only, while (reader->Read(&gauge_response)) { if (gauge_response.value_case() == GaugeResponse::kLongValue) { if (!total_only) { - gpr_log(GPR_INFO, "%s: %ld", gauge_response.name().c_str(), + gpr_log(GPR_INFO, "%s: %lld", gauge_response.name().c_str(), gauge_response.long_value()); } overall_qps += gauge_response.long_value(); diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 57d8c22a954..83dbdc3e59e 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -244,8 +244,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { - gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", workers[i].c_str(), - i); + gpr_log(GPR_INFO, "Starting server on %s (worker #%" PRIuPTR ")", + workers[i].c_str(), i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); @@ -307,8 +307,8 @@ std::unique_ptr RunScenario( auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { const auto& worker = workers[i + num_servers]; - gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", worker.c_str(), - i + num_servers); + gpr_log(GPR_INFO, "Starting client on %s (worker #%" PRIuPTR ")", + worker.c_str(), i + num_servers); clients[i].stub = WorkerService::NewStub( CreateChannel(worker, InsecureChannelCredentials())); ClientConfig per_client_config = client_config; diff --git a/test/cpp/qps/parse_json.cc b/test/cpp/qps/parse_json.cc index a90bf6153c6..e4fc35fa414 100644 --- a/test/cpp/qps/parse_json.cc +++ b/test/cpp/qps/parse_json.cc @@ -55,11 +55,26 @@ void ParseJson(const grpc::string& json, const grpc::string& type, grpc::string errmsg(status.error_message()); gpr_log(GPR_ERROR, "Failed to convert json to binary: errcode=%d msg=%s", status.error_code(), errmsg.c_str()); - gpr_log(GPR_ERROR, "JSON: ", json.c_str()); + gpr_log(GPR_ERROR, "JSON: %s", json.c_str()); abort(); } GPR_ASSERT(msg->ParseFromString(binary)); } +grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg, + const grpc::string& type) { + std::unique_ptr type_resolver( + google::protobuf::util::NewTypeResolverForDescriptorPool( + "type.googleapis.com", + google::protobuf::DescriptorPool::generated_pool())); + grpc::string binary; + grpc::string json_string; + msg.SerializeToString(&binary); + auto status = + BinaryToJsonString(type_resolver.get(), type, binary, &json_string); + GPR_ASSERT(status.ok()); + return json_string; +} + } // testing } // grpc diff --git a/test/cpp/qps/parse_json.h b/test/cpp/qps/parse_json.h index 42d7d22c53c..ce1821f961d 100644 --- a/test/cpp/qps/parse_json.h +++ b/test/cpp/qps/parse_json.h @@ -43,6 +43,9 @@ namespace testing { void ParseJson(const grpc::string& json, const grpc::string& type, GRPC_CUSTOM_MESSAGE* msg); +grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg, + const grpc::string& type); + } // testing } // grpc diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 3ae41399cfc..2ec7d8676c2 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -35,11 +35,9 @@ #include -#include -#include - #include #include "test/cpp/qps/driver.h" +#include "test/cpp/qps/parse_json.h" #include "test/cpp/qps/stats.h" namespace grpc { @@ -104,18 +102,8 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) { } void JsonReporter::ReportQPS(const ScenarioResult& result) { - std::unique_ptr type_resolver( - google::protobuf::util::NewTypeResolverForDescriptorPool( - "type.googleapis.com", - google::protobuf::DescriptorPool::generated_pool())); - grpc::string binary; - grpc::string json_string; - result.SerializeToString(&binary); - auto status = BinaryToJsonString( - type_resolver.get(), "type.googleapis.com/grpc.testing.ScenarioResult", - binary, &json_string); - GPR_ASSERT(status.ok()); - + grpc::string json_string = + SerializeJson(result, "type.googleapis.com/grpc.testing.ScenarioResult"); std::ofstream output_file(report_file_); output_file << json_string; output_file.close(); diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc new file mode 100644 index 00000000000..6907d97bd5e --- /dev/null +++ b/test/cpp/util/proto_reflection_descriptor_database.cc @@ -0,0 +1,316 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/cpp/util/proto_reflection_descriptor_database.h" + +#include + +#include + +using grpc::reflection::v1alpha::ServerReflection; +using grpc::reflection::v1alpha::ServerReflectionRequest; +using grpc::reflection::v1alpha::ServerReflectionResponse; +using grpc::reflection::v1alpha::ListServiceResponse; +using grpc::reflection::v1alpha::ErrorResponse; + +namespace grpc { + +ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase( + std::unique_ptr stub) + : stub_(std::move(stub)) {} + +ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase( + std::shared_ptr channel) + : stub_(ServerReflection::NewStub(channel)) {} + +ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {} + +bool ProtoReflectionDescriptorDatabase::FindFileByName( + const string& filename, google::protobuf::FileDescriptorProto* output) { + if (cached_db_.FindFileByName(filename, output)) { + return true; + } + + if (known_files_.find(filename) != known_files_.end()) { + return false; + } + + ServerReflectionRequest request; + request.set_file_by_filename(filename); + ServerReflectionResponse response; + + DoOneRequest(request, response); + + if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { + AddFileFromResponse(response.file_descriptor_response()); + } else if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kErrorResponse) { + const ErrorResponse error = response.error_response(); + if (error.error_code() == StatusCode::NOT_FOUND) { + gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)", + filename.c_str()); + } else { + gpr_log(GPR_INFO, + "Error on FindFileByName(%s)\n\tError code: %d\n" + "\tError Message: %s", + filename.c_str(), error.error_code(), + error.error_message().c_str()); + } + } else { + gpr_log( + GPR_INFO, + "Error on FindFileByName(%s) response type\n" + "\tExpecting: %d\n\tReceived: %d", + filename.c_str(), + ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse, + response.message_response_case()); + } + + return cached_db_.FindFileByName(filename, output); +} + +bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol( + const string& symbol_name, google::protobuf::FileDescriptorProto* output) { + if (cached_db_.FindFileContainingSymbol(symbol_name, output)) { + return true; + } + + if (missing_symbols_.find(symbol_name) != missing_symbols_.end()) { + return false; + } + + ServerReflectionRequest request; + request.set_file_containing_symbol(symbol_name); + ServerReflectionResponse response; + + DoOneRequest(request, response); + + if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { + AddFileFromResponse(response.file_descriptor_response()); + } else if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kErrorResponse) { + const ErrorResponse error = response.error_response(); + if (error.error_code() == StatusCode::NOT_FOUND) { + missing_symbols_.insert(symbol_name); + gpr_log(GPR_INFO, + "NOT_FOUND from server for FindFileContainingSymbol(%s)", + symbol_name.c_str()); + } else { + gpr_log(GPR_INFO, + "Error on FindFileContainingSymbol(%s)\n" + "\tError code: %d\n\tError Message: %s", + symbol_name.c_str(), error.error_code(), + error.error_message().c_str()); + } + } else { + gpr_log( + GPR_INFO, + "Error on FindFileContainingSymbol(%s) response type\n" + "\tExpecting: %d\n\tReceived: %d", + symbol_name.c_str(), + ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse, + response.message_response_case()); + } + return cached_db_.FindFileContainingSymbol(symbol_name, output); +} + +bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension( + const string& containing_type, int field_number, + google::protobuf::FileDescriptorProto* output) { + if (cached_db_.FindFileContainingExtension(containing_type, field_number, + output)) { + return true; + } + + if (missing_extensions_.find(containing_type) != missing_extensions_.end() && + missing_extensions_[containing_type].find(field_number) != + missing_extensions_[containing_type].end()) { + gpr_log(GPR_INFO, "nested map."); + return false; + } + + ServerReflectionRequest request; + request.mutable_file_containing_extension()->set_containing_type( + containing_type); + request.mutable_file_containing_extension()->set_extension_number( + field_number); + ServerReflectionResponse response; + + DoOneRequest(request, response); + + if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { + AddFileFromResponse(response.file_descriptor_response()); + } else if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kErrorResponse) { + const ErrorResponse error = response.error_response(); + if (error.error_code() == StatusCode::NOT_FOUND) { + if (missing_extensions_.find(containing_type) == + missing_extensions_.end()) { + missing_extensions_[containing_type] = {}; + } + missing_extensions_[containing_type].insert(field_number); + gpr_log(GPR_INFO, + "NOT_FOUND from server for FindFileContainingExtension(%s, %d)", + containing_type.c_str(), field_number); + } else { + gpr_log(GPR_INFO, + "Error on FindFileContainingExtension(%s, %d)\n" + "\tError code: %d\n\tError Message: %s", + containing_type.c_str(), field_number, error.error_code(), + error.error_message().c_str()); + } + } else { + gpr_log( + GPR_INFO, + "Error on FindFileContainingExtension(%s, %d) response type\n" + "\tExpecting: %d\n\tReceived: %d", + containing_type.c_str(), field_number, + ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse, + response.message_response_case()); + } + + return cached_db_.FindFileContainingExtension(containing_type, field_number, + output); +} + +bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers( + const string& extendee_type, std::vector* output) { + if (cached_extension_numbers_.find(extendee_type) != + cached_extension_numbers_.end()) { + *output = cached_extension_numbers_[extendee_type]; + return true; + } + + ServerReflectionRequest request; + request.set_all_extension_numbers_of_type(extendee_type); + ServerReflectionResponse response; + + DoOneRequest(request, response); + + if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase:: + kAllExtensionNumbersResponse) { + auto number = response.all_extension_numbers_response().extension_number(); + *output = std::vector(number.begin(), number.end()); + cached_extension_numbers_[extendee_type] = *output; + return true; + } else if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kErrorResponse) { + const ErrorResponse error = response.error_response(); + if (error.error_code() == StatusCode::NOT_FOUND) { + gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)", + extendee_type.c_str()); + } else { + gpr_log(GPR_INFO, + "Error on FindAllExtensionNumbersExtension(%s)\n" + "\tError code: %d\n\tError Message: %s", + extendee_type.c_str(), error.error_code(), + error.error_message().c_str()); + } + } + return false; +} + +bool ProtoReflectionDescriptorDatabase::GetServices( + std::vector* output) { + ServerReflectionRequest request; + request.set_list_services(""); + ServerReflectionResponse response; + + DoOneRequest(request, response); + + if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kListServicesResponse) { + const ListServiceResponse ls_response = response.list_services_response(); + for (int i = 0; i < ls_response.service_size(); ++i) { + (*output).push_back(ls_response.service(i).name()); + } + return true; + } else if (response.message_response_case() == + ServerReflectionResponse::MessageResponseCase::kErrorResponse) { + const ErrorResponse error = response.error_response(); + gpr_log(GPR_INFO, + "Error on GetServices()\n\tError code: %d\n" + "\tError Message: %s", + error.error_code(), error.error_message().c_str()); + } else { + gpr_log( + GPR_INFO, + "Error on GetServices() response type\n\tExpecting: %d\n\tReceived: %d", + ServerReflectionResponse::MessageResponseCase::kListServicesResponse, + response.message_response_case()); + } + return false; +} + +const google::protobuf::FileDescriptorProto +ProtoReflectionDescriptorDatabase::ParseFileDescriptorProtoResponse( + const std::string& byte_fd_proto) { + google::protobuf::FileDescriptorProto file_desc_proto; + file_desc_proto.ParseFromString(byte_fd_proto); + return file_desc_proto; +} + +void ProtoReflectionDescriptorDatabase::AddFileFromResponse( + const grpc::reflection::v1alpha::FileDescriptorResponse& response) { + for (int i = 0; i < response.file_descriptor_proto_size(); ++i) { + const google::protobuf::FileDescriptorProto file_proto = + ParseFileDescriptorProtoResponse(response.file_descriptor_proto(i)); + if (known_files_.find(file_proto.name()) == known_files_.end()) { + known_files_.insert(file_proto.name()); + cached_db_.Add(file_proto); + } + } +} + +const std::shared_ptr +ProtoReflectionDescriptorDatabase::GetStream() { + if (stream_ == nullptr) { + stream_ = stub_->ServerReflectionInfo(&ctx_); + } + return stream_; +} + +void ProtoReflectionDescriptorDatabase::DoOneRequest( + const ServerReflectionRequest& request, + ServerReflectionResponse& response) { + stream_mutex_.lock(); + GetStream()->Write(request); + GetStream()->Read(&response); + stream_mutex_.unlock(); +} + +} // namespace grpc diff --git a/test/cpp/util/proto_reflection_descriptor_database.h b/test/cpp/util/proto_reflection_descriptor_database.h new file mode 100644 index 00000000000..99c00675bb3 --- /dev/null +++ b/test/cpp/util/proto_reflection_descriptor_database.h @@ -0,0 +1,131 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef GRPC_TEST_CPP_PROTO_SERVER_REFLECTION_DATABSE_H +#define GRPC_TEST_CPP_PROTO_SERVER_REFLECTION_DATABSE_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace grpc { + +// ProtoReflectionDescriptorDatabase takes a stub of ServerReflection and +// provides the methods defined by DescriptorDatabase interfaces. It can be used +// to feed a DescriptorPool instance. +class ProtoReflectionDescriptorDatabase + : public google::protobuf::DescriptorDatabase { + public: + explicit ProtoReflectionDescriptorDatabase( + std::unique_ptr stub); + + explicit ProtoReflectionDescriptorDatabase( + std::shared_ptr channel); + + virtual ~ProtoReflectionDescriptorDatabase(); + + // The following four methods implement DescriptorDatabase interfaces. + // + // Find a file by file name. Fills in in *output and returns true if found. + // Otherwise, returns false, leaving the contents of *output undefined. + bool FindFileByName(const string& filename, + google::protobuf::FileDescriptorProto* output) + GRPC_OVERRIDE; + + // Find the file that declares the given fully-qualified symbol name. + // If found, fills in *output and returns true, otherwise returns false + // and leaves *output undefined. + bool FindFileContainingSymbol(const string& symbol_name, + google::protobuf::FileDescriptorProto* output) + GRPC_OVERRIDE; + + // Find the file which defines an extension extending the given message type + // with the given field number. If found, fills in *output and returns true, + // otherwise returns false and leaves *output undefined. containing_type + // must be a fully-qualified type name. + bool FindFileContainingExtension( + const string& containing_type, int field_number, + google::protobuf::FileDescriptorProto* output) GRPC_OVERRIDE; + + // Finds the tag numbers used by all known extensions of + // extendee_type, and appends them to output in an undefined + // order. This method is best-effort: it's not guaranteed that the + // database will find all extensions, and it's not guaranteed that + // FindFileContainingExtension will return true on all of the found + // numbers. Returns true if the search was successful, otherwise + // returns false and leaves output unchanged. + bool FindAllExtensionNumbers(const string& extendee_type, + std::vector* output) GRPC_OVERRIDE; + + // Provide a list of full names of registered services + bool GetServices(std::vector* output); + + private: + typedef ClientReaderWriter< + grpc::reflection::v1alpha::ServerReflectionRequest, + grpc::reflection::v1alpha::ServerReflectionResponse> + ClientStream; + + const google::protobuf::FileDescriptorProto ParseFileDescriptorProtoResponse( + const std::string& byte_fd_proto); + + void AddFileFromResponse( + const grpc::reflection::v1alpha::FileDescriptorResponse& response); + + const std::shared_ptr GetStream(); + + void DoOneRequest( + const grpc::reflection::v1alpha::ServerReflectionRequest& request, + grpc::reflection::v1alpha::ServerReflectionResponse& response); + + std::shared_ptr stream_; + grpc::ClientContext ctx_; + std::unique_ptr stub_; + std::unordered_set known_files_; + std::unordered_set missing_symbols_; + std::unordered_map> missing_extensions_; + std::unordered_map> cached_extension_numbers_; + std::mutex stream_mutex_; + + google::protobuf::SimpleDescriptorDatabase cached_db_; +}; + +} // namespace grpc + +#endif // GRPC_TEST_CPP_METRICS_SERVER_H diff --git a/test/distrib/cpp/run_distrib_test.sh b/test/distrib/cpp/run_distrib_test.sh new file mode 100755 index 00000000000..bc84b84b8f3 --- /dev/null +++ b/test/distrib/cpp/run_distrib_test.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set -ex + +git clone --recursive $EXTERNAL_GIT_ROOT +cd grpc + +cd third_party/protobuf && ./autogen.sh && \ +./configure && make -j4 && make check && make install && ldconfig + +cd ../.. && make -j4 && make install + +cd examples/cpp/helloworld + +make + +make clean + +cd ../../../examples/cpp/route_guide + +make + +make clean + diff --git a/tools/codegen/extensions/gen_reflection_proto.sh b/tools/codegen/extensions/gen_reflection_proto.sh new file mode 100755 index 00000000000..45a1a9f4ec1 --- /dev/null +++ b/tools/codegen/extensions/gen_reflection_proto.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PROTO_DIR="src/proto/grpc/reflection/v1alpha" +PROTO_FILE="reflection" +HEADER_DIR="include/grpc++/ext" +SRC_DIR="src/cpp/ext" +INCLUDE_DIR="grpc++/ext" +TMP_DIR="tmp" +GRPC_PLUGIN="bins/opt/grpc_cpp_plugin" +PROTOC=third_party/protobuf/src/protoc + +set -e + +TMP_DIR=${TMP_DIR}_${PROTO_FILE} + +cd $(dirname $0)/../../.. + +[ ! -d $HEADER_DIR ] && mkdir -p $HEADER_DIR || : +[ ! -d $SRC_DIR ] && mkdir -p $SRC_DIR || : +[ ! -d $TMP_DIR ] && mkdir -p $TMP_DIR || : + +$PROTOC -I$PROTO_DIR --cpp_out=$TMP_DIR ${PROTO_DIR}/${PROTO_FILE}.proto +$PROTOC -I$PROTO_DIR --grpc_out=$TMP_DIR --plugin=protoc-gen-grpc=${GRPC_PLUGIN} ${PROTO_DIR}/${PROTO_FILE}.proto + +sed -i "s/\"${PROTO_FILE}.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.pb.cc +sed -i "s/\"${PROTO_FILE}.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.grpc.pb.h +sed -i "s/\"${PROTO_FILE}.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.grpc.pb.cc +sed -i "s/\"${PROTO_FILE}.grpc.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.grpc.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.grpc.pb.cc + +/bin/cp LICENSE ${TMP_DIR}/TMP_LICENSE +sed -i -e "s/./ &/" -e "s/.*/ \*&/" ${TMP_DIR}/TMP_LICENSE +sed -i -r "\$a\ *\n *\/\n\n" ${TMP_DIR}/TMP_LICENSE + +sed -i -e "1s/^/ *\n/" -e "1s/^/\/*\n/" ${TMP_DIR}/*.pb.h +sed -i -e "1s/^/ *\n/" -e "1s/^/\/*\n/" ${TMP_DIR}/*.pb.cc + +sed -i "2r ${TMP_DIR}/TMP_LICENSE" ${TMP_DIR}/*.pb.h +sed -i "2r ${TMP_DIR}/TMP_LICENSE" ${TMP_DIR}/*.pb.cc + +/bin/mv ${TMP_DIR}/${PROTO_FILE}.pb.h ${HEADER_DIR} +/bin/mv ${TMP_DIR}/${PROTO_FILE}.grpc.pb.h ${HEADER_DIR} +/bin/mv ${TMP_DIR}/${PROTO_FILE}.pb.cc ${SRC_DIR} +/bin/mv ${TMP_DIR}/${PROTO_FILE}.grpc.pb.cc ${SRC_DIR} +/bin/rm -r $TMP_DIR diff --git a/tools/distrib/check_generated_pb_files.sh b/tools/distrib/check_generated_pb_files.sh new file mode 100755 index 00000000000..557067883c5 --- /dev/null +++ b/tools/distrib/check_generated_pb_files.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set -ex + +# change to root directory +cd $(dirname $0)/../.. + +# build grpc_check_generated_pb_files docker image +docker build -t grpc_check_generated_pb_files tools/dockerfile/grpc_check_generated_pb_files + +# run check_pb_files against the checked out codebase +docker run -e TEST=$TEST --rm=true -v ${HOST_GIT_ROOT:-`pwd`}:/var/local/jenkins/grpc -t grpc_check_generated_pb_files /var/local/jenkins/grpc/tools/dockerfile/grpc_check_generated_pb_files/check_pb_files.sh diff --git a/tools/distrib/check_include_guards.py b/tools/distrib/check_include_guards.py index ef770b30b42..56b2924a1ac 100755 --- a/tools/distrib/check_include_guards.py +++ b/tools/distrib/check_include_guards.py @@ -172,6 +172,8 @@ args = argp.parse_args() KNOWN_BAD = set([ 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', + 'include/grpc++/ext/reflection.grpc.pb.h', + 'include/grpc++/ext/reflection.pb.h', ]) diff --git a/tools/distrib/python/check_grpcio_tools.py b/tools/distrib/python/check_grpcio_tools.py index baf2ff4effb..80c63278f42 100755 --- a/tools/distrib/python/check_grpcio_tools.py +++ b/tools/distrib/python/check_grpcio_tools.py @@ -37,7 +37,7 @@ OUT_OF_DATE_MESSAGE = """file {} is out of date Have you called tools/distrib/python/make_grpcio_tools.py since upgrading protobuf?""" -check_protoc_lib_deps_content = make.get_deps(make.BAZEL_DEPS_PROTOC_LIB_QUERY) +check_protoc_lib_deps_content = make.get_deps() with open(make.GRPC_PYTHON_PROTOC_LIB_DEPS, 'r') as protoc_lib_deps_file: if protoc_lib_deps_file.read() != check_protoc_lib_deps_content: diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst index 10d2fe8c309..e9f137493ba 100644 --- a/tools/distrib/python/grpcio_tools/README.rst +++ b/tools/distrib/python/grpcio_tools/README.rst @@ -126,3 +126,13 @@ Help, I ... GCC 6.0), this is probably a bug where GCC chokes on constant expressions when the :code:`-fwrapv` flag is specified. You should consider setting your environment with :code:`CFLAGS=-fno-wrapv` or using clang (:code:`CC=clang`). + +Usage +----- + +Given protobuf include directories :code:`$INCLUDE`, an output directory +:code:`$OUTPUT`, and proto files :code:`$PROTO_FILES`, invoke as: + +:: + + $ python -m grpc.tools.protoc -I$INCLUDE --python_out=$OUTPUT --grpc_python_out=$OUTPUT $PROTO_FILES diff --git a/tools/distrib/python/grpcio_tools/grpc/tools/protoc.py b/tools/distrib/python/grpcio_tools/grpc/tools/protoc.py index b4dd0ecae2e..1c69e78920c 100644 --- a/tools/distrib/python/grpcio_tools/grpc/tools/protoc.py +++ b/tools/distrib/python/grpcio_tools/grpc/tools/protoc.py @@ -29,10 +29,13 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import pkg_resources import sys from grpc.tools import protoc_compiler if __name__ == '__main__': - protoc_compiler.run_main(sys.argv) + proto_include = pkg_resources.resource_filename('grpc.tools', '_proto') + protoc_compiler.run_main( + sys.argv + ['-I{}'.format(proto_include)]) diff --git a/tools/distrib/python/grpcio_tools/protoc_lib_deps.py b/tools/distrib/python/grpcio_tools/protoc_lib_deps.py index 135ac5cbb3b..cd4effa7ae8 100644 --- a/tools/distrib/python/grpcio_tools/protoc_lib_deps.py +++ b/tools/distrib/python/grpcio_tools/protoc_lib_deps.py @@ -30,3 +30,7 @@ # AUTO-GENERATED BY make_grpcio_tools.py! CC_FILES=['google/protobuf/compiler/zip_writer.cc', 'google/protobuf/compiler/subprocess.cc', 'google/protobuf/compiler/ruby/ruby_generator.cc', 'google/protobuf/compiler/python/python_generator.cc', 'google/protobuf/compiler/plugin.pb.cc', 'google/protobuf/compiler/plugin.cc', 'google/protobuf/compiler/objectivec/objectivec_primitive_field.cc', 'google/protobuf/compiler/objectivec/objectivec_oneof.cc', 'google/protobuf/compiler/objectivec/objectivec_message_field.cc', 'google/protobuf/compiler/objectivec/objectivec_message.cc', 'google/protobuf/compiler/objectivec/objectivec_map_field.cc', 'google/protobuf/compiler/objectivec/objectivec_helpers.cc', 'google/protobuf/compiler/objectivec/objectivec_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_file.cc', 'google/protobuf/compiler/objectivec/objectivec_field.cc', 'google/protobuf/compiler/objectivec/objectivec_extension.cc', 'google/protobuf/compiler/objectivec/objectivec_enum_field.cc', 'google/protobuf/compiler/objectivec/objectivec_enum.cc', 'google/protobuf/compiler/js/js_generator.cc', 'google/protobuf/compiler/javanano/javanano_primitive_field.cc', 'google/protobuf/compiler/javanano/javanano_message_field.cc', 'google/protobuf/compiler/javanano/javanano_message.cc', 'google/protobuf/compiler/javanano/javanano_map_field.cc', 'google/protobuf/compiler/javanano/javanano_helpers.cc', 'google/protobuf/compiler/javanano/javanano_generator.cc', 'google/protobuf/compiler/javanano/javanano_file.cc', 'google/protobuf/compiler/javanano/javanano_field.cc', 'google/protobuf/compiler/javanano/javanano_extension.cc', 'google/protobuf/compiler/javanano/javanano_enum_field.cc', 'google/protobuf/compiler/javanano/javanano_enum.cc', 'google/protobuf/compiler/java/java_string_field_lite.cc', 'google/protobuf/compiler/java/java_string_field.cc', 'google/protobuf/compiler/java/java_shared_code_generator.cc', 'google/protobuf/compiler/java/java_service.cc', 'google/protobuf/compiler/java/java_primitive_field_lite.cc', 'google/protobuf/compiler/java/java_primitive_field.cc', 'google/protobuf/compiler/java/java_name_resolver.cc', 'google/protobuf/compiler/java/java_message_lite.cc', 'google/protobuf/compiler/java/java_message_field_lite.cc', 'google/protobuf/compiler/java/java_message_field.cc', 'google/protobuf/compiler/java/java_message_builder_lite.cc', 'google/protobuf/compiler/java/java_message_builder.cc', 'google/protobuf/compiler/java/java_message.cc', 'google/protobuf/compiler/java/java_map_field_lite.cc', 'google/protobuf/compiler/java/java_map_field.cc', 'google/protobuf/compiler/java/java_lazy_message_field_lite.cc', 'google/protobuf/compiler/java/java_lazy_message_field.cc', 'google/protobuf/compiler/java/java_helpers.cc', 'google/protobuf/compiler/java/java_generator_factory.cc', 'google/protobuf/compiler/java/java_generator.cc', 'google/protobuf/compiler/java/java_file.cc', 'google/protobuf/compiler/java/java_field.cc', 'google/protobuf/compiler/java/java_extension_lite.cc', 'google/protobuf/compiler/java/java_extension.cc', 'google/protobuf/compiler/java/java_enum_lite.cc', 'google/protobuf/compiler/java/java_enum_field_lite.cc', 'google/protobuf/compiler/java/java_enum_field.cc', 'google/protobuf/compiler/java/java_enum.cc', 'google/protobuf/compiler/java/java_doc_comment.cc', 'google/protobuf/compiler/java/java_context.cc', 'google/protobuf/compiler/csharp/csharp_wrapper_field.cc', 'google/protobuf/compiler/csharp/csharp_source_generator_base.cc', 'google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_message_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_reflection_class.cc', 'google/protobuf/compiler/csharp/csharp_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_message_field.cc', 'google/protobuf/compiler/csharp/csharp_message.cc', 'google/protobuf/compiler/csharp/csharp_map_field.cc', 'google/protobuf/compiler/csharp/csharp_helpers.cc', 'google/protobuf/compiler/csharp/csharp_generator.cc', 'google/protobuf/compiler/csharp/csharp_field_base.cc', 'google/protobuf/compiler/csharp/csharp_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_enum.cc', 'google/protobuf/compiler/csharp/csharp_doc_comment.cc', 'google/protobuf/compiler/cpp/cpp_string_field.cc', 'google/protobuf/compiler/cpp/cpp_service.cc', 'google/protobuf/compiler/cpp/cpp_primitive_field.cc', 'google/protobuf/compiler/cpp/cpp_message_field.cc', 'google/protobuf/compiler/cpp/cpp_message.cc', 'google/protobuf/compiler/cpp/cpp_map_field.cc', 'google/protobuf/compiler/cpp/cpp_helpers.cc', 'google/protobuf/compiler/cpp/cpp_generator.cc', 'google/protobuf/compiler/cpp/cpp_file.cc', 'google/protobuf/compiler/cpp/cpp_field.cc', 'google/protobuf/compiler/cpp/cpp_extension.cc', 'google/protobuf/compiler/cpp/cpp_enum_field.cc', 'google/protobuf/compiler/cpp/cpp_enum.cc', 'google/protobuf/compiler/command_line_interface.cc', 'google/protobuf/compiler/code_generator.cc', 'google/protobuf/wrappers.pb.cc', 'google/protobuf/wire_format.cc', 'google/protobuf/util/type_resolver_util.cc', 'google/protobuf/util/time_util.cc', 'google/protobuf/util/message_differencer.cc', 'google/protobuf/util/json_util.cc', 'google/protobuf/util/internal/utility.cc', 'google/protobuf/util/internal/type_info_test_helper.cc', 'google/protobuf/util/internal/type_info.cc', 'google/protobuf/util/internal/protostream_objectwriter.cc', 'google/protobuf/util/internal/protostream_objectsource.cc', 'google/protobuf/util/internal/proto_writer.cc', 'google/protobuf/util/internal/object_writer.cc', 'google/protobuf/util/internal/json_stream_parser.cc', 'google/protobuf/util/internal/json_objectwriter.cc', 'google/protobuf/util/internal/json_escaping.cc', 'google/protobuf/util/internal/field_mask_utility.cc', 'google/protobuf/util/internal/error_listener.cc', 'google/protobuf/util/internal/default_value_objectwriter.cc', 'google/protobuf/util/internal/datapiece.cc', 'google/protobuf/util/field_mask_util.cc', 'google/protobuf/util/field_comparator.cc', 'google/protobuf/unknown_field_set.cc', 'google/protobuf/type.pb.cc', 'google/protobuf/timestamp.pb.cc', 'google/protobuf/text_format.cc', 'google/protobuf/stubs/substitute.cc', 'google/protobuf/stubs/mathlimits.cc', 'google/protobuf/struct.pb.cc', 'google/protobuf/source_context.pb.cc', 'google/protobuf/service.cc', 'google/protobuf/reflection_ops.cc', 'google/protobuf/message.cc', 'google/protobuf/map_field.cc', 'google/protobuf/io/zero_copy_stream_impl.cc', 'google/protobuf/io/tokenizer.cc', 'google/protobuf/io/strtod.cc', 'google/protobuf/io/printer.cc', 'google/protobuf/io/gzip_stream.cc', 'google/protobuf/generated_message_reflection.cc', 'google/protobuf/field_mask.pb.cc', 'google/protobuf/extension_set_heavy.cc', 'google/protobuf/empty.pb.cc', 'google/protobuf/dynamic_message.cc', 'google/protobuf/duration.pb.cc', 'google/protobuf/descriptor_database.cc', 'google/protobuf/descriptor.pb.cc', 'google/protobuf/descriptor.cc', 'google/protobuf/compiler/parser.cc', 'google/protobuf/compiler/importer.cc', 'google/protobuf/api.pb.cc', 'google/protobuf/any.pb.cc', 'google/protobuf/any.cc', 'google/protobuf/wire_format_lite.cc', 'google/protobuf/stubs/time.cc', 'google/protobuf/stubs/strutil.cc', 'google/protobuf/stubs/structurally_valid.cc', 'google/protobuf/stubs/stringprintf.cc', 'google/protobuf/stubs/stringpiece.cc', 'google/protobuf/stubs/statusor.cc', 'google/protobuf/stubs/status.cc', 'google/protobuf/stubs/once.cc', 'google/protobuf/stubs/int128.cc', 'google/protobuf/stubs/common.cc', 'google/protobuf/stubs/bytestream.cc', 'google/protobuf/stubs/atomicops_internals_x86_msvc.cc', 'google/protobuf/stubs/atomicops_internals_x86_gcc.cc', 'google/protobuf/repeated_field.cc', 'google/protobuf/message_lite.cc', 'google/protobuf/io/zero_copy_stream_impl_lite.cc', 'google/protobuf/io/zero_copy_stream.cc', 'google/protobuf/io/coded_stream.cc', 'google/protobuf/generated_message_util.cc', 'google/protobuf/extension_set.cc', 'google/protobuf/arenastring.cc', 'google/protobuf/arena.cc'] +PROTO_FILES=['google/protobuf/wrappers.proto', 'google/protobuf/type.proto', 'google/protobuf/timestamp.proto', 'google/protobuf/struct.proto', 'google/protobuf/source_context.proto', 'google/protobuf/field_mask.proto', 'google/protobuf/empty.proto', 'google/protobuf/duration.proto', 'google/protobuf/descriptor.proto', 'google/protobuf/compiler/plugin.proto', 'google/protobuf/api.proto', 'google/protobuf/any.proto'] + +CC_INCLUDE='third_party/protobuf/src' +PROTO_INCLUDE='third_party/protobuf/src' diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py index 576f7ae32a5..fbe69f43d56 100644 --- a/tools/distrib/python/grpcio_tools/setup.py +++ b/tools/distrib/python/grpcio_tools/setup.py @@ -28,9 +28,11 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from distutils import extension +import errno import os import os.path import shlex +import shutil import sys import setuptools @@ -47,18 +49,41 @@ sys.path.insert(0, os.path.abspath('.')) # ourselves in w.r.t. the multitude of operating systems this ought to build on. # By default we assume a GCC-like compiler. EXTRA_COMPILE_ARGS = shlex.split(os.environ.get('GRPC_PYTHON_CFLAGS', - '-frtti -std=c++11')) + '-fno-wrapv -frtti -std=c++11')) EXTRA_LINK_ARGS = shlex.split(os.environ.get('GRPC_PYTHON_LDFLAGS', '-lpthread')) +GRPC_PYTHON_TOOLS_PACKAGE = 'grpc.tools' +GRPC_PYTHON_PROTO_RESOURCES_NAME = '_proto' + import protoc_lib_deps import grpc_version +def package_data(): + tools_path = GRPC_PYTHON_TOOLS_PACKAGE.replace('.', os.path.sep) + proto_resources_path = os.path.join(tools_path, + GRPC_PYTHON_PROTO_RESOURCES_NAME) + proto_files = [] + for proto_file in protoc_lib_deps.PROTO_FILES: + source = os.path.join(protoc_lib_deps.PROTO_INCLUDE, proto_file) + target = os.path.join(proto_resources_path, proto_file) + relative_target = os.path.join(GRPC_PYTHON_PROTO_RESOURCES_NAME, proto_file) + try: + os.makedirs(os.path.dirname(target)) + except OSError as error: + if error.errno == errno.EEXIST: + pass + else: + raise + shutil.copy(source, target) + proto_files.append(relative_target) + return {GRPC_PYTHON_TOOLS_PACKAGE: proto_files} + def protoc_ext_module(): plugin_sources = [ 'grpc/tools/main.cc', 'grpc_root/src/compiler/python_generator.cc'] + [ - os.path.join('third_party/protobuf/src', cc_file) + os.path.join(protoc_lib_deps.CC_INCLUDE, cc_file) for cc_file in protoc_lib_deps.CC_FILES] plugin_ext = extension.Extension( name='grpc.tools.protoc_compiler', @@ -67,7 +92,7 @@ def protoc_ext_module(): '.', 'grpc_root', 'grpc_root/include', - 'third_party/protobuf/src', + protoc_lib_deps.CC_INCLUDE, ], language='c++', define_macros=[('HAVE_PTHREAD', 1)], @@ -88,9 +113,10 @@ setuptools.setup( protoc_ext_module(), ]), packages=setuptools.find_packages('.'), - # TODO(atash): Figure out why auditwheel doesn't like namespace packages. - #namespace_packages=['grpc'], + namespace_packages=['grpc'], install_requires=[ 'protobuf>=3.0.0a3', + 'grpcio>=0.14.0', ], + package_data=package_data(), ) diff --git a/tools/distrib/python/make_grpcio_tools.py b/tools/distrib/python/make_grpcio_tools.py index 50fbdbb14c0..fd9b38b084b 100755 --- a/tools/distrib/python/make_grpcio_tools.py +++ b/tools/distrib/python/make_grpcio_tools.py @@ -67,11 +67,16 @@ DEPS_FILE_CONTENT=""" # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # AUTO-GENERATED BY make_grpcio_tools.py! -CC_FILES={} +CC_FILES={cc_files} +PROTO_FILES={proto_files} + +CC_INCLUDE={cc_include} +PROTO_INCLUDE={proto_include} """ # Bazel query result prefix for expected source files in protobuf. PROTOBUF_CC_PREFIX = '//:src/' +PROTOBUF_PROTO_PREFIX = '//:src/' GRPC_ROOT = os.path.abspath( os.path.join(os.path.dirname(os.path.abspath(__file__)), @@ -79,7 +84,8 @@ GRPC_ROOT = os.path.abspath( GRPC_PYTHON_ROOT = os.path.join(GRPC_ROOT, 'tools/distrib/python/grpcio_tools') -GRPC_PROTOBUF = os.path.join(GRPC_ROOT, 'third_party/protobuf/src') +GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT = 'third_party/protobuf/src' +GRPC_PROTOBUF = os.path.join(GRPC_ROOT, GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT) GRPC_PROTOC_PLUGINS = os.path.join(GRPC_ROOT, 'src/compiler') GRPC_PYTHON_PROTOBUF = os.path.join(GRPC_PYTHON_ROOT, 'third_party/protobuf/src') @@ -93,18 +99,29 @@ GRPC_PYTHON_INCLUDE = os.path.join(GRPC_PYTHON_ROOT, 'grpc_root/include') BAZEL_DEPS = os.path.join(GRPC_ROOT, 'tools/distrib/python/bazel_deps.sh') BAZEL_DEPS_PROTOC_LIB_QUERY = '//:protoc_lib' +BAZEL_DEPS_COMMON_PROTOS_QUERY = '//:well_known_protos' + +def bazel_query(query): + output = subprocess.check_output([BAZEL_DEPS, query]) + return output.splitlines() -def get_deps(query): +def get_deps(): """Write the result of the bazel query `query` against protobuf to `out_file`.""" - output = subprocess.check_output([BAZEL_DEPS, query]) - output = output.splitlines() + cc_files_output = bazel_query(BAZEL_DEPS_PROTOC_LIB_QUERY) cc_files = [ - name for name in output + name[len(PROTOBUF_CC_PREFIX):] for name in cc_files_output if name.endswith('.cc') and name.startswith(PROTOBUF_CC_PREFIX)] - cc_files = [cc_file[len(PROTOBUF_CC_PREFIX):] for cc_file in cc_files] - deps_file_content = DEPS_FILE_CONTENT.format(cc_files) + proto_files_output = bazel_query(BAZEL_DEPS_COMMON_PROTOS_QUERY) + proto_files = [ + name[len(PROTOBUF_PROTO_PREFIX):] for name in proto_files_output + if name.endswith('.proto') and name.startswith(PROTOBUF_PROTO_PREFIX)] + deps_file_content = DEPS_FILE_CONTENT.format( + cc_files=cc_files, + proto_files=proto_files, + cc_include=repr(GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT), + proto_include=repr(GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT)) return deps_file_content @@ -123,7 +140,7 @@ def main(): shutil.copytree(GRPC_INCLUDE, GRPC_PYTHON_INCLUDE) try: - protoc_lib_deps_content = get_deps(BAZEL_DEPS_PROTOC_LIB_QUERY) + protoc_lib_deps_content = get_deps() except Exception as error: # We allow this script to succeed even if we couldn't get the dependencies, # as then we can assume that even without a successful bazel run the diff --git a/tools/dockerfile/distribtest/cpp_jessie_x64/Dockerfile b/tools/dockerfile/distribtest/cpp_jessie_x64/Dockerfile new file mode 100644 index 00000000000..c24b1c451d3 --- /dev/null +++ b/tools/dockerfile/distribtest/cpp_jessie_x64/Dockerfile @@ -0,0 +1,45 @@ +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +FROM debian:jessie + +# Install packages needed for gRPC and protobuf +RUN apt-get update && apt-get install -y \ + autoconf \ + automake \ + build-essential \ + curl \ + git \ + g++ \ + libtool \ + make \ + pkg-config \ + unzip && apt-get clean + +CMD ["bash"] diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile index 3e31a2b623d..1d4e8e1a4a4 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile @@ -41,3 +41,10 @@ RUN /opt/python/cp27-cp27mu/bin/pip install cython RUN /opt/python/cp34-cp34m/bin/pip install cython RUN /opt/python/cp35-cp35m/bin/pip install cython +#################################################### +# Install auditwheel with fix for namespace packages +RUN git clone https://github.com/pypa/auditwheel /usr/local/src/auditwheel +RUN cd /usr/local/src/auditwheel && git checkout bf071b38c9fe78b025ea05c78b1cb61d7cb09939 +RUN /opt/python/cp35-cp35m/bin/pip install /usr/local/src/auditwheel +RUN rm /usr/local/bin/auditwheel +RUN cd /usr/local/bin && ln -s /opt/python/cp35-cp35m/bin/auditwheel diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile index 5fe62c28b73..810499695ec 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile @@ -41,3 +41,10 @@ RUN /opt/python/cp27-cp27mu/bin/pip install cython RUN /opt/python/cp34-cp34m/bin/pip install cython RUN /opt/python/cp35-cp35m/bin/pip install cython +#################################################### +# Install auditwheel with fix for namespace packages +RUN git clone https://github.com/pypa/auditwheel /usr/local/src/auditwheel +RUN cd /usr/local/src/auditwheel && git checkout bf071b38c9fe78b025ea05c78b1cb61d7cb09939 +RUN /opt/python/cp35-cp35m/bin/pip install /usr/local/src/auditwheel +RUN rm /usr/local/bin/auditwheel +RUN cd /usr/local/bin && ln -s /opt/python/cp35-cp35m/bin/auditwheel diff --git a/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile b/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile new file mode 100644 index 00000000000..7658991462d --- /dev/null +++ b/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile @@ -0,0 +1,78 @@ +# 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. + +FROM debian:jessie + +# Install Git and basic packages. +RUN apt-get update && apt-get install -y \ + autoconf \ + autotools-dev \ + build-essential \ + bzip2 \ + ccache \ + curl \ + gcc \ + gcc-multilib \ + git \ + golang \ + gyp \ + lcov \ + libc6 \ + libc6-dbg \ + libc6-dev \ + libgtest-dev \ + libtool \ + make \ + perl \ + strace \ + python-dev \ + python-setuptools \ + python-yaml \ + telnet \ + unzip \ + wget \ + zip && apt-get clean + +#================ +# Build profiling +RUN apt-get update && apt-get install -y time && apt-get clean + +#================= +# C++ dependencies +RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean + +#====================== +# Zookeeper dependencies +# TODO(jtattermusch): is zookeeper still needed? +RUN apt-get install -y libzookeeper-mt-dev + +RUN mkdir /var/local/jenkins + +# Define the default command. +CMD ["bash"] diff --git a/tools/dockerfile/grpc_check_generated_pb_files/check_pb_files.sh b/tools/dockerfile/grpc_check_generated_pb_files/check_pb_files.sh new file mode 100755 index 00000000000..62e41755ec1 --- /dev/null +++ b/tools/dockerfile/grpc_check_generated_pb_files/check_pb_files.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# 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. + +set -e + +mkdir -p /var/local/git +git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc + +cd /var/local/git/grpc + +# build grpc cpp plugin for generating grpc pb files +make grpc_cpp_plugin + +# generate pb files +tools/codegen/extensions/gen_reflection_proto.sh + +# check if the pb files in the checked out codebase are identical with the newly +# generated ones +git diff --exit-code diff --git a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh index 6f4155944c3..eab7611b3f3 100755 --- a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh +++ b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh @@ -44,7 +44,7 @@ for dir in $DIRS do for glob in $GLOB do - files="$files `find /local-code/$dir -name $glob -and -not -name *.generated.* -and -not -name *.pb.h -and -not -name *.pb.c`" + files="$files `find /local-code/$dir -name $glob -and -not -name *.generated.* -and -not -name *.pb.h -and -not -name *.pb.c -and -not -name *.pb.cc`" done done diff --git a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile index 02d3c0d9ad6..d356433163e 100644 --- a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile +++ b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile @@ -82,5 +82,11 @@ RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins + +# The clang-3.6 symlink for the default clang version was added +# to Ubuntu 16.04 recently, so make sure it's installed. +# Also install clang3.7. +RUN apt-get update && apt-get -y install clang-3.6 clang-3.7 && apt-get clean + # Define the default command. CMD ["bash"] diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 00177920209..7f9d2df6f6c 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -765,11 +765,13 @@ include/grpc++/channel.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/create_channel.h \ +include/grpc++/create_channel_posix.h \ include/grpc++/generic/async_generic_service.h \ include/grpc++/generic/generic_stub.h \ include/grpc++/grpc++.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ +include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/grpc_library.h \ include/grpc++/impl/method_handler_impl.h \ include/grpc++/impl/rpc_method.h \ @@ -792,6 +794,7 @@ include/grpc++/security/server_credentials.h \ include/grpc++/server.h \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ +include/grpc++/server_posix.h \ include/grpc++/support/async_stream.h \ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 1c6884c0dfa..dcf1a4c8c40 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -765,11 +765,13 @@ include/grpc++/channel.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/create_channel.h \ +include/grpc++/create_channel_posix.h \ include/grpc++/generic/async_generic_service.h \ include/grpc++/generic/generic_stub.h \ include/grpc++/grpc++.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ +include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/grpc_library.h \ include/grpc++/impl/method_handler_impl.h \ include/grpc++/impl/rpc_method.h \ @@ -792,6 +794,7 @@ include/grpc++/security/server_credentials.h \ include/grpc++/server.h \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ +include/grpc++/server_posix.h \ include/grpc++/support/async_stream.h \ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ @@ -855,8 +858,8 @@ 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/time.h \ +include/grpc++/impl/codegen/core_codegen.h \ src/cpp/client/secure_credentials.h \ -src/cpp/common/core_codegen.h \ src/cpp/common/secure_auth_context.h \ src/cpp/server/secure_server_credentials.h \ src/cpp/client/create_channel_internal.h \ @@ -872,6 +875,7 @@ src/cpp/client/channel.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ +src/cpp/client/create_channel_posix.cc \ src/cpp/client/credentials.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ @@ -887,6 +891,7 @@ src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ src/cpp/server/server_context.cc \ src/cpp/server/server_credentials.cc \ +src/cpp/server/server_posix.cc \ src/cpp/util/byte_buffer.cc \ src/cpp/util/slice.cc \ src/cpp/util/status.cc \ diff --git a/tools/doxygen/Doxyfile.c++.internal.orig b/tools/doxygen/Doxyfile.c++.internal.orig new file mode 100644 index 00000000000..c214b3d3c84 --- /dev/null +++ b/tools/doxygen/Doxyfile.c++.internal.orig @@ -0,0 +1,2505 @@ + + +# Doxyfile 1.8.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "GRPC C++" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = 0.15.0-dev + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc/ref/c++.internal + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 2 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. +# Note: If this tag is empty the current directory is searched. + +INPUT = include/grpc++/alarm.h \ +include/grpc++/channel.h \ +include/grpc++/client_context.h \ +include/grpc++/completion_queue.h \ +include/grpc++/create_channel.h \ +include/grpc++/generic/async_generic_service.h \ +include/grpc++/generic/generic_stub.h \ +include/grpc++/grpc++.h \ +include/grpc++/impl/call.h \ +include/grpc++/impl/client_unary_call.h \ +include/grpc++/impl/codegen/core_codegen.h \ +include/grpc++/impl/grpc_library.h \ +include/grpc++/impl/method_handler_impl.h \ +include/grpc++/impl/rpc_method.h \ +include/grpc++/impl/rpc_service_method.h \ +include/grpc++/impl/serialization_traits.h \ +include/grpc++/impl/server_builder_option.h \ +include/grpc++/impl/server_builder_plugin.h \ +include/grpc++/impl/server_initializer.h \ +include/grpc++/impl/service_type.h \ +include/grpc++/impl/sync.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++/security/auth_context.h \ +include/grpc++/security/auth_metadata_processor.h \ +include/grpc++/security/credentials.h \ +include/grpc++/security/server_credentials.h \ +include/grpc++/server.h \ +include/grpc++/server_builder.h \ +include/grpc++/server_context.h \ +include/grpc++/support/async_stream.h \ +include/grpc++/support/async_unary_call.h \ +include/grpc++/support/byte_buffer.h \ +include/grpc++/support/channel_arguments.h \ +include/grpc++/support/config.h \ +include/grpc++/support/slice.h \ +include/grpc++/support/status.h \ +include/grpc++/support/status_code_enum.h \ +include/grpc++/support/string_ref.h \ +include/grpc++/support/stub_options.h \ +include/grpc++/support/sync_stream.h \ +include/grpc++/support/time.h \ +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/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.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/alloc.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/log.h \ +include/grpc/impl/codegen/port_platform.h \ +include/grpc/impl/codegen/slice.h \ +include/grpc/impl/codegen/slice_buffer.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/time.h \ +<<<<<<< HEAD +include/grpc++/impl/codegen/config.h \ +include/grpc++/impl/codegen/config_protobuf.h \ +include/grpc++/support/config.h \ +include/grpc++/support/config_protobuf.h \ +include/grpc++/impl/codegen/core_codegen.h \ +======= +>>>>>>> d30d4e279c4a63effaa6e912fc00bd4ad96054c7 +src/cpp/client/secure_credentials.h \ +src/cpp/common/secure_auth_context.h \ +src/cpp/server/secure_server_credentials.h \ +src/cpp/client/create_channel_internal.h \ +src/cpp/server/dynamic_thread_pool.h \ +src/cpp/server/thread_pool_interface.h \ +src/cpp/client/secure_credentials.cc \ +src/cpp/common/auth_property_iterator.cc \ +src/cpp/common/secure_auth_context.cc \ +src/cpp/common/secure_channel_arguments.cc \ +src/cpp/common/secure_create_auth_context.cc \ +src/cpp/server/secure_server_credentials.cc \ +src/cpp/client/channel.cc \ +src/cpp/client/client_context.cc \ +src/cpp/client/create_channel.cc \ +src/cpp/client/create_channel_internal.cc \ +src/cpp/client/credentials.cc \ +src/cpp/client/generic_stub.cc \ +src/cpp/client/insecure_credentials.cc \ +src/cpp/common/channel_arguments.cc \ +src/cpp/common/completion_queue.cc \ +src/cpp/common/core_codegen.cc \ +src/cpp/common/rpc_method.cc \ +src/cpp/server/async_generic_service.cc \ +src/cpp/server/create_default_thread_pool.cc \ +src/cpp/server/dynamic_thread_pool.cc \ +src/cpp/server/insecure_server_credentials.cc \ +src/cpp/server/server.cc \ +src/cpp/server/server_builder.cc \ +src/cpp/server/server_context.cc \ +src/cpp/server/server_credentials.cc \ +src/cpp/util/byte_buffer.cc \ +src/cpp/util/slice.cc \ +src/cpp/util/status.cc \ +src/cpp/util/string_ref.cc \ +src/cpp/util/time.cc \ +src/cpp/codegen/codegen_init.cc + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank the +# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, +# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, +# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, +# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, +# *.qsf, *.as and *.js. + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /