From 3cdbee6cbc580629b64e0d92e745835ebb9bd95d Mon Sep 17 00:00:00 2001 From: haorenfsa Date: Wed, 26 Apr 2017 22:30:10 +0800 Subject: read_fd should always have a certain value when create error occurs [fix: while using eventfd, when error occurs during creating eventfd, a random fd will be closed] --- src/core/lib/iomgr/wakeup_fd_eventfd.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/lib/iomgr/wakeup_fd_eventfd.cc b/src/core/lib/iomgr/wakeup_fd_eventfd.cc index dcf7dab71f..d68c9ada1f 100644 --- a/src/core/lib/iomgr/wakeup_fd_eventfd.cc +++ b/src/core/lib/iomgr/wakeup_fd_eventfd.cc @@ -32,12 +32,11 @@ #include "src/core/lib/profiling/timers.h" static grpc_error* eventfd_create(grpc_wakeup_fd* fd_info) { - int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); - if (efd < 0) { + fd_info->read_fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); + fd_info->write_fd = -1; + if (fd_info->read_fd < 0) { return GRPC_OS_ERROR(errno, "eventfd"); } - fd_info->read_fd = efd; - fd_info->write_fd = -1; return GRPC_ERROR_NONE; } -- cgit v1.2.3 From 5faf1b72edba62a06dd6b4273c2a36f570b7c949 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Sun, 7 Oct 2018 18:41:31 -0400 Subject: Avoid unnecessary ref/unref calls to get mdelem from slices. grpc_mdelem_from_slices() unref's the key and value. As a result, in quite a few cases on the hot path, we first ref slice, so that grpc_mdelem_from_slices() can unref them. Add grpc_mdelem_from_slices_no_unref() which does not unref() the input slices. This cuts 0.5% - 1.0% across app benchmarks. --- include/grpc/grpc.h | 2 +- .../ext/filters/client_channel/client_channel.cc | 2 +- .../ext/filters/http/client_authority_filter.cc | 5 ++-- .../transport/chttp2/transport/chttp2_transport.cc | 5 ++-- .../credentials/plugin/plugin_credentials.cc | 3 +-- src/core/lib/surface/channel.cc | 30 ++++++++++------------ src/core/lib/surface/channel.h | 4 +-- src/core/lib/transport/metadata.cc | 10 ++++++-- src/core/lib/transport/metadata.h | 8 ++++-- 9 files changed, 37 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index a9beee1c9e..416958ed96 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -211,7 +211,7 @@ GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel* channel); possible values). */ GRPCAPI grpc_call* grpc_channel_create_call( grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, - grpc_completion_queue* completion_queue, grpc_slice method, + grpc_completion_queue* completion_queue, const grpc_slice& method, const grpc_slice* host, gpr_timespec deadline, void* reserved); /** Ping the channels peer (load balanced channels will select one sub-channel diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 388736b60a..3df5f6f2a0 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -2211,7 +2211,7 @@ static void add_retriable_send_initial_metadata_op( .grpc_previous_rpc_attempts); } if (GPR_UNLIKELY(calld->num_attempts_completed > 0)) { - grpc_mdelem retry_md = grpc_mdelem_from_slices( + grpc_mdelem retry_md = grpc_mdelem_from_slices_no_unref( GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS, *retry_count_strings[calld->num_attempts_completed - 1]); grpc_error* error = grpc_metadata_batch_add_tail( diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 1ca20ebb26..40b3ea22fd 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -59,9 +59,8 @@ void authority_start_transport_stream_op_batch( initial_metadata->idx.named.authority == nullptr) { grpc_error* error = grpc_metadata_batch_add_head( initial_metadata, &calld->authority_storage, - grpc_mdelem_from_slices( - GRPC_MDSTR_AUTHORITY, - grpc_slice_ref_internal(chand->default_authority))); + grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_AUTHORITY, + chand->default_authority)); if (error != GRPC_ERROR_NONE) { grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 2d4b4da4c6..77a0a69393 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2127,9 +2127,8 @@ void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s, GRPC_LOG_IF_ERROR( "add_status_message", grpc_chttp2_incoming_metadata_buffer_replace_or_add( - &s->metadata_buffer[1], - grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_MESSAGE, - grpc_slice_ref_internal(slice)))); + &s->metadata_buffer[1], grpc_mdelem_from_slices_no_unref( + GRPC_MDSTR_GRPC_MESSAGE, slice))); } s->published_metadata[1] = GRPC_METADATA_SYNTHESIZED_FROM_FAKE; grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 73946ce039..d97963d891 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -102,8 +102,7 @@ static grpc_error* process_plugin_result( } else { for (size_t i = 0; i < num_md; ++i) { grpc_mdelem mdelem = - grpc_mdelem_from_slices(grpc_slice_ref_internal(md[i].key), - grpc_slice_ref_internal(md[i].value)); + grpc_mdelem_from_slices_no_unref(md[i].key, md[i].value); grpc_credentials_mdelem_array_add(r->md_array, mdelem); GRPC_MDELEM_UNREF(mdelem); } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 4294434504..cd0b3cb458 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -326,20 +326,18 @@ static grpc_call* grpc_channel_create_call_internal( return call; } -grpc_call* grpc_channel_create_call(grpc_channel* channel, - grpc_call* parent_call, - uint32_t propagation_mask, - grpc_completion_queue* cq, - grpc_slice method, const grpc_slice* host, - gpr_timespec deadline, void* reserved) { +grpc_call* grpc_channel_create_call( + grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, + grpc_completion_queue* cq, const grpc_slice& method, const grpc_slice* host, + gpr_timespec deadline, void* reserved) { GPR_ASSERT(!reserved); grpc_core::ExecCtx exec_ctx; grpc_call* call = grpc_channel_create_call_internal( channel, parent_call, propagation_mask, cq, nullptr, - grpc_mdelem_from_slices(GRPC_MDSTR_PATH, grpc_slice_ref_internal(method)), - host != nullptr ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, - grpc_slice_ref_internal(*host)) - : GRPC_MDNULL, + grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_PATH, method), + host != nullptr + ? grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_AUTHORITY, *host) + : GRPC_MDNULL, grpc_timespec_to_millis_round_up(deadline)); return call; @@ -347,15 +345,15 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel, grpc_call* grpc_channel_create_pollset_set_call( grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, - grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host, - grpc_millis deadline, void* reserved) { + grpc_pollset_set* pollset_set, const grpc_slice& method, + const grpc_slice* host, grpc_millis deadline, void* reserved) { GPR_ASSERT(!reserved); return grpc_channel_create_call_internal( channel, parent_call, propagation_mask, nullptr, pollset_set, - grpc_mdelem_from_slices(GRPC_MDSTR_PATH, grpc_slice_ref_internal(method)), - host != nullptr ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, - grpc_slice_ref_internal(*host)) - : GRPC_MDNULL, + grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_PATH, method), + host != nullptr + ? grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_AUTHORITY, *host) + : GRPC_MDNULL, deadline); } diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index e5ff2c3596..4ac76b8a29 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -45,8 +45,8 @@ grpc_channel* grpc_channel_create_with_builder( value of \a propagation_mask (see propagation_bits.h for possible values) */ grpc_call* grpc_channel_create_pollset_set_call( grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, - grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host, - grpc_millis deadline, void* reserved); + grpc_pollset_set* pollset_set, const grpc_slice& method, + const grpc_slice* host, grpc_millis deadline, void* reserved); /** Get a (borrowed) pointer to this channels underlying channel stack */ grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel); diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index d164502280..8f84e06fae 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -237,7 +237,7 @@ static void rehash_mdtab(mdtab_shard* shard) { } grpc_mdelem grpc_mdelem_create( - grpc_slice key, grpc_slice value, + const grpc_slice& key, const grpc_slice& value, grpc_mdelem_data* compatible_external_backing_store) { if (!grpc_slice_is_interned(key) || !grpc_slice_is_interned(value)) { if (compatible_external_backing_store != nullptr) { @@ -324,13 +324,19 @@ grpc_mdelem grpc_mdelem_create( return GRPC_MAKE_MDELEM(md, GRPC_MDELEM_STORAGE_INTERNED); } -grpc_mdelem grpc_mdelem_from_slices(grpc_slice key, grpc_slice value) { +grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, + const grpc_slice& value) { grpc_mdelem out = grpc_mdelem_create(key, value, nullptr); grpc_slice_unref_internal(key); grpc_slice_unref_internal(value); return out; } +grpc_mdelem grpc_mdelem_from_slices_no_unref(const grpc_slice& key, + const grpc_slice& value) { + return grpc_mdelem_create(key, value, nullptr); +} + grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata) { bool changed = false; grpc_slice key_slice = diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 338082276c..22481d6824 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -109,7 +109,11 @@ struct grpc_mdelem { (uintptr_t)GRPC_MDELEM_STORAGE_INTERNED_BIT)) /* Unrefs the slices. */ -grpc_mdelem grpc_mdelem_from_slices(grpc_slice key, grpc_slice value); +grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, + const grpc_slice& value); +/* Does not unref the slices. */ +grpc_mdelem grpc_mdelem_from_slices_no_unref(const grpc_slice& key, + const grpc_slice& value); /* Cheaply convert a grpc_metadata to a grpc_mdelem; may use the grpc_metadata object as backing storage (so lifetimes should align) */ @@ -120,7 +124,7 @@ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata); compatible_external_backing_store if it is non-NULL (in which case it's the users responsibility to ensure that it outlives usage) */ grpc_mdelem grpc_mdelem_create( - grpc_slice key, grpc_slice value, + const grpc_slice& key, const grpc_slice& value, grpc_mdelem_data* compatible_external_backing_store); bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b); -- cgit v1.2.3 From b4d5c7cee42154b0e24006287a93022ec605def0 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Mon, 8 Oct 2018 10:10:31 -0700 Subject: Benchmark test for callback unary gRPC Every thread intitiates multiple RPCs. The Callback of the unary RPC then issues a new RPC and this goes until the benchmark shuts down. For shutdown the main thread waits on a conditional variable. After shutdown the callbacks increment a rpcs done variable and once the the rpcs done equate the the total number of outstanding rpcs, the last callback performing the increment operation also issues a signal to wake up the main thread. The mainthread process to join the other threads and perform cleanup --- CMakeLists.txt | 1 + Makefile | 3 + build.yaml | 1 + grpc.gyp | 1 + src/proto/grpc/testing/control.proto | 1 + test/cpp/qps/BUILD | 1 + test/cpp/qps/client.h | 1 + test/cpp/qps/client_callback.cc | 220 +++++++++++++++++++++ test/cpp/qps/qps_worker.cc | 2 + tools/run_tests/generated/sources_and_headers.json | 1 + 10 files changed, 232 insertions(+) create mode 100644 test/cpp/qps/client_callback.cc (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index 66799c456f..b80d99a5c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5249,6 +5249,7 @@ add_library(qps ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/worker_service.grpc.pb.h test/cpp/qps/benchmark_config.cc test/cpp/qps/client_async.cc + test/cpp/qps/client_callback.cc test/cpp/qps/client_sync.cc test/cpp/qps/driver.cc test/cpp/qps/parse_json.cc diff --git a/Makefile b/Makefile index 1c61664fcc..582614bfb5 100644 --- a/Makefile +++ b/Makefile @@ -7510,6 +7510,7 @@ LIBQPS_SRC = \ $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.grpc.pb.cc \ test/cpp/qps/benchmark_config.cc \ test/cpp/qps/client_async.cc \ + test/cpp/qps/client_callback.cc \ test/cpp/qps/client_sync.cc \ test/cpp/qps/driver.cc \ test/cpp/qps/parse_json.cc \ @@ -7566,6 +7567,7 @@ endif endif $(OBJDIR)/$(CONFIG)/test/cpp/qps/benchmark_config.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/benchmark_service.pb.cc $(GENDIR)/src/proto/grpc/testing/benchmark_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_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/benchmark_service.pb.cc $(GENDIR)/src/proto/grpc/testing/benchmark_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_callback.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/benchmark_service.pb.cc $(GENDIR)/src/proto/grpc/testing/benchmark_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.grpc.pb.cc $(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/benchmark_service.pb.cc $(GENDIR)/src/proto/grpc/testing/benchmark_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.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/benchmark_service.pb.cc $(GENDIR)/src/proto/grpc/testing/benchmark_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.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/benchmark_service.pb.cc $(GENDIR)/src/proto/grpc/testing/benchmark_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.pb.cc $(GENDIR)/src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.pb.cc $(GENDIR)/src/proto/grpc/testing/worker_service.grpc.pb.cc @@ -24917,6 +24919,7 @@ test/cpp/interop/server_helper.cc: $(OPENSSL_DEP) test/cpp/microbenchmarks/helpers.cc: $(OPENSSL_DEP) test/cpp/qps/benchmark_config.cc: $(OPENSSL_DEP) test/cpp/qps/client_async.cc: $(OPENSSL_DEP) +test/cpp/qps/client_callback.cc: $(OPENSSL_DEP) test/cpp/qps/client_sync.cc: $(OPENSSL_DEP) test/cpp/qps/driver.cc: $(OPENSSL_DEP) test/cpp/qps/parse_json.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 6f81bf7afc..e69335ba62 100644 --- a/build.yaml +++ b/build.yaml @@ -1965,6 +1965,7 @@ libs: - src/proto/grpc/testing/worker_service.proto - test/cpp/qps/benchmark_config.cc - test/cpp/qps/client_async.cc + - test/cpp/qps/client_callback.cc - test/cpp/qps/client_sync.cc - test/cpp/qps/driver.cc - test/cpp/qps/parse_json.cc diff --git a/grpc.gyp b/grpc.gyp index 16b182349e..8e14b49cc4 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1717,6 +1717,7 @@ 'src/proto/grpc/testing/worker_service.proto', 'test/cpp/qps/benchmark_config.cc', 'test/cpp/qps/client_async.cc', + 'test/cpp/qps/client_callback.cc', 'test/cpp/qps/client_sync.cc', 'test/cpp/qps/driver.cc', 'test/cpp/qps/parse_json.cc', diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index a4a9c8fe57..4cfdc2cafb 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -25,6 +25,7 @@ enum ClientType { SYNC_CLIENT = 0; ASYNC_CLIENT = 1; OTHER_CLIENT = 2; // used for some language-specific variants + CALLBACK_CLIENT = 3; } enum ServerType { diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD index 483b29b1b3..2ef7441371 100644 --- a/test/cpp/qps/BUILD +++ b/test/cpp/qps/BUILD @@ -31,6 +31,7 @@ grpc_cc_library( name = "qps_worker_impl", srcs = [ "client_async.cc", + "client_callback.cc", "client_sync.cc", "qps_server_builder.cc", "qps_worker.cc", diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 0b4b2ff0a9..4ed34e0405 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -533,6 +533,7 @@ class ClientImpl : public Client { std::unique_ptr CreateSynchronousClient(const ClientConfig& args); std::unique_ptr CreateAsyncClient(const ClientConfig& args); +std::unique_ptr CreateCallbackClient(const ClientConfig& args); std::unique_ptr CreateGenericAsyncStreamingClient( const ClientConfig& args); diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc new file mode 100644 index 0000000000..50bb796b93 --- /dev/null +++ b/test/cpp/qps/client_callback.cc @@ -0,0 +1,220 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" +#include "test/cpp/qps/client.h" +#include "test/cpp/qps/usage_timer.h" + +namespace grpc { +namespace testing { + +/** + * Maintains context info per RPC + */ +struct CallbackClientRpcContext { + CallbackClientRpcContext(BenchmarkService::Stub* stub) + : response_(), context_(), alarm_(), stub_(stub) {} + + ~CallbackClientRpcContext() {} + + SimpleResponse response_; + ClientContext context_; + Alarm alarm_; + BenchmarkService::Stub* stub_; +}; + +static std::unique_ptr BenchmarkStubCreator( + const std::shared_ptr& ch) { + return BenchmarkService::NewStub(ch); +} + +class CallbackClient + : public ClientImpl { + public: + CallbackClient(const ClientConfig& config) + : ClientImpl( + config, BenchmarkStubCreator) { + num_threads_ = NumThreads(config); + rpcs_done_ = 0; + SetupLoadTest(config, num_threads_); + total_outstanding_rpcs_ = + config.client_channels() * config.outstanding_rpcs_per_channel(); + } + + virtual ~CallbackClient() {} + + protected: + size_t num_threads_; + size_t total_outstanding_rpcs_; + // The below mutex and condition variable is used by main benchmark thread to + // wait on completion of all RPCs before shutdown + std::mutex shutdown_mu_; + std::condition_variable shutdown_cv_; + // Number of rpcs done after thread completion + size_t rpcs_done_; + // Per Thread Queue of Context data pointers for running a RPC + std::vector>> ctxs_; + virtual void InitThreadFuncImpl(size_t thread_idx) = 0; + virtual bool ThreadFuncImpl(Thread* t, size_t thread_idx) = 0; + + void ThreadFunc(size_t thread_idx, Thread* t) override { + InitThreadFuncImpl(thread_idx); + ThreadFuncImpl(t, thread_idx); + } + + virtual void ScheduleRpc(Thread* t, size_t thread_idx, size_t queue_idx) = 0; + + /** + * The main thread of the benchmark will be waiting on DestroyMultithreading. + * Increment the rpcs_done_ variable to signify that the Callback RPC + * after thread completion is done. When the last outstanding rpc increments + * the counter it should also signal the main thread's conditional variable. + */ + void NotifyMainThreadOfThreadCompletion() { + std::lock_guard l(shutdown_mu_); + rpcs_done_++; + if (rpcs_done_ == total_outstanding_rpcs_) { + shutdown_cv_.notify_one(); + } + } + + private: + int NumThreads(const ClientConfig& config) { + int num_threads = config.async_client_threads(); + if (num_threads <= 0) { // Use dynamic sizing + num_threads = cores_; + gpr_log(GPR_INFO, "Sizing callback client to %d threads", num_threads); + } + return num_threads; + } + + /** + * Wait until all outstanding Callback RPCs are done + */ + void DestroyMultithreading() final { + std::unique_lock l(shutdown_mu_); + while (rpcs_done_ != total_outstanding_rpcs_) { + shutdown_cv_.wait(l); + } + EndThreads(); + } +}; + +class CallbackUnaryClient final : public CallbackClient { + public: + CallbackUnaryClient(const ClientConfig& config) : CallbackClient(config) { + ctxs_.resize(num_threads_); + for (int ch = 0; ch < config.client_channels(); ch++) { + for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) { + size_t bucket = (i * ch) % num_threads_; + ctxs_[bucket].emplace_back( + new CallbackClientRpcContext(channels_[ch].get_stub())); + } + } + StartThreads(num_threads_); + } + ~CallbackUnaryClient() {} + + protected: + bool ThreadFuncImpl(Thread* t, size_t thread_idx) override { + for (size_t i = 0; i < ctxs_[thread_idx].size(); i++) { + ScheduleRpc(t, thread_idx, i); + } + return true; + } + + void InitThreadFuncImpl(size_t thread_idx) override { return; } + + private: + void ScheduleRpc(Thread* t, size_t thread_idx, size_t queue_idx) override { + if (!closed_loop_) { + gpr_timespec next_issue_time = NextIssueTime(thread_idx); + // Start an alarm callback to run the internal callback after + // next_issue_time + ctxs_[thread_idx][queue_idx]->alarm_.experimental().Set( + next_issue_time, [this, t, thread_idx, queue_idx](bool ok) { + IssueUnaryCallbackRpc(t, thread_idx, queue_idx); + }); + } else { + IssueUnaryCallbackRpc(t, thread_idx, queue_idx); + } + } + + void IssueUnaryCallbackRpc(Thread* t, size_t thread_idx, size_t queue_idx) { + GPR_TIMER_SCOPE("CallbackUnaryClient::ThreadFunc", 0); + double start = UsageTimer::Now(); + ctxs_[thread_idx][queue_idx]->stub_->experimental_async()->UnaryCall( + std::move(&ctxs_[thread_idx][queue_idx]->context_), &request_, + &ctxs_[thread_idx][queue_idx]->response_, + [this, t, thread_idx, start, queue_idx](grpc::Status s) { + // Update Histogram with data from the callback run + HistogramEntry entry; + if (s.ok()) { + entry.set_value((UsageTimer::Now() - start) * 1e9); + } + entry.set_status(s.error_code()); + t->UpdateHistogram(&entry); + + if (ThreadCompleted() || !s.ok()) { + // Notify thread of completion + NotifyMainThreadOfThreadCompletion(); + } else { + // Reallocate ctx for next RPC + ctxs_[thread_idx][queue_idx].reset(new CallbackClientRpcContext( + ctxs_[thread_idx][queue_idx]->stub_)); + // Schedule a new RPC + ScheduleRpc(t, thread_idx, queue_idx); + } + }); + } +}; + +std::unique_ptr CreateCallbackClient(const ClientConfig& config) { + switch (config.rpc_type()) { + case UNARY: + return std::unique_ptr(new CallbackUnaryClient(config)); + case STREAMING: + case STREAMING_FROM_CLIENT: + case STREAMING_FROM_SERVER: + case STREAMING_BOTH_WAYS: + assert(false); + return nullptr; + default: + assert(false); + return nullptr; + } +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 7ddf3c1cf3..d97d95d8f3 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -60,6 +60,8 @@ static std::unique_ptr CreateClient(const ClientConfig& config) { return config.payload_config().has_bytebuf_params() ? CreateGenericAsyncStreamingClient(config) : CreateAsyncClient(config); + case ClientType::CALLBACK_CLIENT: + return CreateCallbackClient(config); default: abort(); } diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 8749593ed5..b27f5b5037 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7836,6 +7836,7 @@ "test/cpp/qps/benchmark_config.h", "test/cpp/qps/client.h", "test/cpp/qps/client_async.cc", + "test/cpp/qps/client_callback.cc", "test/cpp/qps/client_sync.cc", "test/cpp/qps/driver.cc", "test/cpp/qps/driver.h", -- cgit v1.2.3 From d6b140df030f4032a2e039b0af174374141300b0 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 8 Oct 2018 16:19:50 -0400 Subject: Revert the change in grpc.h because it's part of C API. I mistakenly added "const ref" which breaks Android client. --- include/grpc/grpc.h | 2 +- src/core/lib/surface/channel.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 416958ed96..a9beee1c9e 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -211,7 +211,7 @@ GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel* channel); possible values). */ GRPCAPI grpc_call* grpc_channel_create_call( grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, - grpc_completion_queue* completion_queue, const grpc_slice& method, + grpc_completion_queue* completion_queue, grpc_slice method, const grpc_slice* host, gpr_timespec deadline, void* reserved); /** Ping the channels peer (load balanced channels will select one sub-channel diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index cd0b3cb458..ebc532c4fd 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -326,10 +326,12 @@ static grpc_call* grpc_channel_create_call_internal( return call; } -grpc_call* grpc_channel_create_call( - grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, - grpc_completion_queue* cq, const grpc_slice& method, const grpc_slice* host, - gpr_timespec deadline, void* reserved) { +grpc_call* grpc_channel_create_call(grpc_channel* channel, + grpc_call* parent_call, + uint32_t propagation_mask, + grpc_completion_queue* cq, + grpc_slice method, const grpc_slice* host, + gpr_timespec deadline, void* reserved) { GPR_ASSERT(!reserved); grpc_core::ExecCtx exec_ctx; grpc_call* call = grpc_channel_create_call_internal( -- cgit v1.2.3 From c8d5db17173318ff5efe3e0721bca3340251f738 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 11 Oct 2018 15:27:27 -0400 Subject: Update TCP read estimates as soon as we read the whole buffer. If we have a continous stream of bytes on the socket, we will never grow the buffer, because we will never get EAGAIN, and call finish. This is a serious performance issue, which can be misued. As soon as we have a full buffer, update the estimate. --- src/core/lib/iomgr/tcp_posix.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index e40bf81c90..7fd0e91346 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -468,7 +468,9 @@ static void tcp_do_read(grpc_tcp* tcp) { GRPC_STATS_INC_TCP_READ_SIZE(read_bytes); add_to_estimate(tcp, static_cast(read_bytes)); GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length); - if (static_cast(read_bytes) < tcp->incoming_buffer->length) { + if (static_cast(read_bytes) == tcp->incoming_buffer->length) { + finish_estimate(tcp); + } else if (static_cast(read_bytes) < tcp->incoming_buffer->length) { grpc_slice_buffer_trim_end( tcp->incoming_buffer, tcp->incoming_buffer->length - static_cast(read_bytes), -- cgit v1.2.3 From 78434ad30360583ab4f71c1aca1dc3e850a31e98 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 11 Oct 2018 15:28:49 -0400 Subject: Do not wait for allocation if buffer is less than half the target. We overallocate by 2x for target. Unless buffer is more than half full, we should not delay read for more allocation. --- src/core/lib/iomgr/tcp_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 7fd0e91346..aa2704ce26 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -500,7 +500,7 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) { static void tcp_continue_read(grpc_tcp* tcp) { size_t target_read_size = get_target_read_size(tcp); - if (tcp->incoming_buffer->length < target_read_size && + if (tcp->incoming_buffer->length < target_read_size / 2 && tcp->incoming_buffer->count < MAX_READ_IOVEC) { if (grpc_tcp_trace.enabled()) { gpr_log(GPR_INFO, "TCP:%p alloc_slices", tcp); -- cgit v1.2.3 From 10f995d283607a161e2ddcae5dd94636de950ec5 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 9 Oct 2018 14:33:41 -0700 Subject: Enable channelz by default --- src/core/lib/channel/channelz.h | 4 ++-- test/core/channel/channelz_test.cc | 9 ++++++++- test/core/end2end/tests/channelz.cc | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index fddef793fb..88551befc8 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -42,13 +42,13 @@ /** This is the default value for whether or not to enable channelz. If * GRPC_ARG_ENABLE_CHANNELZ is set, it will override this default value. */ -#define GRPC_ENABLE_CHANNELZ_DEFAULT false +#define GRPC_ENABLE_CHANNELZ_DEFAULT true /** This is the default value for the maximum amount of memory used by trace * events per channel trace node. If * GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE is set, it will override * this default value. */ -#define GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT 0 +#define GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT 1024 * 4 namespace grpc_core { diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index aed1fba47c..b7cdde581a 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -238,8 +238,15 @@ TEST_P(ChannelzChannelTest, BasicChannel) { TEST(ChannelzChannelTest, ChannelzDisabled) { grpc_core::ExecCtx exec_ctx; + // explicitly disable channelz + grpc_arg arg[2]; + arg[0] = grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), 0); + arg[1] = grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_ENABLE_CHANNELZ), false); + grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg}; grpc_channel* channel = - grpc_insecure_channel_create("fake_target", nullptr, nullptr); + grpc_insecure_channel_create("fake_target", &args, nullptr); ChannelNode* channelz_channel = grpc_channel_get_channelz_node(channel); ASSERT_EQ(channelz_channel, nullptr); grpc_channel_destroy(channel); diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc index 41549190e3..da8a8eca42 100644 --- a/test/core/end2end/tests/channelz.cc +++ b/test/core/end2end/tests/channelz.cc @@ -199,9 +199,12 @@ static void run_one_request(grpc_end2end_test_config config, static void test_channelz(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - grpc_arg arg = grpc_channel_arg_integer_create( + grpc_arg arg[2]; + arg[0] = grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), 0); + arg[1] = grpc_channel_arg_integer_create( const_cast(GRPC_ARG_ENABLE_CHANNELZ), true); - grpc_channel_args args = {1, &arg}; + grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg}; f = begin_test(config, "test_channelz", &args, &args); grpc_core::channelz::ChannelNode* channelz_channel = @@ -307,7 +310,14 @@ static void test_channelz_with_channel_trace(grpc_end2end_test_config config) { static void test_channelz_disabled(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - f = begin_test(config, "test_channelz_disabled", nullptr, nullptr); + grpc_arg arg[2]; + arg[0] = grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), 0); + arg[1] = grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_ENABLE_CHANNELZ), false); + grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg}; + + f = begin_test(config, "test_channelz_disabled", &args, &args); grpc_core::channelz::ChannelNode* channelz_channel = grpc_channel_get_channelz_node(f.client); GPR_ASSERT(channelz_channel == nullptr); -- cgit v1.2.3 From 079e25016751169a2aebb1b03ef735d4f63e1d70 Mon Sep 17 00:00:00 2001 From: Naresh Date: Fri, 12 Oct 2018 16:05:07 +0000 Subject: Rename BUILD files to Bazel convention --- src/proto/grpc/reflection/v1alpha/BUILD | 32 ------ src/proto/grpc/reflection/v1alpha/BUILD.bazel | 32 ++++++ src/proto/grpc/testing/BUILD | 152 -------------------------- src/proto/grpc/testing/BUILD.bazel | 152 ++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 184 deletions(-) delete mode 100644 src/proto/grpc/reflection/v1alpha/BUILD create mode 100644 src/proto/grpc/reflection/v1alpha/BUILD.bazel delete mode 100644 src/proto/grpc/testing/BUILD create mode 100644 src/proto/grpc/testing/BUILD.bazel (limited to 'src') diff --git a/src/proto/grpc/reflection/v1alpha/BUILD b/src/proto/grpc/reflection/v1alpha/BUILD deleted file mode 100644 index 4d919d029e..0000000000 --- a/src/proto/grpc/reflection/v1alpha/BUILD +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) # Apache v2 - -load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") - -grpc_package(name = "reflection", visibility = "public") - -grpc_proto_library( - name = "reflection_proto", - srcs = ["reflection.proto"], -) - -filegroup( - name = "reflection_proto_file", - srcs = [ - "reflection.proto", - ], -) - diff --git a/src/proto/grpc/reflection/v1alpha/BUILD.bazel b/src/proto/grpc/reflection/v1alpha/BUILD.bazel new file mode 100644 index 0000000000..4d919d029e --- /dev/null +++ b/src/proto/grpc/reflection/v1alpha/BUILD.bazel @@ -0,0 +1,32 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") + +grpc_package(name = "reflection", visibility = "public") + +grpc_proto_library( + name = "reflection_proto", + srcs = ["reflection.proto"], +) + +filegroup( + name = "reflection_proto_file", + srcs = [ + "reflection.proto", + ], +) + diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD deleted file mode 100644 index 7048911b9a..0000000000 --- a/src/proto/grpc/testing/BUILD +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) # Apache v2 - -load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") - -grpc_package(name = "testing", visibility = "public") - -exports_files([ - "echo.proto", - "echo_messages.proto", -]) - -grpc_proto_library( - name = "compiler_test_proto", - srcs = ["compiler_test.proto"], - generate_mocks = True, -) - -grpc_proto_library( - name = "control_proto", - srcs = ["control.proto"], - has_services = False, - deps = [ - "payloads_proto", - "stats_proto", - ], -) - -grpc_proto_library( - name = "echo_messages_proto", - srcs = ["echo_messages.proto"], - has_services = False, -) - -grpc_proto_library( - name = "echo_proto", - srcs = ["echo.proto"], - deps = ["echo_messages_proto"], - generate_mocks = True, -) - -grpc_proto_library( - name = "empty_proto", - srcs = ["empty.proto"], - has_services = False, -) - -py_proto_library( - name = "py_empty_proto", - protos = ["empty.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - -grpc_proto_library( - name = "messages_proto", - srcs = ["messages.proto"], - has_services = False, -) - -py_proto_library( - name = "py_messages_proto", - protos = ["messages.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - -grpc_proto_library( - name = "metrics_proto", - srcs = ["metrics.proto"], -) - -grpc_proto_library( - name = "payloads_proto", - srcs = ["payloads.proto"], - has_services = False, -) - -grpc_proto_library( - name = "benchmark_service_proto", - srcs = ["benchmark_service.proto"], - deps = [ - "messages_proto", - ], -) - -grpc_proto_library( - name = "report_qps_scenario_service_proto", - srcs = ["report_qps_scenario_service.proto"], - deps = [ - "control_proto", - ], -) - -grpc_proto_library( - name = "worker_service_proto", - srcs = ["worker_service.proto"], - deps = [ - "control_proto", - ], -) - -grpc_proto_library( - name = "stats_proto", - srcs = ["stats.proto"], - has_services = False, - deps = [ - "//src/proto/grpc/core:stats_proto", - ] -) - -grpc_proto_library( - name = "test_proto", - srcs = ["test.proto"], - deps = [ - "empty_proto", - "messages_proto", - ], -) - -py_proto_library( - name = "py_test_proto", - protos = ["test.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], - proto_deps = [ - ":py_empty_proto", - ":py_messages_proto", - ] -) - diff --git a/src/proto/grpc/testing/BUILD.bazel b/src/proto/grpc/testing/BUILD.bazel new file mode 100644 index 0000000000..7048911b9a --- /dev/null +++ b/src/proto/grpc/testing/BUILD.bazel @@ -0,0 +1,152 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") +load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") + +grpc_package(name = "testing", visibility = "public") + +exports_files([ + "echo.proto", + "echo_messages.proto", +]) + +grpc_proto_library( + name = "compiler_test_proto", + srcs = ["compiler_test.proto"], + generate_mocks = True, +) + +grpc_proto_library( + name = "control_proto", + srcs = ["control.proto"], + has_services = False, + deps = [ + "payloads_proto", + "stats_proto", + ], +) + +grpc_proto_library( + name = "echo_messages_proto", + srcs = ["echo_messages.proto"], + has_services = False, +) + +grpc_proto_library( + name = "echo_proto", + srcs = ["echo.proto"], + deps = ["echo_messages_proto"], + generate_mocks = True, +) + +grpc_proto_library( + name = "empty_proto", + srcs = ["empty.proto"], + has_services = False, +) + +py_proto_library( + name = "py_empty_proto", + protos = ["empty.proto",], + with_grpc = True, + deps = [ + requirement('protobuf'), + ], +) + +grpc_proto_library( + name = "messages_proto", + srcs = ["messages.proto"], + has_services = False, +) + +py_proto_library( + name = "py_messages_proto", + protos = ["messages.proto",], + with_grpc = True, + deps = [ + requirement('protobuf'), + ], +) + +grpc_proto_library( + name = "metrics_proto", + srcs = ["metrics.proto"], +) + +grpc_proto_library( + name = "payloads_proto", + srcs = ["payloads.proto"], + has_services = False, +) + +grpc_proto_library( + name = "benchmark_service_proto", + srcs = ["benchmark_service.proto"], + deps = [ + "messages_proto", + ], +) + +grpc_proto_library( + name = "report_qps_scenario_service_proto", + srcs = ["report_qps_scenario_service.proto"], + deps = [ + "control_proto", + ], +) + +grpc_proto_library( + name = "worker_service_proto", + srcs = ["worker_service.proto"], + deps = [ + "control_proto", + ], +) + +grpc_proto_library( + name = "stats_proto", + srcs = ["stats.proto"], + has_services = False, + deps = [ + "//src/proto/grpc/core:stats_proto", + ] +) + +grpc_proto_library( + name = "test_proto", + srcs = ["test.proto"], + deps = [ + "empty_proto", + "messages_proto", + ], +) + +py_proto_library( + name = "py_test_proto", + protos = ["test.proto",], + with_grpc = True, + deps = [ + requirement('protobuf'), + ], + proto_deps = [ + ":py_empty_proto", + ":py_messages_proto", + ] +) + -- cgit v1.2.3 From c992454355c2c7cb30166df1ffe8a743d4bce9ab Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Fri, 12 Oct 2018 12:11:52 -0700 Subject: Revert "Rename BUILD files to Bazel convention" This reverts commit 079e25016751169a2aebb1b03ef735d4f63e1d70. --- src/proto/grpc/reflection/v1alpha/BUILD | 32 ++++++ src/proto/grpc/reflection/v1alpha/BUILD.bazel | 32 ------ src/proto/grpc/testing/BUILD | 152 ++++++++++++++++++++++++++ src/proto/grpc/testing/BUILD.bazel | 152 -------------------------- 4 files changed, 184 insertions(+), 184 deletions(-) create mode 100644 src/proto/grpc/reflection/v1alpha/BUILD delete mode 100644 src/proto/grpc/reflection/v1alpha/BUILD.bazel create mode 100644 src/proto/grpc/testing/BUILD delete mode 100644 src/proto/grpc/testing/BUILD.bazel (limited to 'src') diff --git a/src/proto/grpc/reflection/v1alpha/BUILD b/src/proto/grpc/reflection/v1alpha/BUILD new file mode 100644 index 0000000000..4d919d029e --- /dev/null +++ b/src/proto/grpc/reflection/v1alpha/BUILD @@ -0,0 +1,32 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") + +grpc_package(name = "reflection", visibility = "public") + +grpc_proto_library( + name = "reflection_proto", + srcs = ["reflection.proto"], +) + +filegroup( + name = "reflection_proto_file", + srcs = [ + "reflection.proto", + ], +) + diff --git a/src/proto/grpc/reflection/v1alpha/BUILD.bazel b/src/proto/grpc/reflection/v1alpha/BUILD.bazel deleted file mode 100644 index 4d919d029e..0000000000 --- a/src/proto/grpc/reflection/v1alpha/BUILD.bazel +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) # Apache v2 - -load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") - -grpc_package(name = "reflection", visibility = "public") - -grpc_proto_library( - name = "reflection_proto", - srcs = ["reflection.proto"], -) - -filegroup( - name = "reflection_proto_file", - srcs = [ - "reflection.proto", - ], -) - diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD new file mode 100644 index 0000000000..7048911b9a --- /dev/null +++ b/src/proto/grpc/testing/BUILD @@ -0,0 +1,152 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") +load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") + +grpc_package(name = "testing", visibility = "public") + +exports_files([ + "echo.proto", + "echo_messages.proto", +]) + +grpc_proto_library( + name = "compiler_test_proto", + srcs = ["compiler_test.proto"], + generate_mocks = True, +) + +grpc_proto_library( + name = "control_proto", + srcs = ["control.proto"], + has_services = False, + deps = [ + "payloads_proto", + "stats_proto", + ], +) + +grpc_proto_library( + name = "echo_messages_proto", + srcs = ["echo_messages.proto"], + has_services = False, +) + +grpc_proto_library( + name = "echo_proto", + srcs = ["echo.proto"], + deps = ["echo_messages_proto"], + generate_mocks = True, +) + +grpc_proto_library( + name = "empty_proto", + srcs = ["empty.proto"], + has_services = False, +) + +py_proto_library( + name = "py_empty_proto", + protos = ["empty.proto",], + with_grpc = True, + deps = [ + requirement('protobuf'), + ], +) + +grpc_proto_library( + name = "messages_proto", + srcs = ["messages.proto"], + has_services = False, +) + +py_proto_library( + name = "py_messages_proto", + protos = ["messages.proto",], + with_grpc = True, + deps = [ + requirement('protobuf'), + ], +) + +grpc_proto_library( + name = "metrics_proto", + srcs = ["metrics.proto"], +) + +grpc_proto_library( + name = "payloads_proto", + srcs = ["payloads.proto"], + has_services = False, +) + +grpc_proto_library( + name = "benchmark_service_proto", + srcs = ["benchmark_service.proto"], + deps = [ + "messages_proto", + ], +) + +grpc_proto_library( + name = "report_qps_scenario_service_proto", + srcs = ["report_qps_scenario_service.proto"], + deps = [ + "control_proto", + ], +) + +grpc_proto_library( + name = "worker_service_proto", + srcs = ["worker_service.proto"], + deps = [ + "control_proto", + ], +) + +grpc_proto_library( + name = "stats_proto", + srcs = ["stats.proto"], + has_services = False, + deps = [ + "//src/proto/grpc/core:stats_proto", + ] +) + +grpc_proto_library( + name = "test_proto", + srcs = ["test.proto"], + deps = [ + "empty_proto", + "messages_proto", + ], +) + +py_proto_library( + name = "py_test_proto", + protos = ["test.proto",], + with_grpc = True, + deps = [ + requirement('protobuf'), + ], + proto_deps = [ + ":py_empty_proto", + ":py_messages_proto", + ] +) + diff --git a/src/proto/grpc/testing/BUILD.bazel b/src/proto/grpc/testing/BUILD.bazel deleted file mode 100644 index 7048911b9a..0000000000 --- a/src/proto/grpc/testing/BUILD.bazel +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) # Apache v2 - -load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") - -grpc_package(name = "testing", visibility = "public") - -exports_files([ - "echo.proto", - "echo_messages.proto", -]) - -grpc_proto_library( - name = "compiler_test_proto", - srcs = ["compiler_test.proto"], - generate_mocks = True, -) - -grpc_proto_library( - name = "control_proto", - srcs = ["control.proto"], - has_services = False, - deps = [ - "payloads_proto", - "stats_proto", - ], -) - -grpc_proto_library( - name = "echo_messages_proto", - srcs = ["echo_messages.proto"], - has_services = False, -) - -grpc_proto_library( - name = "echo_proto", - srcs = ["echo.proto"], - deps = ["echo_messages_proto"], - generate_mocks = True, -) - -grpc_proto_library( - name = "empty_proto", - srcs = ["empty.proto"], - has_services = False, -) - -py_proto_library( - name = "py_empty_proto", - protos = ["empty.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - -grpc_proto_library( - name = "messages_proto", - srcs = ["messages.proto"], - has_services = False, -) - -py_proto_library( - name = "py_messages_proto", - protos = ["messages.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - -grpc_proto_library( - name = "metrics_proto", - srcs = ["metrics.proto"], -) - -grpc_proto_library( - name = "payloads_proto", - srcs = ["payloads.proto"], - has_services = False, -) - -grpc_proto_library( - name = "benchmark_service_proto", - srcs = ["benchmark_service.proto"], - deps = [ - "messages_proto", - ], -) - -grpc_proto_library( - name = "report_qps_scenario_service_proto", - srcs = ["report_qps_scenario_service.proto"], - deps = [ - "control_proto", - ], -) - -grpc_proto_library( - name = "worker_service_proto", - srcs = ["worker_service.proto"], - deps = [ - "control_proto", - ], -) - -grpc_proto_library( - name = "stats_proto", - srcs = ["stats.proto"], - has_services = False, - deps = [ - "//src/proto/grpc/core:stats_proto", - ] -) - -grpc_proto_library( - name = "test_proto", - srcs = ["test.proto"], - deps = [ - "empty_proto", - "messages_proto", - ], -) - -py_proto_library( - name = "py_test_proto", - protos = ["test.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], - proto_deps = [ - ":py_empty_proto", - ":py_messages_proto", - ] -) - -- cgit v1.2.3 From 45e8ada064b7e95599a4aef5434cdd2ff02d6543 Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Fri, 12 Oct 2018 12:12:29 -0700 Subject: Revert "Bazel rules for Python grpcio_reflection" This reverts commit 2e78e516ad8cb45cff705581625f85e5033b4e5b. --- src/proto/grpc/reflection/v1alpha/BUILD | 8 ----- src/proto/grpc/testing/BUILD | 11 ------- src/proto/grpc/testing/proto2/BUILD.bazel | 30 ------------------- .../grpc_reflection/v1alpha/BUILD.bazel | 34 ---------------------- .../grpcio_tests/tests/reflection/BUILD.bazel | 21 ------------- 5 files changed, 104 deletions(-) delete mode 100644 src/proto/grpc/testing/proto2/BUILD.bazel delete mode 100644 src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel delete mode 100644 src/python/grpcio_tests/tests/reflection/BUILD.bazel (limited to 'src') diff --git a/src/proto/grpc/reflection/v1alpha/BUILD b/src/proto/grpc/reflection/v1alpha/BUILD index 4d919d029e..4605418447 100644 --- a/src/proto/grpc/reflection/v1alpha/BUILD +++ b/src/proto/grpc/reflection/v1alpha/BUILD @@ -22,11 +22,3 @@ grpc_proto_library( name = "reflection_proto", srcs = ["reflection.proto"], ) - -filegroup( - name = "reflection_proto_file", - srcs = [ - "reflection.proto", - ], -) - diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 7048911b9a..f6a8f69d24 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -15,8 +15,6 @@ licenses(["notice"]) # Apache v2 load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") grpc_package(name = "testing", visibility = "public") @@ -60,15 +58,6 @@ grpc_proto_library( has_services = False, ) -py_proto_library( - name = "py_empty_proto", - protos = ["empty.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - grpc_proto_library( name = "messages_proto", srcs = ["messages.proto"], diff --git a/src/proto/grpc/testing/proto2/BUILD.bazel b/src/proto/grpc/testing/proto2/BUILD.bazel deleted file mode 100644 index c4c4f004ef..0000000000 --- a/src/proto/grpc/testing/proto2/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") - -package(default_visibility = ["//visibility:public"]) - -py_proto_library( - name = "empty2_proto", - protos = [ - "empty2.proto", - ], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - -py_proto_library( - name = "empty2_extensions_proto", - protos = [ - "empty2_extensions.proto", - ], - proto_deps = [ - ":empty2_proto", - ], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel deleted file mode 100644 index 3a2ba26371..0000000000 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ /dev/null @@ -1,34 +0,0 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") - -package(default_visibility = ["//visibility:public"]) - -genrule( - name = "mv_reflection_proto", - srcs = [ - "//src/proto/grpc/reflection/v1alpha:reflection_proto_file", - ], - outs = ["reflection.proto",], - cmd = "cp $< $@", -) - -py_proto_library( - name = "py_reflection_proto", - protos = [":mv_reflection_proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - -py_library( - name = "grpc_reflection", - srcs = ["reflection.py",], - deps = [ - ":py_reflection_proto", - "//src/python/grpcio/grpc:grpcio", - requirement('protobuf'), - ], - imports=["../../",], -) - diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel deleted file mode 100644 index c0efb0b7ce..0000000000 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - -package(default_visibility = ["//visibility:public"]) - -py_test( - name="_reflection_servicer_test", - size="small", - timeout="moderate", - srcs=["_reflection_servicer_test.py",], - main="_reflection_servicer_test.py", - deps=[ - "//src/python/grpcio/grpc:grpcio", - "//src/python/grpcio_reflection/grpc_reflection/v1alpha:grpc_reflection", - "//src/python/grpcio_tests/tests/unit:test_common", - "//src/proto/grpc/testing:py_empty_proto", - "//src/proto/grpc/testing/proto2:empty2_extensions_proto", - requirement('protobuf'), - ], - imports=["../../",], -) - -- cgit v1.2.3 From 9d2f985f555718af2ab97eb50b332f06d7abd4f9 Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Fri, 12 Oct 2018 12:12:36 -0700 Subject: Revert "Bazel rules for gRPC Python interop tests" This reverts commit 9172775bc82b071acb81f08e81e7d7706a9dee3f. --- requirements.bazel.txt | 1 - src/proto/grpc/testing/BUILD | 23 ----- src/python/grpcio_tests/tests/interop/BUILD.bazel | 97 ---------------------- .../tests/interop/credentials/BUILD.bazel | 9 -- 4 files changed, 130 deletions(-) delete mode 100644 src/python/grpcio_tests/tests/interop/BUILD.bazel delete mode 100644 src/python/grpcio_tests/tests/interop/credentials/BUILD.bazel (limited to 'src') diff --git a/requirements.bazel.txt b/requirements.bazel.txt index efbf5314af..16f31f9e94 100644 --- a/requirements.bazel.txt +++ b/requirements.bazel.txt @@ -8,4 +8,3 @@ wheel>=0.29 futures>=2.2.0 google-auth>=1.0.0 oauth2client==4.1.0 -requests>=2.14.2 diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index f6a8f69d24..16721ff2ed 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -64,15 +64,6 @@ grpc_proto_library( has_services = False, ) -py_proto_library( - name = "py_messages_proto", - protos = ["messages.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], -) - grpc_proto_library( name = "metrics_proto", srcs = ["metrics.proto"], @@ -125,17 +116,3 @@ grpc_proto_library( "messages_proto", ], ) - -py_proto_library( - name = "py_test_proto", - protos = ["test.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], - proto_deps = [ - ":py_empty_proto", - ":py_messages_proto", - ] -) - diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel deleted file mode 100644 index a39f30d32a..0000000000 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ /dev/null @@ -1,97 +0,0 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - -package(default_visibility = ["//visibility:public"]) - -py_library( - name = "_intraop_test_case", - srcs = ["_intraop_test_case.py"], - deps = [ - ":methods", - ], - imports=["../../",], -) - -py_library( - name = "client", - srcs = ["client.py"], - deps = [ - "//src/python/grpcio/grpc:grpcio", - ":methods", - ":resources", - "//src/proto/grpc/testing:py_test_proto", - requirement('google-auth'), - ], - imports=["../../",], -) - -py_library( - name = "methods", - srcs = ["methods.py"], - deps = [ - "//src/python/grpcio/grpc:grpcio", - "//src/proto/grpc/testing:py_empty_proto", - "//src/proto/grpc/testing:py_messages_proto", - "//src/proto/grpc/testing:py_test_proto", - requirement('google-auth'), - requirement('requests'), - requirement('enum34'), - ], - imports=["../../",], -) - -py_library( - name = "resources", - srcs = ["resources.py"], - data = [ - "//src/python/grpcio_tests/tests/interop/credentials", - ], -) - -py_library( - name = "server", - srcs = ["server.py"], - deps = [ - "//src/python/grpcio/grpc:grpcio", - ":methods", - ":resources", - "//src/python/grpcio_tests/tests/unit:test_common", - "//src/proto/grpc/testing:py_test_proto", - ], - imports=["../../",], -) - -py_test( - name="_insecure_intraop_test", - size="small", - srcs=["_insecure_intraop_test.py",], - main="_insecure_intraop_test.py", - deps=[ - "//src/python/grpcio/grpc:grpcio", - ":_intraop_test_case", - ":methods", - ":server", - "//src/python/grpcio_tests/tests/unit:test_common", - "//src/proto/grpc/testing:py_test_proto", - ], - imports=["../../",], - data=[ - "//src/python/grpcio_tests/tests/unit/credentials", - ], -) - -py_test( - name="_secure_intraop_test", - size="small", - srcs=["_secure_intraop_test.py",], - main="_secure_intraop_test.py", - deps=[ - "//src/python/grpcio/grpc:grpcio", - ":_intraop_test_case", - ":methods", - ":server", - "//src/python/grpcio_tests/tests/unit:test_common", - "//src/proto/grpc/testing:py_test_proto", - ], - imports=["../../",], -) - diff --git a/src/python/grpcio_tests/tests/interop/credentials/BUILD.bazel b/src/python/grpcio_tests/tests/interop/credentials/BUILD.bazel deleted file mode 100644 index bc2b997292..0000000000 --- a/src/python/grpcio_tests/tests/interop/credentials/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -filegroup( - name="credentials", - srcs=glob([ - "**", - ]), -) - -- cgit v1.2.3 From a280d89937db5a2f14aa05642dccfd00131498cc Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Sun, 14 Oct 2018 22:47:15 -0400 Subject: Use grpc_mdelem_create() directly. Remove grpc_mdelem_from_slices_no_unref() since it's a wrapper around grpc_mdelem_create(). --- src/core/ext/filters/client_channel/client_channel.cc | 4 ++-- src/core/ext/filters/http/client_authority_filter.cc | 4 ++-- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 4 ++-- src/core/lib/security/credentials/plugin/plugin_credentials.cc | 2 +- src/core/lib/surface/channel.cc | 8 ++++---- src/core/lib/transport/metadata.cc | 5 ----- src/core/lib/transport/metadata.h | 3 --- 7 files changed, 11 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 3df5f6f2a0..d2c88742bf 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -2211,9 +2211,9 @@ static void add_retriable_send_initial_metadata_op( .grpc_previous_rpc_attempts); } if (GPR_UNLIKELY(calld->num_attempts_completed > 0)) { - grpc_mdelem retry_md = grpc_mdelem_from_slices_no_unref( + grpc_mdelem retry_md = grpc_mdelem_create( GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS, - *retry_count_strings[calld->num_attempts_completed - 1]); + *retry_count_strings[calld->num_attempts_completed - 1], nullptr); grpc_error* error = grpc_metadata_batch_add_tail( &retry_state->send_initial_metadata, &retry_state->send_initial_metadata_storage[calld->send_initial_metadata diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 40b3ea22fd..6383f12594 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -59,8 +59,8 @@ void authority_start_transport_stream_op_batch( initial_metadata->idx.named.authority == nullptr) { grpc_error* error = grpc_metadata_batch_add_head( initial_metadata, &calld->authority_storage, - grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_AUTHORITY, - chand->default_authority)); + grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, chand->default_authority, + nullptr)); if (error != GRPC_ERROR_NONE) { grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 77a0a69393..8a481bb7d5 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2127,8 +2127,8 @@ void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s, GRPC_LOG_IF_ERROR( "add_status_message", grpc_chttp2_incoming_metadata_buffer_replace_or_add( - &s->metadata_buffer[1], grpc_mdelem_from_slices_no_unref( - GRPC_MDSTR_GRPC_MESSAGE, slice))); + &s->metadata_buffer[1], + grpc_mdelem_create(GRPC_MDSTR_GRPC_MESSAGE, slice, nullptr))); } s->published_metadata[1] = GRPC_METADATA_SYNTHESIZED_FROM_FAKE; grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index d97963d891..4015124298 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -102,7 +102,7 @@ static grpc_error* process_plugin_result( } else { for (size_t i = 0; i < num_md; ++i) { grpc_mdelem mdelem = - grpc_mdelem_from_slices_no_unref(md[i].key, md[i].value); + grpc_mdelem_create(md[i].key, md[i].value, nullptr); grpc_credentials_mdelem_array_add(r->md_array, mdelem); GRPC_MDELEM_UNREF(mdelem); } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index ebc532c4fd..044241470b 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -336,9 +336,9 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel, grpc_core::ExecCtx exec_ctx; grpc_call* call = grpc_channel_create_call_internal( channel, parent_call, propagation_mask, cq, nullptr, - grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_PATH, method), + grpc_mdelem_create(GRPC_MDSTR_PATH, method, nullptr), host != nullptr - ? grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_AUTHORITY, *host) + ? grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, *host, nullptr) : GRPC_MDNULL, grpc_timespec_to_millis_round_up(deadline)); @@ -352,9 +352,9 @@ grpc_call* grpc_channel_create_pollset_set_call( GPR_ASSERT(!reserved); return grpc_channel_create_call_internal( channel, parent_call, propagation_mask, nullptr, pollset_set, - grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_PATH, method), + grpc_mdelem_create(GRPC_MDSTR_PATH, method, nullptr), host != nullptr - ? grpc_mdelem_from_slices_no_unref(GRPC_MDSTR_AUTHORITY, *host) + ? grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, *host, nullptr) : GRPC_MDNULL, deadline); } diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 8f84e06fae..60af22393e 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -332,11 +332,6 @@ grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, return out; } -grpc_mdelem grpc_mdelem_from_slices_no_unref(const grpc_slice& key, - const grpc_slice& value) { - return grpc_mdelem_create(key, value, nullptr); -} - grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata) { bool changed = false; grpc_slice key_slice = diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 22481d6824..989c7544c1 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -111,9 +111,6 @@ struct grpc_mdelem { /* Unrefs the slices. */ grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, const grpc_slice& value); -/* Does not unref the slices. */ -grpc_mdelem grpc_mdelem_from_slices_no_unref(const grpc_slice& key, - const grpc_slice& value); /* Cheaply convert a grpc_metadata to a grpc_mdelem; may use the grpc_metadata object as backing storage (so lifetimes should align) */ -- cgit v1.2.3 From 118e134ded9dba1b509852d0986b9e3427eb498f Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 12 Oct 2018 10:25:32 -0700 Subject: fix Exception throw for invalid channel args * unit test included * throw ValueError exception from Cython to Python * prevent the deconstruction method from failing when Channel initialization failed --- src/python/grpcio/grpc/_channel.py | 5 ++++- src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi | 4 ++-- src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi | 4 ++-- src/python/grpcio_tests/tests/unit/_channel_args_test.py | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 3494c9b15a..eeeb4ddb33 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -981,4 +981,7 @@ class Channel(grpc.Channel): # then deletion of this grpc._channel.Channel instance can be made to # effect closure of the underlying cygrpc.Channel instance. cygrpc.fork_unregister_channel(self) - _moot(self._connectivity_state) + # This prevent the failed-at-initializing object removal from failing. + # Though the __init__ failed, the removal will still trigger __del__. + if hasattr(self, "_connectivity_state"): + _moot(self._connectivity_state) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi index 6cb1bc0c05..e0e068e452 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi @@ -32,7 +32,7 @@ cdef class _ArgumentProcessor: cdef grpc_arg c_argument - cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references) + cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references) except * cdef class _ArgumentsProcessor: @@ -42,5 +42,5 @@ cdef class _ArgumentsProcessor: cdef readonly list _references cdef grpc_channel_args _c_arguments - cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable) + cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable) except * cdef un_c(self) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi index 2239e26b32..b7a4277ff6 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi @@ -52,7 +52,7 @@ cdef grpc_arg _unwrap_grpc_arg(tuple wrapped_arg): cdef class _ArgumentProcessor: - cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references): + cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references) except *: key, value = argument cdef bytes encoded_key = _encode(key) if encoded_key is not key: @@ -89,7 +89,7 @@ cdef class _ArgumentsProcessor: self._argument_processors = [] self._references = [] - cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable): + cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable) except *: self._c_arguments.arguments_length = len(self._arguments) if self._c_arguments.arguments_length == 0: return NULL diff --git a/src/python/grpcio_tests/tests/unit/_channel_args_test.py b/src/python/grpcio_tests/tests/unit/_channel_args_test.py index 869c2f4d2f..dd1d2969a2 100644 --- a/src/python/grpcio_tests/tests/unit/_channel_args_test.py +++ b/src/python/grpcio_tests/tests/unit/_channel_args_test.py @@ -33,6 +33,14 @@ TEST_CHANNEL_ARGS = ( ('arg6', TestPointerWrapper()), ) +INVALID_TEST_CHANNEL_ARGS = [ + { + 'foo': 'bar' + }, + (('key',),), + 'str', +] + class ChannelArgsTest(unittest.TestCase): @@ -44,6 +52,14 @@ class ChannelArgsTest(unittest.TestCase): futures.ThreadPoolExecutor(max_workers=1), options=TEST_CHANNEL_ARGS) + def test_invalid_client_args(self): + for invalid_arg in INVALID_TEST_CHANNEL_ARGS: + self.assertRaises( + ValueError, + grpc.insecure_channel, + 'localhost:8080', + options=invalid_arg) + if __name__ == '__main__': unittest.main(verbosity=2) -- cgit v1.2.3 From 9929a23ecdf1b221f7b93481206f3dc87ffdd308 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 9 Oct 2018 11:24:31 +0200 Subject: add dlerror stubs --- src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs index 7185d68efe..63c6c1f2f2 100644 --- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs +++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs @@ -183,6 +183,9 @@ namespace Grpc.Core.Internal [DllImport("libdl.so")] internal static extern IntPtr dlopen(string filename, int flags); + [DllImport("libdl.so")] + internal static extern IntPtr dlerror(); + [DllImport("libdl.so")] internal static extern IntPtr dlsym(IntPtr handle, string symbol); } @@ -192,6 +195,9 @@ namespace Grpc.Core.Internal [DllImport("libSystem.dylib")] internal static extern IntPtr dlopen(string filename, int flags); + [DllImport("libSystem.dylib")] + internal static extern IntPtr dlerror(); + [DllImport("libSystem.dylib")] internal static extern IntPtr dlsym(IntPtr handle, string symbol); } @@ -208,6 +214,9 @@ namespace Grpc.Core.Internal [DllImport("__Internal")] internal static extern IntPtr dlopen(string filename, int flags); + [DllImport("__Internal")] + internal static extern IntPtr dlerror(); + [DllImport("__Internal")] internal static extern IntPtr dlsym(IntPtr handle, string symbol); } @@ -222,6 +231,9 @@ namespace Grpc.Core.Internal [DllImport("libcoreclr.so")] internal static extern IntPtr dlopen(string filename, int flags); + [DllImport("libcoreclr.so")] + internal static extern IntPtr dlerror(); + [DllImport("libcoreclr.so")] internal static extern IntPtr dlsym(IntPtr handle, string symbol); } -- cgit v1.2.3 From a959b6d7d2b6df11afe5381390fbfae6000675d3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 9 Oct 2018 11:56:57 +0200 Subject: Show dlerror if grpc_csharp_ext load fails --- src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs index 63c6c1f2f2..1786fc2e3f 100644 --- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs +++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs @@ -51,11 +51,12 @@ namespace Grpc.Core.Internal Logger.Debug("Attempting to load native library \"{0}\"", this.libraryPath); - this.handle = PlatformSpecificLoadLibrary(this.libraryPath); + this.handle = PlatformSpecificLoadLibrary(this.libraryPath, out string loadLibraryErrorDetail); if (this.handle == IntPtr.Zero) { - throw new IOException(string.Format("Error loading native library \"{0}\"", this.libraryPath)); + throw new IOException(string.Format("Error loading native library \"{0}\". {1}", + this.libraryPath, loadLibraryErrorDetail)); } } @@ -129,31 +130,44 @@ namespace Grpc.Core.Internal /// /// Loads library in a platform specific way. /// - private static IntPtr PlatformSpecificLoadLibrary(string libraryPath) + private static IntPtr PlatformSpecificLoadLibrary(string libraryPath, out string errorMsg) { if (PlatformApis.IsWindows) { + // TODO(jtattermusch): populate the error on Windows + errorMsg = null; return Windows.LoadLibrary(libraryPath); } if (PlatformApis.IsLinux) { if (PlatformApis.IsMono) { - return Mono.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY); + return LoadLibraryPosix(Mono.dlopen, Mono.dlerror, libraryPath, out errorMsg); } if (PlatformApis.IsNetCore) { - return CoreCLR.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY); + return LoadLibraryPosix(CoreCLR.dlopen, CoreCLR.dlerror, libraryPath, out errorMsg); } - return Linux.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY); + return LoadLibraryPosix(Linux.dlopen, Linux.dlerror, libraryPath, out errorMsg); } if (PlatformApis.IsMacOSX) { - return MacOSX.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY); + return LoadLibraryPosix(MacOSX.dlopen, MacOSX.dlerror, libraryPath, out errorMsg); } throw new InvalidOperationException("Unsupported platform."); } + private static IntPtr LoadLibraryPosix(Func dlopenFunc, Func dlerrorFunc, string libraryPath, out string errorMsg) + { + errorMsg = null; + IntPtr ret = dlopenFunc(libraryPath, RTLD_GLOBAL + RTLD_LAZY); + if (ret == IntPtr.Zero) + { + errorMsg = Marshal.PtrToStringAnsi(dlerrorFunc()); + } + return ret; + } + private static string FirstValidLibraryPath(string[] libraryPathAlternatives) { GrpcPreconditions.CheckArgument(libraryPathAlternatives.Length > 0, "libraryPathAlternatives cannot be empty."); -- cgit v1.2.3 From 08ae060a445ae544eb58455e751eb2b77e70b65c Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 15 Oct 2018 11:33:30 -0400 Subject: Fix formatting errors introduced in a280d899. --- src/core/lib/surface/channel.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 044241470b..d7095c24d4 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -337,9 +337,8 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel, grpc_call* call = grpc_channel_create_call_internal( channel, parent_call, propagation_mask, cq, nullptr, grpc_mdelem_create(GRPC_MDSTR_PATH, method, nullptr), - host != nullptr - ? grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, *host, nullptr) - : GRPC_MDNULL, + host != nullptr ? grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, *host, nullptr) + : GRPC_MDNULL, grpc_timespec_to_millis_round_up(deadline)); return call; @@ -353,9 +352,8 @@ grpc_call* grpc_channel_create_pollset_set_call( return grpc_channel_create_call_internal( channel, parent_call, propagation_mask, nullptr, pollset_set, grpc_mdelem_create(GRPC_MDSTR_PATH, method, nullptr), - host != nullptr - ? grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, *host, nullptr) - : GRPC_MDNULL, + host != nullptr ? grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, *host, nullptr) + : GRPC_MDNULL, deadline); } -- cgit v1.2.3 From c27d2fcbbe4bec9e57b6aaaf92d0a93457e60da8 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 15 Oct 2018 15:59:17 -0400 Subject: Ban gevent test --- src/python/grpcio_tests/commands.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 0dfbf3180b..6931d93ef0 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -116,6 +116,8 @@ class TestGevent(setuptools.Command): # eventually succeed, but need to dig into performance issues. 'unit._cython._no_messages_server_completion_queue_per_call_test.Test.test_rpcs', 'unit._cython._no_messages_single_server_completion_queue_test.Test.test_rpcs', + # TODO(https://github.com/grpc/grpc/issues/16890) enable this test + 'unit._cython._channel_test.ChannelTest.test_multiple_channels_lonely_connectivity', # I have no idea why this doesn't work in gevent, but it shouldn't even be # using the c-core 'testing._client_test.ClientTest.test_infinite_request_stream_real_time', -- cgit v1.2.3 From f1d3d32f9cb0a0337b3de9b61af05b651a8cc4e3 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 15 Oct 2018 19:45:45 -0400 Subject: Assume UNKNOWN if no status --- src/core/ext/filters/client_channel/subchannel.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 3a1c14c6f1..78ff426b11 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -760,9 +760,12 @@ static void get_call_status(grpc_subchannel_call* call, grpc_error_get_status(error, call->deadline, status, nullptr, nullptr, nullptr); } else { - GPR_ASSERT(md_batch->idx.named.grpc_status != nullptr); - *status = - grpc_get_status_code_from_metadata(md_batch->idx.named.grpc_status->md); + if (md_batch->idx.named.grpc_status != nullptr) { + *status = grpc_get_status_code_from_metadata( + md_batch->idx.named.grpc_status->md); + } else { + *status = GRPC_STATUS_UNKNOWN; + } } GRPC_ERROR_UNREF(error); } -- cgit v1.2.3