From 3c77a3887a06a8eb79ead685450e3b4127d345a0 Mon Sep 17 00:00:00 2001 From: zhoulin xie Date: Sun, 24 Feb 2019 15:16:49 +0800 Subject: [PATCH 001/176] Fix some misspells in doc Signed-off-by: zhoulin xie --- doc/interop-test-descriptions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/interop-test-descriptions.md b/doc/interop-test-descriptions.md index 208af424298..141b5ccc293 100755 --- a/doc/interop-test-descriptions.md +++ b/doc/interop-test-descriptions.md @@ -1135,7 +1135,7 @@ responses, it closes with OK. ### Echo Status [Echo Status]: #echo-status When the client sends a response_status in the request payload, the server closes -the stream with the status code and messsage contained within said response_status. +the stream with the status code and message contained within said response_status. The server will not process any further messages on the stream sent by the client. This can be used by clients to verify correct handling of different status codes and associated status messages end-to-end. @@ -1152,7 +1152,7 @@ key and the corresponding value back to the client as trailing metadata. [Observe ResponseParameters.interval_us]: #observe-responseparametersinterval_us In StreamingOutputCall and FullDuplexCall, server delays sending a -StreamingOutputCallResponse by the ResponseParameters's `interval_us` for that +StreamingOutputCallResponse by the ResponseParameters' `interval_us` for that particular response, relative to the last response sent. That is, `interval_us` acts like a sleep *before* sending the response and accumulates from one response to the next. From 4778d42cb5f59f9a5a9dc8cf725146165dad65f9 Mon Sep 17 00:00:00 2001 From: Kim Bao Long Date: Mon, 25 Feb 2019 13:51:18 +0700 Subject: [PATCH 002/176] Replacing 'HTTP' by 'HTTPS' for securing links Currently, when we access **github.com** with **HTTP**, it is redirected to **HTTPS** automatically. So this commit aims to replace **http://github.com** by **https://github.com** for security. Co-Authored-By: Nguyen Phuong An Signed-off-by: Kim Bao Long --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3a4c1f17d1..b9d564ade8a 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ Libraries in different languages may be in various states of development. We are | Language | Source repo | |-------------------------|------------------------------------------------------| -| Java | [grpc-java](http://github.com/grpc/grpc-java) | -| Go | [grpc-go](http://github.com/grpc/grpc-go) | +| Java | [grpc-java](https://github.com/grpc/grpc-java) | +| Go | [grpc-go](https://github.com/grpc/grpc-go) | | NodeJS | [grpc-node](https://github.com/grpc/grpc-node) | | WebJS | [grpc-web](https://github.com/grpc/grpc-web) | | Dart | [grpc-dart](https://github.com/grpc/grpc-dart) | From 036cdc661647f7c24c95b1c53a1a684b3537fa50 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Sat, 15 Jun 2019 22:19:03 +0800 Subject: [PATCH 003/176] Properly detect C++ exception for MSVC Inspired from protobuf https://github.com/protocolbuffers/protobuf/blob/77f03d932a35e8aa0a98c0c728ad3f5aacfe30ce/src/google/protobuf/stubs/common.h#L50 --- include/grpc/impl/codegen/port_platform.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d7294d59d41..591385eb705 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -618,10 +618,14 @@ typedef unsigned __int64 uint64_t; /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */ #ifndef GRPC_ALLOW_EXCEPTIONS -/* If not already set, set to 1 on Windows (style guide standard) but to - * 0 on non-Windows platforms unless the compiler defines __EXCEPTIONS */ #ifdef GPR_WINDOWS +#if defined(_MSC_VER) && defined(_CPPUNWIND) #define GRPC_ALLOW_EXCEPTIONS 1 +#elif defined(__EXCEPTIONS) +#define GRPC_ALLOW_EXCEPTIONS 1 +#else +#define GRPC_ALLOW_EXCEPTIONS 0 +#endif #else /* GPR_WINDOWS */ #ifdef __EXCEPTIONS #define GRPC_ALLOW_EXCEPTIONS 1 From 9e65a8876290bdd782e197fe8b98c35530c90427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Mon, 15 Jul 2019 16:11:35 +0200 Subject: [PATCH 004/176] Fixed "implicitly-declared operator=" error from gcc 9 --- include/grpcpp/impl/codegen/call_op_set.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 84d1407cbe2..814cf29f913 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -88,6 +88,9 @@ class WriteOptions { WriteOptions(const WriteOptions& other) : flags_(other.flags_), last_message_(other.last_message_) {} + /// Default assignment operator + WriteOptions& operator=(const WriteOptions& other) = default; + /// Clear all flags. inline void Clear() { flags_ = 0; } From 46dddacdf302188ae5f029b471697fcd20c9a1ac Mon Sep 17 00:00:00 2001 From: Christian Maurer Date: Thu, 18 Jul 2019 13:11:18 +0200 Subject: [PATCH 005/176] remove all unused-parameter warnings --- .../impl/codegen/async_generic_service.h | 2 +- .../grpcpp/impl/codegen/async_stream_impl.h | 6 +- .../impl/codegen/async_unary_call_impl.h | 8 +- include/grpcpp/impl/codegen/call_op_set.h | 35 ++--- include/grpcpp/impl/codegen/callback_common.h | 4 +- .../grpcpp/impl/codegen/channel_interface.h | 8 +- .../impl/codegen/client_callback_impl.h | 44 +++---- .../grpcpp/impl/codegen/interceptor_common.h | 4 +- .../grpcpp/impl/codegen/method_handler_impl.h | 8 +- .../grpcpp/impl/codegen/rpc_service_method.h | 4 +- .../impl/codegen/server_callback_impl.h | 25 ++-- .../grpcpp/impl/codegen/server_interface.h | 2 +- include/grpcpp/impl/codegen/time.h | 2 +- include/grpcpp/impl/server_builder_plugin.h | 4 +- include/grpcpp/security/credentials_impl.h | 4 +- include/grpcpp/server_impl.h | 8 +- .../grpcpp/support/channel_arguments_impl.h | 2 +- src/compiler/cpp_generator.cc | 85 +++++++------ test/cpp/codegen/compiler_test_golden | 120 +++++++++--------- 19 files changed, 191 insertions(+), 184 deletions(-) diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index 7c720ce3c23..c7dd5f7d24a 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -100,7 +100,7 @@ class ServerGenericBidiReactor /// Similar to ServerBidiReactor::OnStarted except for argument type. /// /// \param[in] context The context object associated with this RPC. - virtual void OnStarted(GenericServerContext* context) {} + virtual void OnStarted(GenericServerContext* /*context*/) {} private: void OnStarted(::grpc_impl::ServerContext* ctx) final { diff --git a/include/grpcpp/impl/codegen/async_stream_impl.h b/include/grpcpp/impl/codegen/async_stream_impl.h index 633a3d5dd00..4b94c470a52 100644 --- a/include/grpcpp/impl/codegen/async_stream_impl.h +++ b/include/grpcpp/impl/codegen/async_stream_impl.h @@ -197,7 +197,7 @@ template class ClientAsyncReader final : public ClientAsyncReaderInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncReader)); } @@ -346,7 +346,7 @@ template class ClientAsyncWriter final : public ClientAsyncWriterInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncWriter)); } @@ -514,7 +514,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncReaderWriterInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncReaderWriter)); } diff --git a/include/grpcpp/impl/codegen/async_unary_call_impl.h b/include/grpcpp/impl/codegen/async_unary_call_impl.h index ff8bf15602b..e885a077031 100644 --- a/include/grpcpp/impl/codegen/async_unary_call_impl.h +++ b/include/grpcpp/impl/codegen/async_unary_call_impl.h @@ -96,7 +96,7 @@ class ClientAsyncResponseReader final : public ClientAsyncResponseReaderInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncResponseReader)); } @@ -178,7 +178,7 @@ class ClientAsyncResponseReader final // disable operator new static void* operator new(std::size_t size); - static void* operator new(std::size_t size, void* p) { return p; } + static void* operator new(std::size_t /*size*/, void* p) { return p; } ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, ::grpc::internal::CallOpSendMessage, @@ -303,12 +303,12 @@ namespace std { template class default_delete<::grpc_impl::ClientAsyncResponseReader> { public: - void operator()(void* p) {} + void operator()(void* /*p*/) {} }; template class default_delete<::grpc_impl::ClientAsyncResponseReaderInterface> { public: - void operator()(void* p) {} + void operator()(void* /*p*/) {} }; } // namespace std diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 84d1407cbe2..c062963a13a 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -206,13 +206,14 @@ namespace internal { template class CallNoOp { protected: - void AddOp(grpc_op* ops, size_t* nops) {} - void FinishOp(bool* status) {} + void AddOp(grpc_op* /*ops*/, size_t* /*nops*/) {} + void FinishOp(bool* /*status*/) {} void SetInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + } }; class CallOpSendInitialMetadata { @@ -252,7 +253,7 @@ class CallOpSendInitialMetadata { maybe_compression_level_.level; } } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (!send_ || hijacked_) return; g_core_codegen_interface->gpr_free(initial_metadata_); send_ = false; @@ -267,9 +268,9 @@ class CallOpSendInitialMetadata { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -363,7 +364,7 @@ class CallOpSendMessage { nullptr); } - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -605,7 +606,7 @@ class CallOpClientSendClose { op->flags = 0; op->reserved = NULL; } - void FinishOp(bool* status) { send_ = false; } + void FinishOp(bool* /*status*/) { send_ = false; } void SetInterceptionHookPoint( InterceptorBatchMethodsImpl* interceptor_methods) { @@ -615,9 +616,9 @@ class CallOpClientSendClose { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -658,7 +659,7 @@ class CallOpServerSendStatus { op->reserved = NULL; } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (!send_status_available_ || hijacked_) return; g_core_codegen_interface->gpr_free(trailing_metadata_); send_status_available_ = false; @@ -675,9 +676,9 @@ class CallOpServerSendStatus { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -712,7 +713,7 @@ class CallOpRecvInitialMetadata { op->reserved = NULL; } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (metadata_map_ == nullptr || hijacked_) return; } @@ -766,7 +767,7 @@ class CallOpClientRecvStatus { op->reserved = NULL; } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (recv_status_ == nullptr || hijacked_) return; grpc::string binary_error_details = metadata_map_->GetBinaryErrorDetails(); *recv_status_ = diff --git a/include/grpcpp/impl/codegen/callback_common.h b/include/grpcpp/impl/codegen/callback_common.h index 6170170b978..5adf4596c85 100644 --- a/include/grpcpp/impl/codegen/callback_common.h +++ b/include/grpcpp/impl/codegen/callback_common.h @@ -69,7 +69,7 @@ class CallbackWithStatusTag : public grpc_experimental_completion_queue_functor { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(CallbackWithStatusTag)); } @@ -133,7 +133,7 @@ class CallbackWithSuccessTag : public grpc_experimental_completion_queue_functor { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(CallbackWithSuccessTag)); } diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index dd2fe8d687a..06d96abeca4 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -149,10 +149,10 @@ class ChannelInterface { // Returns an empty Call object (rather than being pure) since this is a new // method and adding a new pure method to an interface would be a breaking // change (even though this is private and non-API) - virtual internal::Call CreateCallInternal(const internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - ::grpc_impl::CompletionQueue* cq, - size_t interceptor_pos) { + virtual internal::Call CreateCallInternal( + const internal::RpcMethod& /*method*/, + ::grpc_impl::ClientContext* /*context*/, + ::grpc_impl::CompletionQueue* /*cq*/, size_t /*interceptor_pos*/) { return internal::Call(); } diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h index 81847bc9e04..37746ef5ce4 100644 --- a/include/grpcpp/impl/codegen/client_callback_impl.h +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -272,7 +272,7 @@ class ClientBidiReactor { /// have completed and provides the RPC status outcome. /// /// \param[in] s The status outcome of this RPC - virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} /// Notifies the application that a read of initial metadata from the /// server is done. If the application chooses not to implement this method, @@ -281,19 +281,19 @@ class ClientBidiReactor { /// /// \param[in] ok Was the initial metadata read successfully? If false, no /// further read-side operation will succeed. - virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} /// Notifies the application that a StartRead operation completed. /// /// \param[in] ok Was it successful? If false, no further read-side operation /// will succeed. - virtual void OnReadDone(bool ok) {} + virtual void OnReadDone(bool /*ok*/) {} /// Notifies the application that a StartWrite operation completed. /// /// \param[in] ok Was it successful? If false, no further write-side operation /// will succeed. - virtual void OnWriteDone(bool ok) {} + virtual void OnWriteDone(bool /*ok*/) {} /// Notifies the application that a StartWritesDone operation completed. Note /// that this is only used on explicit StartWritesDone operations and not for @@ -301,7 +301,7 @@ class ClientBidiReactor { /// /// \param[in] ok Was it successful? If false, the application will later see /// the failure reflected as a bad status in OnDone. - virtual void OnWritesDoneDone(bool ok) {} + virtual void OnWritesDoneDone(bool /*ok*/) {} private: friend class ClientCallbackReaderWriter; @@ -325,9 +325,9 @@ class ClientReadReactor { void AddMultipleHolds(int holds) { reader_->AddHold(holds); } void RemoveHold() { reader_->RemoveHold(); } - virtual void OnDone(const ::grpc::Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + virtual void OnReadDone(bool /*ok*/) {} private: friend class ClientCallbackReader; @@ -358,10 +358,10 @@ class ClientWriteReactor { void AddMultipleHolds(int holds) { writer_->AddHold(holds); } void RemoveHold() { writer_->RemoveHold(); } - virtual void OnDone(const ::grpc::Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} - virtual void OnWritesDoneDone(bool ok) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + virtual void OnWriteDone(bool /*ok*/) {} + virtual void OnWritesDoneDone(bool /*ok*/) {} private: friend class ClientCallbackWriter; @@ -385,8 +385,8 @@ class ClientUnaryReactor { virtual ~ClientUnaryReactor() {} void StartCall() { call_->StartCall(); } - virtual void OnDone(const ::grpc::Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} private: friend class ClientCallbackUnary; @@ -416,7 +416,7 @@ class ClientCallbackReaderWriterImpl : public experimental::ClientCallbackReaderWriter { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackReaderWriterImpl)); } @@ -490,7 +490,7 @@ class ClientCallbackReaderWriterImpl call_.PerformOps(&writes_done_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); @@ -628,7 +628,7 @@ class ClientCallbackReaderImpl : public experimental::ClientCallbackReader { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackReaderImpl)); } @@ -682,7 +682,7 @@ class ClientCallbackReaderImpl call_.PerformOps(&read_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); @@ -768,7 +768,7 @@ class ClientCallbackWriterImpl : public experimental::ClientCallbackWriter { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackWriterImpl)); } @@ -830,7 +830,7 @@ class ClientCallbackWriterImpl call_.PerformOps(&writes_done_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); @@ -956,7 +956,7 @@ class ClientCallbackWriterFactory { class ClientCallbackUnaryImpl final : public experimental::ClientCallbackUnary { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackUnaryImpl)); } @@ -985,7 +985,7 @@ class ClientCallbackUnaryImpl final : public experimental::ClientCallbackUnary { start_ops_.set_core_cq_tag(&start_tag_); call_.PerformOps(&start_ops_); - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); diff --git a/include/grpcpp/impl/codegen/interceptor_common.h b/include/grpcpp/impl/codegen/interceptor_common.h index e7290aca838..01ffe19bc4a 100644 --- a/include/grpcpp/impl/codegen/interceptor_common.h +++ b/include/grpcpp/impl/codegen/interceptor_common.h @@ -465,7 +465,7 @@ class CancelInterceptorBatchMethods return nullptr; } - void ModifySendMessage(const void* message) override { + void ModifySendMessage(const void* /*message*/) override { GPR_CODEGEN_ASSERT( false && "It is illegal to call ModifySendMessage on a method which " @@ -486,7 +486,7 @@ class CancelInterceptorBatchMethods return Status(); } - void ModifySendStatus(const Status& status) override { + void ModifySendStatus(const Status& /*status*/) override { GPR_CODEGEN_ASSERT(false && "It is illegal to call ModifySendStatus on a method " "which has a Cancel notification"); diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 1903f898ba8..f18a56249a5 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -88,7 +88,7 @@ class RpcMethodHandler : public MethodHandler { } void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void** /*handler_data*/) final { ByteBuffer buf; buf.set_buffer(req); auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -193,7 +193,7 @@ class ServerStreamingHandler : public MethodHandler { } void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void** /*handler_data*/) final { ByteBuffer buf; buf.set_buffer(req); auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -328,8 +328,8 @@ class ErrorMethodHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + Status* /*status*/, void** /*handler_data*/) final { // We have to destroy any request payload if (req != nullptr) { g_core_codegen_interface->grpc_byte_buffer_destroy(req); diff --git a/include/grpcpp/impl/codegen/rpc_service_method.h b/include/grpcpp/impl/codegen/rpc_service_method.h index 0b16feed820..fb4c32659fc 100644 --- a/include/grpcpp/impl/codegen/rpc_service_method.h +++ b/include/grpcpp/impl/codegen/rpc_service_method.h @@ -76,8 +76,8 @@ class MethodHandler { a HandlerParameter and passed to RunHandler. It is illegal to access the pointer after calling RunHandler. Ownership of the deserialized request is retained by the handler. Returns nullptr if deserialization failed. */ - virtual void* Deserialize(grpc_call* call, grpc_byte_buffer* req, - Status* status, void** handler_data) { + virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + Status* /*status*/, void** /*handler_data*/) { GPR_CODEGEN_ASSERT(req == nullptr); return nullptr; } diff --git a/include/grpcpp/impl/codegen/server_callback_impl.h b/include/grpcpp/impl/codegen/server_callback_impl.h index 08ecdfd6497..052548c2236 100644 --- a/include/grpcpp/impl/codegen/server_callback_impl.h +++ b/include/grpcpp/impl/codegen/server_callback_impl.h @@ -314,7 +314,7 @@ class ServerBidiReactor : public internal::ServerReactor { /// is a result of the client calling StartCall(). /// /// \param[in] context The context object now associated with this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context) {} + virtual void OnStarted(::grpc_impl::ServerContext* /*context*/) {} /// Notifies the application that an explicit StartSendInitialMetadata /// operation completed. Not used when the sending of initial metadata @@ -322,20 +322,20 @@ class ServerBidiReactor : public internal::ServerReactor { /// /// \param[in] ok Was it successful? If false, no further write-side operation /// will succeed. - virtual void OnSendInitialMetadataDone(bool ok) {} + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} /// Notifies the application that a StartRead operation completed. /// /// \param[in] ok Was it successful? If false, no further read-side operation /// will succeed. - virtual void OnReadDone(bool ok) {} + virtual void OnReadDone(bool /*ok*/) {} /// Notifies the application that a StartWrite (or StartWriteLast) operation /// completed. /// /// \param[in] ok Was it successful? If false, no further write-side operation /// will succeed. - virtual void OnWriteDone(bool ok) {} + virtual void OnWriteDone(bool /*ok*/) {} /// Notifies the application that all operations associated with this RPC /// have completed. This is an override (from the internal base class) but not @@ -376,11 +376,12 @@ class ServerReadReactor : public internal::ServerReactor { /// /// \param[in] context The context object now associated with this RPC /// \param[in] resp The response object to be used by this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} + virtual void OnStarted(::grpc_impl::ServerContext* /*context*/, + Response* /*resp*/) {} /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + virtual void OnReadDone(bool /*ok*/) {} void OnDone() override {} void OnCancel() override {} @@ -423,12 +424,12 @@ class ServerWriteReactor : public internal::ServerReactor { /// /// \param[in] context The context object now associated with this RPC /// \param[in] req The request object sent by the client - virtual void OnStarted(::grpc_impl::ServerContext* context, - const Request* req) {} + virtual void OnStarted(::grpc_impl::ServerContext* /*context*/, + const Request* /*req*/) {} /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + virtual void OnWriteDone(bool /*ok*/) {} void OnDone() override {} void OnCancel() override {} @@ -849,7 +850,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { } void* Deserialize(grpc_call* call, grpc_byte_buffer* req, - ::grpc::Status* status, void** handler_data) final { + ::grpc::Status* status, void** /*handler_data*/) final { ::grpc::ByteBuffer buf; buf.set_buffer(req); auto* request = diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index a375d3c0b4c..eb44b632ca0 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -130,7 +130,7 @@ class ServerInterface : public internal::CallHook { virtual ~experimental_registration_interface() {} /// May not be abstract since this is a post-1.0 API addition virtual void RegisterCallbackGenericService( - experimental::CallbackGenericService* service) {} + experimental::CallbackGenericService* /*service*/) {} }; /// NOTE: The function experimental_registration() is not stable public API. diff --git a/include/grpcpp/impl/codegen/time.h b/include/grpcpp/impl/codegen/time.h index c32f2544fa9..b3521722e9e 100644 --- a/include/grpcpp/impl/codegen/time.h +++ b/include/grpcpp/impl/codegen/time.h @@ -39,7 +39,7 @@ namespace grpc { template class TimePoint { public: - TimePoint(const T& time) { you_need_a_specialization_of_TimePoint(); } + TimePoint(const T& /*time*/) { you_need_a_specialization_of_TimePoint(); } gpr_timespec raw_time() { gpr_timespec t; return t; diff --git a/include/grpcpp/impl/server_builder_plugin.h b/include/grpcpp/impl/server_builder_plugin.h index 349995c8c1c..203e5465bc3 100644 --- a/include/grpcpp/impl/server_builder_plugin.h +++ b/include/grpcpp/impl/server_builder_plugin.h @@ -42,7 +42,7 @@ class ServerBuilderPlugin { /// UpdateServerBuilder will be called at an early stage in /// ServerBuilder::BuildAndStart(), right after the ServerBuilderOptions have /// done their updates. - virtual void UpdateServerBuilder(grpc_impl::ServerBuilder* builder) {} + virtual void UpdateServerBuilder(grpc_impl::ServerBuilder* /*builder*/) {} /// InitServer will be called in ServerBuilder::BuildAndStart(), after the /// Server instance is created. @@ -57,7 +57,7 @@ class ServerBuilderPlugin { /// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(), /// before the Server instance is created. - virtual void UpdateChannelArguments(ChannelArguments* args) {} + virtual void UpdateChannelArguments(ChannelArguments* /*args*/) {} virtual bool has_sync_methods() const { return false; } virtual bool has_async_methods() const { return false; } diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index bd79f30ae12..05a74fef0e0 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -95,10 +95,10 @@ class ChannelCredentials : private grpc::GrpcLibraryCodegen { // This function should have been a pure virtual function, but it is // implemented as a virtual function so that it does not break API. virtual std::shared_ptr CreateChannelWithInterceptors( - const grpc::string& target, const ChannelArguments& args, + const grpc::string& /*target*/, const ChannelArguments& /*args*/, std::vector> - interceptor_creators) { + /*interceptor_creators*/) { return nullptr; } }; diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 52988b50288..390def53719 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -81,16 +81,16 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { public: virtual ~GlobalCallbacks() {} /// Called before server is created. - virtual void UpdateArguments(ChannelArguments* args) {} + virtual void UpdateArguments(ChannelArguments* /*args*/) {} /// Called before application callback for each synchronous server request virtual void PreSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called after application callback for each synchronous server request virtual void PostSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called before server is started. - virtual void PreServerStart(Server* server) {} + virtual void PreServerStart(Server* /*server*/) {} /// Called after a server port is added. - virtual void AddPort(Server* server, const grpc::string& addr, - grpc::ServerCredentials* creds, int port) {} + virtual void AddPort(Server* /*server*/, const grpc::string& /*addr*/, + grpc::ServerCredentials* /*creds*/, int /*port*/) {} }; /// Set the global callback object. Can only be called once per application. /// Does not take ownership of callbacks, and expects the pointed to object diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index ac3b6c4a7e2..ca3188a9e75 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -132,7 +132,7 @@ class ChannelArguments { /// Default pointer argument operations. struct PointerVtableMembers { static void* Copy(void* in) { return in; } - static void Destroy(void* in) {} + static void Destroy(void* /*in*/) {} static int Compare(void* a, void* b) { if (a < b) return -1; if (a > b) return 1; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 044647d9a81..a253df8f1bb 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -794,8 +794,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -815,9 +815,9 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -837,8 +837,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -860,8 +860,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -896,7 +896,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, "class WithAsyncMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -923,16 +924,16 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); printer->Print( *vars, "virtual void $Method$(" - "::grpc::ServerContext* context, const $RealRequest$* request, " - "$RealResponse$* response, " + "::grpc::ServerContext* /*context*/, const $RealRequest$* /*request*/, " + "$RealResponse$* /*response*/, " "::grpc::experimental::ServerCallbackRpcController* " "controller) { controller->Finish(::grpc::Status(" "::grpc::StatusCode::UNIMPLEMENTED, \"\")); }\n"); @@ -941,9 +942,9 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -958,8 +959,8 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -975,8 +976,8 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1006,7 +1007,8 @@ void PrintHeaderServerMethodCallback( "class ExperimentalWithCallbackMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, "ExperimentalWithCallbackMethod_$Method$() {\n"); @@ -1080,7 +1082,8 @@ void PrintHeaderServerMethodRawCallback( "BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, "ExperimentalWithRawCallbackMethod_$Method$() {\n"); @@ -1143,7 +1146,7 @@ void PrintHeaderServerMethodStreamedUnary( "public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1164,8 +1167,8 @@ void PrintHeaderServerMethodStreamedUnary( *vars, "// disable regular version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1194,7 +1197,7 @@ void PrintHeaderServerMethodSplitStreaming( "public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1216,8 +1219,8 @@ void PrintHeaderServerMethodSplitStreaming( *vars, "// disable regular version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1245,7 +1248,8 @@ void PrintHeaderServerMethodGeneric( "class WithGenericMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -1261,8 +1265,8 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1271,9 +1275,9 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1282,8 +1286,8 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1293,8 +1297,8 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1318,7 +1322,8 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 34fb5bfb53f..56ee741e0b2 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -252,7 +252,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA1() { ::grpc::Service::MarkMethodAsync(0); @@ -261,7 +261,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -272,7 +272,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA2() { ::grpc::Service::MarkMethodAsync(1); @@ -281,7 +281,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -292,7 +292,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA3() { ::grpc::Service::MarkMethodAsync(2); @@ -301,7 +301,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -312,7 +312,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA4() { ::grpc::Service::MarkMethodAsync(3); @@ -321,7 +321,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -333,7 +333,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -355,16 +355,16 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; template class ExperimentalWithCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodCallback(1, @@ -375,7 +375,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -386,7 +386,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodCallback(2, @@ -397,7 +397,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -408,7 +408,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodCallback(3, @@ -419,7 +419,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -431,7 +431,7 @@ class ServiceA final { template class WithGenericMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA1() { ::grpc::Service::MarkMethodGeneric(0); @@ -440,7 +440,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -448,7 +448,7 @@ class ServiceA final { template class WithGenericMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA2() { ::grpc::Service::MarkMethodGeneric(1); @@ -457,7 +457,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -465,7 +465,7 @@ class ServiceA final { template class WithGenericMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA3() { ::grpc::Service::MarkMethodGeneric(2); @@ -474,7 +474,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -482,7 +482,7 @@ class ServiceA final { template class WithGenericMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA4() { ::grpc::Service::MarkMethodGeneric(3); @@ -491,7 +491,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -499,7 +499,7 @@ class ServiceA final { template class WithRawMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA1() { ::grpc::Service::MarkMethodRaw(0); @@ -508,7 +508,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -519,7 +519,7 @@ class ServiceA final { template class WithRawMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA2() { ::grpc::Service::MarkMethodRaw(1); @@ -528,7 +528,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -539,7 +539,7 @@ class ServiceA final { template class WithRawMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA3() { ::grpc::Service::MarkMethodRaw(2); @@ -548,7 +548,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -559,7 +559,7 @@ class ServiceA final { template class WithRawMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA4() { ::grpc::Service::MarkMethodRaw(3); @@ -568,7 +568,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -579,7 +579,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, @@ -595,16 +595,16 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodA1(::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; template class ExperimentalWithRawCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodRawCallback(1, @@ -615,7 +615,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -626,7 +626,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodRawCallback(2, @@ -637,7 +637,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -648,7 +648,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodRawCallback(3, @@ -659,7 +659,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -670,7 +670,7 @@ class ServiceA final { template class WithStreamedUnaryMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_MethodA1() { ::grpc::Service::MarkMethodStreamed(0, @@ -680,7 +680,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -691,7 +691,7 @@ class ServiceA final { template class WithSplitStreamingMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithSplitStreamingMethod_MethodA3() { ::grpc::Service::MarkMethodStreamed(2, @@ -701,7 +701,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -790,7 +790,7 @@ class ServiceB final { template class WithAsyncMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodB1() { ::grpc::Service::MarkMethodAsync(0); @@ -799,7 +799,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -811,7 +811,7 @@ class ServiceB final { template class ExperimentalWithCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -833,17 +833,17 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; typedef ExperimentalWithCallbackMethod_MethodB1 ExperimentalCallbackService; template class WithGenericMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodB1() { ::grpc::Service::MarkMethodGeneric(0); @@ -852,7 +852,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -860,7 +860,7 @@ class ServiceB final { template class WithRawMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodB1() { ::grpc::Service::MarkMethodRaw(0); @@ -869,7 +869,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -880,7 +880,7 @@ class ServiceB final { template class ExperimentalWithRawCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, @@ -896,16 +896,16 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodB1(::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; template class WithStreamedUnaryMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_MethodB1() { ::grpc::Service::MarkMethodStreamed(0, @@ -915,7 +915,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } From 07c4b1e0bb3726ae0d22ded27aaefe82060195bf Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 1 Aug 2019 17:48:31 -0700 Subject: [PATCH 006/176] Bump version to v1.23.0-pre1 --- BUILD | 2 +- build.yaml | 2 +- doc/g_stands_for.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index 6b51f07b82f..c708318ecbf 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gangnam" core_version = "7.0.0" -version = "1.23.0-dev" +version = "1.23.0-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 999c761056f..1ba055c65dd 100644 --- a/build.yaml +++ b/build.yaml @@ -15,7 +15,7 @@ settings: core_version: 7.0.0 csharp_major_version: 2 g_stands_for: gangnam - version: 1.23.0-dev + version: 1.23.0-pre1 filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index fe1cbc90005..373357ab8a6 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -22,4 +22,4 @@ - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) - 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) -- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/master) +- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/v1.23.x) From d030df29518fe15d8b247aa7ce248b0bef77d631 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 1 Aug 2019 17:48:59 -0700 Subject: [PATCH 007/176] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12b2707f951..6a5b4b5cd8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.23.0-dev") +set(PACKAGE_VERSION "1.23.0-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 0107f145204..d4d82581cef 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.23.0-dev -CSHARP_VERSION = 2.23.0-dev +CPP_VERSION = 1.23.0-pre1 +CSHARP_VERSION = 2.23.0-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 56d6f5b3edb..304ae372101 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.23.0-dev' - version = '0.0.9-dev' + # version = '1.23.0-pre1' + version = '0.0.9-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.23.0-dev' + grpc_version = '1.23.0-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6325348602e..d3a82b572dc 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2c0441ba95c..c90445baae2 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 12a8728ac34..87bd9e7c481 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index bbfd08f9774..dc05dc86ba2 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index cb221ff932d..7d2cb708925 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.23.0dev - 1.23.0dev + 1.23.0RC1 + 1.23.0RC1 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 7fb7823c9f2..751cbfa1c22 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.23.0-dev"; } +grpc::string Version() { return "1.23.0-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index d84da7c9e2f..ca9e88f268d 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.23.0-dev"; + public const string CurrentVersion = "2.23.0-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 4f100873bc7..00ff3ccb780 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.23.0-dev + 2.23.0-pre1 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index f29bd98b5a2..1906f266e20 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.23.0-dev +set VERSION=2.23.0-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index dc1f8b2c090..6dc9d4a3f13 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.23.0-dev' + v = '1.23.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 939078def22..98b4ef0dc12 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.23.0-dev' + v = '1.23.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 3b248db0148..bf467558d31 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 231ba1a9a9f..f5d7ec747af 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index bb707f50a9f..038ca5c1b25 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.23.0dev" +#define PHP_GRPC_VERSION "1.23.0RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index d2f8be43f34..d8f04ec88f3 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.23.0.dev0""" +__version__ = """1.23.0rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 548d2810b5b..2215172be39 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index f7029fff484..d7b9e92800b 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index d66daa473ed..04a5cd79401 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 97213872a91..8f47ca23c9b 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 31921b4cc90..42aad42fa57 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 5c8926cb6c8..71930c6730f 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index a1fc87448a1..aab9f1b57ab 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 051bc067e55..fa31c144282 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.23.0.dev' + VERSION = '1.23.0.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e66a4a799fd..e5e7a16717c 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.23.0.dev' + VERSION = '1.23.0.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 127d3c1f9bc..2b4e8218b50 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index e85ae495546..d508459f0fd 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-dev +PROJECT_NUMBER = 1.23.0-pre1 # 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 diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 96da09eefc6..ec0c30b0e79 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-dev +PROJECT_NUMBER = 1.23.0-pre1 # 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 From 8c99479bc7bc90177357376207a9056857b4d7ce Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Aug 2019 16:38:15 -0700 Subject: [PATCH 008/176] move ChannelExtensions to Grpc.Core.Api --- .../Interceptors/ChannelExtensions.cs | 12 ++++++------ src/csharp/Grpc.Core/ForwardedTypes.cs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/Interceptors/ChannelExtensions.cs (87%) diff --git a/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs b/src/csharp/Grpc.Core.Api/Interceptors/ChannelExtensions.cs similarity index 87% rename from src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs rename to src/csharp/Grpc.Core.Api/Interceptors/ChannelExtensions.cs index c7d0c2472a1..fe3b516857e 100644 --- a/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs +++ b/src/csharp/Grpc.Core.Api/Interceptors/ChannelExtensions.cs @@ -38,9 +38,9 @@ namespace Grpc.Core.Interceptors /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that /// in this case, the last interceptor added will be the first to take control. /// - public static CallInvoker Intercept(this Channel channel, Interceptor interceptor) + public static CallInvoker Intercept(this ChannelBase channel, Interceptor interceptor) { - return new DefaultCallInvoker(channel).Intercept(interceptor); + return channel.CreateCallInvoker().Intercept(interceptor); } /// @@ -59,9 +59,9 @@ namespace Grpc.Core.Interceptors /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that /// in this case, the last interceptor added will be the first to take control. /// - public static CallInvoker Intercept(this Channel channel, params Interceptor[] interceptors) + public static CallInvoker Intercept(this ChannelBase channel, params Interceptor[] interceptors) { - return new DefaultCallInvoker(channel).Intercept(interceptors); + return channel.CreateCallInvoker().Intercept(interceptors); } /// @@ -79,9 +79,9 @@ namespace Grpc.Core.Interceptors /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that /// in this case, the last interceptor added will be the first to take control. /// - public static CallInvoker Intercept(this Channel channel, Func interceptor) + public static CallInvoker Intercept(this ChannelBase channel, Func interceptor) { - return new DefaultCallInvoker(channel).Intercept(interceptor); + return channel.CreateCallInvoker().Intercept(interceptor); } } } diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index 4394a7c907c..eaf974c3356 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -38,6 +38,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(CallInvoker))] [assembly:TypeForwardedToAttribute(typeof(CallInvokerExtensions))] [assembly:TypeForwardedToAttribute(typeof(CallOptions))] +[assembly:TypeForwardedToAttribute(typeof(ChannelExtensions))] [assembly:TypeForwardedToAttribute(typeof(ClientBase))] [assembly:TypeForwardedToAttribute(typeof(ClientBase<>))] [assembly:TypeForwardedToAttribute(typeof(ChannelCredentials))] From 33b8b3f998a469dd38b6774399d717393c1a4841 Mon Sep 17 00:00:00 2001 From: Christian Maurer Date: Tue, 6 Aug 2019 12:48:37 +0200 Subject: [PATCH 009/176] Removed whitespace before asterisk --- src/compiler/cpp_generator.cc | 8 +++--- test/cpp/codegen/compiler_test_golden | 40 +++++++++++++-------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index a253df8f1bb..d4545ad49a8 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -896,7 +896,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, "class WithAsyncMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1007,7 +1007,7 @@ void PrintHeaderServerMethodCallback( "class ExperimentalWithCallbackMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1082,7 +1082,7 @@ void PrintHeaderServerMethodRawCallback( "BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1322,7 +1322,7 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 56ee741e0b2..4f97076e39a 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -252,7 +252,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA1() { ::grpc::Service::MarkMethodAsync(0); @@ -272,7 +272,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA2() { ::grpc::Service::MarkMethodAsync(1); @@ -292,7 +292,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA3() { ::grpc::Service::MarkMethodAsync(2); @@ -312,7 +312,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA4() { ::grpc::Service::MarkMethodAsync(3); @@ -333,7 +333,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -364,7 +364,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodCallback(1, @@ -386,7 +386,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodCallback(2, @@ -408,7 +408,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodCallback(3, @@ -499,7 +499,7 @@ class ServiceA final { template class WithRawMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA1() { ::grpc::Service::MarkMethodRaw(0); @@ -519,7 +519,7 @@ class ServiceA final { template class WithRawMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA2() { ::grpc::Service::MarkMethodRaw(1); @@ -539,7 +539,7 @@ class ServiceA final { template class WithRawMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA3() { ::grpc::Service::MarkMethodRaw(2); @@ -559,7 +559,7 @@ class ServiceA final { template class WithRawMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA4() { ::grpc::Service::MarkMethodRaw(3); @@ -579,7 +579,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, @@ -604,7 +604,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodRawCallback(1, @@ -626,7 +626,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodRawCallback(2, @@ -648,7 +648,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodRawCallback(3, @@ -790,7 +790,7 @@ class ServiceB final { template class WithAsyncMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodB1() { ::grpc::Service::MarkMethodAsync(0); @@ -811,7 +811,7 @@ class ServiceB final { template class ExperimentalWithCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -860,7 +860,7 @@ class ServiceB final { template class WithRawMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodB1() { ::grpc::Service::MarkMethodRaw(0); @@ -880,7 +880,7 @@ class ServiceB final { template class ExperimentalWithRawCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, From b99d3e146497b06e556317c1aa6a43f364ae2772 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 6 Aug 2019 14:10:14 -0700 Subject: [PATCH 010/176] Remove redundant and problematic memset --- src/core/ext/filters/client_idle/client_idle_filter.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/ext/filters/client_idle/client_idle_filter.cc b/src/core/ext/filters/client_idle/client_idle_filter.cc index d2b23a9d20f..542fad05b80 100644 --- a/src/core/ext/filters/client_idle/client_idle_filter.cc +++ b/src/core/ext/filters/client_idle/client_idle_filter.cc @@ -193,8 +193,6 @@ void ChannelData::EnterIdle() { GRPC_IDLE_FILTER_LOG("the channel will enter IDLE"); // Hold a ref to the channel stack for the transport op. GRPC_CHANNEL_STACK_REF(channel_stack_, "idle transport op"); - // Initialize the transport op. - memset(&idle_transport_op_, 0, sizeof(idle_transport_op_)); idle_transport_op_.disconnect_with_error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"), GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE); From 988ca514b9cd87c7010bfafe329b9495603e9b7b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 29 Jul 2019 18:53:00 -0700 Subject: [PATCH 011/176] serialization to IBufferWriter attempt 1 --- .../Grpc.Core.Api/SerializationContext.cs | 18 +++++ .../Internal/DefaultSerializationContext.cs | 74 +++++++++++++++++-- .../Internal/NativeMethods.Generated.cs | 33 +++++++++ src/csharp/ext/grpc_csharp_ext.c | 61 +++++++++++++++ .../runtimes/grpc_csharp_ext_dummy_stubs.c | 12 +++ .../Grpc.Core/Internal/native_methods.include | 3 + 6 files changed, 196 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/SerializationContext.cs b/src/csharp/Grpc.Core.Api/SerializationContext.cs index 9aef2adbcd5..79107040411 100644 --- a/src/csharp/Grpc.Core.Api/SerializationContext.cs +++ b/src/csharp/Grpc.Core.Api/SerializationContext.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Buffers; namespace Grpc.Core { @@ -35,5 +36,22 @@ namespace Grpc.Core { throw new NotImplementedException(); } + + /// + /// Expose serializer as buffer writer + /// + public virtual IBufferWriter GetBufferWriter() + { + throw new NotImplementedException(); + } + + /// + /// Complete the payload written so far. + /// + public virtual void Complete() + { + throw new NotImplementedException(); + + } } } diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index cceb194879e..9098850a52e 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -17,6 +17,8 @@ #endregion using Grpc.Core.Utils; +using System; +using System.Buffers; using System.Threading; namespace Grpc.Core.Internal @@ -27,7 +29,8 @@ namespace Grpc.Core.Internal new ThreadLocal(() => new DefaultSerializationContext(), false); bool isComplete; - byte[] payload; + //byte[] payload; + NativeBufferWriter bufferWriter; public DefaultSerializationContext() { @@ -38,18 +41,48 @@ namespace Grpc.Core.Internal { GrpcPreconditions.CheckState(!isComplete); this.isComplete = true; - this.payload = payload; + + GetBufferWriter(); + var destSpan = bufferWriter.GetSpan(payload.Length); + payload.AsSpan().CopyTo(destSpan); + bufferWriter.Advance(payload.Length); + bufferWriter.Complete(); + //this.payload = payload; + } + + /// + /// Expose serializer as buffer writer + /// + public override IBufferWriter GetBufferWriter() + { + if (bufferWriter == null) + { + // TODO: avoid allocation.. + bufferWriter = new NativeBufferWriter(); + } + return bufferWriter; + } + + /// + /// Complete the payload written so far. + /// + public override void Complete() + { + GrpcPreconditions.CheckState(!isComplete); + bufferWriter.Complete(); + this.isComplete = true; } - internal byte[] GetPayload() + internal SliceBufferSafeHandle GetPayload() { - return this.payload; + return bufferWriter.GetSliceBuffer(); } public void Reset() { this.isComplete = false; - this.payload = null; + //this.payload = null; + this.bufferWriter = null; } public static DefaultSerializationContext GetInitializedThreadLocal() @@ -58,5 +91,36 @@ namespace Grpc.Core.Internal instance.Reset(); return instance; } + + private class NativeBufferWriter : IBufferWriter + { + private SliceBufferSafeHandle sliceBuffer = SliceBufferSafeHandle.Create(); + + public void Advance(int count) + { + sliceBuffer.Advance(count); + } + + public Memory GetMemory(int sizeHint = 0) + { + // TODO: implement + throw new NotImplementedException(); + } + + public Span GetSpan(int sizeHint = 0) + { + return sliceBuffer.GetSpan(sizeHint); + } + + public void Complete() + { + sliceBuffer.Complete(); + } + + public SliceBufferSafeHandle GetSliceBuffer() + { + return sliceBuffer; + } + } } } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index ca3dfe97ce1..b23170376d4 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -122,6 +122,9 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_auth_context_property_iterator_delegate grpcsharp_auth_context_property_iterator; public readonly Delegates.grpcsharp_auth_property_iterator_next_delegate grpcsharp_auth_property_iterator_next; public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release; + public readonly Delegates.grpcsharp_slice_buffer_create_delegate grpcsharp_slice_buffer_create; + public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; + public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; public readonly Delegates.gprsharp_inf_past_delegate gprsharp_inf_past; @@ -224,6 +227,9 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_property_iterator = GetMethodDelegate(library); this.grpcsharp_auth_property_iterator_next = GetMethodDelegate(library); this.grpcsharp_auth_context_release = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_create = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_destroy = GetMethodDelegate(library); this.gprsharp_now = GetMethodDelegate(library); this.gprsharp_inf_future = GetMethodDelegate(library); this.gprsharp_inf_past = GetMethodDelegate(library); @@ -325,6 +331,9 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_property_iterator = DllImportsFromStaticLib.grpcsharp_auth_context_property_iterator; this.grpcsharp_auth_property_iterator_next = DllImportsFromStaticLib.grpcsharp_auth_property_iterator_next; this.grpcsharp_auth_context_release = DllImportsFromStaticLib.grpcsharp_auth_context_release; + this.grpcsharp_slice_buffer_create = DllImportsFromStaticLib.grpcsharp_slice_buffer_create; + this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; this.gprsharp_inf_past = DllImportsFromStaticLib.gprsharp_inf_past; @@ -426,6 +435,9 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_property_iterator = DllImportsFromSharedLib.grpcsharp_auth_context_property_iterator; this.grpcsharp_auth_property_iterator_next = DllImportsFromSharedLib.grpcsharp_auth_property_iterator_next; this.grpcsharp_auth_context_release = DllImportsFromSharedLib.grpcsharp_auth_context_release; + this.grpcsharp_slice_buffer_create = DllImportsFromSharedLib.grpcsharp_slice_buffer_create; + this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; this.gprsharp_inf_past = DllImportsFromSharedLib.gprsharp_inf_past; @@ -530,6 +542,9 @@ namespace Grpc.Core.Internal public delegate AuthContextSafeHandle.NativeAuthPropertyIterator grpcsharp_auth_context_property_iterator_delegate(AuthContextSafeHandle authContext); public delegate IntPtr grpcsharp_auth_property_iterator_next_delegate(ref AuthContextSafeHandle.NativeAuthPropertyIterator iterator); // returns const auth_property* public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext); + public delegate SliceBufferSafeHandle grpcsharp_slice_buffer_create_delegate(); + public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_past_delegate(ClockType clockType); @@ -812,6 +827,15 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_auth_context_release(IntPtr authContext); + [DllImport(ImportName)] + public static extern SliceBufferSafeHandle grpcsharp_slice_buffer_create(); + + [DllImport(ImportName)] + public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); + [DllImport(ImportName)] public static extern Timespec gprsharp_now(ClockType clockType); @@ -1111,6 +1135,15 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_auth_context_release(IntPtr authContext); + [DllImport(ImportName)] + public static extern SliceBufferSafeHandle grpcsharp_slice_buffer_create(); + + [DllImport(ImportName)] + public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); + [DllImport(ImportName)] public static extern Timespec gprsharp_now(ClockType clockType); diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 02e219ead87..e271494c942 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1182,6 +1182,67 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) { typedef void(GPR_CALLTYPE* test_callback_funcptr)(int32_t success); +/* Slice buffer functionality */ +GPR_EXPORT grpc_slice_buffer* GPR_CALLTYPE +grpcsharp_slice_buffer_create() { + grpc_slice_buffer* slice_buffer = (grpc_slice_buffer*)gpr_malloc(sizeof(grpc_slice_buffer)); + grpc_slice_buffer_init(slice_buffer); + return slice_buffer; +} + +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) { + grpc_slice_buffer_destroy(buffer); + gpr_free(buffer); +} + +GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE +grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { + grpc_byte_buffer* bb = + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + memset(bb, 0, sizeof(grpc_byte_buffer)); + bb->type = GRPC_BB_RAW; + bb->data.raw.compression = GRPC_COMPRESS_NONE; + bb->data.raw.slice_buffer = *slice_buffer; + // TODO: just use move slice_buffer... + + // we transferred the ownership of members from the slice buffer to the + // the internals of byte buffer, so we just overwrite the original slice buffer with + // default values. + grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. + return bb; +} + +GPR_EXPORT void* GPR_CALLTYPE +grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, + size_t requested_tail_space) { + + // TODO: what if available_tail_space == requested_tail_space == 0 + + if (available_tail_space >= requested_tail_space) + { + // TODO: should this be allowed at all? + grpc_slice_buffer garbage; + grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, &garbage); + grpc_slice_buffer_reset_and_unref(&garbage); + } + else + { + if (available_tail_space > 0) + { + grpc_slice_buffer garbage; + grpc_slice_buffer_trim_end(buffer, available_tail_space, &garbage); + grpc_slice_buffer_reset_and_unref(&garbage); + } + + grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); + grpc_slice_buffer_add(buffer, new_slice); + } + + grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); + return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; +} + /* Version info */ GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_version_string() { return grpc_version_string(); diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index 8ff26e4ca4d..bc312bc6daf 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -374,6 +374,18 @@ void grpcsharp_auth_context_release() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_slice_buffer_create() { + fprintf(stderr, "Should never reach here"); + abort(); +} +void grpcsharp_slice_buffer_adjust_tail_space() { + fprintf(stderr, "Should never reach here"); + abort(); +} +void grpcsharp_slice_buffer_destroy() { + fprintf(stderr, "Should never reach here"); + abort(); +} void gprsharp_now() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index ed7c93a7479..d8f94744723 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -88,6 +88,9 @@ native_method_signatures = [ 'AuthContextSafeHandle.NativeAuthPropertyIterator grpcsharp_auth_context_property_iterator(AuthContextSafeHandle authContext)', 'IntPtr grpcsharp_auth_property_iterator_next(ref AuthContextSafeHandle.NativeAuthPropertyIterator iterator) // returns const auth_property*', 'void grpcsharp_auth_context_release(IntPtr authContext)', + 'SliceBufferSafeHandle grpcsharp_slice_buffer_create()', + 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', + 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)', 'Timespec gprsharp_inf_past(ClockType clockType)', From 36e46234f72f0de72602931a546b8f8495072ddd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 29 Jul 2019 19:57:08 -0700 Subject: [PATCH 012/176] IBufferWriter: tests now passing with a hack --- .../Grpc.Core/Internal/AsyncCallBase.cs | 2 +- .../Internal/NativeMethods.Generated.cs | 22 +++++++++++++++++++ src/csharp/ext/grpc_csharp_ext.c | 17 ++++++++++++++ .../runtimes/grpc_csharp_ext_dummy_stubs.c | 8 +++++++ .../Grpc.Core/Internal/native_methods.include | 2 ++ 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index ac1f9066516..23cb5ccffc7 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -220,7 +220,7 @@ namespace Grpc.Core.Internal { context = DefaultSerializationContext.GetInitializedThreadLocal(); serializer(msg, context); - return context.GetPayload(); + return context.GetPayload().GetPayload(); } finally { diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index b23170376d4..dcb0f84649c 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -124,6 +124,8 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release; public readonly Delegates.grpcsharp_slice_buffer_create_delegate grpcsharp_slice_buffer_create; public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; + public readonly Delegates.grpcsharp_slice_buffer_slice_count_delegate grpcsharp_slice_buffer_slice_count; + public readonly Delegates.grpcsharp_slice_buffer_slice_peek_delegate grpcsharp_slice_buffer_slice_peek; public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; @@ -229,6 +231,8 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_release = GetMethodDelegate(library); this.grpcsharp_slice_buffer_create = GetMethodDelegate(library); this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_slice_count = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_slice_peek = GetMethodDelegate(library); this.grpcsharp_slice_buffer_destroy = GetMethodDelegate(library); this.gprsharp_now = GetMethodDelegate(library); this.gprsharp_inf_future = GetMethodDelegate(library); @@ -333,6 +337,8 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_release = DllImportsFromStaticLib.grpcsharp_auth_context_release; this.grpcsharp_slice_buffer_create = DllImportsFromStaticLib.grpcsharp_slice_buffer_create; this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_slice_count = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_count; + this.grpcsharp_slice_buffer_slice_peek = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_peek; this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; @@ -437,6 +443,8 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_release = DllImportsFromSharedLib.grpcsharp_auth_context_release; this.grpcsharp_slice_buffer_create = DllImportsFromSharedLib.grpcsharp_slice_buffer_create; this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_slice_count = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_count; + this.grpcsharp_slice_buffer_slice_peek = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_peek; this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; @@ -544,6 +552,8 @@ namespace Grpc.Core.Internal public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext); public delegate SliceBufferSafeHandle grpcsharp_slice_buffer_create_delegate(); public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + public delegate UIntPtr grpcsharp_slice_buffer_slice_count_delegate(SliceBufferSafeHandle sliceBuffer); + public delegate void grpcsharp_slice_buffer_slice_peek_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); @@ -833,6 +843,12 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + [DllImport(ImportName)] + public static extern UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); @@ -1141,6 +1157,12 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + [DllImport(ImportName)] + public static extern UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index e271494c942..1f115b1caf2 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1196,6 +1196,19 @@ grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) { gpr_free(buffer); } +GPR_EXPORT size_t GPR_CALLTYPE +grpcsharp_slice_buffer_slice_count(grpc_slice_buffer* buffer) { + return buffer->count; +} + +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_t* slice_len, uint8_t** slice_data_ptr) { + GPR_ASSERT(buffer->count > index); + grpc_slice* slice_ptr = &buffer->slices[index]; + *slice_len = GRPC_SLICE_LENGTH(*slice_ptr); + *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); +} + GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = @@ -1217,6 +1230,10 @@ GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { + if (available_tail_space == 0 && requested_tail_space == 0) + { + return NULL; + } // TODO: what if available_tail_space == requested_tail_space == 0 if (available_tail_space >= requested_tail_space) diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index bc312bc6daf..9007d7f3ad0 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -382,6 +382,14 @@ void grpcsharp_slice_buffer_adjust_tail_space() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_slice_buffer_slice_count() { + fprintf(stderr, "Should never reach here"); + abort(); +} +void grpcsharp_slice_buffer_slice_peek() { + fprintf(stderr, "Should never reach here"); + abort(); +} void grpcsharp_slice_buffer_destroy() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index d8f94744723..055af4a7a27 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -90,6 +90,8 @@ native_method_signatures = [ 'void grpcsharp_auth_context_release(IntPtr authContext)', 'SliceBufferSafeHandle grpcsharp_slice_buffer_create()', 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', + 'UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer)', + 'void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr)', 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)', From 1154c2d17ea07d0b95dd6f4ac8776c4f3841570e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 29 Jul 2019 19:58:36 -0700 Subject: [PATCH 013/176] fixup: add SliceBufferSafeHandle --- .../Internal/SliceBufferSafeHandle.cs | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs new file mode 100644 index 00000000000..ef9e7fbce37 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -0,0 +1,122 @@ +#region Copyright notice and license + +// Copyright 2019 The 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. + +#endregion + +using System; +using System.Runtime.InteropServices; +using Grpc.Core; +using Grpc.Core.Logging; +using Grpc.Core.Utils; + +namespace Grpc.Core.Internal +{ + /// + /// grpc_slice_buffer + /// + internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid + { + static readonly NativeMethods Native = NativeMethods.Get(); + static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); + + private IntPtr tailSpacePtr; + private UIntPtr tailSpaceLen; + + + private SliceBufferSafeHandle() + { + } + + public static SliceBufferSafeHandle Create() + { + return Native.grpcsharp_slice_buffer_create(); + } + + public IntPtr Handle + { + get + { + return handle; + } + } + + public void Advance(int count) + { + GrpcPreconditions.CheckArgument(count >= 0); + GrpcPreconditions.CheckArgument(tailSpacePtr != IntPtr.Zero || count == 0); + GrpcPreconditions.CheckArgument(tailSpaceLen.ToUInt64() >= (ulong)count); + tailSpaceLen = new UIntPtr(tailSpaceLen.ToUInt64() - (ulong)count); + tailSpacePtr += count; + } + + public unsafe Span GetSpan(int sizeHint) + { + GrpcPreconditions.CheckArgument(sizeHint >= 0); + if (tailSpaceLen.ToUInt64() < (ulong) sizeHint) + { + // TODO: should we ignore the hint sometimes when + // available tail space is close enough to the sizeHint? + AdjustTailSpace(sizeHint); + } + return new Span(tailSpacePtr.ToPointer(), (int) tailSpaceLen.ToUInt64()); + } + + public void Complete() + { + AdjustTailSpace(0); + } + + public byte[] GetPayload() + { + ulong sliceCount = Native.grpcsharp_slice_buffer_slice_count(this).ToUInt64(); + + Slice[] slices = new Slice[sliceCount]; + int totalLen = 0; + for (int i = 0; i < (int) sliceCount; i++) + { + Native.grpcsharp_slice_buffer_slice_peek(this, new UIntPtr((ulong) i), out UIntPtr sliceLen, out IntPtr dataPtr); + slices[i] = new Slice(dataPtr, (int) sliceLen.ToUInt64()); + totalLen += (int) sliceLen.ToUInt64(); + + } + var result = new byte[totalLen]; + int offset = 0; + for (int i = 0; i < (int) sliceCount; i++) + { + slices[i].ToSpanUnsafe().CopyTo(result.AsSpan(offset, slices[i].Length)); + offset += slices[i].Length; + } + GrpcPreconditions.CheckState(totalLen == offset); + return result; + } + // TODO: converting contents to byte[] + + // Gets data of server_rpc_new completion. + private void AdjustTailSpace(int requestedSize) + { + GrpcPreconditions.CheckArgument(requestedSize >= 0); + var requestedTailSpaceLen = new UIntPtr((ulong) requestedSize); + tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, tailSpaceLen, requestedTailSpaceLen); + tailSpaceLen = requestedTailSpaceLen; + } + + protected override bool ReleaseHandle() + { + Native.grpcsharp_slice_buffer_destroy(handle); + return true; + } + } +} From b9183153211d109ba57598812ee8d90a12236443 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 16:16:56 -0700 Subject: [PATCH 014/176] a bit of refactor --- src/csharp/Grpc.Core/Internal/AsyncCallBase.cs | 2 +- src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 23cb5ccffc7..b26b7921955 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -220,7 +220,7 @@ namespace Grpc.Core.Internal { context = DefaultSerializationContext.GetInitializedThreadLocal(); serializer(msg, context); - return context.GetPayload().GetPayload(); + return context.GetPayload().ToByteArray(); } finally { diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index ef9e7fbce37..5b540c69d44 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -79,7 +79,9 @@ namespace Grpc.Core.Internal AdjustTailSpace(0); } - public byte[] GetPayload() + // copies the content of the slice buffer to a newly allocated byte array + // due to its overhead, this method should only be used for testing. + public byte[] ToByteArray() { ulong sliceCount = Native.grpcsharp_slice_buffer_slice_count(this).ToUInt64(); @@ -102,7 +104,6 @@ namespace Grpc.Core.Internal GrpcPreconditions.CheckState(totalLen == offset); return result; } - // TODO: converting contents to byte[] // Gets data of server_rpc_new completion. private void AdjustTailSpace(int requestedSize) @@ -112,7 +113,6 @@ namespace Grpc.Core.Internal tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, tailSpaceLen, requestedTailSpaceLen); tailSpaceLen = requestedTailSpaceLen; } - protected override bool ReleaseHandle() { Native.grpcsharp_slice_buffer_destroy(handle); From 31eff3e679f12f3db28c80527f7f376c1beb8efd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 17:16:49 -0700 Subject: [PATCH 015/176] stuff builds but tests crash --- .../Internal/FakeNativeCall.cs | 10 +-- src/csharp/Grpc.Core/Internal/AsyncCall.cs | 6 +- .../Grpc.Core/Internal/AsyncCallBase.cs | 6 +- .../Grpc.Core/Internal/AsyncCallServer.cs | 2 +- .../Grpc.Core/Internal/CallSafeHandle.cs | 26 +++---- src/csharp/Grpc.Core/Internal/INativeCall.cs | 10 +-- .../Internal/NativeMethods.Generated.cs | 30 ++++----- .../SendMessageBenchmark.cs | 5 +- .../UnaryCallOverheadBenchmark.cs | 4 +- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 2 +- src/csharp/ext/grpc_csharp_ext.c | 67 ++++++++++--------- .../Grpc.Core/Internal/native_methods.include | 10 +-- 12 files changed, 91 insertions(+), 87 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs index ef67918dabb..c16b55ca941 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs @@ -101,13 +101,13 @@ namespace Grpc.Core.Internal.Tests return "PEER"; } - public void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(IUnaryResponseClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { StartCallMaybeFail(); UnaryResponseClientCallback = callback; } - public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(BatchContextSafeHandle ctx, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { StartCallMaybeFail(); throw new NotImplementedException(); @@ -119,7 +119,7 @@ namespace Grpc.Core.Internal.Tests UnaryResponseClientCallback = callback; } - public void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartServerStreaming(IReceivedStatusOnClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { StartCallMaybeFail(); ReceivedStatusOnClientCallback = callback; @@ -146,7 +146,7 @@ namespace Grpc.Core.Internal.Tests SendCompletionCallback = callback; } - public void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) + public void StartSendMessage(ISendCompletionCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) { SendCompletionCallback = callback; } @@ -157,7 +157,7 @@ namespace Grpc.Core.Internal.Tests } public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, - byte[] optionalPayload, WriteFlags writeFlags) + SliceBufferSafeHandle payload, WriteFlags writeFlags) { SendStatusFromServerCallback = callback; } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index ce3508d398e..aefa58a0cee 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -95,7 +95,7 @@ namespace Grpc.Core.Internal readingDone = true; } - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { @@ -160,7 +160,7 @@ namespace Grpc.Core.Internal halfcloseRequested = true; readingDone = true; - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); unaryResponseTcs = new TaskCompletionSource(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) @@ -235,7 +235,7 @@ namespace Grpc.Core.Internal halfcloseRequested = true; - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); streamingResponseCallFinishedTcs = new TaskCompletionSource(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index b26b7921955..07f9ecf23e9 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -115,7 +115,7 @@ namespace Grpc.Core.Internal /// protected Task SendMessageInternalAsync(TWrite msg, WriteFlags writeFlags) { - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); lock (myLock) { @@ -213,14 +213,14 @@ namespace Grpc.Core.Internal /// protected abstract Task CheckSendAllowedOrEarlyResult(); - protected byte[] UnsafeSerialize(TWrite msg) + protected SliceBufferSafeHandle UnsafeSerialize(TWrite msg) { DefaultSerializationContext context = null; try { context = DefaultSerializationContext.GetInitializedThreadLocal(); serializer(msg, context); - return context.GetPayload().ToByteArray(); + return context.GetPayload(); } finally { diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index 0bf1fb3b7dd..e1c3a215422 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -129,7 +129,7 @@ namespace Grpc.Core.Internal /// public Task SendStatusFromServerAsync(Status status, Metadata trailers, ResponseWithFlags? optionalWrite) { - byte[] payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null; + var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null; var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); lock (myLock) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 2e637c9704b..6208f45a00a 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -67,19 +67,19 @@ namespace Grpc.Core.Internal Native.grpcsharp_call_set_credentials(this, credentials).CheckOk(); } - public void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(IUnaryResponseClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IUnaryResponseClientCallback, callback); - Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags) + Native.grpcsharp_call_start_unary(this, ctx, payload, writeFlags, metadataArray, callFlags) .CheckOk(); } } - public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(BatchContextSafeHandle ctx, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { - Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags) + Native.grpcsharp_call_start_unary(this, ctx, payload, writeFlags, metadataArray, callFlags) .CheckOk(); } @@ -92,12 +92,12 @@ namespace Grpc.Core.Internal } } - public void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartServerStreaming(IReceivedStatusOnClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedStatusOnClientCallback, callback); - Native.grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags).CheckOk(); + Native.grpcsharp_call_start_server_streaming(this, ctx, payload, writeFlags, metadataArray, callFlags).CheckOk(); } } @@ -110,12 +110,12 @@ namespace Grpc.Core.Internal } } - public void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) + public void StartSendMessage(ISendCompletionCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendCompletionCallback, callback); - Native.grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata ? 1 : 0).CheckOk(); + Native.grpcsharp_call_send_message(this, ctx, payload, writeFlags, sendEmptyInitialMetadata ? 1 : 0).CheckOk(); } } @@ -129,13 +129,13 @@ namespace Grpc.Core.Internal } public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, - byte[] optionalPayload, WriteFlags writeFlags) + SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags) { + // TODO: optionalPayload == null -> pass null SliceBufferSafeHandle using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); - var optionalPayloadLength = optionalPayload != null ? new UIntPtr((ulong)optionalPayload.Length) : UIntPtr.Zero; - + const int MaxStackAllocBytes = 256; int maxBytes = MarshalUtils.GetMaxByteCountUTF8(status.Detail); if (maxBytes > MaxStackAllocBytes) @@ -156,7 +156,7 @@ namespace Grpc.Core.Internal byte* ptr = stackalloc byte[maxBytes]; int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, new IntPtr(ptr), new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + optionalPayload, writeFlags).CheckOk(); } else { // for larger status (rare), rent a buffer from the pool and @@ -168,7 +168,7 @@ namespace Grpc.Core.Internal { int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, new IntPtr(ptr), new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + optionalPayload, writeFlags).CheckOk(); } } finally diff --git a/src/csharp/Grpc.Core/Internal/INativeCall.cs b/src/csharp/Grpc.Core/Internal/INativeCall.cs index 98117c6988a..70e98bfc9af 100644 --- a/src/csharp/Grpc.Core/Internal/INativeCall.cs +++ b/src/csharp/Grpc.Core/Internal/INativeCall.cs @@ -67,13 +67,13 @@ namespace Grpc.Core.Internal string GetPeer(); - void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); + void StartUnary(IUnaryResponseClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); + void StartUnary(BatchContextSafeHandle ctx, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); + void StartServerStreaming(IReceivedStatusOnClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); @@ -83,11 +83,11 @@ namespace Grpc.Core.Internal void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray); - void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata); + void StartSendMessage(ISendCompletionCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata); void StartSendCloseFromClient(ISendCompletionCallback callback); - void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags); + void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags); void StartServerSide(IReceivedCloseOnServerCallback callback); } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index dcb0f84649c..d492d0c9525 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -487,13 +487,13 @@ namespace Grpc.Core.Internal public delegate void grpcsharp_call_credentials_release_delegate(IntPtr credentials); public delegate CallError grpcsharp_call_cancel_delegate(CallSafeHandle call); public delegate CallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description); - public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); - public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); - public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); + public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata); public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); - public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags); public delegate CallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -563,7 +563,7 @@ namespace Grpc.Core.Internal public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback); public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr); public delegate void grpcsharp_test_override_method_delegate(string methodName, string variant); - public delegate CallError grpcsharp_test_call_start_unary_echo_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public delegate CallError grpcsharp_test_call_start_unary_echo_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } /// @@ -649,25 +649,25 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); + public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata); [DllImport(ImportName)] public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -877,7 +877,7 @@ namespace Grpc.Core.Internal public static extern void grpcsharp_test_override_method(string methodName, string variant); [DllImport(ImportName)] - public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } /// @@ -963,25 +963,25 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); + public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata); [DllImport(ImportName)] public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -1191,7 +1191,7 @@ namespace Grpc.Core.Internal public static extern void grpcsharp_test_override_method(string methodName, string variant); [DllImport(ImportName)] - public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } } } diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index 8496813efb0..76c59ca579c 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -50,11 +50,14 @@ namespace Grpc.Microbenchmarks var call = CreateFakeCall(cq); var sendCompletionCallback = new NopSendCompletionCallback(); - var payload = new byte[PayloadSize]; + var payload = SliceBufferSafeHandle.Create(); + payload.GetSpan(PayloadSize); + payload.Advance(PayloadSize); var writeFlags = default(WriteFlags); for (int i = 0; i < Iterations; i++) { + // TODO: sending for the first time actually steals the slices... call.StartSendMessage(sendCompletionCallback, payload, writeFlags, false); var callback = completionRegistry.Extract(completionRegistry.LastRegisteredKey); callback.OnComplete(true); diff --git a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs index 8448f03dd62..177a49d9223 100644 --- a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs @@ -70,8 +70,8 @@ namespace Grpc.Microbenchmarks var native = NativeMethods.Get(); // replace the implementation of a native method with a fake - NativeMethods.Delegates.grpcsharp_call_start_unary_delegate fakeCallStartUnary = (CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags) => { - return native.grpcsharp_test_call_start_unary_echo(call, ctx, sendBuffer, sendBufferLen, writeFlags, metadataArray, metadataFlags); + NativeMethods.Delegates.grpcsharp_call_start_unary_delegate fakeCallStartUnary = (CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags) => { + return native.grpcsharp_test_call_start_unary_echo(call, ctx, sendBuffer, writeFlags, metadataArray, metadataFlags); }; native.GetType().GetField(nameof(native.grpcsharp_call_start_unary)).SetValue(native, fakeCallStartUnary); diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index a59afa19118..e5bac1967c9 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -61,7 +61,7 @@ namespace Grpc.Microbenchmarks var native = NativeMethods.Get(); // nop the native-call via reflection - NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { + NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags) => { completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go return CallError.OK; }; diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 1f115b1caf2..abddbc0e7a1 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -41,10 +41,26 @@ #define GPR_CALLTYPE #endif -grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) { - grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); - grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1); - grpc_slice_unref(slice); +//grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) { +// grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); +// grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1); +// grpc_slice_unref(slice); +// return bb; +//} + +static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { + grpc_byte_buffer* bb = + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + memset(bb, 0, sizeof(grpc_byte_buffer)); + bb->type = GRPC_BB_RAW; + bb->data.raw.compression = GRPC_COMPRESS_NONE; + bb->data.raw.slice_buffer = *slice_buffer; + // TODO: just use move slice_buffer... + + // we transferred the ownership of members from the slice buffer to the + // the internals of byte buffer, so we just overwrite the original slice buffer with + // default values. + grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. return bb; } @@ -582,8 +598,8 @@ static grpc_call_error grpcsharp_call_start_batch(grpc_call* call, } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[6]; @@ -598,7 +614,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len); + ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -635,12 +651,12 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( /* Only for testing. Shortcircuits the unary call logic and only echoes the message as if it was received from the server */ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_test_call_start_unary_echo( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { // prepare as if we were performing a normal RPC. grpc_byte_buffer* send_message = - string_to_byte_buffer(send_buffer, send_buffer_len); + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ctx->recv_message = send_message; // echo message sent by the client as if // received from server. @@ -693,8 +709,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; @@ -709,7 +725,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len); + ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -776,15 +792,15 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_message( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, 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); + ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[0].data.send_message.send_message = ctx->send_message; ops[0].flags = write_flags; ops[0].reserved = NULL; @@ -811,7 +827,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( grpc_call* call, grpcsharp_batch_context* ctx, grpc_status_code status_code, const char* status_details, size_t status_details_len, grpc_metadata_array* trailing_metadata, int32_t send_empty_initial_metadata, - const char* optional_send_buffer, size_t optional_send_buffer_len, + grpc_slice_buffer* optional_send_buffer, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[3]; @@ -833,7 +849,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( if (optional_send_buffer) { ops[nops].op = GRPC_OP_SEND_MESSAGE; ctx->send_message = - string_to_byte_buffer(optional_send_buffer, optional_send_buffer_len); + grpcsharp_create_byte_buffer_from_stolen_slices(optional_send_buffer); ops[nops].data.send_message.send_message = ctx->send_message; ops[nops].flags = write_flags; ops[nops].reserved = NULL; @@ -1209,22 +1225,7 @@ grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_ *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); } -GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE -grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { - grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); - memset(bb, 0, sizeof(grpc_byte_buffer)); - bb->type = GRPC_BB_RAW; - bb->data.raw.compression = GRPC_COMPRESS_NONE; - bb->data.raw.slice_buffer = *slice_buffer; - // TODO: just use move slice_buffer... - // we transferred the ownership of members from the slice buffer to the - // the internals of byte buffer, so we just overwrite the original slice buffer with - // default values. - grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. - return bb; -} GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index 055af4a7a27..4f5f61d332c 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -25,13 +25,13 @@ native_method_signatures = [ 'void grpcsharp_call_credentials_release(IntPtr credentials)', 'CallError grpcsharp_call_cancel(CallSafeHandle call)', 'CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description)', - 'CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', + 'CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', 'CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', - 'CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', + 'CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', 'CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', - 'CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata)', + 'CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata)', 'CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx)', - 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags)', + 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags)', 'CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx)', 'CallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call, BatchContextSafeHandle ctx)', 'CallError grpcsharp_call_start_serverside(CallSafeHandle call, BatchContextSafeHandle ctx)', @@ -101,7 +101,7 @@ native_method_signatures = [ 'CallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback)', 'IntPtr grpcsharp_test_nop(IntPtr ptr)', 'void grpcsharp_test_override_method(string methodName, string variant)', - 'CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', + 'CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', ] import re From 8ad2b146ed5caa995c89726de59c375935145cb4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 17:38:08 -0700 Subject: [PATCH 016/176] fix grpcsharp_create_byte_buffer_from_stolen_slices --- src/csharp/ext/grpc_csharp_ext.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index abddbc0e7a1..82fa81abf7d 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -41,26 +41,15 @@ #define GPR_CALLTYPE #endif -//grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) { -// grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); -// grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1); -// grpc_slice_unref(slice); -// return bb; -//} - static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); memset(bb, 0, sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; - bb->data.raw.slice_buffer = *slice_buffer; - // TODO: just use move slice_buffer... + grpc_slice_buffer_init(&bb->data.raw.slice_buffer); - // we transferred the ownership of members from the slice buffer to the - // the internals of byte buffer, so we just overwrite the original slice buffer with - // default values. - grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. + grpc_slice_buffer_swap(&bb->data.raw.slice_buffer, slice_buffer); return bb; } From 70c7aa162354188f25aa790bdc7a7443c00f2af1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 18:07:12 -0700 Subject: [PATCH 017/176] stuff now works --- src/csharp/Grpc.Core/Internal/CallSafeHandle.cs | 6 ++++++ src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 6208f45a00a..cfcab5dc692 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -132,6 +132,12 @@ namespace Grpc.Core.Internal SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags) { // TODO: optionalPayload == null -> pass null SliceBufferSafeHandle + // do this properly + if (optionalPayload == null) + { + optionalPayload = SliceBufferSafeHandle.NullInstance; + } + using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 5b540c69d44..5ea4432684c 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -32,6 +32,8 @@ namespace Grpc.Core.Internal static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); + public static readonly SliceBufferSafeHandle NullInstance = new SliceBufferSafeHandle(); + private IntPtr tailSpacePtr; private UIntPtr tailSpaceLen; From 1c177fff1e9cba4fc3632e12d39572a31fa2704f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 31 Jul 2019 16:22:50 -0700 Subject: [PATCH 018/176] refactoring and simplifications --- .../Internal/DefaultSerializationContext.cs | 51 ++++--------------- .../Internal/NativeMethods.Generated.cs | 11 ++++ .../Internal/SliceBufferSafeHandle.cs | 44 +++++++++++----- src/csharp/ext/grpc_csharp_ext.c | 7 ++- .../runtimes/grpc_csharp_ext_dummy_stubs.c | 4 ++ .../Grpc.Core/Internal/native_methods.include | 1 + 6 files changed, 63 insertions(+), 55 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index 9098850a52e..db5e78a608d 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -30,7 +30,7 @@ namespace Grpc.Core.Internal bool isComplete; //byte[] payload; - NativeBufferWriter bufferWriter; + SliceBufferSafeHandle sliceBuffer; public DefaultSerializationContext() { @@ -43,10 +43,10 @@ namespace Grpc.Core.Internal this.isComplete = true; GetBufferWriter(); - var destSpan = bufferWriter.GetSpan(payload.Length); + var destSpan = sliceBuffer.GetSpan(payload.Length); payload.AsSpan().CopyTo(destSpan); - bufferWriter.Advance(payload.Length); - bufferWriter.Complete(); + sliceBuffer.Advance(payload.Length); + sliceBuffer.Complete(); //this.payload = payload; } @@ -55,12 +55,12 @@ namespace Grpc.Core.Internal /// public override IBufferWriter GetBufferWriter() { - if (bufferWriter == null) + if (sliceBuffer == null) { // TODO: avoid allocation.. - bufferWriter = new NativeBufferWriter(); + sliceBuffer = SliceBufferSafeHandle.Create(); } - return bufferWriter; + return sliceBuffer; } /// @@ -69,20 +69,20 @@ namespace Grpc.Core.Internal public override void Complete() { GrpcPreconditions.CheckState(!isComplete); - bufferWriter.Complete(); + sliceBuffer.Complete(); this.isComplete = true; } internal SliceBufferSafeHandle GetPayload() { - return bufferWriter.GetSliceBuffer(); + return sliceBuffer; } public void Reset() { this.isComplete = false; //this.payload = null; - this.bufferWriter = null; + this.sliceBuffer = null; // reset instead... } public static DefaultSerializationContext GetInitializedThreadLocal() @@ -92,35 +92,6 @@ namespace Grpc.Core.Internal return instance; } - private class NativeBufferWriter : IBufferWriter - { - private SliceBufferSafeHandle sliceBuffer = SliceBufferSafeHandle.Create(); - - public void Advance(int count) - { - sliceBuffer.Advance(count); - } - - public Memory GetMemory(int sizeHint = 0) - { - // TODO: implement - throw new NotImplementedException(); - } - - public Span GetSpan(int sizeHint = 0) - { - return sliceBuffer.GetSpan(sizeHint); - } - - public void Complete() - { - sliceBuffer.Complete(); - } - - public SliceBufferSafeHandle GetSliceBuffer() - { - return sliceBuffer; - } - } + } } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index d492d0c9525..c724b30ca8f 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -126,6 +126,7 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; public readonly Delegates.grpcsharp_slice_buffer_slice_count_delegate grpcsharp_slice_buffer_slice_count; public readonly Delegates.grpcsharp_slice_buffer_slice_peek_delegate grpcsharp_slice_buffer_slice_peek; + public readonly Delegates.grpcsharp_slice_buffer_reset_and_unref_delegate grpcsharp_slice_buffer_reset_and_unref; public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; @@ -233,6 +234,7 @@ namespace Grpc.Core.Internal this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate(library); this.grpcsharp_slice_buffer_slice_count = GetMethodDelegate(library); this.grpcsharp_slice_buffer_slice_peek = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_reset_and_unref = GetMethodDelegate(library); this.grpcsharp_slice_buffer_destroy = GetMethodDelegate(library); this.gprsharp_now = GetMethodDelegate(library); this.gprsharp_inf_future = GetMethodDelegate(library); @@ -339,6 +341,7 @@ namespace Grpc.Core.Internal this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; this.grpcsharp_slice_buffer_slice_count = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_count; this.grpcsharp_slice_buffer_slice_peek = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_peek; + this.grpcsharp_slice_buffer_reset_and_unref = DllImportsFromStaticLib.grpcsharp_slice_buffer_reset_and_unref; this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; @@ -445,6 +448,7 @@ namespace Grpc.Core.Internal this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; this.grpcsharp_slice_buffer_slice_count = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_count; this.grpcsharp_slice_buffer_slice_peek = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_peek; + this.grpcsharp_slice_buffer_reset_and_unref = DllImportsFromSharedLib.grpcsharp_slice_buffer_reset_and_unref; this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; @@ -554,6 +558,7 @@ namespace Grpc.Core.Internal public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); public delegate UIntPtr grpcsharp_slice_buffer_slice_count_delegate(SliceBufferSafeHandle sliceBuffer); public delegate void grpcsharp_slice_buffer_slice_peek_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + public delegate void grpcsharp_slice_buffer_reset_and_unref_delegate(SliceBufferSafeHandle sliceBuffer); public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); @@ -849,6 +854,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_reset_and_unref(SliceBufferSafeHandle sliceBuffer); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); @@ -1163,6 +1171,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_reset_and_unref(SliceBufferSafeHandle sliceBuffer); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 5ea4432684c..76a97f4a0a2 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Buffers; using System.Runtime.InteropServices; using Grpc.Core; using Grpc.Core.Logging; @@ -25,9 +26,10 @@ using Grpc.Core.Utils; namespace Grpc.Core.Internal { /// - /// grpc_slice_buffer + /// Represents grpc_slice_buffer with some extra utility functions to allow + /// writing data to it using the IBufferWriter interface. /// - internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid + internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid, IBufferWriter { static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); @@ -35,8 +37,7 @@ namespace Grpc.Core.Internal public static readonly SliceBufferSafeHandle NullInstance = new SliceBufferSafeHandle(); private IntPtr tailSpacePtr; - private UIntPtr tailSpaceLen; - + private int tailSpaceLen; private SliceBufferSafeHandle() { @@ -59,21 +60,30 @@ namespace Grpc.Core.Internal { GrpcPreconditions.CheckArgument(count >= 0); GrpcPreconditions.CheckArgument(tailSpacePtr != IntPtr.Zero || count == 0); - GrpcPreconditions.CheckArgument(tailSpaceLen.ToUInt64() >= (ulong)count); - tailSpaceLen = new UIntPtr(tailSpaceLen.ToUInt64() - (ulong)count); + GrpcPreconditions.CheckArgument(tailSpaceLen >= count); + tailSpaceLen = tailSpaceLen - count; tailSpacePtr += count; } - public unsafe Span GetSpan(int sizeHint) + // provides access to the "tail space" of this buffer. + // Use GetSpan when possible for better efficiency. + public Memory GetMemory(int sizeHint = 0) + { + // TODO: implement + throw new NotImplementedException(); + } + + // provides access to the "tail space" of this buffer. + public unsafe Span GetSpan(int sizeHint = 0) { GrpcPreconditions.CheckArgument(sizeHint >= 0); - if (tailSpaceLen.ToUInt64() < (ulong) sizeHint) + if (tailSpaceLen < sizeHint) { // TODO: should we ignore the hint sometimes when // available tail space is close enough to the sizeHint? AdjustTailSpace(sizeHint); } - return new Span(tailSpacePtr.ToPointer(), (int) tailSpaceLen.ToUInt64()); + return new Span(tailSpacePtr.ToPointer(), tailSpaceLen); } public void Complete() @@ -81,8 +91,17 @@ namespace Grpc.Core.Internal AdjustTailSpace(0); } + // resets the data contained by this slice buffer + public void Reset() + { + // deletes all the data in the slice buffer + tailSpacePtr = IntPtr.Zero; + tailSpaceLen = 0; + Native.grpcsharp_slice_buffer_reset_and_unref(this); + } + // copies the content of the slice buffer to a newly allocated byte array - // due to its overhead, this method should only be used for testing. + // Note that this method has a relatively high overhead and should maily be used for testing. public byte[] ToByteArray() { ulong sliceCount = Native.grpcsharp_slice_buffer_slice_count(this).ToUInt64(); @@ -111,9 +130,8 @@ namespace Grpc.Core.Internal private void AdjustTailSpace(int requestedSize) { GrpcPreconditions.CheckArgument(requestedSize >= 0); - var requestedTailSpaceLen = new UIntPtr((ulong) requestedSize); - tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, tailSpaceLen, requestedTailSpaceLen); - tailSpaceLen = requestedTailSpaceLen; + tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, new UIntPtr((ulong) tailSpaceLen), new UIntPtr((ulong) requestedSize)); + tailSpaceLen = requestedSize; } protected override bool ReleaseHandle() { diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 82fa81abf7d..78027d270dc 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1195,6 +1195,11 @@ grpcsharp_slice_buffer_create() { return slice_buffer; } +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_slice_buffer_reset_and_unref(grpc_slice_buffer* buffer) { + grpc_slice_buffer_reset_and_unref(buffer); +} + GPR_EXPORT void GPR_CALLTYPE grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) { grpc_slice_buffer_destroy(buffer); @@ -1214,8 +1219,6 @@ grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_ *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); } - - GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index 9007d7f3ad0..58a7c58e91a 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -390,6 +390,10 @@ void grpcsharp_slice_buffer_slice_peek() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_slice_buffer_reset_and_unref() { + fprintf(stderr, "Should never reach here"); + abort(); +} void grpcsharp_slice_buffer_destroy() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index 4f5f61d332c..f2b3a165a3b 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -92,6 +92,7 @@ native_method_signatures = [ 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', 'UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer)', 'void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr)', + 'void grpcsharp_slice_buffer_reset_and_unref(SliceBufferSafeHandle sliceBuffer)', 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)', From aaddd42c00647a0fea619d7dfda090c038f6d7fa Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 31 Jul 2019 17:29:04 -0700 Subject: [PATCH 019/176] add serializationScope and refactoring for efficiency --- .../ContextualMarshallerTest.cs | 2 + src/csharp/Grpc.Core/Internal/AsyncCall.cs | 15 +++++-- .../Grpc.Core/Internal/AsyncCallBase.cs | 44 ++++++++----------- .../Grpc.Core/Internal/AsyncCallServer.cs | 39 ++++++++-------- .../Internal/DefaultSerializationContext.cs | 40 ++++++++++------- 5 files changed, 78 insertions(+), 62 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs index c3aee726f26..99f92e12628 100644 --- a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs @@ -52,6 +52,8 @@ namespace Grpc.Core.Tests } if (str == "SERIALIZE_TO_NULL") { + // TODO: test for not calling complete Complete() (that resulted in null payload before...) + // TODO: test for calling Complete(null byte array) return; } var bytes = System.Text.Encoding.UTF8.GetBytes(str); diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index aefa58a0cee..4111c5347ce 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -95,10 +95,10 @@ namespace Grpc.Core.Internal readingDone = true; } - var payload = UnsafeSerialize(msg); - + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? var ctx = details.Channel.Environment.BatchContextPool.Lease(); try { @@ -160,11 +160,14 @@ namespace Grpc.Core.Internal halfcloseRequested = true; readingDone = true; - var payload = UnsafeSerialize(msg); + //var payload = UnsafeSerialize(msg); unaryResponseTcs = new TaskCompletionSource(); + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); callStartedOk = true; } @@ -235,11 +238,15 @@ namespace Grpc.Core.Internal halfcloseRequested = true; - var payload = UnsafeSerialize(msg); + //var payload = UnsafeSerialize(msg); streamingResponseCallFinishedTcs = new TaskCompletionSource(); + + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); callStartedOk = true; } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 07f9ecf23e9..bd4b0d81832 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -115,23 +115,25 @@ namespace Grpc.Core.Internal /// protected Task SendMessageInternalAsync(TWrite msg, WriteFlags writeFlags) { - var payload = UnsafeSerialize(msg); - - lock (myLock) + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - GrpcPreconditions.CheckState(started); - var earlyResult = CheckSendAllowedOrEarlyResult(); - if (earlyResult != null) + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + lock (myLock) { - return earlyResult; - } + GrpcPreconditions.CheckState(started); + var earlyResult = CheckSendAllowedOrEarlyResult(); + if (earlyResult != null) + { + return earlyResult; + } - call.StartSendMessage(SendCompletionCallback, payload, writeFlags, !initialMetadataSent); + call.StartSendMessage(SendCompletionCallback, payload, writeFlags, !initialMetadataSent); - initialMetadataSent = true; - streamingWritesCounter++; - streamingWriteTcs = new TaskCompletionSource(); - return streamingWriteTcs.Task; + initialMetadataSent = true; + streamingWritesCounter++; + streamingWriteTcs = new TaskCompletionSource(); + return streamingWriteTcs.Task; + } } } @@ -213,19 +215,11 @@ namespace Grpc.Core.Internal /// protected abstract Task CheckSendAllowedOrEarlyResult(); - protected SliceBufferSafeHandle UnsafeSerialize(TWrite msg) + // runs the serializer, propagating any exceptions being thrown without modifying them + protected SliceBufferSafeHandle UnsafeSerialize(TWrite msg, DefaultSerializationContext context) { - DefaultSerializationContext context = null; - try - { - context = DefaultSerializationContext.GetInitializedThreadLocal(); - serializer(msg, context); - return context.GetPayload(); - } - finally - { - context?.Reset(); - } + serializer(msg, context); + return context.GetPayload(); } protected Exception TryDeserialize(IBufferReader reader, out TRead msg) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index e1c3a215422..e0bb41e15dc 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -129,28 +129,31 @@ namespace Grpc.Core.Internal /// public Task SendStatusFromServerAsync(Status status, Metadata trailers, ResponseWithFlags? optionalWrite) { - var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null; - var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); - - lock (myLock) + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - GrpcPreconditions.CheckState(started); - GrpcPreconditions.CheckState(!disposed); - GrpcPreconditions.CheckState(!halfcloseRequested, "Can only send status from server once."); + var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response, serializationScope.Context) : null; + var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); - using (var metadataArray = MetadataArraySafeHandle.Create(trailers)) - { - call.StartSendStatusFromServer(SendStatusFromServerCompletionCallback, status, metadataArray, !initialMetadataSent, - payload, writeFlags); - } - halfcloseRequested = true; - initialMetadataSent = true; - sendStatusFromServerTcs = new TaskCompletionSource(); - if (optionalWrite.HasValue) + lock (myLock) { - streamingWritesCounter++; + GrpcPreconditions.CheckState(started); + GrpcPreconditions.CheckState(!disposed); + GrpcPreconditions.CheckState(!halfcloseRequested, "Can only send status from server once."); + + using (var metadataArray = MetadataArraySafeHandle.Create(trailers)) + { + call.StartSendStatusFromServer(SendStatusFromServerCompletionCallback, status, metadataArray, !initialMetadataSent, + payload, writeFlags); + } + halfcloseRequested = true; + initialMetadataSent = true; + sendStatusFromServerTcs = new TaskCompletionSource(); + if (optionalWrite.HasValue) + { + streamingWritesCounter++; + } + return sendStatusFromServerTcs.Task; } - return sendStatusFromServerTcs.Task; } } diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index db5e78a608d..6bf9da56264 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -29,8 +29,7 @@ namespace Grpc.Core.Internal new ThreadLocal(() => new DefaultSerializationContext(), false); bool isComplete; - //byte[] payload; - SliceBufferSafeHandle sliceBuffer; + SliceBufferSafeHandle sliceBuffer = SliceBufferSafeHandle.Create(); public DefaultSerializationContext() { @@ -42,12 +41,10 @@ namespace Grpc.Core.Internal GrpcPreconditions.CheckState(!isComplete); this.isComplete = true; - GetBufferWriter(); var destSpan = sliceBuffer.GetSpan(payload.Length); payload.AsSpan().CopyTo(destSpan); sliceBuffer.Advance(payload.Length); sliceBuffer.Complete(); - //this.payload = payload; } /// @@ -55,11 +52,6 @@ namespace Grpc.Core.Internal /// public override IBufferWriter GetBufferWriter() { - if (sliceBuffer == null) - { - // TODO: avoid allocation.. - sliceBuffer = SliceBufferSafeHandle.Create(); - } return sliceBuffer; } @@ -81,17 +73,35 @@ namespace Grpc.Core.Internal public void Reset() { this.isComplete = false; - //this.payload = null; - this.sliceBuffer = null; // reset instead... + this.sliceBuffer.Reset(); } - public static DefaultSerializationContext GetInitializedThreadLocal() + // Get a cached thread local instance of deserialization context + // and wrap it in a disposable struct that allows easy resetting + // via "using" statement. + public static UsageScope GetInitializedThreadLocalScope() { var instance = threadLocalInstance.Value; - instance.Reset(); - return instance; + return new UsageScope(instance); } - + public struct UsageScope : IDisposable + { + readonly DefaultSerializationContext context; + + public UsageScope(DefaultSerializationContext context) + { + this.context = context; + } + + public DefaultSerializationContext Context => context; + + // TODO: add Serialize method... + + public void Dispose() + { + context.Reset(); + } + } } } From 74dcdbb3c39619c1a725dc9a7e62c2cb5b62eda4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 7 Aug 2019 12:57:38 -0700 Subject: [PATCH 020/176] fix adjust_tail_space --- src/csharp/ext/grpc_csharp_ext.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 78027d270dc..89391e67e15 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1223,32 +1223,30 @@ GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { - if (available_tail_space == 0 && requested_tail_space == 0) - { - return NULL; + if (available_tail_space == requested_tail_space) { + // nothing to do } - // TODO: what if available_tail_space == requested_tail_space == 0 - - if (available_tail_space >= requested_tail_space) + else if (available_tail_space >= requested_tail_space) { - // TODO: should this be allowed at all? - grpc_slice_buffer garbage; - grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, &garbage); - grpc_slice_buffer_reset_and_unref(&garbage); + grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, NULL); } else { if (available_tail_space > 0) { - grpc_slice_buffer garbage; - grpc_slice_buffer_trim_end(buffer, available_tail_space, &garbage); - grpc_slice_buffer_reset_and_unref(&garbage); + grpc_slice_buffer_trim_end(buffer, available_tail_space, NULL); } grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); - grpc_slice_buffer_add(buffer, new_slice); + // TODO: this always adds as a new slice entry into the sb, but it doesn't have the problem of + // sometimes splitting the continguous new_slice across two different slices (like grpc_slice_buffer_add would) + grpc_slice_buffer_add_indexed(buffer, new_slice); } + if (buffer->count == 0) + { + return NULL; + } grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; } From f32bd8b091669f2ce1056d2ddbae694dbb54cb18 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 7 Aug 2019 12:59:57 -0700 Subject: [PATCH 021/176] add default serialization context test --- .../DefaultSerializationContextTest.cs | 144 ++++++++++++++++++ src/csharp/tests.json | 1 + 2 files changed, 145 insertions(+) create mode 100644 src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs new file mode 100644 index 00000000000..4d09d80bb72 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -0,0 +1,144 @@ +#region Copyright notice and license + +// Copyright 2019 The 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. + +#endregion + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +namespace Grpc.Core.Internal.Tests +{ + public class DefaultSerializationContextTest + { + [TestCase] + public void CompleteAllowedOnlyOnce() + { + var context = new DefaultSerializationContext(); + var buffer = GetTestBuffer(10); + + context.Complete(buffer); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(buffer)); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } + + [TestCase] + public void CompleteAllowedOnlyOnce2() + { + var context = new DefaultSerializationContext(); + + context.Complete(); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(GetTestBuffer(10))); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void ByteArrayPayload(int payloadSize) + { + var context = new DefaultSerializationContext(); + var origPayload = GetTestBuffer(payloadSize); + + context.Complete(origPayload); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void BufferWriter_OneSegment(int payloadSize) + { + var context = new DefaultSerializationContext(); + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); + bufferWriter.Advance(payloadSize); + // TODO: test that call to Complete() is required. + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } + + [TestCase(1, 4)] // small slice size tests grpc_slice with inline data + [TestCase(10, 4)] + [TestCase(100, 4)] + [TestCase(1000, 4)] + [TestCase(1, 64)] // larger slice size tests allocated grpc_slices + [TestCase(10, 64)] + [TestCase(1000, 50)] + [TestCase(1000, 64)] + public void BufferWriter_MultipleSegments(int payloadSize, int maxSliceSize) + { + var context = new DefaultSerializationContext(); + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + for (int offset = 0; offset < payloadSize; offset += maxSliceSize) + { + var sliceSize = Math.Min(maxSliceSize, payloadSize - offset); + // we allocate last slice as too big intentionally to test that shrinking works + var dest = bufferWriter.GetSpan(maxSliceSize); + + origPayload.AsSpan(offset, sliceSize).CopyTo(dest); + bufferWriter.Advance(sliceSize); + } + context.Complete(); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + + context.GetPayload().Dispose(); // TODO: do it better.. (use the scope...) + } + + // AdjustTailSpace(0) if previous tail size is 0.... + + // test that context.Complete() call is required... + + // BufferWriter.GetMemory... (add refs to the original memory?) + + // TODO: set payload and then get IBufferWriter should throw? + + // TODO: test Reset()... + + // TODO: destroy SliceBufferSafeHandles... (use usagescope...) + + + + + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } + } +} diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 2eb786e0983..75bda4c25ea 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -9,6 +9,7 @@ "Grpc.Core.Internal.Tests.CompletionQueueSafeHandleTest", "Grpc.Core.Internal.Tests.DefaultDeserializationContextTest", "Grpc.Core.Internal.Tests.DefaultObjectPoolTest", + "Grpc.Core.Internal.Tests.DefaultSerializationContextTest", "Grpc.Core.Internal.Tests.FakeBufferReaderManagerTest", "Grpc.Core.Internal.Tests.MetadataArraySafeHandleTest", "Grpc.Core.Internal.Tests.ReusableSliceBufferTest", From d57dec1c7dc19a245ddc74971781b53610bda4cc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:03:18 -0700 Subject: [PATCH 022/176] improve DefaultSerializationContextTest --- .../DefaultSerializationContextTest.cs | 151 ++++++++++++------ 1 file changed, 104 insertions(+), 47 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs index 4d09d80bb72..aa7631587be 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -17,9 +17,6 @@ #endregion using System; -using System.Buffers; -using System.Collections.Generic; -using System.Runtime.InteropServices; using Grpc.Core; using Grpc.Core.Internal; using Grpc.Core.Utils; @@ -32,22 +29,28 @@ namespace Grpc.Core.Internal.Tests [TestCase] public void CompleteAllowedOnlyOnce() { - var context = new DefaultSerializationContext(); - var buffer = GetTestBuffer(10); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var buffer = GetTestBuffer(10); - context.Complete(buffer); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete(buffer)); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + context.Complete(buffer); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(buffer)); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } } [TestCase] public void CompleteAllowedOnlyOnce2() { - var context = new DefaultSerializationContext(); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; - context.Complete(); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete(GetTestBuffer(10))); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + context.Complete(); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(GetTestBuffer(10))); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } } [TestCase(0)] @@ -57,13 +60,16 @@ namespace Grpc.Core.Internal.Tests [TestCase(1000)] public void ByteArrayPayload(int payloadSize) { - var context = new DefaultSerializationContext(); - var origPayload = GetTestBuffer(payloadSize); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); - context.Complete(origPayload); + context.Complete(origPayload); - var nativePayload = context.GetPayload().ToByteArray(); - CollectionAssert.AreEqual(origPayload, nativePayload); + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } } [TestCase(0)] @@ -73,16 +79,40 @@ namespace Grpc.Core.Internal.Tests [TestCase(1000)] public void BufferWriter_OneSegment(int payloadSize) { - var context = new DefaultSerializationContext(); - var origPayload = GetTestBuffer(payloadSize); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); - var bufferWriter = context.GetBufferWriter(); - origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); - bufferWriter.Advance(payloadSize); - // TODO: test that call to Complete() is required. + var bufferWriter = context.GetBufferWriter(); + origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); + bufferWriter.Advance(payloadSize); + // TODO: test that call to Complete() is required. - var nativePayload = context.GetPayload().ToByteArray(); - CollectionAssert.AreEqual(origPayload, nativePayload); + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void BufferWriter_OneSegment_GetMemory(int payloadSize) + { + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + origPayload.AsSpan().CopyTo(bufferWriter.GetMemory(payloadSize).Span); + bufferWriter.Advance(payloadSize); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } } [TestCase(1, 4)] // small slice size tests grpc_slice with inline data @@ -95,41 +125,68 @@ namespace Grpc.Core.Internal.Tests [TestCase(1000, 64)] public void BufferWriter_MultipleSegments(int payloadSize, int maxSliceSize) { - var context = new DefaultSerializationContext(); - var origPayload = GetTestBuffer(payloadSize); - - var bufferWriter = context.GetBufferWriter(); - for (int offset = 0; offset < payloadSize; offset += maxSliceSize) + using (var scope = NewDefaultSerializationContextScope()) { - var sliceSize = Math.Min(maxSliceSize, payloadSize - offset); - // we allocate last slice as too big intentionally to test that shrinking works - var dest = bufferWriter.GetSpan(maxSliceSize); + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + for (int offset = 0; offset < payloadSize; offset += maxSliceSize) + { + var sliceSize = Math.Min(maxSliceSize, payloadSize - offset); + // we allocate last slice as too big intentionally to test that shrinking works + var dest = bufferWriter.GetSpan(maxSliceSize); + + origPayload.AsSpan(offset, sliceSize).CopyTo(dest); + bufferWriter.Advance(sliceSize); + } + context.Complete(); - origPayload.AsSpan(offset, sliceSize).CopyTo(dest); - bufferWriter.Advance(sliceSize); + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); } - context.Complete(); - - var nativePayload = context.GetPayload().ToByteArray(); - CollectionAssert.AreEqual(origPayload, nativePayload); - - context.GetPayload().Dispose(); // TODO: do it better.. (use the scope...) } - // AdjustTailSpace(0) if previous tail size is 0.... + [TestCase] + public void ContextIsReusable() + { + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + + var origPayload1 = GetTestBuffer(10); + context.Complete(origPayload1); + CollectionAssert.AreEqual(origPayload1, context.GetPayload().ToByteArray()); - // test that context.Complete() call is required... + context.Reset(); - // BufferWriter.GetMemory... (add refs to the original memory?) + var origPayload2 = GetTestBuffer(20); + + var bufferWriter = context.GetBufferWriter(); + origPayload2.AsSpan().CopyTo(bufferWriter.GetMemory(origPayload2.Length).Span); + bufferWriter.Advance(origPayload2.Length); + CollectionAssert.AreEqual(origPayload2, context.GetPayload().ToByteArray()); - // TODO: set payload and then get IBufferWriter should throw? + context.Reset(); + + // TODO: that's should be a null payload... + CollectionAssert.AreEqual(new byte[0], context.GetPayload().ToByteArray()); + } + } - // TODO: test Reset()... + //test ideas: - // TODO: destroy SliceBufferSafeHandles... (use usagescope...) + // test that context.Complete() call is required... + // set payload with Complete([]) and then get IBufferWriter should throw (because it's been completed already?) + // other ideas: + // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) + private DefaultSerializationContext.UsageScope NewDefaultSerializationContextScope() + { + return new DefaultSerializationContext.UsageScope(new DefaultSerializationContext()); + } private byte[] GetTestBuffer(int length) { From 389d759344a58e8ae2be85623905b11da0b8e969 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:19:33 -0700 Subject: [PATCH 023/176] improve doc comments for SerializationContext --- src/csharp/Grpc.Core.Api/SerializationContext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/SerializationContext.cs b/src/csharp/Grpc.Core.Api/SerializationContext.cs index 79107040411..76f1951b68e 100644 --- a/src/csharp/Grpc.Core.Api/SerializationContext.cs +++ b/src/csharp/Grpc.Core.Api/SerializationContext.cs @@ -28,7 +28,7 @@ namespace Grpc.Core { /// /// Use the byte array as serialized form of current message and mark serialization process as complete. - /// Complete() can only be called once. By calling this method the caller gives up the ownership of the + /// Complete() can only be called once. By calling this method the caller gives up the ownership of the /// payload which must not be accessed afterwards. /// /// the serialized form of current message @@ -38,7 +38,8 @@ namespace Grpc.Core } /// - /// Expose serializer as buffer writer + /// Gets buffer writer that can be used to write the serialized data. Once serialization is finished, + /// Complete() needs to be called. /// public virtual IBufferWriter GetBufferWriter() { @@ -46,7 +47,7 @@ namespace Grpc.Core } /// - /// Complete the payload written so far. + /// Complete the payload written to the buffer writer. Complete() can only be called once. /// public virtual void Complete() { From 891dc61d8e238fa07e5323164bf00189bff42d3f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:28:29 -0700 Subject: [PATCH 024/176] move slice memory manager --- .../Grpc.Core/Internal/ReusableSliceBuffer.cs | 41 +-------- .../Grpc.Core/Internal/SliceMemoryManager.cs | 87 +++++++++++++++++++ 2 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs diff --git a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs index 078e59e9d1b..eed6ba4ae15 100644 --- a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs +++ b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs @@ -101,45 +101,6 @@ namespace Grpc.Core.Internal { Next = next; } - } - - // Allow creating instances of Memory from Slice. - // Represents a chunk of native memory, but doesn't manage its lifetime. - // Instances of this class are reuseable - they can be reset to point to a different memory chunk. - // That is important to make the instances cacheable (rather then creating new instances - // the old ones will be reused to reduce GC pressure). - private class SliceMemoryManager : MemoryManager - { - private Slice slice; - - public void Reset(Slice slice) - { - this.slice = slice; - } - - public void Reset() - { - Reset(new Slice(IntPtr.Zero, 0)); - } - - public override Span GetSpan() - { - return slice.ToSpanUnsafe(); - } - - public override MemoryHandle Pin(int elementIndex = 0) - { - throw new NotSupportedException(); - } - - public override void Unpin() - { - } - - protected override void Dispose(bool disposing) - { - // NOP - } - } + } } } diff --git a/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs new file mode 100644 index 00000000000..342d90df36c --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs @@ -0,0 +1,87 @@ +#region Copyright notice and license + +// Copyright 2019 The 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. + +#endregion + +using Grpc.Core.Utils; +using System; +using System.Threading; + +using System.Buffers; + +namespace Grpc.Core.Internal +{ + internal class ReusableSliceBuffer + { + public const int MaxCachedSegments = 1024; // ~4MB payload for 4K slices + + readonly SliceSegment[] cachedSegments = new SliceSegment[MaxCachedSegments]; + int populatedSegmentCount; + + public ReadOnlySequence PopulateFrom(IBufferReader bufferReader) + { + populatedSegmentCount = 0; + long offset = 0; + SliceSegment prevSegment = null; + while (bufferReader.TryGetNextSlice(out Slice slice)) + { + // Initialize cached segment if still null or just allocate a new segment if we already reached MaxCachedSegments + var current = populatedSegmentCount < cachedSegments.Length ? cachedSegments[populatedSegmentCount] : new SliceSegment(); + if (current == null) + { + current = cachedSegments[populatedSegmentCount] = new SliceSegment(); + } + + current.Reset(slice, offset); + prevSegment?.SetNext(current); + + populatedSegmentCount ++; + offset += slice.Length; + prevSegment = current; + } + + // Not necessary for ending the ReadOnlySequence, but for making sure we + // don't keep more than MaxCachedSegments alive. + prevSegment?.SetNext(null); + + if (populatedSegmentCount == 0) + { + return ReadOnlySequence.Empty; + } + + var firstSegment = cachedSegments[0]; + var lastSegment = prevSegment; + return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); + } + + public void Invalidate() + { + if (populatedSegmentCount == 0) + { + return; + } + var segment = cachedSegments[0]; + while (segment != null) + { + segment.Reset(new Slice(IntPtr.Zero, 0), 0); + var nextSegment = (SliceSegment) segment.Next; + segment.SetNext(null); + segment = nextSegment; + } + populatedSegmentCount = 0; + } + } +} From fb5411fba9d91f73814b6c107a268c374ad58721 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:30:28 -0700 Subject: [PATCH 025/176] support GetMemory() --- .../Grpc.Core/Internal/SliceBufferSafeHandle.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 76a97f4a0a2..0ce37317f1a 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -39,6 +39,8 @@ namespace Grpc.Core.Internal private IntPtr tailSpacePtr; private int tailSpaceLen; + private SliceMemoryManager memoryManagerLazy; + private SliceBufferSafeHandle() { } @@ -63,14 +65,20 @@ namespace Grpc.Core.Internal GrpcPreconditions.CheckArgument(tailSpaceLen >= count); tailSpaceLen = tailSpaceLen - count; tailSpacePtr += count; + memoryManagerLazy?.Reset(); } // provides access to the "tail space" of this buffer. // Use GetSpan when possible for better efficiency. public Memory GetMemory(int sizeHint = 0) { - // TODO: implement - throw new NotImplementedException(); + GetSpan(sizeHint); + if (memoryManagerLazy == null) + { + memoryManagerLazy = new SliceMemoryManager(); + } + memoryManagerLazy.Reset(new Slice(tailSpacePtr, tailSpaceLen)); + return memoryManagerLazy.Memory; } // provides access to the "tail space" of this buffer. @@ -97,6 +105,7 @@ namespace Grpc.Core.Internal // deletes all the data in the slice buffer tailSpacePtr = IntPtr.Zero; tailSpaceLen = 0; + memoryManagerLazy?.Reset(); Native.grpcsharp_slice_buffer_reset_and_unref(this); } From 66cd7cbb8fce6136ead7fd05fe79356c2cf072c9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:31:01 -0700 Subject: [PATCH 026/176] improve default serialization context tests --- .../DefaultSerializationContextTest.cs | 23 +++++++++++++------ .../Internal/DefaultSerializationContext.cs | 9 +++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs index aa7631587be..fcb12ae6656 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -87,7 +87,7 @@ namespace Grpc.Core.Internal.Tests var bufferWriter = context.GetBufferWriter(); origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); bufferWriter.Advance(payloadSize); - // TODO: test that call to Complete() is required. + context.Complete(); var nativePayload = context.GetPayload().ToByteArray(); CollectionAssert.AreEqual(origPayload, nativePayload); @@ -109,6 +109,7 @@ namespace Grpc.Core.Internal.Tests var bufferWriter = context.GetBufferWriter(); origPayload.AsSpan().CopyTo(bufferWriter.GetMemory(payloadSize).Span); bufferWriter.Advance(payloadSize); + context.Complete(); var nativePayload = context.GetPayload().ToByteArray(); CollectionAssert.AreEqual(origPayload, nativePayload); @@ -154,6 +155,8 @@ namespace Grpc.Core.Internal.Tests { var context = scope.Context; + Assert.Throws(typeof(NullReferenceException), () => context.GetPayload()); + var origPayload1 = GetTestBuffer(10); context.Complete(origPayload1); CollectionAssert.AreEqual(origPayload1, context.GetPayload().ToByteArray()); @@ -165,20 +168,26 @@ namespace Grpc.Core.Internal.Tests var bufferWriter = context.GetBufferWriter(); origPayload2.AsSpan().CopyTo(bufferWriter.GetMemory(origPayload2.Length).Span); bufferWriter.Advance(origPayload2.Length); + context.Complete(); CollectionAssert.AreEqual(origPayload2, context.GetPayload().ToByteArray()); context.Reset(); - // TODO: that's should be a null payload... - CollectionAssert.AreEqual(new byte[0], context.GetPayload().ToByteArray()); + Assert.Throws(typeof(NullReferenceException), () => context.GetPayload()); } } - //test ideas: - - // test that context.Complete() call is required... + [TestCase] + public void GetBufferWriterThrowsForCompletedContext() + { + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + context.Complete(GetTestBuffer(10)); - // set payload with Complete([]) and then get IBufferWriter should throw (because it's been completed already?) + Assert.Throws(typeof(InvalidOperationException), () => context.GetBufferWriter()); + } + } // other ideas: // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index 6bf9da56264..4d45b5c684f 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -52,6 +52,7 @@ namespace Grpc.Core.Internal /// public override IBufferWriter GetBufferWriter() { + GrpcPreconditions.CheckState(!isComplete); return sliceBuffer; } @@ -67,6 +68,11 @@ namespace Grpc.Core.Internal internal SliceBufferSafeHandle GetPayload() { + if (!isComplete) + { + // mimic the legacy behavior when byte[] was used to represent the payload. + throw new NullReferenceException("No payload was set. Complete() needs to be called before payload can be used."); + } return sliceBuffer; } @@ -95,9 +101,6 @@ namespace Grpc.Core.Internal } public DefaultSerializationContext Context => context; - - // TODO: add Serialize method... - public void Dispose() { context.Reset(); From 532bdf7cd29f613fdfe2184b4c7035398def5353 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:35:00 -0700 Subject: [PATCH 027/176] fixup SliceMemoryManager --- .../Grpc.Core/Internal/SliceMemoryManager.cs | 74 +++++++------------ 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs index 342d90df36c..dad2d96bd75 100644 --- a/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs +++ b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs @@ -24,64 +24,42 @@ using System.Buffers; namespace Grpc.Core.Internal { - internal class ReusableSliceBuffer + // Allow creating instances of Memory from Slice. + // Represents a chunk of native memory, but doesn't manage its lifetime. + // Instances of this class are reuseable - they can be reset to point to a different memory chunk. + // That is important to make the instances cacheable (rather then creating new instances + // the old ones will be reused to reduce GC pressure). + internal class SliceMemoryManager : MemoryManager { - public const int MaxCachedSegments = 1024; // ~4MB payload for 4K slices + private Slice slice; - readonly SliceSegment[] cachedSegments = new SliceSegment[MaxCachedSegments]; - int populatedSegmentCount; - - public ReadOnlySequence PopulateFrom(IBufferReader bufferReader) + public void Reset(Slice slice) { - populatedSegmentCount = 0; - long offset = 0; - SliceSegment prevSegment = null; - while (bufferReader.TryGetNextSlice(out Slice slice)) - { - // Initialize cached segment if still null or just allocate a new segment if we already reached MaxCachedSegments - var current = populatedSegmentCount < cachedSegments.Length ? cachedSegments[populatedSegmentCount] : new SliceSegment(); - if (current == null) - { - current = cachedSegments[populatedSegmentCount] = new SliceSegment(); - } - - current.Reset(slice, offset); - prevSegment?.SetNext(current); + this.slice = slice; + } - populatedSegmentCount ++; - offset += slice.Length; - prevSegment = current; - } + public void Reset() + { + Reset(new Slice(IntPtr.Zero, 0)); + } - // Not necessary for ending the ReadOnlySequence, but for making sure we - // don't keep more than MaxCachedSegments alive. - prevSegment?.SetNext(null); + public override Span GetSpan() + { + return slice.ToSpanUnsafe(); + } - if (populatedSegmentCount == 0) - { - return ReadOnlySequence.Empty; - } + public override MemoryHandle Pin(int elementIndex = 0) + { + throw new NotSupportedException(); + } - var firstSegment = cachedSegments[0]; - var lastSegment = prevSegment; - return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); + public override void Unpin() + { } - public void Invalidate() + protected override void Dispose(bool disposing) { - if (populatedSegmentCount == 0) - { - return; - } - var segment = cachedSegments[0]; - while (segment != null) - { - segment.Reset(new Slice(IntPtr.Zero, 0), 0); - var nextSegment = (SliceSegment) segment.Next; - segment.SetNext(null); - segment = nextSegment; - } - populatedSegmentCount = 0; + // NOP } } } From 79c9aa081d7ee9cc6368edc66be8428fe54f0dc6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:38:45 -0700 Subject: [PATCH 028/176] add slice buffer safe handle tests --- .../Internal/SliceBufferSafeHandleTest.cs | 38 +++++++++++++++++++ src/csharp/tests.json | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs new file mode 100644 index 00000000000..563187948d2 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -0,0 +1,38 @@ +#region Copyright notice and license + +// Copyright 2019 The 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. + +#endregion + +using System; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +namespace Grpc.Core.Internal.Tests +{ + public class SliceBufferSafeHandleTest + { + [TestCase] + public void BasicTest() + { + + } + + // other ideas: + // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) + } +} diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 75bda4c25ea..e18266ab9d7 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -13,6 +13,7 @@ "Grpc.Core.Internal.Tests.FakeBufferReaderManagerTest", "Grpc.Core.Internal.Tests.MetadataArraySafeHandleTest", "Grpc.Core.Internal.Tests.ReusableSliceBufferTest", + "Grpc.Core.Internal.Tests.SliceBufferSafeHandleTest", "Grpc.Core.Internal.Tests.SliceTest", "Grpc.Core.Internal.Tests.TimespecTest", "Grpc.Core.Internal.Tests.WellKnownStringsTest", From ec14872fc283ac36b6898ab1f9d0fad758d6329e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:48:36 -0700 Subject: [PATCH 029/176] address TODO" --- src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs index 99f92e12628..dbceb27baf9 100644 --- a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs @@ -52,8 +52,8 @@ namespace Grpc.Core.Tests } if (str == "SERIALIZE_TO_NULL") { - // TODO: test for not calling complete Complete() (that resulted in null payload before...) - // TODO: test for calling Complete(null byte array) + // for contextual marshaller, serializing to null payload corresponds + // to not calling the Complete() method in the serializer. return; } var bytes = System.Text.Encoding.UTF8.GetBytes(str); From ded29be883e888081174a9be88de4ce2618303af Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 15:43:57 -0700 Subject: [PATCH 030/176] slice buffer improvements --- .../Internal/SliceBufferSafeHandleTest.cs | 95 ++++++++++++++++++- .../Internal/SliceBufferSafeHandle.cs | 33 +++++-- 2 files changed, 115 insertions(+), 13 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 563187948d2..61c817dafc9 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -27,12 +27,99 @@ namespace Grpc.Core.Internal.Tests public class SliceBufferSafeHandleTest { [TestCase] - public void BasicTest() + public void Complete_EmptyBuffer() { - + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + sliceBuffer.Complete(); + CollectionAssert.AreEqual(new byte[0], sliceBuffer.ToByteArray()); + } } - // other ideas: - // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) + [TestCase] + public void Complete_TailSizeZero() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var origPayload = GetTestBuffer(10); + origPayload.AsSpan().CopyTo(sliceBuffer.GetSpan(origPayload.Length)); + sliceBuffer.Advance(origPayload.Length); + // call complete where tail space size == 0 + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload, sliceBuffer.ToByteArray()); + } + } + + [TestCase] + public void Complete_TruncateTailSpace() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var origPayload = GetTestBuffer(10); + var dest = sliceBuffer.GetSpan(origPayload.Length + 10); + origPayload.AsSpan().CopyTo(dest); + sliceBuffer.Advance(origPayload.Length); + // call complete where tail space needs to be truncated + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload, sliceBuffer.ToByteArray()); + } + } + + [TestCase] + public void SliceBufferIsReusable() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var origPayload = GetTestBuffer(10); + origPayload.AsSpan().CopyTo(sliceBuffer.GetSpan(origPayload.Length)); + sliceBuffer.Advance(origPayload.Length); + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload, sliceBuffer.ToByteArray()); + + sliceBuffer.Reset(); + + var origPayload2 = GetTestBuffer(20); + origPayload2.AsSpan().CopyTo(sliceBuffer.GetSpan(origPayload2.Length)); + sliceBuffer.Advance(origPayload2.Length); + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload2, sliceBuffer.ToByteArray()); + + sliceBuffer.Reset(); + + CollectionAssert.AreEqual(new byte[0], sliceBuffer.ToByteArray()); + } + } + + [TestCase] + public void SliceBuffer_SizeHintZero() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var destSpan = sliceBuffer.GetSpan(0); + Assert.IsTrue(destSpan.Length > 0); // some non-zero size memory is made available + + sliceBuffer.Reset(); + + var destMemory = sliceBuffer.GetMemory(0); + Assert.IsTrue(destMemory.Length > 0); + } + } + + // Advance() - multiple chunks... + + // other TODOS: + + // -- provide a null instance of SliceBufferSafeHandle + //-- order of UnsafeSerialize in AsyncCall methods... + + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } } } diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 0ce37317f1a..77c14f1d9fb 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -31,6 +31,7 @@ namespace Grpc.Core.Internal /// internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid, IBufferWriter { + const int DefaultTailSpaceSize = 4096; // default buffer to allocate if no size hint is provided static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); @@ -72,7 +73,7 @@ namespace Grpc.Core.Internal // Use GetSpan when possible for better efficiency. public Memory GetMemory(int sizeHint = 0) { - GetSpan(sizeHint); + EnsureBufferSpace(sizeHint); if (memoryManagerLazy == null) { memoryManagerLazy = new SliceMemoryManager(); @@ -84,13 +85,7 @@ namespace Grpc.Core.Internal // provides access to the "tail space" of this buffer. public unsafe Span GetSpan(int sizeHint = 0) { - GrpcPreconditions.CheckArgument(sizeHint >= 0); - if (tailSpaceLen < sizeHint) - { - // TODO: should we ignore the hint sometimes when - // available tail space is close enough to the sizeHint? - AdjustTailSpace(sizeHint); - } + EnsureBufferSpace(sizeHint); return new Span(tailSpacePtr.ToPointer(), tailSpaceLen); } @@ -135,7 +130,27 @@ namespace Grpc.Core.Internal return result; } - // Gets data of server_rpc_new completion. + private void EnsureBufferSpace(int sizeHint) + { + GrpcPreconditions.CheckArgument(sizeHint >= 0); + if (sizeHint == 0) + { + // if no hint is provided, keep the available space within some "reasonable" boundaries. + // This is quite a naive approach which could use some fine-tuning, but currently in most case we know + // the required buffer size in advance anyway, so this approach seems good enough for now. + if (tailSpaceLen < DefaultTailSpaceSize /2 ) + { + AdjustTailSpace(DefaultTailSpaceSize); + } + } + else if (tailSpaceLen < sizeHint) + { + // if hint is provided, always make sure we provide at least that much space + AdjustTailSpace(sizeHint); + } + } + + // make sure there's exactly requestedSize bytes of continguous buffer space at the end of this slice buffer private void AdjustTailSpace(int requestedSize) { GrpcPreconditions.CheckArgument(requestedSize >= 0); From 127d69383abc0c442625038be6d57522b35f20c6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 16:00:41 -0700 Subject: [PATCH 031/176] better tests --- .../Internal/SliceBufferSafeHandleTest.cs | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 61c817dafc9..5feb9a711da 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -105,10 +105,52 @@ namespace Grpc.Core.Internal.Tests } } - // Advance() - multiple chunks... + [TestCase(0)] + [TestCase(1000)] + public void SliceBuffer_BigPayload(int sizeHint) + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var bigPayload = GetTestBuffer(4 * 1024 * 1024); + + int offset = 0; + while (offset < bigPayload.Length) + { + var destSpan = sliceBuffer.GetSpan(sizeHint); + int copySize = Math.Min(destSpan.Length, bigPayload.Length - offset); + bigPayload.AsSpan(offset, copySize).CopyTo(destSpan); + sliceBuffer.Advance(copySize); + offset += copySize; + } + + sliceBuffer.Complete(); + CollectionAssert.AreEqual(bigPayload, sliceBuffer.ToByteArray()); + } + } - // other TODOS: + [TestCase] + public void SliceBuffer_NegativeSizeHint() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.GetSpan(-1)); + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.GetMemory(-1)); + } + } + + [TestCase] + public void SliceBuffer_AdvanceBadArg() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + int size = 10; + var destSpan = sliceBuffer.GetSpan(size); + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.Advance(size + 1)); + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.Advance(-1)); + } + } + // TODO: other TODOs // -- provide a null instance of SliceBufferSafeHandle //-- order of UnsafeSerialize in AsyncCall methods... From ec351c1ac2329be334adb93a46f04c2a80a1ec39 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:00:12 -0700 Subject: [PATCH 032/176] reorder UnsafeSerialize --- .../Internal/SliceBufferSafeHandleTest.cs | 1 - src/csharp/Grpc.Core/Internal/AsyncCall.cs | 31 +++++++++---------- .../Grpc.Core/Internal/AsyncCallBase.cs | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 5feb9a711da..89d5f187a22 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -152,7 +152,6 @@ namespace Grpc.Core.Internal.Tests // TODO: other TODOs // -- provide a null instance of SliceBufferSafeHandle - //-- order of UnsafeSerialize in AsyncCall methods... private byte[] GetTestBuffer(int length) { diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 4111c5347ce..830a1f4edc6 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -160,16 +160,15 @@ namespace Grpc.Core.Internal halfcloseRequested = true; readingDone = true; - //var payload = UnsafeSerialize(msg); - - unaryResponseTcs = new TaskCompletionSource(); using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) - using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? - - call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); - callStartedOk = true; + var payload = UnsafeSerialize(msg, serializationScope.Context); + unaryResponseTcs = new TaskCompletionSource(); + using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) + { + call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); + callStartedOk = true; + } } return unaryResponseTcs.Task; @@ -238,17 +237,15 @@ namespace Grpc.Core.Internal halfcloseRequested = true; - //var payload = UnsafeSerialize(msg); - - streamingResponseCallFinishedTcs = new TaskCompletionSource(); - using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) - using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? - - call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); - callStartedOk = true; + var payload = UnsafeSerialize(msg, serializationScope.Context); + streamingResponseCallFinishedTcs = new TaskCompletionSource(); + using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) + { + call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); + callStartedOk = true; + } } call.StartReceiveInitialMetadata(ReceivedResponseHeadersCallback); } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index bd4b0d81832..252fe114506 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -117,7 +117,7 @@ namespace Grpc.Core.Internal { using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + var payload = UnsafeSerialize(msg, serializationScope.Context); lock (myLock) { GrpcPreconditions.CheckState(started); From 36dcea650dc333ca0ba19942f01742f4bec602f9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:03:33 -0700 Subject: [PATCH 033/176] address a TODO --- src/csharp/ext/grpc_csharp_ext.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 89391e67e15..9ffc5591d8b 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1238,8 +1238,9 @@ grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t avail } grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); - // TODO: this always adds as a new slice entry into the sb, but it doesn't have the problem of - // sometimes splitting the continguous new_slice across two different slices (like grpc_slice_buffer_add would) + // grpc_slice_buffer_add_indexed always adds as a new slice entry into the sb (which is suboptimal in some cases) + // but it doesn't have the problem of sometimes splitting the continguous new_slice across two different slices + // (like grpc_slice_buffer_add would) grpc_slice_buffer_add_indexed(buffer, new_slice); } From dd5515870747ecdc5cfd92398aa02fd47b667132 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:20:27 -0700 Subject: [PATCH 034/176] address TODO in SendMessageBenchmark --- .../Grpc.Microbenchmarks/SendMessageBenchmark.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index 76c59ca579c..f850a0a006f 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -50,18 +50,21 @@ namespace Grpc.Microbenchmarks var call = CreateFakeCall(cq); var sendCompletionCallback = new NopSendCompletionCallback(); - var payload = SliceBufferSafeHandle.Create(); - payload.GetSpan(PayloadSize); - payload.Advance(PayloadSize); + var sliceBuffer = SliceBufferSafeHandle.Create(); var writeFlags = default(WriteFlags); for (int i = 0; i < Iterations; i++) { - // TODO: sending for the first time actually steals the slices... - call.StartSendMessage(sendCompletionCallback, payload, writeFlags, false); + // SendMessage steals the slices from the slice buffer, so we need to repopulate in each iteration. + sliceBuffer.Reset(); + sliceBuffer.GetSpan(PayloadSize); + sliceBuffer.Advance(PayloadSize); + + call.StartSendMessage(sendCompletionCallback, sliceBuffer, writeFlags, false); var callback = completionRegistry.Extract(completionRegistry.LastRegisteredKey); callback.OnComplete(true); } + sliceBuffer.Dispose(); cq.Dispose(); } From 9ae5c5df245a2ed683de6028e3aa55bb88723269 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:35:00 -0700 Subject: [PATCH 035/176] address a TODO --- .../Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs | 3 --- src/csharp/Grpc.Core/Internal/AsyncCallServer.cs | 2 +- src/csharp/Grpc.Core/Internal/CallSafeHandle.cs | 7 ------- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 2 +- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 89d5f187a22..76387478312 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -150,9 +150,6 @@ namespace Grpc.Core.Internal.Tests } } - // TODO: other TODOs - // -- provide a null instance of SliceBufferSafeHandle - private byte[] GetTestBuffer(int length) { var testBuffer = new byte[length]; diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index e0bb41e15dc..58bc40b0ace 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -131,7 +131,7 @@ namespace Grpc.Core.Internal { using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response, serializationScope.Context) : null; + var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response, serializationScope.Context) : SliceBufferSafeHandle.NullInstance; var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); lock (myLock) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index cfcab5dc692..7fadc1d8b47 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -131,13 +131,6 @@ namespace Grpc.Core.Internal public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags) { - // TODO: optionalPayload == null -> pass null SliceBufferSafeHandle - // do this properly - if (optionalPayload == null) - { - optionalPayload = SliceBufferSafeHandle.NullInstance; - } - using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index e5bac1967c9..8aa2e96832a 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -117,7 +117,7 @@ namespace Grpc.Microbenchmarks { for (int i = 0; i < Iterations; i++) { - call.StartSendStatusFromServer(this, status, metadata, false, null, WriteFlags.NoCompress); + call.StartSendStatusFromServer(this, status, metadata, false, SliceBufferSafeHandle.NullInstance, WriteFlags.NoCompress); } } From 2f5464754516f2922e1a1d2711b0a90f3dc25070 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 20:38:49 -0400 Subject: [PATCH 036/176] clang format --- src/csharp/ext/grpc_csharp_ext.c | 93 ++++++++++++++++---------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 9ffc5591d8b..2360c9e1d5f 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -41,9 +41,10 @@ #define GPR_CALLTYPE #endif -static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { +static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices( + grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); memset(bb, 0, sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; @@ -587,8 +588,8 @@ static grpc_call_error grpcsharp_call_start_batch(grpc_call* call, } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[6]; @@ -603,7 +604,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); + ctx->send_message = + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -640,8 +642,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( /* Only for testing. Shortcircuits the unary call logic and only echoes the message as if it was received from the server */ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_test_call_start_unary_echo( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { // prepare as if we were performing a normal RPC. grpc_byte_buffer* send_message = @@ -698,8 +700,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; @@ -714,7 +716,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); + ctx->send_message = + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -781,15 +784,16 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_message( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, 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 = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); + ctx->send_message = + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[0].data.send_message.send_message = ctx->send_message; ops[0].flags = write_flags; ops[0].reserved = NULL; @@ -816,8 +820,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( grpc_call* call, grpcsharp_batch_context* ctx, grpc_status_code status_code, const char* status_details, size_t status_details_len, grpc_metadata_array* trailing_metadata, int32_t send_empty_initial_metadata, - grpc_slice_buffer* optional_send_buffer, - uint32_t write_flags) { + grpc_slice_buffer* optional_send_buffer, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[3]; memset(ops, 0, sizeof(ops)); @@ -1188,9 +1191,9 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) { typedef void(GPR_CALLTYPE* test_callback_funcptr)(int32_t success); /* Slice buffer functionality */ -GPR_EXPORT grpc_slice_buffer* GPR_CALLTYPE -grpcsharp_slice_buffer_create() { - grpc_slice_buffer* slice_buffer = (grpc_slice_buffer*)gpr_malloc(sizeof(grpc_slice_buffer)); +GPR_EXPORT grpc_slice_buffer* GPR_CALLTYPE grpcsharp_slice_buffer_create() { + grpc_slice_buffer* slice_buffer = + (grpc_slice_buffer*)gpr_malloc(sizeof(grpc_slice_buffer)); grpc_slice_buffer_init(slice_buffer); return slice_buffer; } @@ -1212,44 +1215,40 @@ grpcsharp_slice_buffer_slice_count(grpc_slice_buffer* buffer) { } GPR_EXPORT void GPR_CALLTYPE -grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_t* slice_len, uint8_t** slice_data_ptr) { +grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, + size_t* slice_len, uint8_t** slice_data_ptr) { GPR_ASSERT(buffer->count > index); grpc_slice* slice_ptr = &buffer->slices[index]; *slice_len = GRPC_SLICE_LENGTH(*slice_ptr); *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); } -GPR_EXPORT void* GPR_CALLTYPE -grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, +GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space( + grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { - - if (available_tail_space == requested_tail_space) { - // nothing to do - } - else if (available_tail_space >= requested_tail_space) - { - grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, NULL); + if (available_tail_space == requested_tail_space) { + // nothing to do + } else if (available_tail_space >= requested_tail_space) { + grpc_slice_buffer_trim_end( + buffer, available_tail_space - requested_tail_space, NULL); + } else { + if (available_tail_space > 0) { + grpc_slice_buffer_trim_end(buffer, available_tail_space, NULL); } - else - { - if (available_tail_space > 0) - { - grpc_slice_buffer_trim_end(buffer, available_tail_space, NULL); - } - grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); - // grpc_slice_buffer_add_indexed always adds as a new slice entry into the sb (which is suboptimal in some cases) - // but it doesn't have the problem of sometimes splitting the continguous new_slice across two different slices - // (like grpc_slice_buffer_add would) - grpc_slice_buffer_add_indexed(buffer, new_slice); - } - - if (buffer->count == 0) - { - return NULL; - } - grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); - return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; + grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); + // grpc_slice_buffer_add_indexed always adds as a new slice entry into the + // sb (which is suboptimal in some cases) but it doesn't have the problem of + // sometimes splitting the continguous new_slice across two different slices + // (like grpc_slice_buffer_add would) + grpc_slice_buffer_add_indexed(buffer, new_slice); + } + + if (buffer->count == 0) { + return NULL; + } + grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); + return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; } /* Version info */ From d1b64c3a3e6fe44c4588fb8f6be553eebf180264 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 14 Aug 2019 00:25:48 +0800 Subject: [PATCH 037/176] add en example which easy start grpc by 4 kinds method of service with python --- examples/python/easy_start_demo/LICENSE | 373 ++++++++++++++++++ examples/python/easy_start_demo/PyClient.py | 93 +++++ examples/python/easy_start_demo/PyServer.py | 87 ++++ examples/python/easy_start_demo/README.md | 37 ++ .../customGrpcPackages/demo_pb2.py | 174 ++++++++ .../customGrpcPackages/demo_pb2_grpc.py | 99 +++++ examples/python/easy_start_demo/demo.proto | 51 +++ examples/python/easy_start_demo/notes | 3 + 8 files changed, 917 insertions(+) create mode 100644 examples/python/easy_start_demo/LICENSE create mode 100644 examples/python/easy_start_demo/PyClient.py create mode 100644 examples/python/easy_start_demo/PyServer.py create mode 100644 examples/python/easy_start_demo/README.md create mode 100644 examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py create mode 100644 examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py create mode 100644 examples/python/easy_start_demo/demo.proto create mode 100644 examples/python/easy_start_demo/notes diff --git a/examples/python/easy_start_demo/LICENSE b/examples/python/easy_start_demo/LICENSE new file mode 100644 index 00000000000..a612ad9813b --- /dev/null +++ b/examples/python/easy_start_demo/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/examples/python/easy_start_demo/PyClient.py b/examples/python/easy_start_demo/PyClient.py new file mode 100644 index 00000000000..257c817e06f --- /dev/null +++ b/examples/python/easy_start_demo/PyClient.py @@ -0,0 +1,93 @@ +""" +Author: Zhongying Wang +Email: kerbalwzy@gmail.com +License: MPL2 +DateTime: 2019-08-13T23:30:00Z +PythonVersion: Python3.6.3 +""" +import grpc +import time +from customGrpcPackages import demo_pb2, demo_pb2_grpc + +# Constants +PyGrpcServerAddress = "127.0.0.1:23334" +ClientId = 1 + + +# 简单模式 +# Unary +def simple_method(stub): + print("--------------Call SimpleMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp = stub.SimpleMethod(req) + print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") + print("--------------Call SimpleMethod Over---------------") + + +# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) +# Client Streaming (In a single call, the client can transfer data to the server several times, +# but the server can only return a response once.) +def c_stream_method(stub): + print("--------------Call CStreamMethod Begin--------------") + + # 创建一个生成器 + # create a generator + def req_msgs(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") + yield req + + resp = stub.CStreamMethod(req_msgs()) + print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") + print("--------------Call CStreamMethod Over---------------") + + +# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) +# Server Streaming (In a single call, the client can only transmit data to the server at one time, +# but the server can return the response many times.) +def s_stream_method(stub): + print("--------------Call SStreamMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp_s = stub.SStreamMethod(req) + for resp in resp_s: + print(f"recv from server({resp.Sid}, message={resp.RespMsg})") + + print("--------------Call SStreamMethod Over---------------") + + +# 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) +# Bidirectional Streaming (In a single call, both client and server can send and receive data +# to each other multiple times.) +def twf_method(stub): + print("--------------Call TWFMethod Begin---------------") + + # 创建一个生成器 + # create a generator + def req_msgs(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") + yield req + time.sleep(1) + + resp_s = stub.TWFMethod(req_msgs()) + for resp in resp_s: + print(f"recv from server({resp.Sid}, message={resp.RespMsg})") + + print("--------------Call TWFMethod Over---------------") + + +def main(): + with grpc.insecure_channel(PyGrpcServerAddress) as channel: + stub = demo_pb2_grpc.GRPCDemoStub(channel) + + simple_method(stub) + + c_stream_method(stub) + + s_stream_method(stub) + + twf_method(stub) + + +if __name__ == '__main__': + main() diff --git a/examples/python/easy_start_demo/PyServer.py b/examples/python/easy_start_demo/PyServer.py new file mode 100644 index 00000000000..a814205d0d1 --- /dev/null +++ b/examples/python/easy_start_demo/PyServer.py @@ -0,0 +1,87 @@ +""" +Author: Zhongying Wang +Email: kerbalwzy@gmail.com +License: MPL2 +DateTime: 2019-08-13T23:30:00Z +PythonVersion: Python3.6.3 +""" +import time + +import grpc +from threading import Thread +from concurrent import futures +from customGrpcPackages import demo_pb2, demo_pb2_grpc + +# Constants +ServerAddress = '127.0.0.1:23334' +ServerId = 1 + + +class DemoServer(demo_pb2_grpc.GRPCDemoServicer): + + # 简单模式 + # Unary + def SimpleMethod(self, request, context): + print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}") + resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") + return resp + + # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + # Client Streaming (In a single call, the client can transfer data to the server several times, + # but the server can only return a response once.) + def CStreamMethod(self, request_iterator, context): + print("CStreamMethod called by client...") + for req in request_iterator: + print(f"recv from client({req.Cid}), message={req.ReqMsg}") + resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server CStreamMethod ok") + return resp + + # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + # Server Streaming (In a single call, the client can only transmit data to the server at one time, + # but the server can return the response many times.) + def SStreamMethod(self, request, context): + print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}") + + # 创建一个生成器 + def resp_msgs(): + for i in range(5): + resp = demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + yield resp + + return resp_msgs() + + # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) + # Bidirectional Streaming (In a single call, both client and server can send and receive data + # to each other multiple times.) + def TWFMethod(self, request_iterator, context): + # 开启一个子线程去接收数据 + # Open a sub thread to receive data + def parse_req(): + for req in request_iterator: + print(f"recv from client{req.Cid}, message={req.ReqMsg}") + + t = Thread(target=parse_req) + t.start() + + for i in range(5): + yield demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + + t.join() + + +def main(): + server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + + demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server) + + server.add_insecure_port(ServerAddress) + print("------------------start Python GRPC server") + server.start() + + # In python3, `server` have no attribute `wait_for_termination` + while 1: + time.sleep(10) + + +if __name__ == '__main__': + main() diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md new file mode 100644 index 00000000000..2bb9059bc90 --- /dev/null +++ b/examples/python/easy_start_demo/README.md @@ -0,0 +1,37 @@ +## easyDemo for using GRPC in Python +###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。 +###This paper mainly introduces four ways of data transmission when GRPC is used in Python. + +- ####简单模式 (Unary) +```text +没啥好说的,跟调普通方法没差 +There's nothing to say. It's no different from the usual way. +``` +- ####客户端流模式 (Client Streaming) +```text +在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. +In a single call, the client can transfer data to the server several times, +but the server can only return a response once. +``` +- ####服务端流模式 (Server Streaming) +```text +在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 +In a single call, the client can only transmit data to the server at one time, +but the server can return the response many times. +``` +- ####双向流模式 (Bidirectional Streaming) +```text +在一次调用中, 客户端和服务器都可以向对方多次收发数据 +In a single call, both client and server can send and receive data +to each other multiple times. +``` +---- +Author: Zhongying Wang + +Email: kerbalwzy@gmail.com + +License: MPL2 + +DateTime: 2019-08-13T23:30:00Z + +PythonVersion: Python3.6.3 \ No newline at end of file diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py new file mode 100644 index 00000000000..4df1dad0b43 --- /dev/null +++ b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py @@ -0,0 +1,174 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: demo.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='demo.proto', + package='demo', + syntax='proto3', + serialized_options=None, + serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xcd\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x30\n\rCStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x30\n\rSStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12.\n\tTWFMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') +) + + + + +_REQUEST = _descriptor.Descriptor( + name='Request', + full_name='demo.Request', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='Cid', full_name='demo.Request.Cid', index=0, + number=1, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='ReqMsg', full_name='demo.Request.ReqMsg', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=20, + serialized_end=58, +) + + +_RESPONSE = _descriptor.Descriptor( + name='Response', + full_name='demo.Response', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='Sid', full_name='demo.Response.Sid', index=0, + number=1, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='RespMsg', full_name='demo.Response.RespMsg', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=60, + serialized_end=100, +) + +DESCRIPTOR.message_types_by_name['Request'] = _REQUEST +DESCRIPTOR.message_types_by_name['Response'] = _RESPONSE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Request = _reflection.GeneratedProtocolMessageType('Request', (_message.Message,), { + 'DESCRIPTOR' : _REQUEST, + '__module__' : 'demo_pb2' + # @@protoc_insertion_point(class_scope:demo.Request) + }) +_sym_db.RegisterMessage(Request) + +Response = _reflection.GeneratedProtocolMessageType('Response', (_message.Message,), { + 'DESCRIPTOR' : _RESPONSE, + '__module__' : 'demo_pb2' + # @@protoc_insertion_point(class_scope:demo.Response) + }) +_sym_db.RegisterMessage(Response) + + + +_GRPCDEMO = _descriptor.ServiceDescriptor( + name='GRPCDemo', + full_name='demo.GRPCDemo', + file=DESCRIPTOR, + index=0, + serialized_options=None, + serialized_start=103, + serialized_end=308, + methods=[ + _descriptor.MethodDescriptor( + name='SimpleMethod', + full_name='demo.GRPCDemo.SimpleMethod', + index=0, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), + _descriptor.MethodDescriptor( + name='CStreamMethod', + full_name='demo.GRPCDemo.CStreamMethod', + index=1, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), + _descriptor.MethodDescriptor( + name='SStreamMethod', + full_name='demo.GRPCDemo.SStreamMethod', + index=2, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), + _descriptor.MethodDescriptor( + name='TWFMethod', + full_name='demo.GRPCDemo.TWFMethod', + index=3, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), +]) +_sym_db.RegisterServiceDescriptor(_GRPCDEMO) + +DESCRIPTOR.services_by_name['GRPCDemo'] = _GRPCDEMO + +# @@protoc_insertion_point(module_scope) diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py new file mode 100644 index 00000000000..4aaccf1144a --- /dev/null +++ b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py @@ -0,0 +1,99 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from . import demo_pb2 as demo__pb2 + + +class GRPCDemoStub(object): + """服务service是用来gRPC的方法的, 格式固定 + 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.SimpleMethod = channel.unary_unary( + '/demo.GRPCDemo/SimpleMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + self.CStreamMethod = channel.stream_unary( + '/demo.GRPCDemo/CStreamMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + self.SStreamMethod = channel.unary_stream( + '/demo.GRPCDemo/SStreamMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + self.TWFMethod = channel.stream_stream( + '/demo.GRPCDemo/TWFMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + + +class GRPCDemoServicer(object): + """服务service是用来gRPC的方法的, 格式固定 + 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """ + + def SimpleMethod(self, request, context): + """简单模式 + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CStreamMethod(self, request_iterator, context): + """客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SStreamMethod(self, request, context): + """服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def TWFMethod(self, request_iterator, context): + """双向流模式 (在一次调用中, 客户端和服务器都可以向对象多次收发数据) + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_GRPCDemoServicer_to_server(servicer, server): + rpc_method_handlers = { + 'SimpleMethod': grpc.unary_unary_rpc_method_handler( + servicer.SimpleMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + 'CStreamMethod': grpc.stream_unary_rpc_method_handler( + servicer.CStreamMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + 'SStreamMethod': grpc.unary_stream_rpc_method_handler( + servicer.SStreamMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + 'TWFMethod': grpc.stream_stream_rpc_method_handler( + servicer.TWFMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'demo.GRPCDemo', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto new file mode 100644 index 00000000000..4fb76bce752 --- /dev/null +++ b/examples/python/easy_start_demo/demo.proto @@ -0,0 +1,51 @@ +// 语法版本声明,必须放在非注释的第一行 +// Syntax version declaration, Must be placed on the first line of non-commentary +syntax = "proto3"; + +// 包名定义, Python中使用时可以省略不写(PS:我还要再Go中使用,所以留在这里了) +// Package name definition, which can be omitted in Python (PS: I'll use it again in Go, so stay here) +package demo; + +/* +`message`是用来定义传输的数据的格式的, 等号后面的是字段编号 +消息定义中的每个字段都有唯一的编号 +总体格式类似于Python中定义一个类或者Golang中定义一个结构体 +*/ +/* +`message` is used to define the structure of the data to be transmitted, After the equal sign is the field number. +Each field in the message definition has a unique number. +The overall format is similar to defining a class in Python or a structure in Golang. +*/ +message Request { + int64 Cid = 1; + string ReqMsg = 2; +} + +message Response { + int64 Sid = 1; + string RespMsg = 2; +} + +// service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 +// `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang +service GRPCDemo { + // 简单模式 + // Unary + rpc SimpleMethod (Request) returns (Response); + + // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + // Client Streaming (In a single call, the client can transfer data to the server several times, + // but the server can only return a response once.) + rpc CStreamMethod (stream Request) returns (Response); + + // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + // Server Streaming (In a single call, the client can only transmit data to the server at one time, + // but the server can return the response many times.) + rpc SStreamMethod (Request) returns (stream Response); + + // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) + // Bidirectional Streaming (In a single call, both client and server can send and receive data + // to each other multiple times.) + rpc TWFMethod (stream Request) returns (stream Response); +} + diff --git a/examples/python/easy_start_demo/notes b/examples/python/easy_start_demo/notes new file mode 100644 index 00000000000..f0518fc1746 --- /dev/null +++ b/examples/python/easy_start_demo/notes @@ -0,0 +1,3 @@ +//自动生成代码 +//Automatic code generation +>>> python -m grpc_tools.protoc -I ./ ./demo.proto --python_out=./customGrpcPackages --grpc_python_out=./customGrpcPackages \ No newline at end of file From 313b7c593ae050e9d900640525edc1a5a0d78977 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 13 Aug 2019 14:42:48 -0700 Subject: [PATCH 038/176] Backport #19924 to v1.23.x --- .../chttp2/transport/chttp2_transport.cc | 54 +++++++++++++------ .../transport/chttp2/transport/frame_ping.cc | 1 + .../chttp2/transport/frame_rst_stream.cc | 8 +++ .../chttp2/transport/frame_rst_stream.h | 7 +++ .../chttp2/transport/frame_settings.cc | 1 + .../chttp2/transport/hpack_parser.cc | 5 +- .../ext/transport/chttp2/transport/internal.h | 7 +++ .../ext/transport/chttp2/transport/parsing.cc | 14 +++-- .../ext/transport/chttp2/transport/writing.cc | 1 + 9 files changed, 71 insertions(+), 27 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 16146569886..8e81e0a5c2b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -74,6 +74,8 @@ #define DEFAULT_MAX_PINGS_BETWEEN_DATA 2 #define DEFAULT_MAX_PING_STRIKES 2 +#define DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 + static int g_default_client_keepalive_time_ms = DEFAULT_CLIENT_KEEPALIVE_TIME_MS; static int g_default_client_keepalive_timeout_ms = @@ -105,6 +107,7 @@ static void write_action(void* t, grpc_error* error); static void write_action_end_locked(void* t, grpc_error* error); static void read_action_locked(void* t, grpc_error* error); +static void continue_read_action_locked(grpc_chttp2_transport* t); static void complete_fetch_locked(void* gs, grpc_error* error); /** Set a transport level setting, and push it to our peer */ @@ -797,10 +800,8 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, !grpc_resource_user_safe_alloc(t->resource_user, GRPC_RESOURCE_QUOTA_CALL_SIZE)) { gpr_log(GPR_ERROR, "Memory exhausted, rejecting the stream."); - grpc_slice_buffer_add( - &t->qbuf, - grpc_chttp2_rst_stream_create( - id, static_cast(GRPC_HTTP2_REFUSED_STREAM), nullptr)); + grpc_chttp2_add_rst_stream_to_next_write(t, id, GRPC_HTTP2_REFUSED_STREAM, + nullptr); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); return nullptr; } @@ -1045,6 +1046,19 @@ static void write_action_begin_locked(void* gt, grpc_error* error_ignored) { GRPC_CLOSURE_SCHED( GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler), GRPC_ERROR_NONE); + if (t->reading_paused_on_pending_induced_frames) { + GPR_ASSERT(t->num_pending_induced_frames == 0); + /* We had paused reading, because we had many induced frames (SETTINGS + * ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have + * been able to flush qbuf, we can resume reading. */ + GRPC_CHTTP2_IF_TRACING(gpr_log( + GPR_INFO, + "transport %p : Resuming reading after being paused due to too " + "many unwritten SETTINGS ACK, PINGS ACK and RST_STREAM frames", + t)); + t->reading_paused_on_pending_induced_frames = false; + continue_read_action_locked(t); + } } else { GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(); set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing"); @@ -1114,7 +1128,6 @@ static void write_action_end_locked(void* tp, grpc_error* error) { } grpc_chttp2_end_write(t, GRPC_ERROR_REF(error)); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing"); } @@ -2113,10 +2126,8 @@ void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_http2_error_code http_error; grpc_error_get_status(due_to_error, s->deadline, nullptr, nullptr, &http_error, nullptr); - grpc_slice_buffer_add( - &t->qbuf, - grpc_chttp2_rst_stream_create( - s->id, static_cast(http_error), &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write( + t, s->id, static_cast(http_error), &s->stats.outgoing); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); } } @@ -2427,9 +2438,8 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_slice_buffer_add(&t->qbuf, status_hdr); grpc_slice_buffer_add(&t->qbuf, message_pfx); grpc_slice_buffer_add(&t->qbuf, grpc_slice_ref_internal(slice)); - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, + &s->stats.outgoing); grpc_chttp2_mark_stream_closed(t, s, 1, 1, error); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API); @@ -2600,10 +2610,16 @@ static void read_action_locked(void* tp, grpc_error* error) { grpc_slice_buffer_reset_and_unref_internal(&t->read_buffer); if (keep_reading) { - const bool urgent = t->goaway_error != GRPC_ERROR_NONE; - grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); - grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, - nullptr); + if (t->num_pending_induced_frames >= DEFAULT_MAX_PENDING_INDUCED_FRAMES) { + t->reading_paused_on_pending_induced_frames = true; + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, + "transport %p : Pausing reading due to too " + "many unwritten SETTINGS ACK and RST_STREAM frames", + t)); + } else { + continue_read_action_locked(t); + } GRPC_CHTTP2_UNREF_TRANSPORT(t, "keep_reading"); } else { GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action"); @@ -2612,6 +2628,12 @@ static void read_action_locked(void* tp, grpc_error* error) { GRPC_ERROR_UNREF(error); } +static void continue_read_action_locked(grpc_chttp2_transport* t) { + const bool urgent = t->goaway_error != GRPC_ERROR_NONE; + grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); + grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, nullptr); +} + // t is reffed prior to calling the first time, and once the callback chain // that kicks off finishes, it's unreffed static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) { diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc index 9a56bf093f4..87c92dffc38 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -118,6 +118,7 @@ grpc_error* grpc_chttp2_ping_parser_parse(void* parser, t->ping_acks = static_cast(gpr_realloc( t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks))); } + t->num_pending_induced_frames++; t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes; grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE); } diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc index cda09c3dea1..1350a967b9f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc @@ -58,6 +58,14 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, return slice; } +void grpc_chttp2_add_rst_stream_to_next_write( + grpc_chttp2_transport* t, uint32_t id, uint32_t code, + grpc_transport_one_way_stats* stats) { + t->num_pending_induced_frames++; + grpc_slice_buffer_add(&t->qbuf, + grpc_chttp2_rst_stream_create(id, code, stats)); +} + grpc_error* grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags) { if (length != 4) { diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index 64707666181..d61e62394a4 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -33,6 +33,13 @@ typedef struct { grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, grpc_transport_one_way_stats* stats); +// Adds RST_STREAM frame to t->qbuf (buffer for the next write). Should be +// called when we want to add RST_STREAM and we are not in +// write_action_begin_locked. +void grpc_chttp2_add_rst_stream_to_next_write( + grpc_chttp2_transport* t, uint32_t id, uint32_t code, + grpc_transport_one_way_stats* stats); + grpc_error* grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser, diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index 3f84679ec31..ba57afa74b9 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -132,6 +132,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t, if (is_last) { memcpy(parser->target_settings, parser->incoming_settings, GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t)); + t->num_pending_induced_frames++; grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create()); if (t->notify_on_receive_settings != nullptr) { GRPC_CLOSURE_SCHED(t->notify_on_receive_settings, diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 724c6c1bffc..22c0962cd49 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -1668,9 +1668,8 @@ static void force_client_rst_stream(void* sp, grpc_error* error) { grpc_chttp2_stream* s = static_cast(sp); grpc_chttp2_transport* t = s->t; if (!s->write_closed) { - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, + &s->stats.outgoing); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM); grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE); } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 643cd25b8bd..e6fc3b599e0 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -493,6 +493,13 @@ struct grpc_chttp2_transport { grpc_core::ContextList* cl = nullptr; grpc_core::RefCountedPtr channelz_socket; uint32_t num_messages_in_next_write = 0; + /** The number of pending induced frames (SETTINGS_ACK, PINGS_ACK and + * RST_STREAM) in the outgoing buffer (t->qbuf). If this number goes beyond + * DEFAULT_MAX_PENDING_INDUCED_FRAMES, we pause reading new frames. We would + * only continue reading when we are able to write to the socket again, + * thereby reducing the number of induced frames. */ + uint32_t num_pending_induced_frames = 0; + bool reading_paused_on_pending_induced_frames = false; }; typedef enum { diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 4e6ff60caf8..119a5941d38 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -382,10 +382,9 @@ error_handler: if (s != nullptr) { grpc_chttp2_mark_stream_closed(t, s, true, false, err); } - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, - GRPC_HTTP2_PROTOCOL_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, t->incoming_stream_id, + GRPC_HTTP2_PROTOCOL_ERROR, + &s->stats.outgoing); return init_skip_frame_parser(t, 0); } else { return err; @@ -765,10 +764,9 @@ static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_chttp2_parsing_become_skip_parser(t); if (s) { s->forced_close_error = err; - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, - GRPC_HTTP2_PROTOCOL_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, t->incoming_stream_id, + GRPC_HTTP2_PROTOCOL_ERROR, + &s->stats.outgoing); } else { GRPC_ERROR_UNREF(err); } diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index f3cb390dc7a..d6d9e4521f6 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -219,6 +219,7 @@ class WriteContext { void FlushQueuedBuffers() { /* simple writes are queued to qbuf, and flushed here */ grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf); + t_->num_pending_induced_frames = 0; GPR_ASSERT(t_->qbuf.count == 0); } From d33d30a595ddbe84f41fa8e3ef9755678f4cf8d5 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 14 Aug 2019 09:20:57 +0800 Subject: [PATCH 039/176] update notes --- examples/python/easy_start_demo/PyClient.py | 6 +++--- examples/python/easy_start_demo/PyServer.py | 6 +++--- examples/python/easy_start_demo/README.md | 6 +++--- examples/python/easy_start_demo/demo.proto | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/python/easy_start_demo/PyClient.py b/examples/python/easy_start_demo/PyClient.py index 257c817e06f..383cdb5afed 100644 --- a/examples/python/easy_start_demo/PyClient.py +++ b/examples/python/easy_start_demo/PyClient.py @@ -15,7 +15,7 @@ ClientId = 1 # 简单模式 -# Unary +# Simple def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") @@ -25,7 +25,7 @@ def simple_method(stub): # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) -# Client Streaming (In a single call, the client can transfer data to the server several times, +# Request-streaming (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def c_stream_method(stub): print("--------------Call CStreamMethod Begin--------------") @@ -43,7 +43,7 @@ def c_stream_method(stub): # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) -# Server Streaming (In a single call, the client can only transmit data to the server at one time, +# Response-streaming (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def s_stream_method(stub): print("--------------Call SStreamMethod Begin--------------") diff --git a/examples/python/easy_start_demo/PyServer.py b/examples/python/easy_start_demo/PyServer.py index a814205d0d1..cfef6bf516a 100644 --- a/examples/python/easy_start_demo/PyServer.py +++ b/examples/python/easy_start_demo/PyServer.py @@ -20,14 +20,14 @@ ServerId = 1 class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # 简单模式 - # Unary + # Simple def SimpleMethod(self, request, context): print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}") resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") return resp # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - # Client Streaming (In a single call, the client can transfer data to the server several times, + # Request-streaming (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def CStreamMethod(self, request_iterator, context): print("CStreamMethod called by client...") @@ -37,7 +37,7 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): return resp # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - # Server Streaming (In a single call, the client can only transmit data to the server at one time, + # Response-streaming (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def SStreamMethod(self, request, context): print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}") diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 2bb9059bc90..5b8ee8c5b3e 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -2,18 +2,18 @@ ###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。 ###This paper mainly introduces four ways of data transmission when GRPC is used in Python. -- ####简单模式 (Unary) +- ####简单模式 (Simple) ```text 没啥好说的,跟调普通方法没差 There's nothing to say. It's no different from the usual way. ``` -- ####客户端流模式 (Client Streaming) +- ####客户端流模式 (Request-streaming) ```text 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. In a single call, the client can transfer data to the server several times, but the server can only return a response once. ``` -- ####服务端流模式 (Server Streaming) +- ####服务端流模式 (Response-streaming) ```text 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 In a single call, the client can only transmit data to the server at one time, diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto index 4fb76bce752..a9506cf92a1 100644 --- a/examples/python/easy_start_demo/demo.proto +++ b/examples/python/easy_start_demo/demo.proto @@ -30,21 +30,21 @@ message Response { // `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang service GRPCDemo { // 简单模式 - // Unary + // Simple rpc SimpleMethod (Request) returns (Response); // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - // Client Streaming (In a single call, the client can transfer data to the server several times, + // Request-streaming (In a single call, the client can transfer data to the server several times, // but the server can only return a response once.) rpc CStreamMethod (stream Request) returns (Response); // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - // Server Streaming (In a single call, the client can only transmit data to the server at one time, + // Response-streaming (In a single call, the client can only transmit data to the server at one time, // but the server can return the response many times.) rpc SStreamMethod (Request) returns (stream Response); // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - // Bidirectional Streaming (In a single call, both client and server can send and receive data + // Bidirectional streaming (In a single call, both client and server can send and receive data // to each other multiple times.) rpc TWFMethod (stream Request) returns (stream Response); } From 03ec155a22fe0177f58d59efd50e8440824b2559 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 14 Aug 2019 10:26:22 -0700 Subject: [PATCH 040/176] Bump version to v1.23.0 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index c708318ecbf..6607963fd3e 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gangnam" core_version = "7.0.0" -version = "1.23.0-pre1" +version = "1.23.0" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 1ba055c65dd..bf64faad540 100644 --- a/build.yaml +++ b/build.yaml @@ -15,7 +15,7 @@ settings: core_version: 7.0.0 csharp_major_version: 2 g_stands_for: gangnam - version: 1.23.0-pre1 + version: 1.23.0 filegroups: - name: alts_proto headers: From 136d3daf53adb7e4b41e0d1e2174665694948c13 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 14 Aug 2019 10:27:19 -0700 Subject: [PATCH 041/176] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a5b4b5cd8a..5ee805b4852 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.23.0-pre1") +set(PACKAGE_VERSION "1.23.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index d4d82581cef..2d8b2d64e52 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.23.0-pre1 -CSHARP_VERSION = 2.23.0-pre1 +CPP_VERSION = 1.23.0 +CSHARP_VERSION = 2.23.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 304ae372101..340783d2674 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.23.0-pre1' - version = '0.0.9-pre1' + # version = '1.23.0' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.23.0-pre1' + grpc_version = '1.23.0' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index d3a82b572dc..ab6738339b2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index c90445baae2..363d600f73c 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 87bd9e7c481..f348874284a 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index dc05dc86ba2..aa81a45d5f3 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 7d2cb708925..22869666b78 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.23.0RC1 - 1.23.0RC1 + 1.23.0 + 1.23.0 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 751cbfa1c22..8427f517b99 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.23.0-pre1"; } +grpc::string Version() { return "1.23.0"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index ca9e88f268d..835bc3c9860 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.23.0-pre1"; + public const string CurrentVersion = "2.23.0"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 00ff3ccb780..28a0ef6e8a1 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.23.0-pre1 + 2.23.0 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 1906f266e20..dc9bcf4c8bb 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.23.0-pre1 +set VERSION=2.23.0 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index 6dc9d4a3f13..730abd861cb 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.23.0-pre1' + v = '1.23.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 98b4ef0dc12..86d2d2d4018 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.23.0-pre1' + v = '1.23.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index bf467558d31..29c669e2648 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.23.0" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index f5d7ec747af..43998fc84ea 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.23.0" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 038ca5c1b25..119d554177c 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.23.0RC1" +#define PHP_GRPC_VERSION "1.23.0" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index d8f04ec88f3..dd1e72ed2cc 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.23.0rc1""" +__version__ = """1.23.0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 2215172be39..9139a633d1e 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index d7b9e92800b..1fbb2c7a889 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 04a5cd79401..91530bc84b0 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 8f47ca23c9b..9c2e33224cc 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 42aad42fa57..c5ce683cf32 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 71930c6730f..9bb8917c6dd 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index aab9f1b57ab..b3d03a317a6 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index fa31c144282..5ca1f443cf0 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.23.0.pre1' + VERSION = '1.23.0' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e5e7a16717c..a70b4789a46 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.23.0.pre1' + VERSION = '1.23.0' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 2b4e8218b50..46bdd9b7df1 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index d508459f0fd..013ab911a13 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-pre1 +PROJECT_NUMBER = 1.23.0 # 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 diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ec0c30b0e79..c72f0485275 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-pre1 +PROJECT_NUMBER = 1.23.0 # 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 From e3f5320ae28c3b73f27a5fd6988ad9d747dcd5b1 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Thu, 15 Aug 2019 16:29:39 +0800 Subject: [PATCH 042/176] remove LICENSE and notes file, Modify the identifier name, --- examples/python/easy_start_demo/LICENSE | 373 ------------------ examples/python/easy_start_demo/PyClient.py | 93 ----- examples/python/easy_start_demo/README.md | 2 - examples/python/easy_start_demo/client.py | 98 +++++ examples/python/easy_start_demo/demo.proto | 6 +- .../demo_pb2.py | 16 +- .../demo_pb2_grpc.py | 49 ++- examples/python/easy_start_demo/notes | 3 - .../{PyServer.py => server.py} | 42 +- 9 files changed, 162 insertions(+), 520 deletions(-) delete mode 100644 examples/python/easy_start_demo/LICENSE delete mode 100644 examples/python/easy_start_demo/PyClient.py create mode 100644 examples/python/easy_start_demo/client.py rename examples/python/easy_start_demo/{customGrpcPackages => demo_grpc_pbs}/demo_pb2.py (88%) rename examples/python/easy_start_demo/{customGrpcPackages => demo_grpc_pbs}/demo_pb2_grpc.py (61%) delete mode 100644 examples/python/easy_start_demo/notes rename examples/python/easy_start_demo/{PyServer.py => server.py} (63%) diff --git a/examples/python/easy_start_demo/LICENSE b/examples/python/easy_start_demo/LICENSE deleted file mode 100644 index a612ad9813b..00000000000 --- a/examples/python/easy_start_demo/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/examples/python/easy_start_demo/PyClient.py b/examples/python/easy_start_demo/PyClient.py deleted file mode 100644 index 383cdb5afed..00000000000 --- a/examples/python/easy_start_demo/PyClient.py +++ /dev/null @@ -1,93 +0,0 @@ -""" -Author: Zhongying Wang -Email: kerbalwzy@gmail.com -License: MPL2 -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 -""" -import grpc -import time -from customGrpcPackages import demo_pb2, demo_pb2_grpc - -# Constants -PyGrpcServerAddress = "127.0.0.1:23334" -ClientId = 1 - - -# 简单模式 -# Simple -def simple_method(stub): - print("--------------Call SimpleMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp = stub.SimpleMethod(req) - print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") - print("--------------Call SimpleMethod Over---------------") - - -# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) -# Request-streaming (In a single call, the client can transfer data to the server several times, -# but the server can only return a response once.) -def c_stream_method(stub): - print("--------------Call CStreamMethod Begin--------------") - - # 创建一个生成器 - # create a generator - def req_msgs(): - for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") - yield req - - resp = stub.CStreamMethod(req_msgs()) - print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") - print("--------------Call CStreamMethod Over---------------") - - -# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) -# Response-streaming (In a single call, the client can only transmit data to the server at one time, -# but the server can return the response many times.) -def s_stream_method(stub): - print("--------------Call SStreamMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp_s = stub.SStreamMethod(req) - for resp in resp_s: - print(f"recv from server({resp.Sid}, message={resp.RespMsg})") - - print("--------------Call SStreamMethod Over---------------") - - -# 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) -# Bidirectional Streaming (In a single call, both client and server can send and receive data -# to each other multiple times.) -def twf_method(stub): - print("--------------Call TWFMethod Begin---------------") - - # 创建一个生成器 - # create a generator - def req_msgs(): - for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") - yield req - time.sleep(1) - - resp_s = stub.TWFMethod(req_msgs()) - for resp in resp_s: - print(f"recv from server({resp.Sid}, message={resp.RespMsg})") - - print("--------------Call TWFMethod Over---------------") - - -def main(): - with grpc.insecure_channel(PyGrpcServerAddress) as channel: - stub = demo_pb2_grpc.GRPCDemoStub(channel) - - simple_method(stub) - - c_stream_method(stub) - - s_stream_method(stub) - - twf_method(stub) - - -if __name__ == '__main__': - main() diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 5b8ee8c5b3e..50529c57df5 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -30,8 +30,6 @@ Author: Zhongying Wang Email: kerbalwzy@gmail.com -License: MPL2 - DateTime: 2019-08-13T23:30:00Z PythonVersion: Python3.6.3 \ No newline at end of file diff --git a/examples/python/easy_start_demo/client.py b/examples/python/easy_start_demo/client.py new file mode 100644 index 00000000000..46d11d05cbf --- /dev/null +++ b/examples/python/easy_start_demo/client.py @@ -0,0 +1,98 @@ +""" +Author: Zhongying Wang +Email: kerbalwzy@gmail.com +DateTime: 2019-08-13T23:30:00Z +PythonVersion: Python3.6.3 +""" +import os +import sys +import time +import grpc + +# add the `demo_grpc_dps` dir into python package search paths +BaseDir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) + +from demo_grpc_pbs import demo_pb2, demo_pb2_grpc + +ServerAddress = "127.0.0.1:23334" +ClientId = 1 + + +# 简单模式 +# Simple Method +def simple_method(stub): + print("--------------Call SimpleMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp = stub.SimpleMethod(req) + print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + print("--------------Call SimpleMethod Over---------------") + + +# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) +# Request-streaming (In a single call, the client can transfer data to the server several times, +# but the server can only return a response once.) +def client_streaming_method(stub): + print("--------------Call ClientStreamingMethod Begin--------------") + + # 创建一个生成器 + # create a generator + def request_messages(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message:%d" % i)) + yield req + + resp = stub.ClientStreamingMethod(request_messages()) + print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + print("--------------Call ClientStreamingMethod Over---------------") + + +# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) +# Response-streaming (In a single call, the client can only transmit data to the server at one time, +# but the server can return the response many times.) +def server_streaming_method(stub): + print("--------------Call ServerStreamingMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp_s = stub.ServerStreamingMethod(req) + for resp in resp_s: + print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + + print("--------------Call ServerStreamingMethod Over---------------") + + +# 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) +# Bidirectional Streaming (In a single call, both client and server can send and receive data +# to each other multiple times.) +def bidirectional_streaming_method(stub): + print("--------------Call BidirectionalStreamingMethod Begin---------------") + + # 创建一个生成器 + # create a generator + def req_messages(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message: %d" % i)) + yield req + time.sleep(1) + + resp_s = stub.BidirectionalStreamingMethod(req_messages()) + for resp in resp_s: + print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + + print("--------------Call BidirectionalStreamingMethod Over---------------") + + +def main(): + with grpc.insecure_channel(ServerAddress) as channel: + stub = demo_pb2_grpc.GRPCDemoStub(channel) + + simple_method(stub) + + client_streaming_method(stub) + + server_streaming_method(stub) + + bidirectional_streaming_method(stub) + + +if __name__ == '__main__': + main() diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto index a9506cf92a1..2844ba7b225 100644 --- a/examples/python/easy_start_demo/demo.proto +++ b/examples/python/easy_start_demo/demo.proto @@ -36,16 +36,16 @@ service GRPCDemo { // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) // Request-streaming (In a single call, the client can transfer data to the server several times, // but the server can only return a response once.) - rpc CStreamMethod (stream Request) returns (Response); + rpc ClientStreamingMethod (stream Request) returns (Response); // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) // Response-streaming (In a single call, the client can only transmit data to the server at one time, // but the server can return the response many times.) - rpc SStreamMethod (Request) returns (stream Response); + rpc ServerStreamingMethod (Request) returns (stream Response); // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) // Bidirectional streaming (In a single call, both client and server can send and receive data // to each other multiple times.) - rpc TWFMethod (stream Request) returns (stream Response); + rpc BidirectionalStreamingMethod (stream Request) returns (stream Response); } diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py similarity index 88% rename from examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py rename to examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py index 4df1dad0b43..de960c8a6c1 100644 --- a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py @@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( package='demo', syntax='proto3', serialized_options=None, - serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xcd\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x30\n\rCStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x30\n\rSStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12.\n\tTWFMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') + serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') ) @@ -128,7 +128,7 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( index=0, serialized_options=None, serialized_start=103, - serialized_end=308, + serialized_end=343, methods=[ _descriptor.MethodDescriptor( name='SimpleMethod', @@ -140,8 +140,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( serialized_options=None, ), _descriptor.MethodDescriptor( - name='CStreamMethod', - full_name='demo.GRPCDemo.CStreamMethod', + name='ClientStreamingMethod', + full_name='demo.GRPCDemo.ClientStreamingMethod', index=1, containing_service=None, input_type=_REQUEST, @@ -149,8 +149,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( serialized_options=None, ), _descriptor.MethodDescriptor( - name='SStreamMethod', - full_name='demo.GRPCDemo.SStreamMethod', + name='ServerStreamingMethod', + full_name='demo.GRPCDemo.ServerStreamingMethod', index=2, containing_service=None, input_type=_REQUEST, @@ -158,8 +158,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( serialized_options=None, ), _descriptor.MethodDescriptor( - name='TWFMethod', - full_name='demo.GRPCDemo.TWFMethod', + name='BidirectionalStreamingMethod', + full_name='demo.GRPCDemo.BidirectionalStreamingMethod', index=3, containing_service=None, input_type=_REQUEST, diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py similarity index 61% rename from examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py rename to examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py index 4aaccf1144a..0f7d5dabbd6 100644 --- a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py @@ -1,12 +1,12 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -from . import demo_pb2 as demo__pb2 +import demo_pb2 as demo__pb2 class GRPCDemoStub(object): - """服务service是用来gRPC的方法的, 格式固定 - 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 + `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang """ def __init__(self, channel): @@ -20,51 +20,58 @@ class GRPCDemoStub(object): request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) - self.CStreamMethod = channel.stream_unary( - '/demo.GRPCDemo/CStreamMethod', + self.ClientStreamingMethod = channel.stream_unary( + '/demo.GRPCDemo/ClientStreamingMethod', request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) - self.SStreamMethod = channel.unary_stream( - '/demo.GRPCDemo/SStreamMethod', + self.ServerStreamingMethod = channel.unary_stream( + '/demo.GRPCDemo/ServerStreamingMethod', request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) - self.TWFMethod = channel.stream_stream( - '/demo.GRPCDemo/TWFMethod', + self.BidirectionalStreamingMethod = channel.stream_stream( + '/demo.GRPCDemo/BidirectionalStreamingMethod', request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) class GRPCDemoServicer(object): - """服务service是用来gRPC的方法的, 格式固定 - 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 + `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang """ def SimpleMethod(self, request, context): """简单模式 + Simple """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def CStreamMethod(self, request_iterator, context): + def ClientStreamingMethod(self, request_iterator, context): """客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + Request-streaming (In a single call, the client can transfer data to the server several times, + but the server can only return a response once.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def SStreamMethod(self, request, context): + def ServerStreamingMethod(self, request, context): """服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + Response-streaming (In a single call, the client can only transmit data to the server at one time, + but the server can return the response many times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def TWFMethod(self, request_iterator, context): - """双向流模式 (在一次调用中, 客户端和服务器都可以向对象多次收发数据) + def BidirectionalStreamingMethod(self, request_iterator, context): + """双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) + Bidirectional streaming (In a single call, both client and server can send and receive data + to each other multiple times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -78,18 +85,18 @@ def add_GRPCDemoServicer_to_server(servicer, server): request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), - 'CStreamMethod': grpc.stream_unary_rpc_method_handler( - servicer.CStreamMethod, + 'ClientStreamingMethod': grpc.stream_unary_rpc_method_handler( + servicer.ClientStreamingMethod, request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), - 'SStreamMethod': grpc.unary_stream_rpc_method_handler( - servicer.SStreamMethod, + 'ServerStreamingMethod': grpc.unary_stream_rpc_method_handler( + servicer.ServerStreamingMethod, request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), - 'TWFMethod': grpc.stream_stream_rpc_method_handler( - servicer.TWFMethod, + 'BidirectionalStreamingMethod': grpc.stream_stream_rpc_method_handler( + servicer.BidirectionalStreamingMethod, request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), diff --git a/examples/python/easy_start_demo/notes b/examples/python/easy_start_demo/notes deleted file mode 100644 index f0518fc1746..00000000000 --- a/examples/python/easy_start_demo/notes +++ /dev/null @@ -1,3 +0,0 @@ -//自动生成代码 -//Automatic code generation ->>> python -m grpc_tools.protoc -I ./ ./demo.proto --python_out=./customGrpcPackages --grpc_python_out=./customGrpcPackages \ No newline at end of file diff --git a/examples/python/easy_start_demo/PyServer.py b/examples/python/easy_start_demo/server.py similarity index 63% rename from examples/python/easy_start_demo/PyServer.py rename to examples/python/easy_start_demo/server.py index cfef6bf516a..a4130719ada 100644 --- a/examples/python/easy_start_demo/PyServer.py +++ b/examples/python/easy_start_demo/server.py @@ -1,18 +1,23 @@ """ Author: Zhongying Wang Email: kerbalwzy@gmail.com -License: MPL2 DateTime: 2019-08-13T23:30:00Z PythonVersion: Python3.6.3 """ +import os +import sys import time - import grpc + from threading import Thread from concurrent import futures -from customGrpcPackages import demo_pb2, demo_pb2_grpc -# Constants +# add the `demo_grpc_dps` dir into python package search paths +BaseDir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) + +from demo_grpc_pbs import demo_pb2, demo_pb2_grpc + ServerAddress = '127.0.0.1:23334' ServerId = 1 @@ -22,49 +27,52 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # 简单模式 # Simple def SimpleMethod(self, request, context): - print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}") + print("SimpleMethod called by client(%d) the message: %s" % (request.Cid, request.ReqMsg)) resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") return resp # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) # Request-streaming (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) - def CStreamMethod(self, request_iterator, context): - print("CStreamMethod called by client...") + def ClientStreamingMethod(self, request_iterator, context): + print("ClientStreamingMethod called by client...") for req in request_iterator: - print(f"recv from client({req.Cid}), message={req.ReqMsg}") - resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server CStreamMethod ok") + print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) + resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server ClientStreamingMethod ok") return resp # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) # Response-streaming (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) - def SStreamMethod(self, request, context): - print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}") + def ServerStreamingMethod(self, request, context): + print("ServerStreamingMethod called by client(%d), message= %s" % (request.Cid, request.ReqMsg)) # 创建一个生成器 - def resp_msgs(): + # create a generator + def response_messages(): for i in range(5): - resp = demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + resp = demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message=%d" % i)) yield resp - return resp_msgs() + return response_messages() # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) # Bidirectional Streaming (In a single call, both client and server can send and receive data # to each other multiple times.) - def TWFMethod(self, request_iterator, context): + def BidirectionalStreamingMethod(self, request_iterator, context): + print("BidirectionalStreamingMethod called by client...") + # 开启一个子线程去接收数据 # Open a sub thread to receive data def parse_req(): for req in request_iterator: - print(f"recv from client{req.Cid}, message={req.ReqMsg}") + print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) t = Thread(target=parse_req) t.start() for i in range(5): - yield demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + yield demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message= %d" % i)) t.join() From d2a224252d0021699dcc64d44aa301a0d8797314 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 16 Aug 2019 11:54:31 +0800 Subject: [PATCH 043/176] fix:Update notes, with more standard words --- examples/python/easy_start_demo/README.md | 21 +++++++------------ examples/python/easy_start_demo/demo.proto | 20 +++++++++--------- .../easy_start_demo/demo_grpc_pbs/demo_pb2.py | 20 +++++++++--------- .../demo_grpc_pbs/demo_pb2_grpc.py | 8 +++---- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 50529c57df5..32ad177af17 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -1,35 +1,28 @@ -## easyDemo for using GRPC in Python -###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。 -###This paper mainly introduces four ways of data transmission when GRPC is used in Python. +## Demo for using gRPC in Python -- ####简单模式 (Simple) +在Python中使用gRPC时, 进行数据传输的四种方式。(Four ways of data transmission when gRPC is used in Python.) + +- ####简单模式 (unary-unary) ```text 没啥好说的,跟调普通方法没差 There's nothing to say. It's no different from the usual way. ``` -- ####客户端流模式 (Request-streaming) +- ####客户端流模式 (stream-unary) ```text 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. In a single call, the client can transfer data to the server several times, but the server can only return a response once. ``` -- ####服务端流模式 (Response-streaming) +- ####服务端流模式 (unary-stream) ```text 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. ``` -- ####双向流模式 (Bidirectional Streaming) +- ####双向流模式 (stream-stream) ```text 在一次调用中, 客户端和服务器都可以向对方多次收发数据 In a single call, both client and server can send and receive data to each other multiple times. ``` ----- -Author: Zhongying Wang - -Email: kerbalwzy@gmail.com - -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 \ No newline at end of file diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto index 2844ba7b225..dd29a178d77 100644 --- a/examples/python/easy_start_demo/demo.proto +++ b/examples/python/easy_start_demo/demo.proto @@ -1,9 +1,9 @@ // 语法版本声明,必须放在非注释的第一行 -// Syntax version declaration, Must be placed on the first line of non-commentary +// Syntax version declaration. Must be placed on the first line of non-commentary. syntax = "proto3"; // 包名定义, Python中使用时可以省略不写(PS:我还要再Go中使用,所以留在这里了) -// Package name definition, which can be omitted in Python (PS: I'll use it again in Go, so stay here) +// Package name definition, which can be omitted in Python. (PS: I'll use it again in Go, so stay here) package demo; /* @@ -17,34 +17,34 @@ Each field in the message definition has a unique number. The overall format is similar to defining a class in Python or a structure in Golang. */ message Request { - int64 Cid = 1; - string ReqMsg = 2; + int64 client_id = 1; + string request_data = 2; } message Response { - int64 Sid = 1; - string RespMsg = 2; + int64 server_id = 1; + string response_data = 2; } // service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 // `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang service GRPCDemo { // 简单模式 - // Simple + // unary-unary rpc SimpleMethod (Request) returns (Response); // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - // Request-streaming (In a single call, the client can transfer data to the server several times, + // stream-unary (In a single call, the client can transfer data to the server several times, // but the server can only return a response once.) rpc ClientStreamingMethod (stream Request) returns (Response); // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - // Response-streaming (In a single call, the client can only transmit data to the server at one time, + // unary-stream (In a single call, the client can only transmit data to the server at one time, // but the server can return the response many times.) rpc ServerStreamingMethod (Request) returns (stream Response); // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - // Bidirectional streaming (In a single call, both client and server can send and receive data + // stream-stream (In a single call, both client and server can send and receive data // to each other multiple times.) rpc BidirectionalStreamingMethod (stream Request) returns (stream Response); } diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py index de960c8a6c1..5dfaf837dfd 100644 --- a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py @@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( package='demo', syntax='proto3', serialized_options=None, - serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') + serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"2\n\x07Request\x12\x11\n\tclient_id\x18\x01 \x01(\x03\x12\x14\n\x0crequest_data\x18\x02 \x01(\t\"4\n\x08Response\x12\x11\n\tserver_id\x18\x01 \x01(\x03\x12\x15\n\rresponse_data\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') ) @@ -34,14 +34,14 @@ _REQUEST = _descriptor.Descriptor( containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Cid', full_name='demo.Request.Cid', index=0, + name='client_id', full_name='demo.Request.client_id', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='ReqMsg', full_name='demo.Request.ReqMsg', index=1, + name='request_data', full_name='demo.Request.request_data', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -60,7 +60,7 @@ _REQUEST = _descriptor.Descriptor( oneofs=[ ], serialized_start=20, - serialized_end=58, + serialized_end=70, ) @@ -72,14 +72,14 @@ _RESPONSE = _descriptor.Descriptor( containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Sid', full_name='demo.Response.Sid', index=0, + name='server_id', full_name='demo.Response.server_id', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='RespMsg', full_name='demo.Response.RespMsg', index=1, + name='response_data', full_name='demo.Response.response_data', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -97,8 +97,8 @@ _RESPONSE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=60, - serialized_end=100, + serialized_start=72, + serialized_end=124, ) DESCRIPTOR.message_types_by_name['Request'] = _REQUEST @@ -127,8 +127,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( file=DESCRIPTOR, index=0, serialized_options=None, - serialized_start=103, - serialized_end=343, + serialized_start=127, + serialized_end=367, methods=[ _descriptor.MethodDescriptor( name='SimpleMethod', diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py index 0f7d5dabbd6..b6d6fc72a13 100644 --- a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py @@ -44,7 +44,7 @@ class GRPCDemoServicer(object): def SimpleMethod(self, request, context): """简单模式 - Simple + unary-unary """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -52,7 +52,7 @@ class GRPCDemoServicer(object): def ClientStreamingMethod(self, request_iterator, context): """客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - Request-streaming (In a single call, the client can transfer data to the server several times, + stream-unary (In a single call, the client can transfer data to the server several times, but the server can only return a response once.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -61,7 +61,7 @@ class GRPCDemoServicer(object): def ServerStreamingMethod(self, request, context): """服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - Response-streaming (In a single call, the client can only transmit data to the server at one time, + unary-stream (In a single call, the client can only transmit data to the server at one time, but the server can return the response many times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -70,7 +70,7 @@ class GRPCDemoServicer(object): def BidirectionalStreamingMethod(self, request_iterator, context): """双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - Bidirectional streaming (In a single call, both client and server can send and receive data + stream-stream (In a single call, both client and server can send and receive data to each other multiple times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) From 5ca7452c51d4ac87185db1d3025b84c517605397 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 16 Aug 2019 11:57:35 +0800 Subject: [PATCH 044/176] fix:Update the constant name. Replace abbreviations with complete forms of words --- examples/python/easy_start_demo/client.py | 48 +++++++++++------------ examples/python/easy_start_demo/server.py | 44 ++++++++++----------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/examples/python/easy_start_demo/client.py b/examples/python/easy_start_demo/client.py index 46d11d05cbf..b5b994820a3 100644 --- a/examples/python/easy_start_demo/client.py +++ b/examples/python/easy_start_demo/client.py @@ -15,22 +15,22 @@ sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) from demo_grpc_pbs import demo_pb2, demo_pb2_grpc -ServerAddress = "127.0.0.1:23334" -ClientId = 1 +SERVER_ADDRESS = "localhost:23334" +CLIENT_ID = 1 # 简单模式 -# Simple Method +# unary-unary def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp = stub.SimpleMethod(req) - print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + response = stub.SimpleMethod(request) + print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) print("--------------Call SimpleMethod Over---------------") # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) -# Request-streaming (In a single call, the client can transfer data to the server several times, +# stream-unary (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def client_streaming_method(stub): print("--------------Call ClientStreamingMethod Begin--------------") @@ -39,50 +39,50 @@ def client_streaming_method(stub): # create a generator def request_messages(): for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message:%d" % i)) - yield req + request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message:%d" % i)) + yield request - resp = stub.ClientStreamingMethod(request_messages()) - print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + response = stub.ClientStreamingMethod(request_messages()) + print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) print("--------------Call ClientStreamingMethod Over---------------") # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) -# Response-streaming (In a single call, the client can only transmit data to the server at one time, +# unary-stream (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def server_streaming_method(stub): print("--------------Call ServerStreamingMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp_s = stub.ServerStreamingMethod(req) - for resp in resp_s: - print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + response_iterator = stub.ServerStreamingMethod(request) + for response in response_iterator: + print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) print("--------------Call ServerStreamingMethod Over---------------") # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) -# Bidirectional Streaming (In a single call, both client and server can send and receive data +# stream-stream (In a single call, both client and server can send and receive data # to each other multiple times.) def bidirectional_streaming_method(stub): print("--------------Call BidirectionalStreamingMethod Begin---------------") # 创建一个生成器 # create a generator - def req_messages(): + def request_messages(): for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message: %d" % i)) - yield req + request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message: %d" % i)) + yield request time.sleep(1) - resp_s = stub.BidirectionalStreamingMethod(req_messages()) - for resp in resp_s: - print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + response_iterator = stub.BidirectionalStreamingMethod(request_messages()) + for response in response_iterator: + print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) print("--------------Call BidirectionalStreamingMethod Over---------------") def main(): - with grpc.insecure_channel(ServerAddress) as channel: + with grpc.insecure_channel(SERVER_ADDRESS) as channel: stub = demo_pb2_grpc.GRPCDemoStub(channel) simple_method(stub) diff --git a/examples/python/easy_start_demo/server.py b/examples/python/easy_start_demo/server.py index a4130719ada..60fb84768b7 100644 --- a/examples/python/easy_start_demo/server.py +++ b/examples/python/easy_start_demo/server.py @@ -18,61 +18,61 @@ sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) from demo_grpc_pbs import demo_pb2, demo_pb2_grpc -ServerAddress = '127.0.0.1:23334' -ServerId = 1 +SERVER_ADDRESS = 'localhost:23334' +SERVER_ID = 1 class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # 简单模式 - # Simple + # unary-unary def SimpleMethod(self, request, context): - print("SimpleMethod called by client(%d) the message: %s" % (request.Cid, request.ReqMsg)) - resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") - return resp + print("SimpleMethod called by client(%d) the message: %s" % (request.client_id, request.request_data)) + response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server SimpleMethod Ok!!!!") + return response # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - # Request-streaming (In a single call, the client can transfer data to the server several times, + # stream-unary (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def ClientStreamingMethod(self, request_iterator, context): print("ClientStreamingMethod called by client...") - for req in request_iterator: - print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) - resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server ClientStreamingMethod ok") - return resp + for request in request_iterator: + print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) + response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server ClientStreamingMethod ok") + return response # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - # Response-streaming (In a single call, the client can only transmit data to the server at one time, + # unary-stream (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def ServerStreamingMethod(self, request, context): - print("ServerStreamingMethod called by client(%d), message= %s" % (request.Cid, request.ReqMsg)) + print("ServerStreamingMethod called by client(%d), message= %s" % (request.client_id, request.request_data)) # 创建一个生成器 # create a generator def response_messages(): for i in range(5): - resp = demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message=%d" % i)) - yield resp + response = demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message=%d" % i)) + yield response return response_messages() # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - # Bidirectional Streaming (In a single call, both client and server can send and receive data + # stream-stream (In a single call, both client and server can send and receive data # to each other multiple times.) def BidirectionalStreamingMethod(self, request_iterator, context): print("BidirectionalStreamingMethod called by client...") # 开启一个子线程去接收数据 # Open a sub thread to receive data - def parse_req(): - for req in request_iterator: - print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) + def parse_request(): + for request in request_iterator: + print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) - t = Thread(target=parse_req) + t = Thread(target=parse_request) t.start() for i in range(5): - yield demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message= %d" % i)) + yield demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message= %d" % i)) t.join() @@ -82,7 +82,7 @@ def main(): demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server) - server.add_insecure_port(ServerAddress) + server.add_insecure_port(SERVER_ADDRESS) print("------------------start Python GRPC server") server.start() From 7beba8547eaa94a7eb465e983b8e3f74993feae1 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 16 Aug 2019 12:08:27 +0800 Subject: [PATCH 045/176] fix:Make the title appear properly --- examples/python/easy_start_demo/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 32ad177af17..919b9c5cc61 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -2,24 +2,24 @@ 在Python中使用gRPC时, 进行数据传输的四种方式。(Four ways of data transmission when gRPC is used in Python.) -- ####简单模式 (unary-unary) +- #### 简单模式 (unary-unary) ```text 没啥好说的,跟调普通方法没差 There's nothing to say. It's no different from the usual way. ``` -- ####客户端流模式 (stream-unary) +- #### 客户端流模式 (stream-unary) ```text 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. In a single call, the client can transfer data to the server several times, but the server can only return a response once. ``` -- ####服务端流模式 (unary-stream) +- #### 服务端流模式 (unary-stream) ```text 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. ``` -- ####双向流模式 (stream-stream) +- #### 双向流模式 (stream-stream) ```text 在一次调用中, 客户端和服务器都可以向对方多次收发数据 In a single call, both client and server can send and receive data From 28b06712352ed5e264647437fe3fe6f0de1b9d10 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 15:53:56 -0700 Subject: [PATCH 046/176] Make MethodHandler and related interfaces generic --- BUILD | 2 + BUILD.gn | 1 + CMakeLists.txt | 5 +- Makefile | 4 + build.yaml | 1 + gRPC-C++.podspec | 1 + include/grpcpp/impl/codegen/byte_buffer.h | 27 +-- .../impl/codegen/completion_queue_impl.h | 33 ++-- include/grpcpp/impl/codegen/method_handler.h | 73 ++++++++ .../grpcpp/impl/codegen/method_handler_impl.h | 176 ++++++++++-------- .../impl/codegen/security/auth_context.h | 6 +- .../grpcpp/impl/codegen/server_context_impl.h | 31 ++- .../grpcpp/impl/codegen/server_interface.h | 2 + .../grpcpp/impl/codegen/sync_stream_impl.h | 10 +- include/grpcpp/support/method_handler.h | 24 +++ src/compiler/cpp_generator.cc | 4 +- src/cpp/server/server_cc.cc | 2 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + 19 files changed, 268 insertions(+), 136 deletions(-) create mode 100644 include/grpcpp/impl/codegen/method_handler.h create mode 100644 include/grpcpp/support/method_handler.h diff --git a/BUILD b/BUILD index c510757c35d..04f53e18248 100644 --- a/BUILD +++ b/BUILD @@ -280,6 +280,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", "include/grpcpp/support/message_allocator.h", + "include/grpcpp/support/method_handler.h", "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", @@ -2027,6 +2028,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/interceptor_common.h", "include/grpcpp/impl/codegen/message_allocator.h", "include/grpcpp/impl/codegen/metadata_map.h", + "include/grpcpp/impl/codegen/method_handler.h", "include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/rpc_method.h", "include/grpcpp/impl/codegen/rpc_service_method.h", diff --git a/BUILD.gn b/BUILD.gn index eea022eac51..6ee85b19383 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1107,6 +1107,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/interceptor_common.h", "include/grpcpp/impl/codegen/message_allocator.h", "include/grpcpp/impl/codegen/metadata_map.h", + "include/grpcpp/impl/codegen/method_handler.h", "include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/proto_buffer_reader.h", "include/grpcpp/impl/codegen/proto_buffer_writer.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 65aadb7cf1a..d204d3799da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3480,6 +3480,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -3993,6 +3994,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -4202,6 +4204,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -4580,6 +4583,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -17370,7 +17374,6 @@ target_include_directories(timer_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} diff --git a/Makefile b/Makefile index e28b9bb2f45..ef0a86eb36a 100644 --- a/Makefile +++ b/Makefile @@ -5857,6 +5857,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ @@ -6328,6 +6329,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ @@ -6506,6 +6508,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ @@ -6888,6 +6891,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ diff --git a/build.yaml b/build.yaml index ee5a45e26fd..454ce09facc 100644 --- a/build.yaml +++ b/build.yaml @@ -378,6 +378,7 @@ filegroups: - include/grpcpp/impl/codegen/interceptor_common.h - include/grpcpp/impl/codegen/message_allocator.h - include/grpcpp/impl/codegen/metadata_map.h + - include/grpcpp/impl/codegen/method_handler.h - include/grpcpp/impl/codegen/method_handler_impl.h - include/grpcpp/impl/codegen/rpc_method.h - include/grpcpp/impl/codegen/rpc_service_method.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index d71773a7361..80ea8c6b30a 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -186,6 +186,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/interceptor_common.h', 'include/grpcpp/impl/codegen/message_allocator.h', 'include/grpcpp/impl/codegen/metadata_map.h', + 'include/grpcpp/impl/codegen/method_handler.h', 'include/grpcpp/impl/codegen/method_handler_impl.h', 'include/grpcpp/impl/codegen/rpc_method.h', 'include/grpcpp/impl/codegen/rpc_service_method.h', diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index 0b7be6fc753..7fb678d5f7f 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -36,6 +36,12 @@ template class CallbackUnaryHandler; template class CallbackServerStreamingHandler; +template +class RpcMethodHandler; +template +class ServerStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; } // namespace internal } // namespace grpc_impl @@ -51,21 +57,10 @@ class CallOpSendMessage; template class CallOpRecvMessage; class CallOpGenericRecvMessage; -class MethodHandler; -template -class RpcMethodHandler; -template -class ServerStreamingHandler; -template -class ErrorMethodHandler; class ExternalConnectionAcceptorImpl; template class DeserializeFuncType; class GrpcByteBufferPeer; -template -class RpcMethodHandler; -template -class ServerStreamingHandler; } // namespace internal /// A sequence of bytes. @@ -175,19 +170,17 @@ class ByteBuffer final { friend class internal::CallOpRecvMessage; friend class internal::CallOpGenericRecvMessage; template - friend class RpcMethodHandler; - template - friend class ServerStreamingHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template - friend class internal::RpcMethodHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; template - friend class internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template friend class ::grpc_impl::internal::CallbackUnaryHandler; template friend class ::grpc_impl::internal::CallbackServerStreamingHandler; template - friend class internal::ErrorMethodHandler; + friend class ::grpc_impl::internal::ErrorMethodHandler; template friend class internal::DeserializeFuncType; friend class ProtoBufferReader; diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index 7716a57e84a..7cb3d2288c6 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -60,28 +60,27 @@ class ServerWriter; namespace internal { template class ServerReaderWriterBody; -} // namespace internal -} // namespace grpc_impl -namespace grpc { - -class ChannelInterface; -class ServerInterface; -namespace internal { -class CompletionQueueTag; -class RpcMethod; template class RpcMethodHandler; template class ClientStreamingHandler; template class ServerStreamingHandler; -template -class BidiStreamingHandler; template class TemplatedBidiStreamingHandler; -template +template <::grpc::StatusCode code> class ErrorMethodHandler; +} // namespace internal +} // namespace grpc_impl +namespace grpc { + +class ChannelInterface; +class ServerInterface; + +namespace internal { +class CompletionQueueTag; +class RpcMethod; template class BlockingUnaryCallImpl; template @@ -266,15 +265,15 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { template friend class ::grpc_impl::internal::ServerReaderWriterBody; template - friend class ::grpc::internal::RpcMethodHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template - friend class ::grpc::internal::ClientStreamingHandler; + friend class ::grpc_impl::internal::ClientStreamingHandler; template - friend class ::grpc::internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler; template <::grpc::StatusCode code> - friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc_impl::internal::ErrorMethodHandler; friend class ::grpc_impl::Server; friend class ::grpc_impl::ServerContext; friend class ::grpc::ServerInterface; diff --git a/include/grpcpp/impl/codegen/method_handler.h b/include/grpcpp/impl/codegen/method_handler.h new file mode 100644 index 00000000000..4b0f594f237 --- /dev/null +++ b/include/grpcpp/impl/codegen/method_handler.h @@ -0,0 +1,73 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H +#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H + +#include + +namespace grpc { + +namespace internal { + +template +using BidiStreamingHandler = + ::grpc_impl::internal::BidiStreamingHandler; + +template +using RpcMethodHandler = + ::grpc_impl::internal::RpcMethodHandler; + +template +using ClientStreamingHandler = + ::grpc_impl::internal::ClientStreamingHandler; + +template +using ServerStreamingHandler = + ::grpc_impl::internal::ServerStreamingHandler; + +template +using TemplatedBidiStreamingHandler = + ::grpc_impl::internal::TemplatedBidiStreamingHandler; + +template +using StreamedUnaryHandler = + ::grpc_impl::internal::StreamedUnaryHandler; + +template +using SplitServerStreamingHandler = + ::grpc_impl::internal::SplitServerStreamingHandler; + +template +using ErrorMethodHandler = ::grpc_impl::internal::ErrorMethodHandler; + +using UnknownMethodHandler = ::grpc_impl::internal::UnknownMethodHandler; + +using ResourceExhaustedHandler = + ::grpc_impl::internal::ResourceExhaustedHandler; + +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 1903f898ba8..c36599800ca 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -22,9 +22,9 @@ #include #include #include -#include +#include -namespace grpc { +namespace grpc_impl { namespace internal { @@ -36,12 +36,13 @@ namespace internal { // Additionally, we don't need to return if we caught an exception or not; // the handling is the same in either case. template -Status CatchingFunctionHandler(Callable&& handler) { +::grpc::Status CatchingFunctionHandler(Callable&& handler) { #if GRPC_ALLOW_EXCEPTIONS try { return handler(); } catch (...) { - return Status(StatusCode::UNKNOWN, "Unexpected error in RPC handling"); + return ::grpc::Status(::grpc::StatusCode::UNKNOWN, + "Unexpected error in RPC handling"); } #else // GRPC_ALLOW_EXCEPTIONS return handler(); @@ -50,18 +51,18 @@ Status CatchingFunctionHandler(Callable&& handler) { /// A wrapper class of an application provided rpc method handler. template -class RpcMethodHandler : public MethodHandler { +class RpcMethodHandler : public ::grpc::internal::MethodHandler { public: RpcMethodHandler( - std::function + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, ResponseType*)> func, ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { ResponseType rsp; - Status status = param.status; + ::grpc::Status status = param.status; if (status.ok()) { status = CatchingFunctionHandler([this, ¶m, &rsp] { return func_(service_, param.server_context, @@ -71,8 +72,9 @@ class RpcMethodHandler : public MethodHandler { } GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_); - CallOpSet + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> ops; ops.SendInitialMetadata(¶m.server_context->initial_metadata_, param.server_context->initial_metadata_flags()); @@ -87,13 +89,15 @@ class RpcMethodHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; buf.set_buffer(req); - auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = SerializationTraits::Deserialize(&buf, request); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; @@ -104,8 +108,8 @@ class RpcMethodHandler : public MethodHandler { private: /// Application provided rpc handler function. - std::function + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, ResponseType*)> func_; // The class the above handler function lives in. ServiceType* service_; @@ -113,24 +117,28 @@ class RpcMethodHandler : public MethodHandler { /// A wrapper class of an application provided client streaming handler. template -class ClientStreamingHandler : public MethodHandler { +class ClientStreamingHandler : public ::grpc::internal::MethodHandler { public: ClientStreamingHandler( - std::function*, ResponseType*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReader*, + ResponseType*)> func, ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { - ServerReader reader(param.call, param.server_context); + ::grpc_impl::ServerReader reader(param.call, + param.server_context); ResponseType rsp; - Status status = CatchingFunctionHandler([this, ¶m, &reader, &rsp] { - return func_(service_, param.server_context, &reader, &rsp); - }); - - CallOpSet + ::grpc::Status status = + CatchingFunctionHandler([this, ¶m, &reader, &rsp] { + return func_(service_, param.server_context, &reader, &rsp); + }); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> ops; if (!param.server_context->sent_initial_metadata_) { ops.SendInitialMetadata(¶m.server_context->initial_metadata_, @@ -148,27 +156,30 @@ class ClientStreamingHandler : public MethodHandler { } private: - std::function*, ResponseType*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReader*, + ResponseType*)> func_; ServiceType* service_; }; /// A wrapper class of an application provided server streaming handler. template -class ServerStreamingHandler : public MethodHandler { +class ServerStreamingHandler : public ::grpc::internal::MethodHandler { public: ServerStreamingHandler( - std::function*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, + ::grpc_impl::ServerWriter*)> func, ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { - Status status = param.status; + ::grpc::Status status = param.status; if (status.ok()) { - ServerWriter writer(param.call, param.server_context); + ::grpc_impl::ServerWriter writer(param.call, + param.server_context); status = CatchingFunctionHandler([this, ¶m, &writer] { return func_(service_, param.server_context, static_cast(param.request), &writer); @@ -176,7 +187,9 @@ class ServerStreamingHandler : public MethodHandler { static_cast(param.request)->~RequestType(); } - CallOpSet ops; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; if (!param.server_context->sent_initial_metadata_) { ops.SendInitialMetadata(¶m.server_context->initial_metadata_, param.server_context->initial_metadata_flags()); @@ -192,13 +205,15 @@ class ServerStreamingHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; buf.set_buffer(req); - auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = SerializationTraits::Deserialize(&buf, request); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; @@ -208,8 +223,9 @@ class ServerStreamingHandler : public MethodHandler { } private: - std::function*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, + ::grpc_impl::ServerWriter*)> func_; ServiceType* service_; }; @@ -222,19 +238,22 @@ class ServerStreamingHandler : public MethodHandler { /// Instead, it is expected to be an implicitly-captured argument of func /// (through bind or something along those lines) template -class TemplatedBidiStreamingHandler : public MethodHandler { +class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler { public: TemplatedBidiStreamingHandler( - std::function func) + std::function<::grpc::Status(::grpc_impl::ServerContext*, Streamer*)> + func) : func_(func), write_needed_(WriteNeeded) {} void RunHandler(const HandlerParameter& param) final { Streamer stream(param.call, param.server_context); - Status status = CatchingFunctionHandler([this, ¶m, &stream] { + ::grpc::Status status = CatchingFunctionHandler([this, ¶m, &stream] { return func_(param.server_context, &stream); }); - CallOpSet ops; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; if (!param.server_context->sent_initial_metadata_) { ops.SendInitialMetadata(¶m.server_context->initial_metadata_, param.server_context->initial_metadata_flags()); @@ -244,8 +263,8 @@ class TemplatedBidiStreamingHandler : public MethodHandler { if (write_needed_ && status.ok()) { // If we needed a write but never did one, we need to mark the // status as a fail - status = Status(StatusCode::INTERNAL, - "Service did not provide response message"); + status = ::grpc::Status(::grpc::StatusCode::INTERNAL, + "Service did not provide response message"); } } ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); @@ -257,59 +276,65 @@ class TemplatedBidiStreamingHandler : public MethodHandler { } private: - std::function func_; + std::function<::grpc::Status(::grpc_impl::ServerContext*, Streamer*)> func_; const bool write_needed_; }; template class BidiStreamingHandler : public TemplatedBidiStreamingHandler< - ServerReaderWriter, false> { + ::grpc_impl::ServerReaderWriter, false> { public: BidiStreamingHandler( - std::function*)> + std::function<::grpc::Status( + ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReaderWriter*)> func, ServiceType* service) : TemplatedBidiStreamingHandler< - ServerReaderWriter, false>(std::bind( - func, service, std::placeholders::_1, std::placeholders::_2)) {} + ::grpc_impl::ServerReaderWriter, false>( + std::bind(func, service, std::placeholders::_1, + std::placeholders::_2)) {} }; template class StreamedUnaryHandler : public TemplatedBidiStreamingHandler< - ServerUnaryStreamer, true> { + ::grpc_impl::ServerUnaryStreamer, true> { public: explicit StreamedUnaryHandler( - std::function*)> + std::function<::grpc::Status( + ::grpc_impl::ServerContext*, + ::grpc_impl::ServerUnaryStreamer*)> func) : TemplatedBidiStreamingHandler< - ServerUnaryStreamer, true>(func) {} + ::grpc_impl::ServerUnaryStreamer, true>( + func) {} }; template class SplitServerStreamingHandler : public TemplatedBidiStreamingHandler< - ServerSplitStreamer, false> { + ::grpc_impl::ServerSplitStreamer, false> { public: explicit SplitServerStreamingHandler( - std::function*)> + std::function<::grpc::Status( + ::grpc_impl::ServerContext*, + ::grpc_impl::ServerSplitStreamer*)> func) : TemplatedBidiStreamingHandler< - ServerSplitStreamer, false>(func) {} + ::grpc_impl::ServerSplitStreamer, false>( + func) {} }; /// General method handler class for errors that prevent real method use /// e.g., handle unknown method by returning UNIMPLEMENTED error. -template -class ErrorMethodHandler : public MethodHandler { +template <::grpc::StatusCode code> +class ErrorMethodHandler : public ::grpc::internal::MethodHandler { public: template static void FillOps(::grpc_impl::ServerContext* context, T* ops) { - Status status(code, ""); + ::grpc::Status status(code, ""); if (!context->sent_initial_metadata_) { ops->SendInitialMetadata(&context->initial_metadata_, context->initial_metadata_flags()); @@ -322,27 +347,30 @@ class ErrorMethodHandler : public MethodHandler { } void RunHandler(const HandlerParameter& param) final { - CallOpSet ops; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; FillOps(param.server_context, &ops); param.call->PerformOps(&ops); param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { // We have to destroy any request payload if (req != nullptr) { - g_core_codegen_interface->grpc_byte_buffer_destroy(req); + ::grpc::g_core_codegen_interface->grpc_byte_buffer_destroy(req); } return nullptr; } }; -typedef ErrorMethodHandler UnknownMethodHandler; -typedef ErrorMethodHandler +typedef ErrorMethodHandler<::grpc::StatusCode::UNIMPLEMENTED> + UnknownMethodHandler; +typedef ErrorMethodHandler<::grpc::StatusCode::RESOURCE_EXHAUSTED> ResourceExhaustedHandler; } // namespace internal -} // namespace grpc +} // namespace grpc_impl #endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H diff --git a/include/grpcpp/impl/codegen/security/auth_context.h b/include/grpcpp/impl/codegen/security/auth_context.h index 0e30f7cc3f4..6c0089ca424 100644 --- a/include/grpcpp/impl/codegen/security/auth_context.h +++ b/include/grpcpp/impl/codegen/security/auth_context.h @@ -32,7 +32,7 @@ struct grpc_auth_property_iterator; namespace grpc { class SecureAuthContext; -typedef std::pair AuthProperty; +typedef std::pair AuthProperty; class AuthPropertyIterator : public std::iterator { @@ -86,8 +86,8 @@ class AuthContext { /// Mutation functions: should only be used by an AuthMetadataProcessor. virtual void AddProperty(const grpc::string& key, - const grpc::string_ref& value) = 0; - virtual bool SetPeerIdentityPropertyName(const grpc::string& name) = 0; + const string_ref& value) = 0; + virtual bool SetPeerIdentityPropertyName(const string& name) = 0; }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/server_context_impl.h b/include/grpcpp/impl/codegen/server_context_impl.h index 72137f153b1..7e2a5720199 100644 --- a/include/grpcpp/impl/codegen/server_context_impl.h +++ b/include/grpcpp/impl/codegen/server_context_impl.h @@ -68,9 +68,19 @@ template class CallbackServerStreamingHandler; template class CallbackBidiHandler; +template +class ClientStreamingHandler; +template +class RpcMethodHandler; template class ServerReaderWriterBody; +template +class ServerStreamingHandler; class ServerReactor; +template +class TemplatedBidiStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; } // namespace internal } // namespace grpc_impl @@ -79,20 +89,9 @@ class GenericServerContext; class ServerInterface; namespace internal { -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; -template -class RpcMethodHandler; -template -class TemplatedBidiStreamingHandler; -template -class ErrorMethodHandler; class Call; } // namespace internal -class ServerInterface; namespace testing { class InteropServerContextInspector; class ServerContextTestSpouse; @@ -293,13 +292,13 @@ class ServerContext { template friend class ::grpc_impl::internal::ServerReaderWriterBody; template - friend class ::grpc::internal::RpcMethodHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template - friend class ::grpc::internal::ClientStreamingHandler; + friend class ::grpc_impl::internal::ClientStreamingHandler; template - friend class ::grpc::internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler; template friend class ::grpc_impl::internal::CallbackUnaryHandler; template @@ -309,7 +308,7 @@ class ServerContext { template friend class ::grpc_impl::internal::CallbackBidiHandler; template <::grpc::StatusCode code> - friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc_impl::internal::ErrorMethodHandler; friend class ::grpc_impl::ClientContext; friend class ::grpc::GenericServerContext; diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index a375d3c0b4c..46c4ebb11a5 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,7 @@ class ServerAsyncStreamingInterface; namespace experimental { class CallbackGenericService; +class ServerInterceptorFactoryInterface; } // namespace experimental class ServerInterface : public internal::CallHook { diff --git a/include/grpcpp/impl/codegen/sync_stream_impl.h b/include/grpcpp/impl/codegen/sync_stream_impl.h index dc764e0e27b..ec9cf49862d 100644 --- a/include/grpcpp/impl/codegen/sync_stream_impl.h +++ b/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -613,7 +613,7 @@ class ServerReader final : public ServerReaderInterface { ServerContext* const ctx_; template - friend class ::grpc::internal::ClientStreamingHandler; + friend class ::grpc_impl::internal::ClientStreamingHandler; ServerReader(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -688,7 +688,7 @@ class ServerWriter final : public ServerWriterInterface { ::grpc_impl::ServerContext* const ctx_; template - friend class ::grpc::internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; ServerWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -800,7 +800,7 @@ class ServerReaderWriter final : public ServerReaderWriterInterface { private: internal::ServerReaderWriterBody body_; - friend class ::grpc::internal::TemplatedBidiStreamingHandler< + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerReaderWriter, false>; ServerReaderWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) @@ -870,7 +870,7 @@ class ServerUnaryStreamer final bool read_done_; bool write_done_; - friend class ::grpc::internal::TemplatedBidiStreamingHandler< + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerUnaryStreamer, true>; ServerUnaryStreamer(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) @@ -932,7 +932,7 @@ class ServerSplitStreamer final internal::ServerReaderWriterBody body_; bool read_done_; - friend class ::grpc::internal::TemplatedBidiStreamingHandler< + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerSplitStreamer, false>; ServerSplitStreamer(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) diff --git a/include/grpcpp/support/method_handler.h b/include/grpcpp/support/method_handler.h new file mode 100644 index 00000000000..038e76c8af8 --- /dev/null +++ b/include/grpcpp/support/method_handler.h @@ -0,0 +1,24 @@ +/* + * + * 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. + * + */ + +#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H +#define GRPCPP_SUPPORT_METHOD_HANDLER_H + +#include + +#endif // GRPCPP_SUPPORT_METHOD_HANDLER_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 044647d9a81..e63bdf6de98 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -144,7 +144,7 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/client_callback.h", "grpcpp/impl/codegen/client_context.h", "grpcpp/impl/codegen/completion_queue.h", - "grpcpp/impl/codegen/method_handler_impl.h", + "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", "grpcpp/impl/codegen/server_callback.h", @@ -1657,7 +1657,7 @@ grpc::string GetSourceIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/channel_interface.h", "grpcpp/impl/codegen/client_unary_call.h", "grpcpp/impl/codegen/client_callback.h", - "grpcpp/impl/codegen/method_handler_impl.h", + "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/rpc_service_method.h", "grpcpp/impl/codegen/server_callback.h", "grpcpp/impl/codegen/service_type.h", diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 02cfb59c0e6..f7984645c42 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -31,9 +31,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 168e6c8d770..cef7cc20b1d 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -979,6 +979,7 @@ include/grpcpp/impl/codegen/interceptor.h \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ +include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/proto_buffer_reader.h \ include/grpcpp/impl/codegen/proto_buffer_writer.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3b7af742baa..6359c45665a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -981,6 +981,7 @@ include/grpcpp/impl/codegen/interceptor.h \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ +include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/proto_buffer_reader.h \ include/grpcpp/impl/codegen/proto_buffer_writer.h \ From 6b3bd74e686e65ee7a0ec8913ef2ecacef34cbcf Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 16:17:13 -0700 Subject: [PATCH 047/176] Fix CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d204d3799da..40dcf9e3ec4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -792,6 +792,7 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} From 957a686a70b2cd2c386182eaafd14224e8bc6338 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 16:20:26 -0700 Subject: [PATCH 048/176] Fix the nano pb from CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40dcf9e3ec4..d204d3799da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -792,7 +792,6 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} From 2b8ad5ee56ccd68a9092084e1bcaf760f3eae1f8 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 16:30:51 -0700 Subject: [PATCH 049/176] Fix golden test compilation --- test/cpp/codegen/compiler_test_golden | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 34fb5bfb53f..2c144f7d003 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include From caf64469f0fbfd34c5d4a8ff81eebaa6cce69236 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 10:08:29 +0800 Subject: [PATCH 050/176] Update: rename the folder --- examples/python/{easy_start_demo => data_transmission}/README.md | 0 examples/python/{easy_start_demo => data_transmission}/client.py | 0 examples/python/{easy_start_demo => data_transmission}/demo.proto | 0 .../demo_grpc_pbs/demo_pb2.py | 0 .../demo_grpc_pbs/demo_pb2_grpc.py | 0 examples/python/{easy_start_demo => data_transmission}/server.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename examples/python/{easy_start_demo => data_transmission}/README.md (100%) rename examples/python/{easy_start_demo => data_transmission}/client.py (100%) rename examples/python/{easy_start_demo => data_transmission}/demo.proto (100%) rename examples/python/{easy_start_demo => data_transmission}/demo_grpc_pbs/demo_pb2.py (100%) rename examples/python/{easy_start_demo => data_transmission}/demo_grpc_pbs/demo_pb2_grpc.py (100%) rename examples/python/{easy_start_demo => data_transmission}/server.py (100%) diff --git a/examples/python/easy_start_demo/README.md b/examples/python/data_transmission/README.md similarity index 100% rename from examples/python/easy_start_demo/README.md rename to examples/python/data_transmission/README.md diff --git a/examples/python/easy_start_demo/client.py b/examples/python/data_transmission/client.py similarity index 100% rename from examples/python/easy_start_demo/client.py rename to examples/python/data_transmission/client.py diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/data_transmission/demo.proto similarity index 100% rename from examples/python/easy_start_demo/demo.proto rename to examples/python/data_transmission/demo.proto diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py b/examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py similarity index 100% rename from examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py rename to examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py b/examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py similarity index 100% rename from examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py rename to examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py diff --git a/examples/python/easy_start_demo/server.py b/examples/python/data_transmission/server.py similarity index 100% rename from examples/python/easy_start_demo/server.py rename to examples/python/data_transmission/server.py From 151f5960546e5d25a295dd36f8bc99a1b61dd9ee Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 10:17:08 +0800 Subject: [PATCH 051/176] Fix: Cancel the modification of the package search path and Remove useless notes --- examples/python/data_transmission/client.py | 15 ++------------- .../{demo_grpc_pbs => }/demo_pb2.py | 0 .../{demo_grpc_pbs => }/demo_pb2_grpc.py | 0 examples/python/data_transmission/server.py | 18 ++++-------------- 4 files changed, 6 insertions(+), 27 deletions(-) rename examples/python/data_transmission/{demo_grpc_pbs => }/demo_pb2.py (100%) rename examples/python/data_transmission/{demo_grpc_pbs => }/demo_pb2_grpc.py (100%) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index b5b994820a3..21c61d6cc6e 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -1,19 +1,8 @@ -""" -Author: Zhongying Wang -Email: kerbalwzy@gmail.com -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 -""" -import os -import sys import time import grpc -# add the `demo_grpc_dps` dir into python package search paths -BaseDir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) - -from demo_grpc_pbs import demo_pb2, demo_pb2_grpc +import demo_pb2_grpc +import demo_pb2 SERVER_ADDRESS = "localhost:23334" CLIENT_ID = 1 diff --git a/examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py b/examples/python/data_transmission/demo_pb2.py similarity index 100% rename from examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py rename to examples/python/data_transmission/demo_pb2.py diff --git a/examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py b/examples/python/data_transmission/demo_pb2_grpc.py similarity index 100% rename from examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py rename to examples/python/data_transmission/demo_pb2_grpc.py diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 60fb84768b7..1baba78c0f6 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,22 +1,11 @@ -""" -Author: Zhongying Wang -Email: kerbalwzy@gmail.com -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 -""" -import os -import sys import time import grpc from threading import Thread from concurrent import futures -# add the `demo_grpc_dps` dir into python package search paths -BaseDir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) - -from demo_grpc_pbs import demo_pb2, demo_pb2_grpc +import demo_pb2_grpc +import demo_pb2 SERVER_ADDRESS = 'localhost:23334' SERVER_ID = 1 @@ -51,7 +40,8 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # create a generator def response_messages(): for i in range(5): - response = demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message=%d" % i)) + response = demo_pb2.Response(server_id=SERVER_ID, + response_data=("send by Python server, message=%d" % i)) yield response return response_messages() From 55f1899d78774c073805a4140e81e98ee1e95e10 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 10:36:35 +0800 Subject: [PATCH 052/176] Update:the max_workers argument use default, use 'server.wait_for_termination()' to keep process alive --- examples/python/data_transmission/server.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 1baba78c0f6..e6e51e1b733 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,4 +1,3 @@ -import time import grpc from threading import Thread @@ -68,17 +67,21 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): def main(): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + server = grpc.server(futures.ThreadPoolExecutor()) demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server) server.add_insecure_port(SERVER_ADDRESS) print("------------------start Python GRPC server") server.start() - - # In python3, `server` have no attribute `wait_for_termination` - while 1: - time.sleep(10) + server.wait_for_termination() + + # If raise Error: + # AttributeError: '_Server' object has no attribute 'wait_for_termination' + # You can use the following code instead: + # import time + # while 1: + # time.sleep(10) if __name__ == '__main__': From d5810a155b5a58688067c0f9aaf6bb32d0fab4a7 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 11:14:36 +0800 Subject: [PATCH 053/176] Fix: rebuild README files --- .../python/data_transmission/README.cn.md | 36 +++++++++++++++++++ .../python/data_transmission/README.en.md | 36 +++++++++++++++++++ examples/python/data_transmission/README.md | 28 --------------- 3 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 examples/python/data_transmission/README.cn.md create mode 100644 examples/python/data_transmission/README.en.md delete mode 100644 examples/python/data_transmission/README.md diff --git a/examples/python/data_transmission/README.cn.md b/examples/python/data_transmission/README.cn.md new file mode 100644 index 00000000000..500e9bf95de --- /dev/null +++ b/examples/python/data_transmission/README.cn.md @@ -0,0 +1,36 @@ +## Data transmission demo for using gRPC in Python + +在Python中使用gRPC时, 进行数据传输的四种方式。 + +- #### 简单模式 + + 没啥好说的,跟调普通方法没差 + + `client.py - line:13 - simple_method` + + `server.py - line:17 - SimpleMethod` + +- #### 客户端流模式 + + 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. + + `clien.py - line:24 - client_streaming_method ` + + `server.py - line:25 - ClientStreamingMethod` + +- #### 服务端流模式 + + 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 + + `clien.py - line:42 - server_streaming_method` + + `server.py - line:35 - ServerStreamingMethod` + +- #### 双向流模式 + + 在一次调用中, 客户端和服务器都可以向对方多次收发数据 + + `client.py - line:55 - bidirectional_streaming_method` + + `server.py - line:51 - BidirectionalStreamingMethod` + diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md new file mode 100644 index 00000000000..7fc527cf51a --- /dev/null +++ b/examples/python/data_transmission/README.en.md @@ -0,0 +1,36 @@ +## Data transmission demo for using gRPC in Python + +Four ways of data transmission when gRPC is used in Python. + +- #### unary-unary + + There's nothing to say. It's no different from the usual way. + + `client.py - line:13 - simple_method` + + `server.py - line:17 - SimpleMethod` +- #### stream-unary + + In a single call, the client can transfer data to the server an arbitrary number of times, but the server can only return a response once. + + `clien.py - line:24 - client_streaming_method` + + `server.py - line:25 - ClientStreamingMethod` + +- #### unary-stream + + In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. + + `clien.py - line:42 - server_streaming_method` + + `server.py - line:35 - ServerStreamingMethod` + +- #### stream-stream + + In a single call, both client and server can send and receive data + to each other multiple times. + + `client.py - line:55 - bidirectional_streaming_method` + + `server.py - line:51 - BidirectionalStreamingMethod` + diff --git a/examples/python/data_transmission/README.md b/examples/python/data_transmission/README.md deleted file mode 100644 index 919b9c5cc61..00000000000 --- a/examples/python/data_transmission/README.md +++ /dev/null @@ -1,28 +0,0 @@ -## Demo for using gRPC in Python - -在Python中使用gRPC时, 进行数据传输的四种方式。(Four ways of data transmission when gRPC is used in Python.) - -- #### 简单模式 (unary-unary) -```text -没啥好说的,跟调普通方法没差 -There's nothing to say. It's no different from the usual way. -``` -- #### 客户端流模式 (stream-unary) -```text -在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. -In a single call, the client can transfer data to the server several times, -but the server can only return a response once. -``` -- #### 服务端流模式 (unary-stream) -```text -在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 -In a single call, the client can only transmit data to the server at one time, -but the server can return the response many times. -``` -- #### 双向流模式 (stream-stream) -```text -在一次调用中, 客户端和服务器都可以向对方多次收发数据 -In a single call, both client and server can send and receive data -to each other multiple times. -``` - From b46e3668d31a014c8ab72fbae63f52990051127a Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 20 Aug 2019 14:14:16 -0700 Subject: [PATCH 054/176] s/branch/tail_call/ for CH2 on_hdr(). on_hdr() checks if a void-return function pointer is null before jumping to it. If it is null, it returns an error; else it executes that function and returns success. This change converts the void-returning function to one that returns a grpc_error* and thus saves a branch in on_hdr() (since we're branching once by following the function pointer anyways, we're effectively coalescing these two branches). --- .../chttp2/transport/hpack_parser.cc | 49 +++++++++---------- .../transport/chttp2/transport/hpack_parser.h | 2 +- .../transport/chttp2/transport/hpack_table.cc | 21 ++++++-- .../transport/chttp2/transport/hpack_table.h | 15 ++++-- .../ext/transport/chttp2/transport/parsing.cc | 13 +++-- .../chttp2/hpack_parser_fuzzer_test.cc | 5 +- .../transport/chttp2/hpack_parser_test.cc | 3 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 11 +++-- 8 files changed, 77 insertions(+), 42 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 7414fd7fff8..a5142ffd96f 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -655,12 +655,7 @@ static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md) { grpc_error* err = grpc_chttp2_hptbl_add(&p->table, md); if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err; } - if (GPR_UNLIKELY(p->on_header == nullptr)) { - GRPC_MDELEM_UNREF(md); - return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set"); - } - p->on_header(p->on_header_user_data, md); - return GRPC_ERROR_NONE; + return p->on_header(p->on_header_user_data, md); } static grpc_core::UnmanagedMemorySlice take_string_extern( @@ -765,23 +760,26 @@ static grpc_error* parse_stream_dep0(grpc_chttp2_hpack_parser* p, return parse_stream_dep1(p, cur + 1, end); } +static grpc_error* GPR_ATTRIBUTE_NOINLINE +on_invalid_hpack_idx(grpc_chttp2_hpack_parser* p) { + return grpc_error_set_int( + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid HPACK index received"), + GRPC_ERROR_INT_INDEX, static_cast(p->index)), + GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); +} + /* emit an indexed field; jumps to begin the next field on completion */ static grpc_error* finish_indexed_field(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); - if (GRPC_MDISNULL(md)) { - return grpc_error_set_int( - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Invalid HPACK index received"), - GRPC_ERROR_INT_INDEX, - static_cast(p->index)), - GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); + grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); + if (GPR_UNLIKELY(GRPC_MDISNULL(md))) { + return on_invalid_hpack_idx(p); } - GRPC_MDELEM_REF(md); GRPC_STATS_INC_HPACK_RECV_INDEXED(); grpc_error* err = on_hdr(p, md); - if (err != GRPC_ERROR_NONE) return err; + if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err; return parse_begin(p, cur, end); } @@ -1557,13 +1555,8 @@ static void set_precomputed_md_idx(grpc_chttp2_hpack_parser* p, static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p, bool* is) { grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index); - if (GRPC_MDISNULL(elem)) { - return grpc_error_set_int( - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Invalid HPACK index received"), - GRPC_ERROR_INT_INDEX, - static_cast(p->index)), - GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); + if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) { + return on_invalid_hpack_idx(p); } /* We know that GRPC_MDKEY(elem) points to a reference counted slice since: * 1. elem was a result of grpc_chttp2_hptbl_lookup @@ -1599,10 +1592,16 @@ static grpc_error* parse_value_string_with_literal_key( return parse_value_string(p, cur, end, is_binary_literal_header(p)); } +/* "Uninitialized" header parser to save us a branch in on_hdr(). */ +static grpc_error* on_header_uninitialized(void* user_data, grpc_mdelem md) { + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set"); +} + /* PUBLIC INTERFACE */ void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p) { - p->on_header = nullptr; + p->on_header = on_header_uninitialized; p->on_header_user_data = nullptr; p->state = parse_begin; p->key.data.referenced = grpc_empty_slice(); @@ -1750,7 +1749,7 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser, grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE); } } - parser->on_header = nullptr; + parser->on_header = on_header_uninitialized; parser->on_header_user_data = nullptr; parser->is_boundary = 0xde; parser->is_eof = 0xde; diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index c5691244028..eb90568920c 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -46,7 +46,7 @@ typedef struct { struct grpc_chttp2_hpack_parser { /* user specified callback for each header output */ - void (*on_header)(void* user_data, grpc_mdelem md); + grpc_error* (*on_header)(void* user_data, grpc_mdelem md); void* on_header_user_data; grpc_error* last_error; diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 68d3ec49fda..be03110edcf 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -44,19 +44,34 @@ void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl) { tbl->ents = nullptr; } -grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, - uint32_t tbl_index) { +template +static grpc_mdelem lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, + uint32_t tbl_index) { /* Not static - find the value in the list of valid entries */ tbl_index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1); if (tbl_index < tbl->num_ents) { uint32_t offset = (tbl->num_ents - 1u - tbl_index + tbl->first_ent) % tbl->cap_entries; - return tbl->ents[offset]; + grpc_mdelem md = tbl->ents[offset]; + if (take_ref) { + GRPC_MDELEM_REF(md); + } + return md; } /* Invalid entry: return error */ return GRPC_MDNULL; } +grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, + uint32_t tbl_index) { + return lookup_dynamic_index(tbl, tbl_index); +} + +grpc_mdelem grpc_chttp2_hptbl_lookup_ref_dynamic_index( + const grpc_chttp2_hptbl* tbl, uint32_t tbl_index) { + return lookup_dynamic_index(tbl, tbl_index); +} + /* Evict one element from the table */ static void evict1(grpc_chttp2_hptbl* tbl) { grpc_mdelem first_ent = tbl->ents[tbl->first_ent]; diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index a1aa77f5446..5a6c739f07b 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -95,6 +95,9 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, /* lookup a table entry based on its hpack index */ grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, uint32_t tbl_index); +grpc_mdelem grpc_chttp2_hptbl_lookup_ref_dynamic_index( + const grpc_chttp2_hptbl* tbl, uint32_t tbl_index); +template inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, uint32_t index) { /* Static table comes first, just return an entry from it. @@ -103,9 +106,15 @@ inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, must follow the hpack standard. If that changes, we *must* not rely on reading the core static metadata table here; at that point we'd need our own singleton static metadata in the correct order. */ - return index <= GRPC_CHTTP2_LAST_STATIC_ENTRY - ? grpc_static_mdelem_manifested()[index - 1] - : grpc_chttp2_hptbl_lookup_dynamic_index(tbl, index); + if (index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) { + return grpc_static_mdelem_manifested()[index - 1]; + } else { + if (take_ref) { + return grpc_chttp2_hptbl_lookup_ref_dynamic_index(tbl, index); + } else { + return grpc_chttp2_hptbl_lookup_dynamic_index(tbl, index); + } + } } /* add a table entry to the index */ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 2a2a8206cb6..a39f6e83db7 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -318,7 +318,10 @@ static grpc_error* skip_parser(void* parser, grpc_chttp2_transport* t, return GRPC_ERROR_NONE; } -static void skip_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } +static grpc_error* skip_header(void* tp, grpc_mdelem md) { + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t, int is_header) { @@ -419,7 +422,7 @@ static bool is_nonzero_status(grpc_mdelem md) { !md_cmp(md, GRPC_MDELEM_GRPC_STATUS_0, GRPC_MDSTR_GRPC_STATUS); } -static void on_initial_header(void* tp, grpc_mdelem md) { +static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_initial_header", 0); grpc_chttp2_transport* t = static_cast(tp); @@ -465,7 +468,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) { &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); } GRPC_MDELEM_UNREF(md); - return; + return GRPC_ERROR_NONE; } const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); @@ -496,9 +499,10 @@ static void on_initial_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } } + return GRPC_ERROR_NONE; } -static void on_trailing_header(void* tp, grpc_mdelem md) { +static grpc_error* on_trailing_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_trailing_header", 0); grpc_chttp2_transport* t = static_cast(tp); @@ -547,6 +551,7 @@ static void on_trailing_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } } + return GRPC_ERROR_NONE; } static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t, diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index a8eec1eefd6..9c6ae5da7bb 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -30,7 +30,10 @@ bool squelch = true; bool leak_check = true; -static void onhdr(void* ud, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } +static grpc_error* onhdr(void* ud, grpc_mdelem md) { + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} static void dont_log(gpr_log_func_args* args) {} extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 8be7dc17ed1..4782d484d1b 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -34,7 +34,7 @@ typedef struct { va_list args; } test_checker; -static void onhdr(void* ud, grpc_mdelem md) { +static grpc_error* onhdr(void* ud, grpc_mdelem md) { const char *ekey, *evalue; test_checker* chk = static_cast(ud); ekey = va_arg(chk->args, char*); @@ -44,6 +44,7 @@ static void onhdr(void* ud, grpc_mdelem md) { GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0); GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0); GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; } static void test_vector(grpc_chttp2_hpack_parser* parser, diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 4950e7f7768..86d5d2de14c 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -450,11 +450,12 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) { } BENCHMARK(BM_HpackParserInitDestroy); -static void UnrefHeader(void* user_data, grpc_mdelem md) { +static grpc_error* UnrefHeader(void* user_data, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; } -template +template static void BM_HpackParserParseHeader(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; @@ -781,7 +782,7 @@ class RepresentativeServerTrailingMetadata { static void free_timeout(void* p) { gpr_free(p); } // Benchmark the current on_initial_header implementation -static void OnInitialHeader(void* user_data, grpc_mdelem md) { +static grpc_error* OnInitialHeader(void* user_data, grpc_mdelem md) { // Setup for benchmark. This will bloat the absolute values of this benchmark grpc_chttp2_incoming_metadata_buffer buffer( static_cast(user_data)); @@ -827,10 +828,11 @@ static void OnInitialHeader(void* user_data, grpc_mdelem md) { GPR_ASSERT(0); } } + return GRPC_ERROR_NONE; } // Benchmark timeout handling -static void OnHeaderTimeout(void* user_data, grpc_mdelem md) { +static grpc_error* OnHeaderTimeout(void* user_data, grpc_mdelem md) { if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) { grpc_millis* cached_timeout = static_cast(grpc_mdelem_get_user_data(md, free_timeout)); @@ -858,6 +860,7 @@ static void OnHeaderTimeout(void* user_data, grpc_mdelem md) { } else { GPR_ASSERT(0); } + return GRPC_ERROR_NONE; } // Send the same deadline repeatedly From 96c11d153ff2247293bef1896aa5cc9496335950 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 28 Aug 2019 13:35:40 -0700 Subject: [PATCH 055/176] Revert "Revert #19704 and #20060" --- bazel/grpc_build_system.bzl | 11 +- gRPC-ProtoRPC.podspec | 30 +- gRPC-RxLibrary.podspec | 17 + gRPC.podspec | 116 ++- src/compiler/objective_c_generator.cc | 97 +- src/compiler/objective_c_generator.h | 14 +- src/compiler/objective_c_plugin.cc | 60 +- src/objective-c/BUILD | 244 +++-- .../GRPCClient/GRPCCall+ChannelArg.h | 2 +- .../GRPCClient/GRPCCall+ChannelArg.m | 4 +- .../GRPCClient/GRPCCall+ChannelCredentials.h | 2 +- .../GRPCClient/GRPCCall+ChannelCredentials.m | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 13 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 4 +- src/objective-c/GRPCClient/GRPCCall+GID.h | 2 +- src/objective-c/GRPCClient/GRPCCall+OAuth2.h | 4 +- src/objective-c/GRPCClient/GRPCCall+Tests.h | 2 +- src/objective-c/GRPCClient/GRPCCall+Tests.m | 2 +- src/objective-c/GRPCClient/GRPCCall.h | 240 +---- src/objective-c/GRPCClient/GRPCCall.m | 867 +++--------------- src/objective-c/GRPCClient/GRPCCallLegacy.h | 136 +++ src/objective-c/GRPCClient/GRPCCallLegacy.m | 677 ++++++++++++++ src/objective-c/GRPCClient/GRPCCallOptions.h | 82 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 27 +- src/objective-c/GRPCClient/GRPCDispatchable.h | 30 + src/objective-c/GRPCClient/GRPCInterceptor.h | 32 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 265 ++++-- src/objective-c/GRPCClient/GRPCTransport.h | 82 ++ src/objective-c/GRPCClient/GRPCTransport.m | 142 +++ src/objective-c/GRPCClient/GRPCTypes.h | 187 ++++ .../internal_testing/GRPCCall+InternalTests.m | 2 +- .../private/{ => GRPCCore}/ChannelArgsUtil.h | 0 .../private/{ => GRPCCore}/ChannelArgsUtil.m | 0 .../private/{ => GRPCCore}/GRPCCall+V2API.h | 6 - .../private/{ => GRPCCore}/GRPCCallInternal.h | 14 +- .../private/{ => GRPCCore}/GRPCCallInternal.m | 140 +-- .../private/{ => GRPCCore}/GRPCChannel.h | 0 .../private/{ => GRPCCore}/GRPCChannel.m | 72 +- .../{ => GRPCCore}/GRPCChannelFactory.h | 0 .../{ => GRPCCore}/GRPCChannelPool+Test.h | 0 .../private/{ => GRPCCore}/GRPCChannelPool.h | 2 - .../private/{ => GRPCCore}/GRPCChannelPool.m | 5 +- .../{ => GRPCCore}/GRPCCompletionQueue.h | 0 .../{ => GRPCCore}/GRPCCompletionQueue.m | 0 .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 32 + .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 54 ++ .../GRPCCronetChannelFactory.h | 2 +- .../GRPCCronetChannelFactory.m | 24 +- .../private/GRPCCore/GRPCCoreFactory.h | 45 + .../private/GRPCCore/GRPCCoreFactory.m | 90 ++ .../private/{ => GRPCCore}/GRPCHost.h | 0 .../private/{ => GRPCCore}/GRPCHost.m | 35 +- .../GRPCInsecureChannelFactory.h | 0 .../GRPCInsecureChannelFactory.m | 0 .../private/{ => GRPCCore}/GRPCOpBatchLog.h | 0 .../private/{ => GRPCCore}/GRPCOpBatchLog.m | 0 .../GRPCReachabilityFlagNames.xmacro.h | 0 .../{ => GRPCCore}/GRPCRequestHeaders.h | 2 +- .../{ => GRPCCore}/GRPCRequestHeaders.m | 0 .../{ => GRPCCore}/GRPCSecureChannelFactory.h | 0 .../{ => GRPCCore}/GRPCSecureChannelFactory.m | 0 .../private/{ => GRPCCore}/GRPCWrappedCall.h | 0 .../private/{ => GRPCCore}/GRPCWrappedCall.m | 0 .../private/{ => GRPCCore}/NSData+GRPC.h | 0 .../private/{ => GRPCCore}/NSData+GRPC.m | 0 .../{ => GRPCCore}/NSDictionary+GRPC.h | 0 .../{ => GRPCCore}/NSDictionary+GRPC.m | 0 .../private/{ => GRPCCore}/NSError+GRPC.h | 0 .../private/{ => GRPCCore}/NSError+GRPC.m | 3 +- .../private/GRPCTransport+Private.h | 65 ++ .../private/GRPCTransport+Private.m | 131 +++ .../GRPCClient/{private => }/version.h | 0 src/objective-c/ProtoRPC/ProtoRPC.h | 38 +- src/objective-c/ProtoRPC/ProtoRPC.m | 91 -- src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 67 ++ src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 121 +++ src/objective-c/ProtoRPC/ProtoService.h | 29 +- src/objective-c/ProtoRPC/ProtoService.m | 42 +- src/objective-c/ProtoRPC/ProtoServiceLegacy.h | 23 + src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 71 ++ .../tvOS-sample/tvOS-sample/ViewController.m | 2 + .../WatchKit-Extension/InterfaceController.m | 2 + src/objective-c/tests/BUILD | 8 - src/objective-c/tests/ConfigureCronet.h | 4 - src/objective-c/tests/ConfigureCronet.m | 4 - .../InteropTestsRemoteWithCronet.m | 12 +- .../tests/InteropTests/InteropTests.h | 13 +- .../tests/InteropTests/InteropTests.m | 268 +++--- .../InteropTests/InteropTestsLocalCleartext.m | 5 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 5 +- .../InteropTestsMultipleChannels.m | 3 +- .../tests/InteropTests/InteropTestsRemote.m | 6 - src/objective-c/tests/Podfile | 24 +- .../tests/Tests.xcodeproj/project.pbxproj | 29 +- .../xcschemes/InteropTests.xcscheme | 8 +- .../tests/UnitTests/ChannelPoolTest.m | 6 +- .../tests/UnitTests/ChannelTests.m | 10 +- .../tests/UnitTests/NSErrorUnitTests.m | 2 +- templates/gRPC-ProtoRPC.podspec.template | 30 +- templates/gRPC-RxLibrary.podspec.template | 17 + templates/gRPC.podspec.template | 116 ++- .../{private => }/version.h.template | 0 102 files changed, 3251 insertions(+), 1922 deletions(-) create mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.h create mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.m create mode 100644 src/objective-c/GRPCClient/GRPCDispatchable.h create mode 100644 src/objective-c/GRPCClient/GRPCTransport.h create mode 100644 src/objective-c/GRPCClient/GRPCTransport.m create mode 100644 src/objective-c/GRPCClient/GRPCTypes.h rename src/objective-c/GRPCClient/private/{ => GRPCCore}/ChannelArgsUtil.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/ChannelArgsUtil.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCall+V2API.h (79%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCallInternal.h (70%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCallInternal.m (69%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannel.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannel.m (78%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool+Test.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool.h (98%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool.m (98%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCompletionQueue.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCompletionQueue.m (100%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m rename src/objective-c/GRPCClient/private/{ => GRPCCore/GRPCCoreCronet}/GRPCCronetChannelFactory.h (96%) rename src/objective-c/GRPCClient/private/{ => GRPCCore/GRPCCoreCronet}/GRPCCronetChannelFactory.m (76%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCHost.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCHost.m (82%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCInsecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCInsecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCOpBatchLog.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCOpBatchLog.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCReachabilityFlagNames.xmacro.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCRequestHeaders.h (95%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCRequestHeaders.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCSecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCSecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCWrappedCall.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCWrappedCall.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSData+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSData+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSDictionary+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSDictionary+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSError+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSError+GRPC.m (96%) create mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.h create mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.m rename src/objective-c/GRPCClient/{private => }/version.h (100%) create mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.h create mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.m create mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.h create mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.m rename templates/src/objective-c/GRPCClient/{private => }/version.h.template (100%) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f386b87b583..23f90d0dc80 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -24,7 +24,6 @@ # load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") -load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") @@ -239,19 +238,13 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da ) def grpc_generate_one_off_targets(): - apple_resource_bundle( - # The choice of name is signicant here, since it determines the bundle name. - name = "gRPCCertificates", - resources = ["etc/roots.pem"], - ) - # In open-source, grpc_objc* libraries depend directly on //:grpc native.alias( name = "grpc_objc", actual = "//:grpc", ) -def grpc_objc_use_cronet_config(): +def grpc_generate_objc_one_off_targets(): pass def grpc_sh_test(name, srcs, args = [], data = []): @@ -296,7 +289,7 @@ def grpc_package(name, visibility = "private", features = []): def grpc_objc_library( name, - srcs, + srcs = [], hdrs = [], textual_hdrs = [], data = [], diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 57dac5a10e5..4c5ebb36562 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -42,22 +42,40 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/ProtoRPC' + s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' - s.default_subspec = 'Main' + s.subspec 'Legacy-Header' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + end s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.dependency 'gRPC', version + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/Interface', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", + "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", + "src/objective-c/ProtoRPC/ProtoService.{h,m}" + end + + s.subspec 'Legacy' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "#{src_dir}/*.{h,m}" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", + "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy", version end s.pod_target_xcconfig = { diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 9666c3c1b98..2e412cf67d6 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -42,6 +42,23 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name + s.default_subspec = 'Interface', 'Implementation' + + src_dir = 'src/objective-c/RxLibrary' + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.h" + ss.public_header_files = "#{src_dir}/*.h" + end + + s.subspec 'Implementation' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" + ss.private_header_files = "#{src_dir}/**/*.h" + + ss.dependency "#{s.name}/Interface" + end + src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/gRPC.podspec b/gRPC.podspec index 09baf1e3b4b..e18adcd276e 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -41,13 +41,7 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/GRPCClient' - - s.dependency 'gRPC-RxLibrary', version - s.default_subspec = 'Main' - - # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -55,29 +49,103 @@ Pod::Spec.new do |s| 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - - ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" - ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" - - ss.dependency 'gRPC-Core', version + s.subspec 'Interface-Legacy' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + + ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + ss.dependency "gRPC-RxLibrary/Interface", version end - # CFStream is now default. Leaving this subspec only for compatibility purpose. - s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/version.h' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall.m', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.m', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.m', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/internal/*.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', + 'src/objective-c/GRPCClient/version.h' + + ss.dependency "#{s.name}/Interface-Legacy", version end - s.subspec 'GID' do |ss| - ss.ios.deployment_target = '7.0' + s.subspec 'GRPCCore' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/internal_testing/*.h' + ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', + 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.m', + 'src/objective-c/GRPCClient/GRPCCallLegacy.m' + + # Certificates, to be able to establish TLS connections: + ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + + ss.dependency "#{s.name}/Interface-Legacy", version + ss.dependency "#{s.name}/Interface", version + ss.dependency 'gRPC-Core', version + ss.dependency 'gRPC-RxLibrary', version + end - ss.header_mappings_dir = "#{src_dir}" + s.subspec 'GRPCCoreCronet' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' + ss.dependency "#{s.name}/GRPCCore", version + ss.dependency 'gRPC-Core/Cronet-Implementation', version + ss.dependency 'CronetFramework' + end - ss.dependency "#{s.name}/Main", version - ss.dependency 'Google/SignIn' + # CFStream is now default. Leaving this subspec only for compatibility purpose. + s.subspec 'CFStream' do |ss| + ss.dependency "#{s.name}/GRPCCore", version end end diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 24845ecdb06..ed262308aba 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -238,19 +238,21 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, } void PrintMethodImplementations(Printer* printer, - const MethodDescriptor* method) { + const MethodDescriptor* method, + const Parameters& generator_params) { map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); - // TODO(jcanizales): Print documentation from the method. - printer->Print("// Deprecated methods.\n"); - PrintSimpleSignature(printer, method, vars); - PrintSimpleImplementation(printer, method, vars); + if (!generator_params.no_v1_compatibility) { + // TODO(jcanizales): Print documentation from the method. + PrintSimpleSignature(printer, method, vars); + PrintSimpleImplementation(printer, method, vars); - printer->Print("// Returns a not-yet-started RPC object.\n"); - PrintAdvancedSignature(printer, method, vars); - PrintAdvancedImplementation(printer, method, vars); + printer->Print("// Returns a not-yet-started RPC object.\n"); + PrintAdvancedSignature(printer, method, vars); + PrintAdvancedImplementation(printer, method, vars); + } PrintV2Signature(printer, method, vars); PrintV2Implementation(printer, method, vars); @@ -276,9 +278,12 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetProtocol(const ServiceDescriptor* service) { +::grpc::string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; + if (generator_params.no_v1_compatibility) return output; + // Scope the output stream so it closes and finalizes output to the string. grpc::protobuf::io::StringOutputStream output_stream(&output); Printer printer(&output_stream, '$'); @@ -321,7 +326,8 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetInterface(const ServiceDescriptor* service) { +::grpc::string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; // Scope the output stream so it closes and finalizes output to the string. @@ -338,7 +344,11 @@ void PrintMethodImplementations(Printer* printer, " */\n"); printer.Print(vars, "@interface $service_class$ :" - " GRPCProtoService<$service_class$, $service_class$2>\n"); + " GRPCProtoService<$service_class$2"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, ", $service_class$"); + } + printer.Print(">\n"); printer.Print( "- (instancetype)initWithHost:(NSString *)host " "callOptions:(GRPCCallOptions " @@ -347,17 +357,20 @@ void PrintMethodImplementations(Printer* printer, printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); - printer.Print( - "// The following methods belong to a set of old APIs that have been " - "deprecated.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// The following methods belong to a set of old APIs that have been " + "deprecated.\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); + printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + } printer.Print("@end\n"); return output; } -::grpc::string GetSource(const ServiceDescriptor* service) { +::grpc::string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -381,22 +394,28 @@ void PrintMethodImplementations(Printer* printer, " packageName:@\"$package$\"\n" " serviceName:@\"$service_name$\"\n" " callOptions:callOptions];\n" - "}\n\n" - "- (instancetype)initWithHost:(NSString *)host {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"];\n" - "}\n\n" - "#pragma clang diagnostic pop\n\n"); - + "}\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, + "- (instancetype)initWithHost:(NSString *)host {\n" + " return [super initWithHost:host\n" + " packageName:@\"$package$\"\n" + " serviceName:@\"$service_name$\"];\n" + "}\n\n"); + } + printer.Print("#pragma clang diagnostic pop\n\n"); + + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// Override superclass initializer to disallow different" + " package and service names.\n" + "- (instancetype)initWithHost:(NSString *)host\n" + " packageName:(NSString *)packageName\n" + " serviceName:(NSString *)serviceName {\n" + " return [self initWithHost:host];\n" + "}\n\n"); + } printer.Print( - "// Override superclass initializer to disallow different" - " package and service names.\n" - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName {\n" - " return [self initWithHost:host];\n" - "}\n\n" "- (instancetype)initWithHost:(NSString *)host\n" " packageName:(NSString *)packageName\n" " serviceName:(NSString *)serviceName\n" @@ -404,11 +423,14 @@ void PrintMethodImplementations(Printer* printer, " return [self initWithHost:host callOptions:callOptions];\n" "}\n\n"); + printer.Print("#pragma mark - Class Methods\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "+ (instancetype)serviceWithHost:(NSString *)host {\n" + " return [[self alloc] initWithHost:host];\n" + "}\n\n"); + } printer.Print( - "#pragma mark - Class Methods\n\n" - "+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n" "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" " return [[self alloc] initWithHost:host callOptions:callOptions];\n" @@ -417,7 +439,8 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Method Implementations\n\n"); for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i)); + PrintMethodImplementations(&printer, service->method(i), + generator_params); } printer.Print("@end\n"); diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h index c171e5bf772..518962fceee 100644 --- a/src/compiler/objective_c_generator.h +++ b/src/compiler/objective_c_generator.h @@ -23,6 +23,11 @@ namespace grpc_objective_c_generator { +struct Parameters { + // Do not generate V1 interface and implementation + bool no_v1_compatibility; +}; + using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; @@ -34,7 +39,8 @@ string GetAllMessageClasses(const FileDescriptor* file); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. This interface is // legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service); +string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. @@ -42,11 +48,13 @@ string GetV2Protocol(const ServiceDescriptor* service); // Returns the content to be included defining the @interface segment at the // insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service); +string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included in the "global_scope" insertion point of // the generated implementation file. -string GetSource(const ServiceDescriptor* service); +string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params); } // namespace grpc_objective_c_generator diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index f398033f6db..a08064a08bd 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -111,6 +111,22 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string file_name = google::protobuf::compiler::objectivec::FilePath(file); + grpc_objective_c_generator::Parameters generator_params; + generator_params.no_v1_compatibility = false; + + if (!parameter.empty()) { + std::vector parameters_list = + grpc_generator::tokenize(parameter, ","); + for (auto parameter_string = parameters_list.begin(); + parameter_string != parameters_list.end(); parameter_string++) { + std::vector param = + grpc_generator::tokenize(*parameter_string, "="); + if (param[0] == "no_v1_compatibility") { + generator_params.no_v1_compatibility = true; + } + } + } + { // Generate .pbrpc.h @@ -121,18 +137,25 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { imports = FrameworkImport(file_name + ".pbobjc.h", framework); } - ::grpc::string system_imports = SystemImport("ProtoRPC/ProtoService.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriteable.h") + - SystemImport("RxLibrary/GRXWriter.h"); + ::grpc::string system_imports = + SystemImport("ProtoRPC/ProtoService.h") + + (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + if (!generator_params.no_v1_compatibility) { + system_imports += SystemImport("RxLibrary/GRXWriteable.h") + + SystemImport("RxLibrary/GRXWriter.h"); + } ::grpc::string forward_declarations = - "@class GRPCProtoCall;\n" "@class GRPCUnaryProtoCall;\n" "@class GRPCStreamingProtoCall;\n" "@class GRPCCallOptions;\n" - "@protocol GRPCProtoResponseHandler;\n" - "\n"; + "@protocol GRPCProtoResponseHandler;\n"; + if (!generator_params.no_v1_compatibility) { + forward_declarations += "@class GRPCProtoCall;\n"; + } + forward_declarations += "\n"; ::grpc::string class_declarations = grpc_objective_c_generator::GetAllMessageClasses(file); @@ -152,13 +175,15 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string protocols; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - protocols += grpc_objective_c_generator::GetProtocol(service); + protocols += + grpc_objective_c_generator::GetProtocol(service, generator_params); } ::grpc::string interfaces; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - interfaces += grpc_objective_c_generator::GetInterface(service); + interfaces += + grpc_objective_c_generator::GetInterface(service, generator_params); } Write(context, file_name + ".pbrpc.h", @@ -178,14 +203,16 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports; if (framework.empty()) { imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + LocalImport(file_name + ".pbobjc.h"); } else { imports = FrameworkImport(file_name + ".pbrpc.h", framework) + - FrameworkImport(file_name + ".pbobjc.h", framework) + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + FrameworkImport(file_name + ".pbobjc.h", framework); + } + imports += (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + if (!generator_params.no_v1_compatibility) { + imports += SystemImport("RxLibrary/GRXWriter+Immediate.h"); } ::grpc::string class_imports; @@ -196,7 +223,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - definitions += grpc_objective_c_generator::GetSource(service); + definitions += + grpc_objective_c_generator::GetSource(service, generator_params); } Write(context, file_name + ".pbrpc.m", diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 3a71086f0f6..5f53486d17e 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -18,24 +18,30 @@ licenses(["notice"]) # Apache v2 package(default_visibility = ["//visibility:public"]) -load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_objc_use_cronet_config") +load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_generate_objc_one_off_targets") exports_files(["LICENSE"]) -grpc_objc_use_cronet_config() +grpc_generate_objc_one_off_targets() + +grpc_objc_library( + name = "rx_library_headers", + hdrs = glob([ + "RxLibrary/*.h", + ]), + includes = ["."], +) grpc_objc_library( name = "rx_library", srcs = glob([ "RxLibrary/*.m", - "RxLibrary/transformations/*.m", - ]), - hdrs = glob([ - "RxLibrary/*.h", - "RxLibrary/transformations/*.h", ]), includes = ["."], - deps = [":rx_library_private"], + deps = [ + ":rx_library_headers", + ":rx_library_private", + ], ) grpc_objc_library( @@ -50,84 +56,196 @@ grpc_objc_library( ) grpc_objc_library( - name = "grpc_objc_client", - srcs = glob( - [ - "GRPCClient/*.m", - "GRPCClient/private/*.m", - ], - exclude = ["GRPCClient/GRPCCall+GID.m"], - ), - hdrs = glob( - [ - "GRPCClient/*.h", - "GRPCClient/internal/*.h", - ], - exclude = ["GRPCClient/GRPCCall+GID.h"], - ), - data = ["//:gRPCCertificates"], + name = "grpc_objc_interface_legacy", + hdrs = [ + "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCallLegacy.h", + "GRPCClient/GRPCTypes.h", + ], + deps = [ + "rx_library_headers", + ], +) + +grpc_objc_library( + name = "grpc_objc_interface", + hdrs = [ + "GRPCClient/GRPCCall.h", + "GRPCClient/GRPCCall+Interceptor.h", + "GRPCClient/GRPCCallOptions.h", + "GRPCClient/GRPCInterceptor.h", + "GRPCClient/GRPCTransport.h", + "GRPCClient/GRPCDispatchable.h", + "GRPCClient/internal/GRPCCallOptions+Internal.h", + "GRPCClient/version.h", + ], + srcs = [ + "GRPCClient/GRPCCall.m", + "GRPCClient/GRPCCall+Interceptor.m", + "GRPCClient/GRPCCallOptions.m", + "GRPCClient/GRPCInterceptor.m", + "GRPCClient/GRPCTransport.m", + "GRPCClient/private/GRPCTransport+Private.m", + ], includes = ["."], - textual_hdrs = glob([ - "GRPCClient/private/*.h", - ]), + textual_hdrs = [ + "GRPCClient/private/GRPCTransport+Private.h", + ], deps = [ + ":grpc_objc_interface_legacy", + ], +) + +grpc_objc_library( + name = "grpc_objc_client_core", + hdrs = [ + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCall+ChannelArg.h", + ], + textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), + srcs = [ + "GRPCClient/GRPCCall+ChannelArg.m", + "GRPCClient/GRPCCall+ChannelCredentials.m", + "GRPCClient/GRPCCall+Cronet.m", + "GRPCClient/GRPCCall+OAuth2.m", + "GRPCClient/GRPCCall+Tests.m", + "GRPCClient/GRPCCallLegacy.m", + ] + glob(["GRPCClient/private/GRPCCore/*.m"]), + data = [":gRPCCertificates"], + includes = ["."], + deps = [ + ":grpc_objc_interface", + ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", ], ) +alias( + name = "grpc_objc_client", + actual = "grpc_objc_client_core", +) + +grpc_objc_library( + name = "proto_objc_rpc_legacy_header", + hdrs = [ + "ProtoRPC/ProtoRPCLegacy.h", + ], + includes = ["."], +) + grpc_objc_library( - name = "proto_objc_rpc", - srcs = glob( - ["ProtoRPC/*.m"], - ), - hdrs = glob( - ["ProtoRPC/*.h"], - ), - # Different from Cocoapods, do not import as if @com_google_protobuf//:protobuf_objc is a framework, - # use the real paths of @com_google_protobuf//:protobuf_objc instead + name = "proto_objc_rpc_v2", + srcs = [ + "ProtoRPC/ProtoMethod.m", + "ProtoRPC/ProtoRPC.m", + "ProtoRPC/ProtoService.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", + "ProtoRPC/ProtoService.h", + ], + includes = ["."], defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], deps = [ - ":grpc_objc_client", + ":grpc_objc_interface", + ":proto_objc_rpc_legacy_header", + "@com_google_protobuf//:protobuf_objc", + ], +) + +grpc_objc_library( + name = "proto_objc_rpc", + srcs = [ + "ProtoRPC/ProtoRPCLegacy.m", + "ProtoRPC/ProtoServiceLegacy.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPCLegacy.h", + "ProtoRPC/ProtoService.h", + ], + deps = [ ":rx_library", + ":proto_objc_rpc_v2", + ":proto_objc_rpc_legacy_header", + ":grpc_objc_client_core", "@com_google_protobuf//:protobuf_objc", ], ) +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") + +apple_resource_bundle( + # The choice of name is signicant here, since it determines the bundle name. + name = "gRPCCertificates", + resources = ["//:etc/roots.pem"], +) + +# Internal target combining grpc_objc_client_core and proto_objc_rpc for testing grpc_objc_library( - name = "grpc_objc_client_internal_testing", - srcs = glob( - [ - "GRPCClient/*.m", - "GRPCClient/private/*.m", - "GRPCClient/internal_testing/*.m", - "ProtoRPC/*.m", - ], - exclude = ["GRPCClient/GRPCCall+GID.m"], - ), - hdrs = glob( - [ - "GRPCClient/*.h", - "GRPCClient/internal/*.h", - "GRPCClient/internal_testing/*.h", - "ProtoRPC/*.h", - ], - exclude = ["GRPCClient/GRPCCall+GID.h"], - ), + name = "grpc_objc_client_core_internal_testing", + hdrs = [ + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/internal_testing/GRPCCall+InternalTests.h", + ], + textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), + srcs = [ + "GRPCClient/GRPCCall+ChannelArg.m", + "GRPCClient/GRPCCall+ChannelCredentials.m", + "GRPCClient/GRPCCall+Cronet.m", + "GRPCClient/GRPCCall+OAuth2.m", + "GRPCClient/GRPCCall+Tests.m", + "GRPCClient/GRPCCallLegacy.m", + "GRPCClient/internal_testing/GRPCCall+InternalTests.m", + ] + glob(["GRPCClient/private/GRPCCore/*.m"]), + data = [":gRPCCertificates"], includes = ["."], - data = ["//:gRPCCertificates"], defines = [ "GRPC_TEST_OBJC=1", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", ], - textual_hdrs = glob( - [ - "GRPCClient/private/*.h", - ], - ), deps = [ + ":grpc_objc_interface", + ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", + ], +) + +grpc_objc_library( + name = "proto_objc_rpc_internal_testing", + srcs = [ + "ProtoRPC/ProtoRPCLegacy.m", + "ProtoRPC/ProtoServiceLegacy.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", + "ProtoRPC/ProtoRPCLegacy.h", + "ProtoRPC/ProtoService.h", + ], + deps = [ + ":rx_library", + ":proto_objc_rpc_v2", + ":proto_objc_rpc_legacy_header", + ":grpc_objc_client_core_internal_testing", "@com_google_protobuf//:protobuf_objc", ], ) + +alias( + name = "grpc_objc_client_internal_testing", + actual = "proto_objc_rpc_internal_testing", +) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h index 2ddd53a5c66..ff5a153a0f6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" #include diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index ae60d6208e1..aae1b740c71 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -18,8 +18,8 @@ #import "GRPCCall+ChannelArg.h" -#import "private/GRPCChannelPool.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCChannelPool.h" +#import "private/GRPCCore/GRPCHost.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h index 7d6f79b7655..c3d194bff94 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m index 2689ec2effb..aa97ca82bf8 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m @@ -18,7 +18,7 @@ #import "GRPCCall+ChannelCredentials.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCHost.h" @implementation GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index 3059c6f1860..d107ada3672 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -15,12 +15,16 @@ * limitations under the License. * */ -#ifdef GRPC_COMPILE_WITH_CRONET -#import -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" +#import "GRPCTypes.h" -// Deprecated interface. Please use GRPCCallOptions instead. +typedef struct stream_engine stream_engine; + +// Transport id for Cronet transport +extern const GRPCTransportId gGRPCCoreCronetId; + +// Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; @@ -28,4 +32,3 @@ + (BOOL)isUsingCronet; @end -#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index ba8d2c23db8..a732208e1f6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,8 @@ #import "GRPCCall+Cronet.h" -#ifdef GRPC_COMPILE_WITH_CRONET +const GRPCTransportId gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; + static BOOL useCronet = NO; static stream_engine *globalCronetEngine; @@ -38,4 +39,3 @@ static stream_engine *globalCronetEngine; } @end -#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+GID.h b/src/objective-c/GRPCClient/GRPCCall+GID.h index 8293e92ebe9..80e34ea98da 100644 --- a/src/objective-c/GRPCClient/GRPCCall+GID.h +++ b/src/objective-c/GRPCClient/GRPCCall+GID.h @@ -17,7 +17,7 @@ */ #import "GRPCCall+OAuth2.h" -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h index 60cdc50bfda..cf60c794f27 100644 --- a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h +++ b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h @@ -16,9 +16,9 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" -#import "GRPCCallOptions.h" +@protocol GRPCAuthorizationProtocol; // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (OAuth2) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.h b/src/objective-c/GRPCClient/GRPCCall+Tests.h index edaa5ed582c..af81eec6b82 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.h +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (Tests) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.m b/src/objective-c/GRPCClient/GRPCCall+Tests.m index 20f5cba4178..3a1dff38868 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.m +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.m @@ -18,7 +18,7 @@ #import "GRPCCall+Tests.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCHost.h" #import "GRPCCallOptions.h" diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index d02ec601727..1c7a10048cf 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -33,134 +33,19 @@ */ #import -#import -#include +#import "GRPCCallOptions.h" +#import "GRPCDispatchable.h" +#import "GRPCTypes.h" -#include "GRPCCallOptions.h" +// The legacy header is included for backwards compatibility. Some V1 API users are still using +// GRPCCall by importing GRPCCall.h header so we need this import. +#import "GRPCCallLegacy.h" NS_ASSUME_NONNULL_BEGIN -#pragma mark gRPC errors - -/** Domain of NSError objects produced by gRPC. */ -extern NSString *const kGRPCErrorDomain; - -/** - * gRPC error codes. - * Note that a few of these are never produced by the gRPC libraries, but are of general utility for - * server applications to produce. - */ -typedef NS_ENUM(NSUInteger, GRPCErrorCode) { - /** The operation was cancelled (typically by the caller). */ - GRPCErrorCodeCancelled = 1, - - /** - * Unknown error. Errors raised by APIs that do not return enough error information may be - * converted to this error. - */ - GRPCErrorCodeUnknown = 2, - - /** - * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. - * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the - * server (e.g., a malformed file name). - */ - GRPCErrorCodeInvalidArgument = 3, - - /** - * Deadline expired before operation could complete. For operations that change the state of the - * server, this error may be returned even if the operation has completed successfully. For - * example, a successful response from the server could have been delayed long enough for the - * deadline to expire. - */ - GRPCErrorCodeDeadlineExceeded = 4, - - /** Some requested entity (e.g., file or directory) was not found. */ - GRPCErrorCodeNotFound = 5, - - /** Some entity that we attempted to create (e.g., file or directory) already exists. */ - GRPCErrorCodeAlreadyExists = 6, - - /** - * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't - * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for - * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller - * (UNAUTHENTICATED is used instead for those errors). - */ - GRPCErrorCodePermissionDenied = 7, - - /** - * The request does not have valid authentication credentials for the operation (e.g. the caller's - * identity can't be verified). - */ - GRPCErrorCodeUnauthenticated = 16, - - /** Some resource has been exhausted, perhaps a per-user quota. */ - GRPCErrorCodeResourceExhausted = 8, - - /** - * The RPC was rejected because the server is not in a state required for the procedure's - * execution. For example, a directory to be deleted may be non-empty, etc. - * The client should not retry until the server state has been explicitly fixed (e.g. by - * performing another RPC). The details depend on the service being called, and should be found in - * the NSError's userInfo. - */ - GRPCErrorCodeFailedPrecondition = 9, - - /** - * The RPC was aborted, typically due to a concurrency issue like sequencer check failures, - * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read- - * modify-write sequence). - */ - GRPCErrorCodeAborted = 10, - - /** - * The RPC was attempted past the valid range. E.g., enumerating past the end of a list. - * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state - * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked - * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return - * the element at an index past the current size of the list. - */ - GRPCErrorCodeOutOfRange = 11, - - /** The procedure is not implemented or not supported/enabled in this server. */ - GRPCErrorCodeUnimplemented = 12, - - /** - * Internal error. Means some invariant expected by the server application or the gRPC library has - * been broken. - */ - GRPCErrorCodeInternal = 13, - - /** - * The server is currently unavailable. This is most likely a transient condition and may be - * corrected by retrying with a backoff. Note that it is not always safe to retry - * non-idempotent operations. - */ - GRPCErrorCodeUnavailable = 14, - - /** Unrecoverable data loss or corruption. */ - GRPCErrorCodeDataLoss = 15, -}; - -/** - * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by - * the server. - */ -extern NSString *const kGRPCHeadersKey; -extern NSString *const kGRPCTrailersKey; - /** An object can implement this protocol to receive responses from server from a call. */ -@protocol GRPCResponseHandler - -@required - -/** - * All the responses must be issued to a user-provided dispatch queue. This property specifies the - * dispatch queue to be used for issuing the notifications. - */ -@property(atomic, readonly) dispatch_queue_t dispatchQueue; +@protocol GRPCResponseHandler @optional @@ -302,114 +187,3 @@ extern NSString *const kGRPCTrailersKey; @end NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -/** - * This interface is deprecated. Please use \a GRPCcall2. - * - * Represents a single gRPC remote call. - */ -@interface GRPCCall : GRXWriter - -- (instancetype)init NS_UNAVAILABLE; - -/** - * The container of the request headers of an RPC conforms to this protocol, which is a subset of - * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. - * The keys of this container are the header names, which per the HTTP standard are case- - * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and - * can only consist of ASCII characters. - * A header value is a NSString object (with only ASCII characters), unless the header name has the - * suffix "-bin", in which case the value has to be a NSData object. - */ -/** - * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a - * name-value pair with string names and either string or binary values. - * - * The passed dictionary has to use NSString keys, corresponding to the header names. The value - * associated to each can be a NSString object or a NSData object. E.g.: - * - * call.requestHeaders = @{@"authorization": @"Bearer ..."}; - * - * call.requestHeaders[@"my-header-bin"] = someData; - * - * After the call is started, trying to modify this property is an error. - * - * The property is initialized to an empty NSMutableDictionary. - */ -@property(atomic, readonly) NSMutableDictionary *requestHeaders; - -/** - * This dictionary is populated with the HTTP headers received from the server. This happens before - * any response message is received from the server. It has the same structure as the request - * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a - * NSData value; the others have a NSString value. - * - * The value of this property is nil until all response headers are received, and will change before - * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseHeaders; - -/** - * Same as responseHeaders, but populated with the HTTP trailers received from the server before the - * call finishes. - * - * The value of this property is nil until all response trailers are received, and will change - * before -writesFinishedWithError: is sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseTrailers; - -/** - * The request writer has to write NSData objects into the provided Writeable. The server will - * receive each of those separately and in order as distinct messages. - * A gRPC call might not complete until the request writer finishes. On the other hand, the request - * finishing doesn't necessarily make the call to finish, as the server might continue sending - * 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 - requestsWriter:(GRXWriter *)requestWriter; - -/** - * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and - * finishes the response side of the call with an error of code CANCELED. - */ -- (void)cancel; - -/** - * The following methods are deprecated. - */ -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; -@property(atomic, copy, readwrite) NSString *serverName; -@property NSTimeInterval timeout; -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; - -@end - -#pragma mark Backwards compatibiity - -/** This protocol is kept for backwards compatibility with existing code. */ -DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") -@protocol GRPCRequestHeaders -@property(nonatomic, readonly) NSUInteger count; - -- (id)objectForKeyedSubscript:(id)key; -- (void)setObject:(id)obj forKeyedSubscript:(id)key; - -- (void)removeAllObjects; -- (void)removeObjectForKey:(id)key; -@end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated" -/** This is only needed for backwards-compatibility. */ -@interface NSMutableDictionary (GRPCRequestHeaders) -@end -#pragma clang diagnostic pop -#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index cd293cc8e59..73ee530ef2c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -17,56 +17,86 @@ */ #import "GRPCCall.h" + #import "GRPCCall+Interceptor.h" -#import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" -#import -#import -#import -#import -#include -#include - -#import "private/GRPCCall+V2API.h" -#import "private/GRPCCallInternal.h" -#import "private/GRPCChannelPool.h" -#import "private/GRPCCompletionQueue.h" -#import "private/GRPCHost.h" -#import "private/GRPCRequestHeaders.h" -#import "private/GRPCWrappedCall.h" -#import "private/NSData+GRPC.h" -#import "private/NSDictionary+GRPC.h" -#import "private/NSError+GRPC.h" - -// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, -// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, -// and RECV_STATUS_ON_CLIENT. -NSInteger kMaxClientBatch = 6; +#import "private/GRPCTransport+Private.h" NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; -static NSMutableDictionary *callFlags; -static NSString *const kAuthorizationHeader = @"authorization"; -static NSString *const kBearerPrefix = @"Bearer "; +NSString *const kGRPCErrorDomain = @"io.grpc"; + +/** + * The response dispatcher creates its own serial dispatch queue and target the queue to the + * dispatch queue of a user provided response handler. It removes the requirement of having to use + * serial dispatch queue in the user provided response handler. + */ +@interface GRPCResponseDispatcher : NSObject + +- (nullable instancetype)initWithResponseHandler:(id)responseHandler; + +@end -const char *kCFStreamVarName = "grpc_cfstream"; +@implementation GRPCResponseDispatcher { + id _responseHandler; + dispatch_queue_t _dispatchQueue; +} -@interface GRPCCall () -// Make them read-write. -@property(atomic, strong) NSDictionary *responseHeaders; -@property(atomic, strong) NSDictionary *responseTrailers; +- (instancetype)initWithResponseHandler:(id)responseHandler { + if ((self = [super init])) { + _responseHandler = responseHandler; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { +#else + { +#endif + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _responseHandler.dispatchQueue); + } -- (void)receiveNextMessages:(NSUInteger)numberOfMessages; + return self; +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_responseHandler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_responseHandler didReceiveInitialMetadata:initialMetadata]; + } +} + +- (void)didReceiveData:(id)data { + // For backwards compatibility with didReceiveRawMessage, if the user provided a response handler + // that handles didReceiveRawMesssage, we issue to that method instead + if ([_responseHandler respondsToSelector:@selector(didReceiveRawMessage:)]) { + [_responseHandler didReceiveRawMessage:data]; + } else if ([_responseHandler respondsToSelector:@selector(didReceiveData:)]) { + [_responseHandler didReceiveData:data]; + } +} + +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { + if ([_responseHandler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + [_responseHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; + } +} -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone; +- (void)didWriteData { + if ([_responseHandler respondsToSelector:@selector(didWriteData)]) { + [_responseHandler didWriteData]; + } +} @end @@ -140,54 +170,39 @@ const char *kCFStreamVarName = "grpc_cfstream"; } _responseHandler = responseHandler; - // Initialize the interceptor chain - - // First initialize the internal call - GRPCCall2Internal *internalCall = [[GRPCCall2Internal alloc] init]; - id nextInterceptor = internalCall; - GRPCInterceptorManager *nextManager = nil; - - // Then initialize the global interceptor, if applicable + GRPCResponseDispatcher *dispatcher = + [[GRPCResponseDispatcher alloc] initWithResponseHandler:_responseHandler]; + NSMutableArray> *interceptorFactories; + if (_actualCallOptions.interceptorFactories != nil) { + interceptorFactories = + [NSMutableArray arrayWithArray:_actualCallOptions.interceptorFactories]; + } else { + interceptorFactories = [NSMutableArray array]; + } id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; - if (globalInterceptorFactory) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = - [globalInterceptorFactory createInterceptorWithManager:manager]; - if (interceptor != nil) { - [internalCall setResponseHandler:interceptor]; - nextInterceptor = interceptor; - nextManager = manager; - } + if (globalInterceptorFactory != nil) { + [interceptorFactories addObject:globalInterceptorFactory]; } - - // Finally initialize the interceptors in the chain - NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; - for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; - NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", - interceptorFactories[i]); - if (interceptor == nil) { - NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); - continue; - } - if (nextManager == nil) { - [internalCall setResponseHandler:interceptor]; + // continuously create interceptor until one is successfully created + while (_firstInterceptor == nil) { + if (interceptorFactories.count == 0) { + _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport + previousInterceptor:dispatcher]; + break; } else { - [nextManager setPreviousInterceptor:interceptor]; + _firstInterceptor = + [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:dispatcher + transportId:_callOptions.transport]; + if (_firstInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; + } } - nextInterceptor = interceptor; - nextManager = manager; } - if (nextManager == nil) { - [internalCall setResponseHandler:_responseHandler]; - } else { - [nextManager setPreviousInterceptor:_responseHandler]; + NSAssert(_firstInterceptor != nil, @"Failed to create interceptor or transport."); + if (_firstInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); } - - _firstInterceptor = nextInterceptor; } return self; @@ -200,696 +215,42 @@ const char *kCFStreamVarName = "grpc_cfstream"; } - (void)start { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - GRPCRequestOptions *requestOptions = [_requestOptions copy]; - GRPCCallOptions *callOptions = [_actualCallOptions copy]; - if ([copiedFirstInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); - } + id copiedFirstInterceptor = _firstInterceptor; + GRPCRequestOptions *requestOptions = _requestOptions; + GRPCCallOptions *callOptions = _actualCallOptions; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - (void)cancel { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(cancel)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + id copiedFirstInterceptor = _firstInterceptor; + if (copiedFirstInterceptor != nil) { + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ [copiedFirstInterceptor cancel]; }); } } - (void)writeData:(id)data { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(writeData:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor writeData:data]; - }); - } -} - -- (void)finish { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(finish)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor finish]; - }); - } -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(receiveNextMessages:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; - }); - } -} - -@end - -// The following methods of a C gRPC call object aren't reentrant, and thus -// calls to them must be serialized: -// - start_batch -// - destroy -// -// start_batch with a SEND_MESSAGE argument can only be called after the -// OP_COMPLETE event for any previous write is received. This is achieved by -// pausing the requests writer immediately every time it writes a value, and -// resuming it again when OP_COMPLETE is received. -// -// Similarly, start_batch with a RECV_MESSAGE argument can only be called after -// the OP_COMPLETE event for any previous read is received.This is easier to -// enforce, as we're writing the received messages into the writeable: -// start_batch is enqueued once upon receiving the OP_COMPLETE event for the -// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for -// each RECV_MESSAGE batch. -@implementation GRPCCall { - dispatch_queue_t _callQueue; - - NSString *_host; - NSString *_path; - GRPCCallSafety _callSafety; - GRPCCallOptions *_callOptions; - GRPCWrappedCall *_wrappedCall; - - // The C gRPC library has less guarantees on the ordering of events than we - // do. Particularly, in the face of errors, there's no ordering guarantee at - // all. This wrapper over our actual writeable ensures thread-safety and - // correct ordering. - GRXConcurrentWriteable *_responseWriteable; - - // The network thread wants the requestWriter to resume (when the server is ready for more input), - // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop - // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. - // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or - // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to - // pause the writer immediately on writeValue:, so we need our locking to be recursive. - GRXWriter *_requestWriter; - - // To create a retain cycle when a call is started, up until it finishes. See - // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a - // reference to the call object if all they're interested in is the handler being executed when - // the response arrives. - GRPCCall *_retainSelf; - - GRPCRequestHeaders *_requestHeaders; - - // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type - // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core - // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when - // the SendClose op is added. - BOOL _unaryCall; - NSMutableArray *_unaryOpBatch; - - // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch - // queue - dispatch_queue_t _responseQueue; - - // The OAuth2 token fetched from a token provider. - NSString *_fetchedOauth2AccessToken; - - // The callback to be called when a write message op is done. - void (^_writeDone)(void); - - // Indicate a read request to core is pending. - BOOL _pendingCoreRead; - - // Indicate pending read message request from user. - NSUInteger _pendingReceiveNextMessages; -} - -@synthesize state = _state; - -+ (void)initialize { - // Guarantees the code in {} block is invoked only once. See ref at: - // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc - if (self == [GRPCCall self]) { - grpc_init(); - callFlags = [NSMutableDictionary dictionary]; - } -} - -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { - if (host.length == 0 || path.length == 0) { - return; - } - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - switch (callSafety) { - case GRPCCallSafetyDefault: - callFlags[hostAndPath] = @0; - break; - case GRPCCallSafetyIdempotentRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - default: - break; - } - } -} - -+ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - return [callFlags[hostAndPath] intValue]; - } -} - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter { - return [self initWithHost:host - path:path - callSafety:GRPCCallSafetyDefault - requestsWriter:requestWriter - callOptions:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions { - return [self initWithHost:host - path:path - callSafety:safety - requestsWriter:requestsWriter - callOptions:callOptions - writeDone:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone { - // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. - NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); - NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); - NSAssert(requestsWriter.state == GRXWriterStateNotStarted, - @"The requests writer can't be already started."); - if (!host || !path) { - return nil; - } - if (safety > GRPCCallSafetyCacheableRequest) { - return nil; - } - if (requestsWriter.state != GRXWriterStateNotStarted) { - return nil; - } - - if ((self = [super init])) { - _host = [host copy]; - _path = [path copy]; - _callSafety = safety; - _callOptions = [callOptions copy]; - - // Serial queue to invoke the non-reentrant methods of the grpc_call object. - _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); - - _requestWriter = requestsWriter; - _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; - _writeDone = writeDone; - - if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { - _unaryCall = YES; - _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; - } - - _responseQueue = dispatch_get_main_queue(); - - // do not start a read until initial metadata is received - _pendingReceiveNextMessages = 0; - _pendingCoreRead = YES; - } - return self; -} - -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { - @synchronized(self) { - if (_state != GRXWriterStateNotStarted) { - return; - } - _responseQueue = queue; - } -} - -#pragma mark Finish - -// This function should support being called within a @synchronized(self) block in another function -// Should not manipulate _requestWriter for deadlock prevention. -- (void)finishWithError:(NSError *)errorOrNil { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - _state = GRXWriterStateFinished; - - if (errorOrNil) { - [_responseWriteable cancelWithError:errorOrNil]; - } else { - [_responseWriteable enqueueSuccessfulCompletion]; - } - - // If the call isn't retained anywhere else, it can be deallocated now. - _retainSelf = nil; - } -} - -- (void)cancel { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - [self finishWithError:[NSError - errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; - [_wrappedCall cancel]; - } - _requestWriter.state = GRXWriterStateFinished; -} - -- (void)dealloc { - __block GRPCWrappedCall *wrappedCall = _wrappedCall; - dispatch_async(_callQueue, ^{ - wrappedCall = nil; - }); -} - -#pragma mark Read messages - -// Only called from the call queue. -// The handler will be called from the network queue. -- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { - // TODO(jcanizales): Add error handlers for async failures - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; -} - -// Called initially from the network queue once response headers are received, -// then "recursively" from the responseWriteable queue after each response from the -// server has been written. -// If the call is currently paused, this is a noop. Restarting the call will invoke this -// method. -// TODO(jcanizales): Rename to readResponseIfNotPaused. -- (void)maybeStartNextRead { - @synchronized(self) { - if (_state != GRXWriterStateStarted) { - return; - } - if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { - return; - } - _pendingCoreRead = YES; - _pendingReceiveNextMessages--; - } - - dispatch_async(_callQueue, ^{ - __weak GRPCCall *weakSelf = self; - [self startReadWithHandler:^(grpc_byte_buffer *message) { - if (message == NULL) { - // No more messages from the server - return; - } - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf == nil) { - grpc_byte_buffer_destroy(message); - return; - } - NSData *data = [NSData grpc_dataWithByteBuffer:message]; - grpc_byte_buffer_destroy(message); - if (!data) { - // The app doesn't have enough memory to hold the server response. We - // don't want to throw, because the app shouldn't crash for a behavior - // that's on the hands of any server to have. Instead we finish and ask - // the server to cancel. - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf - finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeResourceExhausted - userInfo:@{ - NSLocalizedDescriptionKey : - @"Client does not have enough memory to " - @"hold the server response." - }]]; - [strongSelf->_wrappedCall cancel]; - } - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } else { - @synchronized(strongSelf) { - [strongSelf->_responseWriteable enqueueValue:data - completionHandler:^{ - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - }]; - } - } - }]; + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor writeData:data]; }); } -#pragma mark Send headers - -- (void)sendHeaders { - // TODO (mxyan): Remove after deprecated methods are removed - uint32_t callSafetyFlags = 0; - switch (_callSafety) { - case GRPCCallSafetyDefault: - callSafetyFlags = 0; - break; - case GRPCCallSafetyIdempotentRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - } - - NSMutableDictionary *headers = [_requestHeaders mutableCopy]; - NSString *fetchedOauth2AccessToken; - @synchronized(self) { - fetchedOauth2AccessToken = _fetchedOauth2AccessToken; - } - if (fetchedOauth2AccessToken != nil) { - headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; - } else if (_callOptions.oauth2AccessToken != nil) { - headers[@"authorization"] = - [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; - } - - // TODO(jcanizales): Add error handlers for async failures - GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] - initWithMetadata:headers - flags:callSafetyFlags - handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA - dispatch_async(_callQueue, ^{ - if (!self->_unaryCall) { - [self->_wrappedCall startBatchWithOperations:@[ op ]]; - } else { - [self->_unaryOpBatch addObject:op]; - } +- (void)finish { + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor finish]; }); } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - if (numberOfMessages == 0) { - return; - } - @synchronized(self) { - _pendingReceiveNextMessages += numberOfMessages; - - if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { - return; - } - [self maybeStartNextRead]; - } -} - -#pragma mark GRXWriteable implementation - -// Only called from the call queue. The error handler will be called from the -// network queue if the write didn't succeed. -// If the call is a unary call, parameter \a errorHandler will be ignored and -// the error handler of GRPCOpSendClose will be executed in case of error. -- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { - __weak GRPCCall *weakSelf = self; - void (^resumingHandler)(void) = ^{ - // Resume the request writer. - GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf->_requestWriter.state = GRXWriterStateStarted; - if (strongSelf->_writeDone) { - strongSelf->_writeDone(); - } - } - }; - GRPCOpSendMessage *op = - [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; - } else { - // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. - // TODO (mxyan): unify the error handlers of all Ops into a single closure. - [_unaryOpBatch addObject:op]; - } -} - -- (void)writeValue:(id)value { - NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); - - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - } - - // Pause the input and only resume it when the C layer notifies us that writes - // can proceed. - _requestWriter.state = GRXWriterStatePaused; - - dispatch_async(_callQueue, ^{ - // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self writeMessage:value withErrorHandler:nil]; - }); -} - -// Only called from the call queue. The error handler will be called from the -// network queue if the requests stream couldn't be closed successfully. -- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] - errorHandler:errorHandler]; - } else { - [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; - [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; - } -} - -- (void)writesFinishedWithError:(NSError *)errorOrNil { - if (errorOrNil) { - [self cancel]; - } else { - dispatch_async(_callQueue, ^{ - // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self finishRequestWithErrorHandler:nil]; - }); - } -} - -#pragma mark Invoke - -// Both handlers will eventually be called, from the network queue. Writes can start immediately -// after this. -// The first one (headersHandler), when the response headers are received. -// The second one (completionHandler), whenever the RPC finishes for any reason. -- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler - completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { - dispatch_async(_callQueue, ^{ - // TODO(jcanizales): Add error handlers for async failures - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; }); } -- (void)invokeCall { - __weak GRPCCall *weakSelf = self; - [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { - // Response headers received. - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - // it is ok to set nil because headers are only received once - strongSelf.responseHeaders = nil; - // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed - NSDictionary *copiedHeaders = - [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; - strongSelf.responseHeaders = copiedHeaders; - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - } - completionHandler:^(NSError *error, NSDictionary *trailers) { - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf.responseTrailers = trailers; - - if (error) { - NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - if (error.userInfo) { - [userInfo addEntriesFromDictionary:error.userInfo]; - } - userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; - // Since gRPC core does not guarantee the headers block being called before this block, - // responseHeaders might be nil. - userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; - error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; - } - [strongSelf finishWithError:error]; - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } - }]; -} - -#pragma mark GRXWriter implementation - -// Lock acquired inside startWithWriteable: -- (void)startCallWithWriteable:(id)writeable { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - - _responseWriteable = - [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; - - GRPCPooledChannel *channel = - [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; - _wrappedCall = [channel wrappedCallWithPath:_path - completionQueue:[GRPCCompletionQueue completionQueue] - callOptions:_callOptions]; - - if (_wrappedCall == nil) { - [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeUnavailable - userInfo:@{ - NSLocalizedDescriptionKey : - @"Failed to create call or channel." - }]]; - return; - } - - [self sendHeaders]; - [self invokeCall]; - } - - // Now that the RPC has been initiated, request writes can start. - [_requestWriter startWithWriteable:self]; -} - -- (void)startWithWriteable:(id)writeable { - id tokenProvider = nil; - @synchronized(self) { - _state = GRXWriterStateStarted; - - // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). - // This makes RPCs in which the call isn't externally retained possible (as long as it is - // started before being autoreleased). Care is taken not to retain self strongly in any of the - // blocks used in this implementation, so that the life of the instance is determined by this - // retain cycle. - _retainSelf = self; - - if (_callOptions == nil) { - GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; - if (_serverName.length != 0) { - callOptions.serverAuthority = _serverName; - } - if (_timeout > 0) { - callOptions.timeout = _timeout; - } - uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; - if (callFlags != 0) { - if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { - _callSafety = GRPCCallSafetyIdempotentRequest; - } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { - _callSafety = GRPCCallSafetyCacheableRequest; - } - } - - id tokenProvider = self.tokenProvider; - if (tokenProvider != nil) { - callOptions.authTokenProvider = tokenProvider; - } - _callOptions = callOptions; - } - - NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, - @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); - - tokenProvider = _callOptions.authTokenProvider; - } - - if (tokenProvider != nil) { - __weak typeof(self) weakSelf = self; - [tokenProvider getTokenWithHandler:^(NSString *token) { - __strong typeof(self) strongSelf = weakSelf; - if (strongSelf) { - BOOL startCall = NO; - @synchronized(strongSelf) { - if (strongSelf->_state != GRXWriterStateFinished) { - startCall = YES; - if (token) { - strongSelf->_fetchedOauth2AccessToken = [token copy]; - } - } - } - if (startCall) { - [strongSelf startCallWithWriteable:writeable]; - } - } - }]; - } else { - [self startCallWithWriteable:writeable]; - } -} - -- (void)setState:(GRXWriterState)newState { - @synchronized(self) { - // Manual transitions are only allowed from the started or paused states. - if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { - return; - } - - switch (newState) { - case GRXWriterStateFinished: - _state = newState; - // Per GRXWriter's contract, setting the state to Finished manually - // means one doesn't wish the writeable to be messaged anymore. - [_responseWriteable cancelSilently]; - _responseWriteable = nil; - return; - case GRXWriterStatePaused: - _state = newState; - return; - case GRXWriterStateStarted: - if (_state == GRXWriterStatePaused) { - _state = newState; - [self maybeStartNextRead]; - } - return; - case GRXWriterStateNotStarted: - return; - } - } -} - @end diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.h b/src/objective-c/GRPCClient/GRPCCallLegacy.h new file mode 100644 index 00000000000..51dd7da3440 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.h @@ -0,0 +1,136 @@ +/* + * + * Copyright 2019 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. + * + */ + +/** + * This is the legacy interface of this gRPC library. This API is deprecated and users should use + * the API in GRPCCall.h. This API exists solely for the purpose of backwards compatibility. + */ + +#import +#import "GRPCTypes.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-completeness" + +/** + * This interface is deprecated. Please use \a GRPCCall2. + * + * Represents a single gRPC remote call. + */ +@interface GRPCCall : GRXWriter + +- (instancetype)init NS_UNAVAILABLE; + +/** + * The container of the request headers of an RPC conforms to this protocol, which is a subset of + * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. + * The keys of this container are the header names, which per the HTTP standard are case- + * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and + * can only consist of ASCII characters. + * A header value is a NSString object (with only ASCII characters), unless the header name has the + * suffix "-bin", in which case the value has to be a NSData object. + */ +/** + * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a + * name-value pair with string names and either string or binary values. + * + * The passed dictionary has to use NSString keys, corresponding to the header names. The value + * associated to each can be a NSString object or a NSData object. E.g.: + * + * call.requestHeaders = @{@"authorization": @"Bearer ..."}; + * + * call.requestHeaders[@"my-header-bin"] = someData; + * + * After the call is started, trying to modify this property is an error. + * + * The property is initialized to an empty NSMutableDictionary. + */ +@property(atomic, readonly) NSMutableDictionary *requestHeaders; + +/** + * This dictionary is populated with the HTTP headers received from the server. This happens before + * any response message is received from the server. It has the same structure as the request + * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a + * NSData value; the others have a NSString value. + * + * The value of this property is nil until all response headers are received, and will change before + * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseHeaders; + +/** + * Same as responseHeaders, but populated with the HTTP trailers received from the server before the + * call finishes. + * + * The value of this property is nil until all response trailers are received, and will change + * before -writesFinishedWithError: is sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseTrailers; + +/** + * The request writer has to write NSData objects into the provided Writeable. The server will + * receive each of those separately and in order as distinct messages. + * A gRPC call might not complete until the request writer finishes. On the other hand, the request + * finishing doesn't necessarily make the call to finish, as the server might continue sending + * 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 + requestsWriter:(GRXWriter *)requestWriter; + +/** + * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and + * finishes the response side of the call with an error of code CANCELED. + */ +- (void)cancel; + +/** + * The following methods are deprecated. + */ ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; +@property(atomic, copy, readwrite) NSString *serverName; +@property NSTimeInterval timeout; +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; + +@end + +#pragma mark Backwards compatibiity + +/** This protocol is kept for backwards compatibility with existing code. */ +DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") +@protocol GRPCRequestHeaders +@property(nonatomic, readonly) NSUInteger count; + +- (id)objectForKeyedSubscript:(id)key; +- (void)setObject:(id)obj forKeyedSubscript:(id)key; + +- (void)removeAllObjects; +- (void)removeObjectForKey:(id)key; +@end + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +/** This is only needed for backwards-compatibility. */ +@interface NSMutableDictionary (GRPCRequestHeaders) +@end +#pragma clang diagnostic pop +#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m new file mode 100644 index 00000000000..d06048c3a89 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.m @@ -0,0 +1,677 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "GRPCCallLegacy.h" + +#import "GRPCCall+OAuth2.h" +#import "GRPCCallOptions.h" +#import "GRPCTypes.h" + +#import "private/GRPCCore/GRPCChannelPool.h" +#import "private/GRPCCore/GRPCCompletionQueue.h" +#import "private/GRPCCore/GRPCHost.h" +#import "private/GRPCCore/GRPCWrappedCall.h" +#import "private/GRPCCore/NSData+GRPC.h" + +#import +#import +#import +#import + +#include + +const char *kCFStreamVarName = "grpc_cfstream"; +static NSMutableDictionary *callFlags; + +// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, +// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, +// and RECV_STATUS_ON_CLIENT. +NSInteger kMaxClientBatch = 6; + +static NSString *const kAuthorizationHeader = @"authorization"; +static NSString *const kBearerPrefix = @"Bearer "; + +@interface GRPCCall () +// Make them read-write. +@property(atomic, strong) NSDictionary *responseHeaders; +@property(atomic, strong) NSDictionary *responseTrailers; + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages; + +@end + +// The following methods of a C gRPC call object aren't reentrant, and thus +// calls to them must be serialized: +// - start_batch +// - destroy +// +// start_batch with a SEND_MESSAGE argument can only be called after the +// OP_COMPLETE event for any previous write is received. This is achieved by +// pausing the requests writer immediately every time it writes a value, and +// resuming it again when OP_COMPLETE is received. +// +// Similarly, start_batch with a RECV_MESSAGE argument can only be called after +// the OP_COMPLETE event for any previous read is received.This is easier to +// enforce, as we're writing the received messages into the writeable: +// start_batch is enqueued once upon receiving the OP_COMPLETE event for the +// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for +// each RECV_MESSAGE batch. +@implementation GRPCCall { + dispatch_queue_t _callQueue; + + NSString *_host; + NSString *_path; + GRPCCallSafety _callSafety; + GRPCCallOptions *_callOptions; + GRPCWrappedCall *_wrappedCall; + + // The C gRPC library has less guarantees on the ordering of events than we + // do. Particularly, in the face of errors, there's no ordering guarantee at + // all. This wrapper over our actual writeable ensures thread-safety and + // correct ordering. + GRXConcurrentWriteable *_responseWriteable; + + // The network thread wants the requestWriter to resume (when the server is ready for more input), + // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop + // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. + // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or + // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to + // pause the writer immediately on writeValue:, so we need our locking to be recursive. + GRXWriter *_requestWriter; + + // To create a retain cycle when a call is started, up until it finishes. See + // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a + // reference to the call object if all they're interested in is the handler being executed when + // the response arrives. + GRPCCall *_retainSelf; + + GRPCRequestHeaders *_requestHeaders; + + // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type + // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core + // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when + // the SendClose op is added. + BOOL _unaryCall; + NSMutableArray *_unaryOpBatch; + + // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch + // queue + dispatch_queue_t _responseQueue; + + // The OAuth2 token fetched from a token provider. + NSString *_fetchedOauth2AccessToken; + + // The callback to be called when a write message op is done. + void (^_writeDone)(void); + + // Indicate a read request to core is pending. + BOOL _pendingCoreRead; + + // Indicate pending read message request from user. + NSUInteger _pendingReceiveNextMessages; +} + +@synthesize state = _state; + ++ (void)initialize { + // Guarantees the code in {} block is invoked only once. See ref at: + // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc + if (self == [GRPCCall self]) { + grpc_init(); + callFlags = [NSMutableDictionary dictionary]; + } +} + ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { + if (host.length == 0 || path.length == 0) { + return; + } + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + switch (callSafety) { + case GRPCCallSafetyDefault: + callFlags[hostAndPath] = @0; + break; + case GRPCCallSafetyIdempotentRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + default: + break; + } + } +} + ++ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + return [callFlags[hostAndPath] intValue]; + } +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter { + return [self initWithHost:host + path:path + callSafety:GRPCCallSafetyDefault + requestsWriter:requestWriter + callOptions:nil + writeDone:nil]; +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions + writeDone:(void (^)(void))writeDone { + // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. + NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); + NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); + NSAssert(requestsWriter.state == GRXWriterStateNotStarted, + @"The requests writer can't be already started."); + if (!host || !path) { + return nil; + } + if (safety > GRPCCallSafetyCacheableRequest) { + return nil; + } + if (requestsWriter.state != GRXWriterStateNotStarted) { + return nil; + } + + if ((self = [super init])) { + _host = [host copy]; + _path = [path copy]; + _callSafety = safety; + _callOptions = [callOptions copy]; + + // Serial queue to invoke the non-reentrant methods of the grpc_call object. + _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); + + _requestWriter = requestsWriter; + _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; + _writeDone = writeDone; + + if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { + _unaryCall = YES; + _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; + } + + _responseQueue = dispatch_get_main_queue(); + + // do not start a read until initial metadata is received + _pendingReceiveNextMessages = 0; + _pendingCoreRead = YES; + } + return self; +} + +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { + @synchronized(self) { + if (_state != GRXWriterStateNotStarted) { + return; + } + _responseQueue = queue; + } +} + +#pragma mark Finish + +// This function should support being called within a @synchronized(self) block in another function +// Should not manipulate _requestWriter for deadlock prevention. +- (void)finishWithError:(NSError *)errorOrNil { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + _state = GRXWriterStateFinished; + + if (errorOrNil) { + [_responseWriteable cancelWithError:errorOrNil]; + } else { + [_responseWriteable enqueueSuccessfulCompletion]; + } + + // If the call isn't retained anywhere else, it can be deallocated now. + _retainSelf = nil; + } +} + +- (void)cancel { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + [self finishWithError:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; + [_wrappedCall cancel]; + } + _requestWriter.state = GRXWriterStateFinished; +} + +- (void)dealloc { + __block GRPCWrappedCall *wrappedCall = _wrappedCall; + dispatch_async(_callQueue, ^{ + wrappedCall = nil; + }); +} + +#pragma mark Read messages + +// Only called from the call queue. +// The handler will be called from the network queue. +- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { + // TODO(jcanizales): Add error handlers for async failures + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; +} + +// Called initially from the network queue once response headers are received, +// then "recursively" from the responseWriteable queue after each response from the +// server has been written. +// If the call is currently paused, this is a noop. Restarting the call will invoke this +// method. +// TODO(jcanizales): Rename to readResponseIfNotPaused. +- (void)maybeStartNextRead { + @synchronized(self) { + if (_state != GRXWriterStateStarted) { + return; + } + if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { + return; + } + _pendingCoreRead = YES; + _pendingReceiveNextMessages--; + } + + dispatch_async(_callQueue, ^{ + __weak GRPCCall *weakSelf = self; + [self startReadWithHandler:^(grpc_byte_buffer *message) { + if (message == NULL) { + // No more messages from the server + return; + } + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf == nil) { + grpc_byte_buffer_destroy(message); + return; + } + NSData *data = [NSData grpc_dataWithByteBuffer:message]; + grpc_byte_buffer_destroy(message); + if (!data) { + // The app doesn't have enough memory to hold the server response. We + // don't want to throw, because the app shouldn't crash for a behavior + // that's on the hands of any server to have. Instead we finish and ask + // the server to cancel. + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf + finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeResourceExhausted + userInfo:@{ + NSLocalizedDescriptionKey : + @"Client does not have enough memory to " + @"hold the server response." + }]]; + [strongSelf->_wrappedCall cancel]; + } + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } else { + @synchronized(strongSelf) { + [strongSelf->_responseWriteable enqueueValue:data + completionHandler:^{ + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + }]; + } + } + }]; + }); +} + +#pragma mark Send headers + +- (void)sendHeaders { + // TODO (mxyan): Remove after deprecated methods are removed + uint32_t callSafetyFlags = 0; + switch (_callSafety) { + case GRPCCallSafetyDefault: + callSafetyFlags = 0; + break; + case GRPCCallSafetyIdempotentRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + } + + NSMutableDictionary *headers = [_requestHeaders mutableCopy]; + NSString *fetchedOauth2AccessToken; + @synchronized(self) { + fetchedOauth2AccessToken = _fetchedOauth2AccessToken; + } + if (fetchedOauth2AccessToken != nil) { + headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; + } else if (_callOptions.oauth2AccessToken != nil) { + headers[@"authorization"] = + [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; + } + + // TODO(jcanizales): Add error handlers for async failures + GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] + initWithMetadata:headers + flags:callSafetyFlags + handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA + dispatch_async(_callQueue, ^{ + if (!self->_unaryCall) { + [self->_wrappedCall startBatchWithOperations:@[ op ]]; + } else { + [self->_unaryOpBatch addObject:op]; + } + }); +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + if (numberOfMessages == 0) { + return; + } + @synchronized(self) { + _pendingReceiveNextMessages += numberOfMessages; + + if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { + return; + } + [self maybeStartNextRead]; + } +} + +#pragma mark GRXWriteable implementation + +// Only called from the call queue. The error handler will be called from the +// network queue if the write didn't succeed. +// If the call is a unary call, parameter \a errorHandler will be ignored and +// the error handler of GRPCOpSendClose will be executed in case of error. +- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { + __weak GRPCCall *weakSelf = self; + void (^resumingHandler)(void) = ^{ + // Resume the request writer. + GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf->_requestWriter.state = GRXWriterStateStarted; + if (strongSelf->_writeDone) { + strongSelf->_writeDone(); + } + } + }; + GRPCOpSendMessage *op = + [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; + } else { + // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. + // TODO (mxyan): unify the error handlers of all Ops into a single closure. + [_unaryOpBatch addObject:op]; + } +} + +- (void)writeValue:(id)value { + NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); + + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + } + + // Pause the input and only resume it when the C layer notifies us that writes + // can proceed. + _requestWriter.state = GRXWriterStatePaused; + + dispatch_async(_callQueue, ^{ + // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self writeMessage:value withErrorHandler:nil]; + }); +} + +// Only called from the call queue. The error handler will be called from the +// network queue if the requests stream couldn't be closed successfully. +- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] + errorHandler:errorHandler]; + } else { + [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; + [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; + } +} + +- (void)writesFinishedWithError:(NSError *)errorOrNil { + if (errorOrNil) { + [self cancel]; + } else { + dispatch_async(_callQueue, ^{ + // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self finishRequestWithErrorHandler:nil]; + }); + } +} + +#pragma mark Invoke + +// Both handlers will eventually be called, from the network queue. Writes can start immediately +// after this. +// The first one (headersHandler), when the response headers are received. +// The second one (completionHandler), whenever the RPC finishes for any reason. +- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler + completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { + dispatch_async(_callQueue, ^{ + // TODO(jcanizales): Add error handlers for async failures + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; + }); +} + +- (void)invokeCall { + __weak GRPCCall *weakSelf = self; + [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { + // Response headers received. + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + // it is ok to set nil because headers are only received once + strongSelf.responseHeaders = nil; + // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed + NSDictionary *copiedHeaders = + [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; + strongSelf.responseHeaders = copiedHeaders; + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + } + completionHandler:^(NSError *error, NSDictionary *trailers) { + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf.responseTrailers = trailers; + + if (error) { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + if (error.userInfo) { + [userInfo addEntriesFromDictionary:error.userInfo]; + } + userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; + // Since gRPC core does not guarantee the headers block being called before this block, + // responseHeaders might be nil. + userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; + error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; + } + [strongSelf finishWithError:error]; + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } + }]; +} + +#pragma mark GRXWriter implementation + +// Lock acquired inside startWithWriteable: +- (void)startCallWithWriteable:(id)writeable { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + + _responseWriteable = + [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; + + GRPCPooledChannel *channel = + [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; + _wrappedCall = [channel wrappedCallWithPath:_path + completionQueue:[GRPCCompletionQueue completionQueue] + callOptions:_callOptions]; + + if (_wrappedCall == nil) { + [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeUnavailable + userInfo:@{ + NSLocalizedDescriptionKey : + @"Failed to create call or channel." + }]]; + return; + } + + [self sendHeaders]; + [self invokeCall]; + } + + // Now that the RPC has been initiated, request writes can start. + [_requestWriter startWithWriteable:self]; +} + +- (void)startWithWriteable:(id)writeable { + id tokenProvider = nil; + @synchronized(self) { + _state = GRXWriterStateStarted; + + // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). + // This makes RPCs in which the call isn't externally retained possible (as long as it is + // started before being autoreleased). Care is taken not to retain self strongly in any of the + // blocks used in this implementation, so that the life of the instance is determined by this + // retain cycle. + _retainSelf = self; + + // If _callOptions is nil, people must be using the deprecated v1 interface. In this case, + // generate the call options from the corresponding GRPCHost configs and apply other options + // that are not covered by GRPCHost. + if (_callOptions == nil) { + GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; + if (_serverName.length != 0) { + callOptions.serverAuthority = _serverName; + } + if (_timeout > 0) { + callOptions.timeout = _timeout; + } + uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; + if (callFlags != 0) { + if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { + _callSafety = GRPCCallSafetyIdempotentRequest; + } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { + _callSafety = GRPCCallSafetyCacheableRequest; + } + } + + id tokenProvider = self.tokenProvider; + if (tokenProvider != nil) { + callOptions.authTokenProvider = tokenProvider; + } + _callOptions = callOptions; + } + + NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, + @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); + + tokenProvider = _callOptions.authTokenProvider; + } + + if (tokenProvider != nil) { + __weak typeof(self) weakSelf = self; + [tokenProvider getTokenWithHandler:^(NSString *token) { + __strong typeof(self) strongSelf = weakSelf; + if (strongSelf) { + BOOL startCall = NO; + @synchronized(strongSelf) { + if (strongSelf->_state != GRXWriterStateFinished) { + startCall = YES; + if (token) { + strongSelf->_fetchedOauth2AccessToken = [token copy]; + } + } + } + if (startCall) { + [strongSelf startCallWithWriteable:writeable]; + } + } + }]; + } else { + [self startCallWithWriteable:writeable]; + } +} + +- (void)setState:(GRXWriterState)newState { + @synchronized(self) { + // Manual transitions are only allowed from the started or paused states. + if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { + return; + } + + switch (newState) { + case GRXWriterStateFinished: + _state = newState; + // Per GRXWriter's contract, setting the state to Finished manually + // means one doesn't wish the writeable to be messaged anymore. + [_responseWriteable cancelSilently]; + _responseWriteable = nil; + return; + case GRXWriterStatePaused: + _state = newState; + return; + case GRXWriterStateStarted: + if (_state == GRXWriterStatePaused) { + _state = newState; + [self maybeStartNextRead]; + } + return; + case GRXWriterStateNotStarted: + return; + } + } +} + +@end diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 98511e3f5cb..e4261b5b5f9 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -18,57 +18,11 @@ #import -NS_ASSUME_NONNULL_BEGIN - -/** - * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 - */ -typedef NS_ENUM(NSUInteger, GRPCCallSafety) { - /** Signal that there is no guarantees on how the call affects the server state. */ - GRPCCallSafetyDefault = 0, - /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ - GRPCCallSafetyIdempotentRequest = 1, - /** - * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET - * verb. - */ - GRPCCallSafetyCacheableRequest = 2, -}; - -// Compression algorithm to be used by a gRPC call -typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { - GRPCCompressNone = 0, - GRPCCompressDeflate, - GRPCCompressGzip, - GRPCStreamCompressGzip, -}; - -// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm -typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; +#import "GRPCTypes.h" -/** The transport to be used by a gRPC call */ -typedef NS_ENUM(NSUInteger, GRPCTransportType) { - GRPCTransportTypeDefault = 0, - /** gRPC internal HTTP/2 stack with BoringSSL */ - GRPCTransportTypeChttp2BoringSSL = 0, - /** Cronet stack */ - GRPCTransportTypeCronet, - /** Insecure channel. FOR TEST ONLY! */ - GRPCTransportTypeInsecure, -}; - -/** - * Implement this protocol to provide a token to gRPC when a call is initiated. - */ -@protocol GRPCAuthorizationProtocol - -/** - * This method is called when gRPC is about to start the call. When OAuth token is acquired, - * \a handler is expected to be called with \a token being the new token to be used for this call. - */ -- (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler; +NS_ASSUME_NONNULL_BEGIN -@end +@protocol GRPCInterceptorFactory; @interface GRPCCallOptions : NSObject @@ -104,7 +58,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readonly) NSArray *interceptorFactories; +@property(copy, readonly) NSArray> *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -192,10 +146,23 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { @property(copy, readonly, nullable) NSString *PEMCertificateChain; /** + * Deprecated: this option is deprecated. Please use the property \a transport + * instead. + * * Select the transport type to be used for this call. */ @property(readonly) GRPCTransportType transportType; +/** + * The transport to be used for this call. Users may choose a native transport + * identifier defined in \a GRPCTransport or provided by a non-native transport + * implementation. If the option is left to be NULL, gRPC will use its default + * transport. + * + * This is currently an experimental option. + */ +@property(readonly) GRPCTransportId transport; + /** * Override the hostname during the TLS hostname validation process. */ @@ -267,7 +234,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readwrite) NSArray *interceptorFactories; +@property(copy, readwrite) NSArray> *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -357,10 +324,23 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { @property(copy, readwrite, nullable) NSString *PEMCertificateChain; /** + * Deprecated: this option is deprecated. Please use the property \a transport + * instead. + * * Select the transport type to be used for this call. */ @property(readwrite) GRPCTransportType transportType; +/** + * The transport to be used for this call. Users may choose a native transport + * identifier defined in \a GRPCTransport or provided by a non-native ttransport + * implementation. If the option is left to be NULL, gRPC will use its default + * transport. + * + * An interceptor must not change the value of this option. + */ +@property(readwrite) GRPCTransportId transport; + /** * Override the hostname during the TLS hostname validation process. */ diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 392e42a9d47..7f88098eb6f 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -17,13 +17,14 @@ */ #import "GRPCCallOptions.h" +#import "GRPCTransport.h" #import "internal/GRPCCallOptions+Internal.h" // The default values for the call options. static NSString *const kDefaultServerAuthority = nil; static const NSTimeInterval kDefaultTimeout = 0; static const BOOL kDefaultFlowControlEnabled = NO; -static NSArray *const kDefaultInterceptorFactories = nil; +static NSArray> *const kDefaultInterceptorFactories = nil; static NSDictionary *const kDefaultInitialMetadata = nil; static NSString *const kDefaultUserAgentPrefix = nil; static const NSUInteger kDefaultResponseSizeLimit = 0; @@ -41,6 +42,7 @@ static NSString *const kDefaultPEMCertificateChain = nil; static NSString *const kDefaultOauth2AccessToken = nil; static const id kDefaultAuthTokenProvider = nil; static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL; +static const GRPCTransportId kDefaultTransport = NULL; static NSString *const kDefaultHostNameOverride = nil; static const id kDefaultLogContext = nil; static NSString *const kDefaultChannelPoolDomain = nil; @@ -62,7 +64,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_serverAuthority; NSTimeInterval _timeout; BOOL _flowControlEnabled; - NSArray *_interceptorFactories; + NSArray> *_interceptorFactories; NSString *_oauth2AccessToken; id _authTokenProvider; NSDictionary *_initialMetadata; @@ -80,6 +82,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_PEMPrivateKey; NSString *_PEMCertificateChain; GRPCTransportType _transportType; + GRPCTransportId _transport; NSString *_hostNameOverride; id _logContext; NSString *_channelPoolDomain; @@ -107,6 +110,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @synthesize PEMPrivateKey = _PEMPrivateKey; @synthesize PEMCertificateChain = _PEMCertificateChain; @synthesize transportType = _transportType; +@synthesize transport = _transport; @synthesize hostNameOverride = _hostNameOverride; @synthesize logContext = _logContext; @synthesize channelPoolDomain = _channelPoolDomain; @@ -134,6 +138,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -143,7 +148,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)initWithServerAuthority:(NSString *)serverAuthority timeout:(NSTimeInterval)timeout flowControlEnabled:(BOOL)flowControlEnabled - interceptorFactories:(NSArray *)interceptorFactories + interceptorFactories:(NSArray> *)interceptorFactories oauth2AccessToken:(NSString *)oauth2AccessToken authTokenProvider:(id)authTokenProvider initialMetadata:(NSDictionary *)initialMetadata @@ -161,6 +166,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType + transport:(GRPCTransportId)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -193,6 +199,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _PEMPrivateKey = [PEMPrivateKey copy]; _PEMCertificateChain = [PEMCertificateChain copy]; _transportType = transportType; + _transport = transport; _hostNameOverride = [hostNameOverride copy]; _logContext = logContext; _channelPoolDomain = [channelPoolDomain copy]; @@ -224,6 +231,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -256,6 +264,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:[_PEMPrivateKey copy] PEMCertificateChain:[_PEMCertificateChain copy] transportType:_transportType + transport:_transport hostNameOverride:[_hostNameOverride copy] logContext:_logContext channelPoolDomain:[_channelPoolDomain copy] @@ -280,6 +289,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO; if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO; if (!(callOptions.transportType == _transportType)) return NO; + if (!(TransportIdIsEqual(callOptions.transport, _transport))) return NO; if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO; if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO; if (!(callOptions.channelID == _channelID)) return NO; @@ -304,6 +314,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { result ^= _PEMCertificateChain.hash; result ^= _hostNameOverride.hash; result ^= _transportType; + result ^= TransportIdHash(_transport); result ^= _logContext.hash; result ^= _channelPoolDomain.hash; result ^= _channelID; @@ -336,6 +347,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @dynamic PEMPrivateKey; @dynamic PEMCertificateChain; @dynamic transportType; +@dynamic transport; @dynamic hostNameOverride; @dynamic logContext; @dynamic channelPoolDomain; @@ -363,6 +375,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -392,6 +405,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -422,6 +436,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -445,7 +460,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _flowControlEnabled = flowControlEnabled; } -- (void)setInterceptorFactories:(NSArray *)interceptorFactories { +- (void)setInterceptorFactories:(NSArray> *)interceptorFactories { _interceptorFactories = interceptorFactories; } @@ -538,6 +553,10 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _transportType = transportType; } +- (void)setTransport:(GRPCTransportId)transport { + _transport = transport; +} + - (void)setHostNameOverride:(NSString *)hostNameOverride { _hostNameOverride = [hostNameOverride copy]; } diff --git a/src/objective-c/GRPCClient/GRPCDispatchable.h b/src/objective-c/GRPCClient/GRPCDispatchable.h new file mode 100644 index 00000000000..650103603d4 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCDispatchable.h @@ -0,0 +1,30 @@ + +/* + * + * Copyright 2019 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. + * + */ + +/** + * An object that processes its methods with a dispatch queue. + */ +@protocol GRPCDispatchable + +/** + * The dispatch queue where the object's methods should be run on. + */ +@property(atomic, readonly) dispatch_queue_t dispatchQueue; + +@end diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 3b62c1b3ec0..509749769b3 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -106,22 +106,20 @@ */ #import "GRPCCall.h" +#import "GRPCDispatchable.h" NS_ASSUME_NONNULL_BEGIN @class GRPCInterceptorManager; @class GRPCInterceptor; +@class GRPCRequestOptions; +@class GRPCCallOptions; +@protocol GRPCResponseHandler; /** * The GRPCInterceptorInterface defines the request events that can occur to an interceptr. */ -@protocol GRPCInterceptorInterface - -/** - * The queue on which all methods of this interceptor should be dispatched on. The queue must be a - * serial queue. - */ -@property(readonly) dispatch_queue_t requestDispatchQueue; +@protocol GRPCInterceptorInterface /** * To start the call. This method will only be called once for each instance. @@ -171,19 +169,20 @@ NS_ASSUME_NONNULL_BEGIN * invoke shutDown method of its corresponding manager so that references to other interceptors can * be released. */ -@interface GRPCInterceptorManager : NSObject +@interface GRPCInterceptorManager : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithNextInterceptor:(id)nextInterceptor - NS_DESIGNATED_INITIALIZER; - -/** Set the previous interceptor in the chain. Can only be set once. */ -- (void)setPreviousInterceptor:(id)previousInterceptor; +- (nullable instancetype)initWithFactories:(nullable NSArray> *)factories + previousInterceptor:(nullable id)previousInterceptor + transportId:(GRPCTransportId)transportId; -/** Indicate shutdown of the interceptor; release the reference to other interceptors */ +/** + * Notify the manager that the interceptor has shut down and the manager should release references + * to other interceptors and stop forwarding requests/responses. + */ - (void)shutDown; // Methods to forward GRPCInterceptorInterface calls to the next interceptor @@ -235,7 +234,6 @@ NS_ASSUME_NONNULL_BEGIN @interface GRPCInterceptor : NSObject - (instancetype)init NS_UNAVAILABLE; - + (instancetype) new NS_UNAVAILABLE; /** @@ -243,9 +241,7 @@ NS_ASSUME_NONNULL_BEGIN * that this interceptor's methods are dispatched onto. */ - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - NS_DESIGNATED_INITIALIZER; + dispatchQueue:(dispatch_queue_t)dispatchQueue; // Default implementation of GRPCInterceptorInterface diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index a385ecd7813..a7ffe05bddc 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -19,117 +19,253 @@ #import #import "GRPCInterceptor.h" +#import "private/GRPCTransport+Private.h" + +@interface GRPCInterceptorManager () + +@end @implementation GRPCInterceptorManager { id _nextInterceptor; id _previousInterceptor; + GRPCInterceptor *_thisInterceptor; + dispatch_queue_t _dispatchQueue; + NSArray> *_factories; + GRPCTransportId _transportId; + BOOL _shutDown; } -- (instancetype)initWithNextInterceptor:(id)nextInterceptor { +- (instancetype)initWithFactories:(NSArray> *)factories + previousInterceptor:(id)previousInterceptor + transportId:(nonnull GRPCTransportId)transportId { if ((self = [super init])) { - _nextInterceptor = nextInterceptor; + if (factories.count == 0) { + [NSException raise:NSInternalInconsistencyException + format:@"Interceptor manager must have factories"]; + } + _thisInterceptor = [factories[0] createInterceptorWithManager:self]; + if (_thisInterceptor == nil) { + return nil; + } + _previousInterceptor = previousInterceptor; + _factories = factories; + // Generate interceptor +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { +#else + { +#endif + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); + _transportId = transportId; } - return self; } -- (void)setPreviousInterceptor:(id)previousInterceptor { - _previousInterceptor = previousInterceptor; +- (void)shutDown { + dispatch_async(_dispatchQueue, ^{ + self->_nextInterceptor = nil; + self->_previousInterceptor = nil; + self->_thisInterceptor = nil; + self->_shutDown = YES; + }); } -- (void)shutDown { - _nextInterceptor = nil; - _previousInterceptor = nil; +- (void)createNextInterceptor { + NSAssert(_nextInterceptor == nil, @"Starting the next interceptor more than once"); + NSAssert(_factories.count > 0, @"Interceptor manager of transport cannot start next interceptor"); + if (_nextInterceptor != nil) { + NSLog(@"Starting the next interceptor more than once"); + return; + } + NSMutableArray> *interceptorFactories = [NSMutableArray + arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]]; + while (_nextInterceptor == nil) { + if (interceptorFactories.count == 0) { + _nextInterceptor = + [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; + break; + } else { + _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:self + transportId:_transportId]; + if (_nextInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; + } + } + } + NSAssert(_nextInterceptor != nil, @"Failed to create interceptor or transport."); + if (_nextInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); + } } - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - (void)writeNextInterceptorWithData:(id)data { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor writeData:data]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; + } + if (_nextInterceptor == nil) { + return; } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor writeData:data]; + }); } - (void)finishNextInterceptor { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor finish]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; + } + if (_nextInterceptor == nil) { + return; } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor finish]; + }); } - (void)cancelNextInterceptor { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor cancel]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; + } + if (_nextInterceptor == nil) { + return; } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor cancel]; + }); } /** Notify the next interceptor in the chain to receive more messages */ - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor receiveNextMessages:numberOfMessages]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; + } + if (_nextInterceptor == nil) { + return; } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor receiveNextMessages:numberOfMessages]; + }); } // Methods to forward GRPCResponseHandler callbacks to the previous object /** Forward initial metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_previousInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; - }); +- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); } /** Forward a received message to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithData:(id)data { - if ([_previousInterceptor respondsToSelector:@selector(didReceiveData:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveData:data]; - }); + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); } /** Forward call close and trailing metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: - (nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error { - if ([_previousInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata + error:(NSError *)error { + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); } /** Forward write completion to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorDidWriteData { - if ([_previousInterceptor respondsToSelector:@selector(didWriteData)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didWriteData]; - }); + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; +} + +- (void)writeData:(id)data { + [_thisInterceptor writeData:data]; +} + +- (void)finish { + [_thisInterceptor finish]; +} + +- (void)cancel { + [_thisInterceptor cancel]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_thisInterceptor receiveNextMessages:numberOfMessages]; +} + +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; + } +} + +- (void)didReceiveData:(id)data { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { + [_thisInterceptor didReceiveData:data]; + } +} + +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { + if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + } +} + +- (void)didWriteData { + if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { + [_thisInterceptor didWriteData]; } } @@ -137,28 +273,21 @@ @implementation GRPCInterceptor { GRPCInterceptorManager *_manager; - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { + dispatchQueue:(dispatch_queue_t)dispatchQueue { if ((self = [super init])) { _manager = interceptorManager; - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; } return self; } -- (dispatch_queue_t)requestDispatchQueue { - return _requestDispatchQueue; -} - - (dispatch_queue_t)dispatchQueue { - return _responseDispatchQueue; + return _dispatchQueue; } - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h new file mode 100644 index 00000000000..d5637922152 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -0,0 +1,82 @@ +/* + * + * Copyright 2019 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. + * + */ + +// The interface for a transport implementation + +#import "GRPCInterceptor.h" + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark Transport ID + +/** + * The default transport implementations available in gRPC. These implementations will be provided + * by gRPC by default unless explicitly excluded. + */ +extern const struct GRPCDefaultTransportImplList { + const GRPCTransportId core_secure; + const GRPCTransportId core_insecure; +} GRPCDefaultTransportImplList; + +/** Returns whether two transport id's are identical. */ +BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); + +/** Returns the hash value of a transport id. */ +NSUInteger TransportIdHash(GRPCTransportId); + +#pragma mark Transport and factory + +@protocol GRPCInterceptorInterface; +@protocol GRPCResponseHandler; +@class GRPCTransportManager; +@class GRPCRequestOptions; +@class GRPCCallOptions; +@class GRPCTransport; + +/** The factory method to create a transport. */ +@protocol GRPCTransportFactory + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; + +@end + +/** The registry of transport implementations. */ +@interface GRPCTransportRegistry : NSObject + ++ (instancetype)sharedInstance; + +/** + * Register a transport implementation with the registry. All transport implementations to be used + * in a process must register with the registry on process start-up in its +load: class method. + * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory + * object to create the corresponding transport instance. + */ +- (void)registerTransportWithId:(GRPCTransportId)transportId + factory:(id)factory; + +@end + +/** + * Base class for transport implementations. All transport implementation should inherit from this + * class. + */ +@interface GRPCTransport : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m new file mode 100644 index 00000000000..439acfb9cc2 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -0,0 +1,142 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "GRPCTransport.h" + +static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; +static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; + +const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { + .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; + +static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; + +static GRPCTransportRegistry *gTransportRegistry = nil; +static dispatch_once_t initTransportRegistry; + +BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs) { + // Directly comparing pointers works because we require users to use the id provided by each + // implementation, not coming up with their own string. + return lhs == rhs; +} + +NSUInteger TransportIdHash(GRPCTransportId transportId) { + if (transportId == NULL) { + transportId = gDefaultTransportId; + } + return [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding].hash; +} + +@implementation GRPCTransportRegistry { + NSMutableDictionary> *_registry; + id _defaultFactory; +} + ++ (instancetype)sharedInstance { + dispatch_once(&initTransportRegistry, ^{ + gTransportRegistry = [[GRPCTransportRegistry alloc] init]; + NSAssert(gTransportRegistry != nil, @"Unable to initialize transport registry."); + if (gTransportRegistry == nil) { + NSLog(@"Unable to initialize transport registry."); + [NSException raise:NSGenericException format:@"Unable to initialize transport registry."]; + } + }); + return gTransportRegistry; +} + +- (instancetype)init { + if ((self = [super init])) { + _registry = [NSMutableDictionary dictionary]; + } + return self; +} + +- (void)registerTransportWithId:(GRPCTransportId)transportId + factory:(id)factory { + NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; + NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", + nsTransportId); + if (_registry[nsTransportId] != nil) { + NSLog(@"The transport %@ has already been registered.", nsTransportId); + return; + } + _registry[nsTransportId] = factory; + + // if the default transport is registered, mark it. + if (0 == strcmp(transportId, gDefaultTransportId)) { + _defaultFactory = factory; + } +} + +- (id)getTransportFactoryWithId:(GRPCTransportId)transportId { + if (transportId == NULL) { + if (_defaultFactory == nil) { + [NSException raise:NSInvalidArgumentException + format:@"Unable to get default transport factory"]; + return nil; + } + return _defaultFactory; + } + NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; + id transportFactory = _registry[nsTransportId]; + if (transportFactory == nil) { + // User named a transport id that was not registered with the registry. + [NSException raise:NSInvalidArgumentException + format:@"Unable to get transport factory with id %s", transportId]; + return nil; + } + return transportFactory; +} + +@end + +@implementation GRPCTransport + +- (dispatch_queue_t)dispatchQueue { + [NSException raise:NSGenericException + format:@"Implementations should override the dispatch queue"]; + return nil; +} + +- (void)startWithRequestOptions:(nonnull GRPCRequestOptions *)requestOptions + callOptions:(nonnull GRPCCallOptions *)callOptions { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)writeData:(nonnull id)data { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)cancel { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)finish { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +@end diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h new file mode 100644 index 00000000000..c804bca4eaa --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -0,0 +1,187 @@ +/* + * + * Copyright 2019 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. + * + */ + +/** + * gRPC error codes. + * Note that a few of these are never produced by the gRPC libraries, but are of + * general utility for server applications to produce. + */ +typedef NS_ENUM(NSUInteger, GRPCErrorCode) { + /** The operation was cancelled (typically by the caller). */ + GRPCErrorCodeCancelled = 1, + + /** + * Unknown error. Errors raised by APIs that do not return enough error + * information may be converted to this error. + */ + GRPCErrorCodeUnknown = 2, + + /** + * The client specified an invalid argument. Note that this differs from + * FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are + * problematic regardless of the state of the server (e.g., a malformed file + * name). + */ + GRPCErrorCodeInvalidArgument = 3, + + /** + * Deadline expired before operation could complete. For operations that + * change the state of the server, this error may be returned even if the + * operation has completed successfully. For example, a successful response + * from the server could have been delayed long enough for the deadline to + * expire. + */ + GRPCErrorCodeDeadlineExceeded = 4, + + /** Some requested entity (e.g., file or directory) was not found. */ + GRPCErrorCodeNotFound = 5, + + /** Some entity that we attempted to create (e.g., file or directory) already + exists. */ + GRPCErrorCodeAlreadyExists = 6, + + /** + * The caller does not have permission to execute the specified operation. + * PERMISSION_DENIED isn't used for rejections caused by exhausting some + * resource (RESOURCE_EXHAUSTED is used instead for those errors). + * PERMISSION_DENIED doesn't indicate a failure to identify the caller + * (UNAUTHENTICATED is used instead for those errors). + */ + GRPCErrorCodePermissionDenied = 7, + + /** + * The request does not have valid authentication credentials for the + * operation (e.g. the caller's identity can't be verified). + */ + GRPCErrorCodeUnauthenticated = 16, + + /** Some resource has been exhausted, perhaps a per-user quota. */ + GRPCErrorCodeResourceExhausted = 8, + + /** + * The RPC was rejected because the server is not in a state required for the + * procedure's execution. For example, a directory to be deleted may be + * non-empty, etc. The client should not retry until the server state has been + * explicitly fixed (e.g. by performing another RPC). The details depend on + * the service being called, and should be found in the NSError's userInfo. + */ + GRPCErrorCodeFailedPrecondition = 9, + + /** + * The RPC was aborted, typically due to a concurrency issue like sequencer + * check failures, transaction aborts, etc. The client should retry at a + * higher-level (e.g., restarting a read- modify-write sequence). + */ + GRPCErrorCodeAborted = 10, + + /** + * The RPC was attempted past the valid range. E.g., enumerating past the end + * of a list. Unlike INVALID_ARGUMENT, this error indicates a problem that may + * be fixed if the system state changes. For example, an RPC to get elements + * of a list will generate INVALID_ARGUMENT if asked to return the element at + * a negative index, but it will generate OUT_OF_RANGE if asked to return the + * element at an index past the current size of the list. + */ + GRPCErrorCodeOutOfRange = 11, + + /** The procedure is not implemented or not supported/enabled in this server. + */ + GRPCErrorCodeUnimplemented = 12, + + /** + * Internal error. Means some invariant expected by the server application or + * the gRPC library has been broken. + */ + GRPCErrorCodeInternal = 13, + + /** + * The server is currently unavailable. This is most likely a transient + * condition and may be corrected by retrying with a backoff. Note that it is + * not always safe to retry non-idempotent operations. + */ + GRPCErrorCodeUnavailable = 14, + + /** Unrecoverable data loss or corruption. */ + GRPCErrorCodeDataLoss = 15, +}; + +/** + * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 + */ +typedef NS_ENUM(NSUInteger, GRPCCallSafety) { + /** + * Signal that there is no guarantees on how the call affects the server + * state. + */ + GRPCCallSafetyDefault = 0, + /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ + GRPCCallSafetyIdempotentRequest = 1, + /** + * Signal that the call is cacheable and will not affect server state. gRPC is + * free to use GET verb. + */ + GRPCCallSafetyCacheableRequest = 2, +}; + +// Compression algorithm to be used by a gRPC call +typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { + GRPCCompressNone = 0, + GRPCCompressDeflate, + GRPCCompressGzip, + GRPCStreamCompressGzip, +}; + +// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm +typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; + +/** The transport to be used by a gRPC call */ +typedef NS_ENUM(NSUInteger, GRPCTransportType) { + GRPCTransportTypeDefault = 0, + /** gRPC internal HTTP/2 stack with BoringSSL */ + GRPCTransportTypeChttp2BoringSSL = 0, + /** Cronet stack */ + GRPCTransportTypeCronet, + /** Insecure channel. FOR TEST ONLY! */ + GRPCTransportTypeInsecure, +}; + +/** Domain of NSError objects produced by gRPC. */ +extern NSString* _Nonnull const kGRPCErrorDomain; + +/** + * Keys used in |NSError|'s |userInfo| dictionary to store the response headers + * and trailers sent by the server. + */ +extern NSString* _Nonnull const kGRPCHeadersKey; +extern NSString* _Nonnull const kGRPCTrailersKey; + +/** The id of a transport implementation. */ +typedef char* _Nonnull GRPCTransportId; + +/** + * Implement this protocol to provide a token to gRPC when a call is initiated. + */ +@protocol GRPCAuthorizationProtocol + +/** + * This method is called when gRPC is about to start the call. When OAuth token is acquired, + * \a handler is expected to be called with \a token being the new token to be used for this call. + */ +- (void)getTokenWithHandler:(void (^_Nonnull)(NSString* _Nullable token))handler; + +@end diff --git a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m index 1bb352f0be2..8f98daa6348 100644 --- a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m +++ b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m @@ -20,7 +20,7 @@ #import "GRPCCall+InternalTests.h" -#import "../private/GRPCOpBatchLog.h" +#import "../private/GRPCCore/GRPCOpBatchLog.h" @implementation GRPCCall (InternalTests) diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.h b/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h similarity index 100% rename from src/objective-c/GRPCClient/private/ChannelArgsUtil.h rename to src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.m b/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m similarity index 100% rename from src/objective-c/GRPCClient/private/ChannelArgsUtil.m rename to src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m diff --git a/src/objective-c/GRPCClient/private/GRPCCall+V2API.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h similarity index 79% rename from src/objective-c/GRPCClient/private/GRPCCall+V2API.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h index 22bf16962c6..f6db3023cac 100644 --- a/src/objective-c/GRPCClient/private/GRPCCall+V2API.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h @@ -18,12 +18,6 @@ @interface GRPCCall (V2API) -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions; - - (instancetype)initWithHost:(NSString *)host path:(NSString *)path callSafety:(GRPCCallSafety)safety diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h similarity index 70% rename from src/objective-c/GRPCClient/private/GRPCCallInternal.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h index ac2d1cba2ec..641b1fb2e8a 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h @@ -16,20 +16,22 @@ * */ -#import +#import NS_ASSUME_NONNULL_BEGIN -@interface GRPCCall2Internal : NSObject +@protocol GRPCResponseHandler; +@class GRPCCallOptions; +@protocol GRPCChannelFactory; -- (instancetype)init; +@interface GRPCCall2Internal : GRPCTransport -- (void)setResponseHandler:(id)responseHandler; +- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager; - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(nullable GRPCCallOptions *)callOptions; + callOptions:(GRPCCallOptions *)callOptions; -- (void)writeData:(NSData *)data; +- (void)writeData:(id)data; - (void)finish; diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m similarity index 69% rename from src/objective-c/GRPCClient/private/GRPCCallInternal.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m index 32e38158fad..ea01fcaf594 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m @@ -19,8 +19,10 @@ #import "GRPCCallInternal.h" #import +#import #import +#import "../GRPCTransport+Private.h" #import "GRPCCall+V2API.h" @implementation GRPCCall2Internal { @@ -28,8 +30,8 @@ GRPCRequestOptions *_requestOptions; /** Options for the call. */ GRPCCallOptions *_callOptions; - /** The handler of responses. */ - id _handler; + /** The interceptor manager to process responses. */ + GRPCTransportManager *_transportManager; /** * Make use of legacy GRPCCall to make calls. Nullified when call is finished. @@ -51,40 +53,28 @@ NSUInteger _pendingReceiveNextMessages; } -- (instancetype)init { - if ((self = [super init])) { +- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager { + dispatch_queue_t dispatchQueue; // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 - if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); - } else { + if (@available(iOS 8.0, macOS 10.10, *)) { + dispatchQueue = dispatch_queue_create( + NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { #else - { + { #endif - _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } + dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + if ((self = [super init])) { _pipe = [GRXBufferedPipe pipe]; + _transportManager = transportManager; + _dispatchQueue = dispatchQueue; } return self; } -- (void)setResponseHandler:(id)responseHandler { - @synchronized(self) { - NSAssert(!_started, @"Call already started."); - if (_started) { - return; - } - _handler = responseHandler; - _initialMetadataPublished = NO; - _started = NO; - _canceled = NO; - _finished = NO; - } -} - -- (dispatch_queue_t)requestDispatchQueue { +- (dispatch_queue_t)dispatchQueue { return _dispatchQueue; } @@ -102,26 +92,15 @@ return; } + GRPCCall *copiedCall = nil; @synchronized(self) { - NSAssert(_handler != nil, @"Response handler required."); - if (_handler == nil) { - NSLog(@"Invalid response handler."); - return; - } _requestOptions = requestOptions; if (callOptions == nil) { _callOptions = [[GRPCCallOptions alloc] init]; } else { _callOptions = [callOptions copy]; } - } - [self start]; -} - -- (void)start { - GRPCCall *copiedCall = nil; - @synchronized(self) { NSAssert(!_started, @"Call already started."); NSAssert(!_canceled, @"Call already canceled."); if (_started) { @@ -140,7 +119,7 @@ callOptions:_callOptions writeDone:^{ @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { [self issueDidWriteData]; } } @@ -158,7 +137,7 @@ void (^valueHandler)(id value) = ^(id value) { @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -171,7 +150,7 @@ }; void (^completionHandler)(NSError *errorOrNil) = ^(NSError *errorOrNil) { @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -207,20 +186,19 @@ _call = nil; _pipe = nil; - if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedHandler = _handler; - _handler = nil; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didCloseWithTrailingMetadata:nil - error:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled by app" - }]]; - }); - } else { - _handler = nil; + if (_transportManager != nil) { + [_transportManager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error: + [NSError + errorWithDomain:kGRPCErrorDomain + code: + GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled by app" + }]]; + [_transportManager shutDown]; } } [copiedCall cancel]; @@ -271,59 +249,25 @@ } - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { - @synchronized(self) { - if (initialMetadata != nil && - [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveInitialMetadata:initialMetadata]; - }); - } + if (initialMetadata != nil) { + [_transportManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } } - (void)issueMessage:(id)message { - @synchronized(self) { - if (message != nil) { - if ([_handler respondsToSelector:@selector(didReceiveData:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveData:message]; - }); - } else if ([_handler respondsToSelector:@selector(didReceiveRawMessage:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveRawMessage:message]; - }); - } - } + if (message != nil) { + [_transportManager forwardPreviousInterceptorWithData:message]; } } - (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - @synchronized(self) { - if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedHandler = _handler; - // Clean up _handler so that no more responses are reported to the handler. - _handler = nil; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); - } else { - _handler = nil; - } - } + [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata + error:error]; + [_transportManager shutDown]; } - (void)issueDidWriteData { - @synchronized(self) { - if (_callOptions.flowControlEnabled && [_handler respondsToSelector:@selector(didWriteData)]) { - id copiedHandler = _handler; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didWriteData]; - }); - } - } + [_transportManager forwardPreviousInterceptorDidWriteData]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannel.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m similarity index 78% rename from src/objective-c/GRPCClient/private/GRPCChannel.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index 1a79fb04a0d..cd2b4313acd 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -20,18 +20,19 @@ #include -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" +#import "../GRPCTransport+Private.h" #import "ChannelArgsUtil.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" +#import "GRPCCoreFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" -#import "version.h" #import #import +#import @implementation GRPCChannelConfiguration @@ -50,32 +51,48 @@ } - (id)channelFactory { - GRPCTransportType type = _callOptions.transportType; - switch (type) { - case GRPCTransportTypeChttp2BoringSSL: - // TODO (mxyan): Remove when the API is deprecated -#ifdef GRPC_COMPILE_WITH_CRONET - if (![GRPCCall isUsingCronet]) { -#else - { -#endif - NSError *error; - id factory = [GRPCSecureChannelFactory - factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates - privateKey:_callOptions.PEMPrivateKey - certChain:_callOptions.PEMCertificateChain - error:&error]; - NSAssert(factory != nil, @"Failed to create secure channel factory"); - if (factory == nil) { - NSLog(@"Error creating secure channel factory: %@", error); + if (_callOptions.transport != NULL) { + id transportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; + if (! + [transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { + // impossible because we are using GRPCCore now + [NSException raise:NSInternalInconsistencyException + format:@"Transport factory type is wrong"]; + } + id coreTransportFactory = + (id)transportFactory; + return [coreTransportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; + } else { + // To maintain backwards compatibility with tranportType + GRPCTransportType type = _callOptions.transportType; + switch (type) { + case GRPCTransportTypeChttp2BoringSSL: + // TODO (mxyan): Remove when the API is deprecated + { + NSError *error; + id factory = [GRPCSecureChannelFactory + factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates + privateKey:_callOptions.PEMPrivateKey + certChain:_callOptions.PEMCertificateChain + error:&error]; + NSAssert(factory != nil, @"Failed to create secure channel factory"); + if (factory == nil) { + NSLog(@"Error creating secure channel factory: %@", error); + } + return factory; } - return factory; + case GRPCTransportTypeCronet: { + id transportFactory = (id)[ + [GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } - // fallthrough - case GRPCTransportTypeCronet: - return [GRPCCronetChannelFactory sharedInstance]; - case GRPCTransportTypeInsecure: - return [GRPCInsecureChannelFactory sharedInstance]; + case GRPCTransportTypeInsecure: + return [GRPCInsecureChannelFactory sharedInstance]; + default: + NSLog(@"Unrecognized transport type"); + return nil; + } } } @@ -198,6 +215,7 @@ } else { channelArgs = channelConfiguration.channelArgs; } + id factory = channelConfiguration.channelFactory; _unmanagedChannel = [factory createChannelWithHost:host channelArgs:channelArgs]; NSAssert(_unmanagedChannel != NULL, @"Failed to create channel"); diff --git a/src/objective-c/GRPCClient/private/GRPCChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCChannelPool.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h index e00ee69e63a..b83a28a2368 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h @@ -18,8 +18,6 @@ #import -#import "GRPCChannelFactory.h" - NS_ASSUME_NONNULL_BEGIN @protocol GRPCChannel; diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCChannelPool.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m index d545793fcce..92f52e67b75 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m @@ -18,19 +18,16 @@ #import -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "GRPCChannel.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool+Test.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "GRPCWrappedCall.h" -#import "version.h" -#import #include extern const char *kCFStreamVarName; diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCompletionQueue.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCompletionQueue.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h new file mode 100644 index 00000000000..83d279d2c72 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -0,0 +1,32 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "../GRPCCoreFactory.h" + +/** + * The factory for gRPC Core + Cronet transport implementation. The + * implementation is not part of the default transports of gRPC and is for + * testing purpose only on Github. + * + * To use this transport, a user must include the GRPCCoreCronet module as a + * dependency of the project and use gGRPCCoreCronetId in call options to + * specify that this is the transport to be used for a call. + */ +@interface GRPCCoreCronetFactory : NSObject + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m new file mode 100644 index 00000000000..5772694fc54 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -0,0 +1,54 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "GRPCCoreCronetFactory.h" + +#import +#import + +#import "../GRPCCallInternal.h" +#import "../GRPCCoreFactory.h" +#import "GRPCCronetChannelFactory.h" + +static GRPCCoreCronetFactory *gGRPCCoreCronetFactory = nil; +static dispatch_once_t gInitGRPCCoreCronetFactory; + +@implementation GRPCCoreCronetFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreCronetFactory, ^{ + gGRPCCoreCronetFactory = [[GRPCCoreCronetFactory alloc] init]; + }); + return gGRPCCoreCronetFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:gGRPCCoreCronetId + factory:[GRPCCoreCronetFactory sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + return [GRPCCronetChannelFactory sharedInstance]; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h similarity index 96% rename from src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h index 738dfdb7370..138ddf1f730 100644 --- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCChannelFactory.h" +#import "../GRPCChannelFactory.h" @class GRPCChannel; typedef struct stream_engine stream_engine; diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m similarity index 76% rename from src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m index 5bcb021dc4b..da3f3afd855 100644 --- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m @@ -18,10 +18,8 @@ #import "GRPCCronetChannelFactory.h" -#import "ChannelArgsUtil.h" -#import "GRPCChannel.h" - -#ifdef GRPC_COMPILE_WITH_CRONET +#import "../ChannelArgsUtil.h" +#import "../GRPCChannel.h" #import #include @@ -59,21 +57,3 @@ } @end - -#else - -@implementation GRPCCronetChannelFactory - -+ (instancetype)sharedInstance { - NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); - return nil; -} - -- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args { - NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); - return NULL; -} - -@end - -#endif diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h new file mode 100644 index 00000000000..3cd312d4ad0 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol GRPCChannelFactory; +@protocol GRPCCallOptions; + +/** The interface for transport implementations that are based on Core. */ +@protocol GRPCCoreTransportFactory + +/** Get the channel factory for GRPCChannel from call options. */ +- (nullable id)createCoreChannelFactoryWithCallOptions: + (GRPCCallOptions *)callOptions; + +@end + +/** The factory for gRPC Core + CFStream + TLS secure channel transport implementation. */ +@interface GRPCCoreSecureFactory : NSObject + +@end + +/** The factory for gRPC Core + CFStream + insecure channel transport implementation. */ +@interface GRPCCoreInsecureFactory : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m new file mode 100644 index 00000000000..19d7231a203 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -0,0 +1,90 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "GRPCCoreFactory.h" + +#import + +#import "GRPCCallInternal.h" +#import "GRPCInsecureChannelFactory.h" +#import "GRPCSecureChannelFactory.h" + +static GRPCCoreSecureFactory *gGRPCCoreSecureFactory = nil; +static GRPCCoreInsecureFactory *gGRPCCoreInsecureFactory = nil; +static dispatch_once_t gInitGRPCCoreSecureFactory; +static dispatch_once_t gInitGRPCCoreInsecureFactory; + +@implementation GRPCCoreSecureFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreSecureFactory, ^{ + gGRPCCoreSecureFactory = [[GRPCCoreSecureFactory alloc] init]; + }); + return gGRPCCoreSecureFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:GRPCDefaultTransportImplList.core_secure + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + NSError *error; + id factory = + [GRPCSecureChannelFactory factoryWithPEMRootCertificates:callOptions.PEMRootCertificates + privateKey:callOptions.PEMPrivateKey + certChain:callOptions.PEMCertificateChain + error:&error]; + if (error != nil) { + NSLog(@"Unable to create secure channel factory"); + return nil; + } + return factory; +} + +@end + +@implementation GRPCCoreInsecureFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreInsecureFactory, ^{ + gGRPCCoreInsecureFactory = [[GRPCCoreInsecureFactory alloc] init]; + }); + return gGRPCCoreInsecureFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:GRPCDefaultTransportImplList.core_insecure + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + return [GRPCInsecureChannelFactory sharedInstance]; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCHost.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m similarity index 82% rename from src/objective-c/GRPCClient/private/GRPCHost.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 63ffc927411..1f6a25ff78f 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -21,17 +21,16 @@ #import #import #import +#import #include #include -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "GRPCChannelFactory.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "NSDictionary+GRPC.h" -#import "version.h" NS_ASSUME_NONNULL_BEGIN @@ -113,20 +112,12 @@ static NSMutableDictionary *gHostCache; options.PEMPrivateKey = _PEMPrivateKey; options.PEMCertificateChain = _PEMCertificateChain; options.hostNameOverride = _hostNameOverride; -#ifdef GRPC_COMPILE_WITH_CRONET - // By old API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default - // channel. - if ([GRPCCall isUsingCronet]) { - if (_transportType == GRPCTransportTypeInsecure) { - options.transportType = GRPCTransportTypeInsecure; - } else { - NSAssert(_transportType == GRPCTransportTypeDefault, @"Invalid transport type"); - options.transportType = GRPCTransportTypeCronet; - } - } else -#endif - { - options.transportType = _transportType; + if (_transportType == GRPCTransportTypeInsecure) { + options.transport = GRPCDefaultTransportImplList.core_insecure; + } else if ([GRPCCall isUsingCronet]) { + options.transport = gGRPCCoreCronetId; + } else { + options.transport = GRPCDefaultTransportImplList.core_secure; } options.logContext = _logContext; @@ -135,16 +126,14 @@ static NSMutableDictionary *gHostCache; + (GRPCCallOptions *)callOptionsForHost:(NSString *)host { // TODO (mxyan): Remove when old API is deprecated - NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:host]]; - if (hostURL.host && hostURL.port == nil) { - host = [hostURL.host stringByAppendingString:@":443"]; - } - GRPCCallOptions *callOptions = nil; @synchronized(gHostCache) { - callOptions = [gHostCache[host] callOptions]; + GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; + callOptions = [hostConfig callOptions]; } + NSAssert(callOptions != nil, @"Unable to create call options object"); if (callOptions == nil) { + NSLog(@"Unable to create call options object"); callOptions = [[GRPCCallOptions alloc] init]; } return callOptions; diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCOpBatchLog.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCOpBatchLog.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m diff --git a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h similarity index 95% rename from src/objective-c/GRPCClient/private/GRPCRequestHeaders.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h index 545ff1cea82..0fced0c385a 100644 --- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h @@ -18,7 +18,7 @@ #import -#import "../GRPCCall.h" +#import @interface GRPCRequestHeaders : NSMutableDictionary diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCRequestHeaders.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCWrappedCall.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCWrappedCall.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSData+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSData+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSDictionary+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSDictionary+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSError+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m similarity index 96% rename from src/objective-c/GRPCClient/private/NSError+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m index 3eefed88d63..5b5fc6263c5 100644 --- a/src/objective-c/GRPCClient/private/NSError+GRPC.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m @@ -18,10 +18,9 @@ #import "NSError+GRPC.h" +#import #include -NSString *const kGRPCErrorDomain = @"io.grpc"; - @implementation NSError (GRPC) + (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode details:(const char *)details diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h new file mode 100644 index 00000000000..2dc7357c363 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -0,0 +1,65 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Private interfaces of the transport registry. + */ +@interface GRPCTransportRegistry (Private) + +/** + * Get a transport implementation's factory by its transport id. If the transport id was not + * registered with the registry, the default transport factory (core + secure) is returned. If the + * default transport does not exist, an exception is thrown. + */ +- (id)getTransportFactoryWithId:(GRPCTransportId)transportId; + +@end + +@interface GRPCTransportManager : NSObject + +- (instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor; + +/** + * Notify the manager that the transport has shut down and the manager should release references to + * its response handler and stop forwarding requests/responses. + */ +- (void)shutDown; + +/** Forward initial metadata to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata; + +/** Forward a received message to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorWithData:(nullable id)data; + +/** Forward call close and trailing metadata to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: + (nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error; + +/** Forward write completion to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorDidWriteData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m new file mode 100644 index 00000000000..9072f7afbe2 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -0,0 +1,131 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "GRPCTransport+Private.h" + +#import + +@implementation GRPCTransportManager { + GRPCTransportId _transportId; + GRPCTransport *_transport; + id _previousInterceptor; + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor { + if ((self = [super init])) { + id factory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; + + _transport = [factory createTransportWithManager:self]; + NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); + if (_transport == nil) { + NSLog(@"Failed to create transport with id: %s", transportId); + return nil; + } + _previousInterceptor = previousInterceptor; + _dispatchQueue = _transport.dispatchQueue; + _transportId = transportId; + } + return self; +} + +- (void)shutDown { + dispatch_async(_dispatchQueue, ^{ + self->_transport = nil; + self->_previousInterceptor = nil; + }); +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + if (_transportId != callOptions.transport) { + [NSException raise:NSInvalidArgumentException + format:@"Interceptors cannot change the call option 'transport'"]; + return; + } + [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; +} + +- (void)writeData:(id)data { + [_transport writeData:data]; +} + +- (void)finish { + [_transport finish]; +} + +- (void)cancel { + [_transport cancel]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_transport receiveNextMessages:numberOfMessages]; +} + +/** Forward initial metadata to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { + if (initialMetadata == nil || _previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); +} + +/** Forward a received message to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorWithData:(id)data { + if (data == nil || _previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); +} + +/** Forward call close and trailing metadata to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata + error:(NSError *)error { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); +} + +/** Forward write completion to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorDidWriteData { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); +} + +@end diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/version.h similarity index 100% rename from src/objective-c/GRPCClient/private/version.h rename to src/objective-c/GRPCClient/version.h diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index 12db46adeda..c91adc7b7cd 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -17,12 +17,16 @@ */ #import -#import + +// import legacy header for compatibility with users using the ProtoRPC interface +#import "ProtoRPCLegacy.h" #import "ProtoMethod.h" NS_ASSUME_NONNULL_BEGIN +@class GRPCRequestOptions; +@class GRPCCallOptions; @class GPBMessage; /** An object can implement this protocol to receive responses from server from a call. */ @@ -160,35 +164,3 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -__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 - : (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 - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - @interface GRPCProtoCall : ProtoRPC -#pragma clang diagnostic pop - - @end - -#pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 4700fdd1124..dbfa3c0f23d 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -27,24 +27,6 @@ #import #import -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - NSUnderlyingErrorKey : parsingError, - @"Expected class" : expectedClass, - @"Received value" : proto, - }; - // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. - return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; -} - @implementation GRPCUnaryProtoCall { GRPCStreamingProtoCall *_call; GPBMessage *_message; @@ -291,76 +273,3 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing } @end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation ProtoRPC { -#pragma clang diagnostic pop - id _responseWriteable; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestsWriter { - [NSException raise:NSInvalidArgumentException - format:@"Please use ProtoRPC's designated initializer instead."]; - return nil; -} -#pragma clang diagnostic pop - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - method:(GRPCProtoMethod *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - // Because we can't tell the type system to constrain the class, we need to check at runtime: - if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { - [NSException raise:NSInvalidArgumentException - format:@"A protobuf class to parse the responses must be provided."]; - } - // A writer that serializes the proto messages to send. - GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { - if (![proto isKindOfClass:[GPBMessage class]]) { - [NSException raise:NSInvalidArgumentException - format:@"Request must be a proto message: %@", proto]; - } - return [proto data]; - }]; - if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { - __weak ProtoRPC *weakSelf = self; - - // A writeable that parses the proto messages received. - _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { - // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. - NSError *error = nil; - id parsed = [responseClass parseFromData:value error:&error]; - if (parsed) { - [responsesWriteable writeValue:parsed]; - } else { - [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; - } - } - completionHandler:^(NSError *errorOrNil) { - [responsesWriteable writesFinishedWithError:errorOrNil]; - }]; - } - return self; -} - -- (void)start { - [self startWithWriteable:_responseWriteable]; -} - -- (void)startWithWriteable:(id)writeable { - [super startWithWriteable:writeable]; - // Break retain cycles. - _responseWriteable = nil; -} -@end - -@implementation GRPCProtoCall - -@end diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h new file mode 100644 index 00000000000..b8d4003f695 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -0,0 +1,67 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import + +// Import category headers for Swift build +#import +#import +#import +#import +#import +#import + +@class GRPCProtoMethod; +@class GRXWriter; +@protocol GRXWriteable; + +__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 + : (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 + */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + @interface GRPCProtoCall + : ProtoRPC +#pragma clang diagnostic pop + + @end + + /** + * Generate an NSError object that represents a failure in parsing a proto class. For gRPC + * internal use only. + */ + NSError * + ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m new file mode 100644 index 00000000000..4ba93674063 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -0,0 +1,121 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "ProtoRPCLegacy.h" + +#import "ProtoMethod.h" + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS +#import +#else +#import +#endif +#import +#import +#import + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoRPC { +#pragma clang diagnostic pop + id _responseWriteable; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestsWriter { + [NSException raise:NSInvalidArgumentException + format:@"Please use ProtoRPC's designated initializer instead."]; + return nil; +} +#pragma clang diagnostic pop + +// Designated initializer +- (instancetype)initWithHost:(NSString *)host + method:(GRPCProtoMethod *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + // Because we can't tell the type system to constrain the class, we need to check at runtime: + if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { + [NSException raise:NSInvalidArgumentException + format:@"A protobuf class to parse the responses must be provided."]; + } + // A writer that serializes the proto messages to send. + GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { + if (![proto isKindOfClass:[GPBMessage class]]) { + [NSException raise:NSInvalidArgumentException + format:@"Request must be a proto message: %@", proto]; + } + return [proto data]; + }]; + if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { + __weak ProtoRPC *weakSelf = self; + + // A writeable that parses the proto messages received. + _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { + // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. + NSError *error = nil; + id parsed = [responseClass parseFromData:value error:&error]; + if (parsed) { + [responsesWriteable writeValue:parsed]; + } else { + [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; + } + } + completionHandler:^(NSError *errorOrNil) { + [responsesWriteable writesFinishedWithError:errorOrNil]; + }]; + } + return self; +} + +- (void)start { + [self startWithWriteable:_responseWriteable]; +} + +- (void)startWithWriteable:(id)writeable { + [super startWithWriteable:writeable]; + // Break retain cycles. + _responseWriteable = nil; +} +@end + +@implementation GRPCProtoCall + +@end + +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + NSUnderlyingErrorKey : parsingError, + @"Expected class" : expectedClass, + @"Received value" : proto, + }; + // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. + return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; +} diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 900ec8d0e1e..fd8a86bb2b2 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -18,14 +18,12 @@ #import -@class GRPCProtoCall; +#import +#import "ProtoRPC.h" + @protocol GRXWriteable; @class GRXWriter; @class GRPCCallOptions; -@class GRPCProtoCall; -@class GRPCUnaryProtoCall; -@class GRPCStreamingProtoCall; -@protocol GRPCProtoResponseHandler; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" @@ -38,15 +36,6 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName; - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable; - - (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method message:(nonnull id)message responseHandler:(nonnull id)handler @@ -58,6 +47,18 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ callOptions:(nullable GRPCCallOptions *)callOptions responseClass:(nonnull Class)responseClass; +@end + + @interface ProtoService(Legacy) + + - (instancetype)initWithHost : (NSString *)host packageName + : (NSString *)packageName serviceName : (NSString *)serviceName; + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable; + @end #pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 80a1f2f226c..e84cab8903f 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -29,15 +29,21 @@ #pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation ProtoService { #pragma clang diagnostic pop + + GRPCCallOptions *_callOptions; NSString *_host; NSString *_packageName; NSString *_serviceName; - GRPCCallOptions *_callOptions; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" +// Do not call the default init method - (instancetype)init { - return [self initWithHost:nil packageName:nil serviceName:nil]; + [NSException raise:NSGenericException format:@"Do not call init method of ProtoService"]; + return [self initWithHost:nil packageName:nil serviceName:nil callOptions:nil]; } +#pragma clang diagnostic pop // Designated initializer - (instancetype)initWithHost:(NSString *)host @@ -58,38 +64,6 @@ return self; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -// Do not call designated initializer here due to nullability incompatibility. This method is from -// old API and does not assert on nullability of the parameters. - -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName { - if ((self = [super init])) { - _host = [host copy]; - _packageName = [packageName copy]; - _serviceName = [serviceName copy]; - _callOptions = nil; - } - return self; -} - -#pragma clang diagnostic pop - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; - return [[GRPCProtoCall alloc] initWithHost:_host - method:methodName - requestsWriter:requestsWriter - responseClass:responseClass - responsesWriteable:responsesWriteable]; -} - - (GRPCUnaryProtoCall *)RPCToMethod:(NSString *)method message:(id)message responseHandler:(id)handler diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h new file mode 100644 index 00000000000..7b0b7a4de7e --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h @@ -0,0 +1,23 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import "ProtoService.h" + +@class GRPCProtoCall; +@class GRXWriter; +@protocol GRXWriteable; diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m new file mode 100644 index 00000000000..6aa64955381 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -0,0 +1,71 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import + +#import "ProtoMethod.h" +#import "ProtoRPCLegacy.h" +#import "ProtoService.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoService (Legacy) +#pragma clang diagnostic pop + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +// Do not call designated initializer here due to nullability incompatibility. This method is from +// old API and does not assert on nullability of the parameters. + +- (instancetype)initWithHost:(NSString *)host + packageName:(NSString *)packageName + serviceName:(NSString *)serviceName { + if ((self = [super init])) { + Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); + Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); + Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); + + object_setIvar(self, hostIvar, [host copy]); + object_setIvar(self, packageNameIvar, [packageName copy]); + object_setIvar(self, serviceNameIvar, [serviceName copy]); + } + return self; +} +#pragma clang diagnostic pop + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); + Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); + Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); + NSString *host = object_getIvar(self, hostIvar); + NSString *packageName = object_getIvar(self, packageNameIvar); + NSString *serviceName = object_getIvar(self, serviceNameIvar); + + GRPCProtoMethod *methodName = + [[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method]; + return [[GRPCProtoCall alloc] initWithHost:host + method:methodName + requestsWriter:requestsWriter + responseClass:responseClass + responsesWriteable:responsesWriteable]; +} + +@end diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index c94ee8c2569..9c466260121 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -25,6 +25,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif +#import +#import @interface ViewController () diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index 3e97767cf0c..ce204a9c146 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -24,6 +24,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif +#import +#import @interface InterfaceController () diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index fed92596b17..65a32d742a9 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -95,19 +95,12 @@ tvos_application( deps = ["host-lib"], ) -grpc_objc_testing_library( - name = "CronetConfig", - srcs = ["ConfigureCronet.m"], - hdrs = ["ConfigureCronet.h"], -) - grpc_objc_testing_library( name = "InteropTests-lib", hdrs = ["InteropTests/InteropTests.h"], srcs = ["InteropTests/InteropTests.m"], deps = [ ":InteropTestsBlockCallbacks-lib", - ":CronetConfig", ], ) @@ -200,7 +193,6 @@ ios_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", - # ":InteropTestsMulitpleChannels-lib", # needs Cronet ], test_host = ":ios-host", ) diff --git a/src/objective-c/tests/ConfigureCronet.h b/src/objective-c/tests/ConfigureCronet.h index cc5c038f3c6..ba0efc4df66 100644 --- a/src/objective-c/tests/ConfigureCronet.h +++ b/src/objective-c/tests/ConfigureCronet.h @@ -16,8 +16,6 @@ * */ -#ifdef GRPC_COMPILE_WITH_CRONET - #ifdef __cplusplus extern "C" { #endif @@ -30,5 +28,3 @@ void configureCronet(void); #ifdef __cplusplus } #endif - -#endif diff --git a/src/objective-c/tests/ConfigureCronet.m b/src/objective-c/tests/ConfigureCronet.m index ab137e28cad..6fc7e0ee9f5 100644 --- a/src/objective-c/tests/ConfigureCronet.m +++ b/src/objective-c/tests/ConfigureCronet.m @@ -16,8 +16,6 @@ * */ -#ifdef GRPC_COMPILE_WITH_CRONET - #import "ConfigureCronet.h" #import @@ -35,5 +33,3 @@ void configureCronet(void) { [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; }); } - -#endif diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index a2a79c46316..aa1af301b96 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -22,6 +22,7 @@ #import #import +#import "../ConfigureCronet.h" #import "InteropTests.h" // The server address is derived from preprocessor macro, which is @@ -40,12 +41,19 @@ static int32_t kRemoteInteropServerOverhead = 12; @implementation InteropTestsRemoteWithCronet ++ (void)setUp { + configureCronet(); + [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; + + [super setUp]; +} + + (NSString *)host { return kRemoteSSLHost; } -+ (BOOL)useCronet { - return YES; ++ (GRPCTransportId)transport { + return gGRPCCoreCronetId; } - (int32_t)encodingOverhead { diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index 28fcbff9695..a4adecd5415 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -48,11 +48,19 @@ - (int32_t)encodingOverhead; /** + * DEPRECATED: \a transportType is a deprecated option. Please use \a transport instead. + * * The type of transport to be used. The base implementation returns default. Subclasses should * override to appropriate settings. */ + (GRPCTransportType)transportType; +/* + * The transport to be used. The base implementation returns NULL. Subclasses should override to + * appropriate settings. + */ ++ (GRPCTransportId)transport; + /** * The root certificates to be used. The base implementation returns nil. Subclasses should override * to appropriate settings. @@ -65,9 +73,4 @@ */ + (NSString *)hostNameOverride; -/** - * Whether to use Cronet for all the v1 API tests in the test suite. - */ -+ (BOOL)useCronet; - @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index a8f7db7ee93..21198f7bad9 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -20,9 +20,6 @@ #include -#ifdef GRPC_COMPILE_WITH_CRONET -#import -#endif #import #import #import @@ -38,7 +35,6 @@ #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" -#import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" #define TEST_TIMEOUT 32 @@ -91,9 +87,8 @@ BOOL isRemoteInteropTest(NSString *host) { - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:queue - responseDispatchQueue:queue]; + return + [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager dispatchQueue:queue]; } @end @@ -101,21 +96,19 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject - (instancetype) -initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; @@ -125,8 +118,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -155,29 +147,25 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (instancetype) -initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -192,8 +180,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:_requestDispatchQueue - responseDispatchQueue:_responseDispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -218,22 +205,16 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); GRPCInterceptorManager *_manager; - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; -} - -- (dispatch_queue_t)requestDispatchQueue { - return _requestDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (dispatch_queue_t)dispatchQueue { - return _responseDispatchQueue; + return _dispatchQueue; } - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -247,9 +228,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { - if ((self = [super initWithInterceptorManager:interceptorManager - requestDispatchQueue:requestDispatchQueue - responseDispatchQueue:responseDispatchQueue])) { + if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -258,8 +237,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager _responseDataHook = responseDataHook; _responseCloseHook = responseCloseHook; _didWriteDataHook = didWriteDataHook; - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; _manager = interceptorManager; } return self; @@ -320,8 +298,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @property BOOL enabled; -- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue; +- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue; - (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -340,26 +317,23 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @implementation GlobalInterceptorFactory -- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { +- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue { _enabled = NO; - return [super initWithRequestDispatchQueue:requestDispatchQueue - responseDispatchQueue:responseDispatchQueue - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + return [super initWithDispatchQueue:dispatchQueue + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { if (_enabled) { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:_requestDispatchQueue - responseDispatchQueue:_responseDispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -425,10 +399,15 @@ static dispatch_once_t initGlobalInterceptorFactory; return 0; } +// For backwards compatibility + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } ++ (GRPCTransportId)transport { + return NULL; +} + + (NSString *)PEMRootCertificates { return nil; } @@ -437,26 +416,11 @@ static dispatch_once_t initGlobalInterceptorFactory; return nil; } -+ (BOOL)useCronet { - return NO; -} - + (void)setUp { -#ifdef GRPC_COMPILE_WITH_CRONET - configureCronet(); - if ([self useCronet]) { - [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; - } -#endif -#ifdef GRPC_CFSTREAM - setenv(kCFStreamVarName, "1", 1); -#endif - dispatch_once(&initGlobalInterceptorFactory, ^{ dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); globalInterceptorFactory = - [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue - responseDispatchQueue:globalInterceptorQueue]; + [[GlobalInterceptorFactory alloc] initWithDispatchQueue:globalInterceptorQueue]; [GRPCCall2 registerGlobalInterceptor:globalInterceptorFactory]; }); } @@ -502,7 +466,9 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -531,7 +497,9 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -608,7 +576,9 @@ static dispatch_once_t initGlobalInterceptorFactory; request.payload.body = [NSMutableData dataWithLength:271828]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -656,7 +626,9 @@ static dispatch_once_t initGlobalInterceptorFactory; request.responseStatus.code = GRPC_STATUS_CANCELLED; } GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -958,7 +930,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1010,7 +984,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1167,7 +1143,9 @@ static dispatch_once_t initGlobalInterceptorFactory; __block BOOL receivedResponse = NO; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = self.class.transportType; + options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1200,7 +1178,9 @@ static dispatch_once_t initGlobalInterceptorFactory; [self expectationWithDescription:@"Call completed."]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = self.class.transportType; + options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1286,48 +1266,47 @@ static dispatch_once_t initGlobalInterceptorFactory; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#ifndef GRPC_COMPILE_WITH_CRONET -- (void)testKeepalive { +- (void)testKeepaliveWithV2API { XCTAssertNotNil([[self class] host]); + if ([[self class] transport] == gGRPCCoreCronetId) { + // Cronet does not support keepalive + return; + } __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; - [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:[[self class] host]]; - - NSArray *requests = @[ @27182, @8 ]; - NSArray *responses = @[ @31415, @9 ]; - - GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init]; - - __block int index = 0; + NSNumber *kRequestSize = @27182; + NSNumber *kResponseSize = @31415; - id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] - requestedResponseSize:responses[index]]; - [requestsBuffer writeValue:request]; + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:kRequestSize + requestedResponseSize:kResponseSize]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; + options.PEMRootCertificates = [[self class] PEMRootCertificates]; + options.hostNameOverride = [[self class] hostNameOverride]; + options.keepaliveInterval = 1.5; + options.keepaliveTimeout = 0; - [_service - fullDuplexCallWithRequestsWriter:requestsBuffer - eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, - NSError *error) { - if (index == 0) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertTrue(response, @"Event handler called without an event."); - XCTAssertFalse(done); - index++; - } else { - // Keepalive should kick after 1s elapsed and fails the call. - XCTAssertNotNil(error); - XCTAssertEqual(error.code, GRPC_STATUS_UNAVAILABLE); - XCTAssertEqualObjects( - error.localizedDescription, @"keepalive watchdog timeout", - @"Unexpected failure that is not keepalive watchdog timeout."); - XCTAssertTrue(done); - [expectation fulfill]; - } - }]; + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler: + [[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual( + error.code, GRPC_STATUS_UNAVAILABLE, + @"Received status %ld instead of UNAVAILABLE (14).", + error.code); + [expectation fulfill]; + }] + callOptions:options]; + [call writeMessage:request]; + [call start]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + [call finish]; } -#endif - (void)testDefaultInterceptor { XCTAssertNotNil([[self class] host]); @@ -1342,7 +1321,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init] ]; @@ -1397,8 +1378,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1446,7 +1426,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1524,8 +1506,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1552,6 +1533,7 @@ static dispatch_once_t initGlobalInterceptorFactory; // finish must happen after the hijacking, so directly reply with a close [manager forwardPreviousInterceptorCloseWithTrailingMetadata:@{@"grpc-status" : @"0"} error:nil]; + [manager shutDown]; } receiveNextMessagesHook:nil responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { @@ -1578,7 +1560,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init], factory ]; @@ -1687,7 +1671,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1742,16 +1728,15 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testConflictingGlobalInterceptors { id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; @try { [GRPCCall2 registerGlobalInterceptor:factory]; XCTFail(@"Did not receive an exception when registering global interceptor the second time"); @@ -1775,8 +1760,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1872,7 +1856,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index a9c69183332..2e638099e1e 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -17,6 +17,7 @@ */ #import +#import #import #import "InteropTests.h" @@ -60,8 +61,8 @@ static int32_t kLocalInteropServerOverhead = 10; [GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; } -+ (GRPCTransportType)transportType { - return GRPCTransportTypeInsecure; ++ (GRPCTransportId)transport { + return GRPCDefaultTransportImplList.core_insecure; } @end diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index e8222f602f4..30d8f4c34af 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -17,6 +17,7 @@ */ #import +#import #import #import "InteropTests.h" @@ -56,8 +57,8 @@ static int32_t kLocalInteropServerOverhead = 10; return kLocalInteropServerOverhead; // bytes } -+ (GRPCTransportType)transportType { - return GRPCTransportTypeChttp2BoringSSL; ++ (GRPCTransportId)transport { + return GRPCDefaultTransportImplList.core_secure; } - (void)setUp { diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 98893a466bd..dc48391cbcc 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -18,9 +18,8 @@ #import -#ifdef GRPC_COMPILE_WITH_CRONET #import -#endif +#import #import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" diff --git a/src/objective-c/tests/InteropTests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m index c1cd9b81efc..2dd8f0aed89 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTests/InteropTestsRemote.m @@ -53,14 +53,8 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteInteropServerOverhead; // bytes } -#ifdef GRPC_COMPILE_WITH_CRONET -+ (GRPCTransportType)transportType { - return GRPCTransportTypeCronet; -} -#else + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } -#endif @end diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index c2297aa00fd..c83e8861e93 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -30,25 +30,25 @@ target 'MacTests' do grpc_deps end -target 'UnitTests' do - platform :ios, '8.0' - grpc_deps -end - %w( + UnitTests InteropTests - CronetTests ).each do |target_name| target target_name do platform :ios, '8.0' grpc_deps - - pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC - pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true end end +target 'CronetTests' do + platform :ios, '8.0' + grpc_deps + + pod 'gRPC/GRPCCoreCronet', :path => GRPC_LOCAL_SRC + pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true +end + # gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's # pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded # and before they are installed in the user project. @@ -103,7 +103,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if /gRPC-(mac|i|tv)OS/.match(target.name) + if /gRPC(-macOS|-iOS|-tvOS|\.|-[0-9a-f])/.match(target.name) target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' @@ -114,7 +114,7 @@ post_install do |installer| end # Enable NSAssert on gRPC - if /(gRPC|ProtoRPC|RxLibrary)-(mac|i|tv)OS/.match(target.name) + if /(gRPC|ProtoRPC|RxLibrary)/.match(target.name) target.build_configurations.each do |config| if config.name != 'Release' config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES' diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index a88838fdc8b..6cb9f5560b9 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -8,15 +8,14 @@ /* Begin PBXBuildFile section */ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; + 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; - 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; - 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487B22778256006656AD /* ChannelPoolTest.m */; }; 5E7F487E22778256006656AD /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487C22778256006656AD /* ChannelTests.m */; }; 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; @@ -34,6 +33,7 @@ 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; + 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; @@ -515,7 +515,6 @@ 5EA476F12272816A000F72FC /* Frameworks */, 5EA476F22272816A000F72FC /* Resources */, D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -630,6 +629,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -678,24 +678,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -721,7 +703,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-GRPCCoreCronet/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -898,6 +880,7 @@ files = ( 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, + 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, @@ -910,9 +893,7 @@ buildActionMask = 2147483647; files = ( 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, - 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */, 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, - 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */, 5E7F488422778A88006656AD /* InteropTests.m in Sources */, diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme index adb3c366af2..cbde360a338 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme @@ -23,7 +23,7 @@ @@ -48,7 +48,7 @@ + buildConfiguration = "Test"> -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" #define TEST_TIMEOUT 32 diff --git a/src/objective-c/tests/UnitTests/ChannelTests.m b/src/objective-c/tests/UnitTests/ChannelTests.m index df78e8b1162..1ed0f16ecaf 100644 --- a/src/objective-c/tests/UnitTests/ChannelTests.m +++ b/src/objective-c/tests/UnitTests/ChannelTests.m @@ -19,11 +19,11 @@ #import #import "../../GRPCClient/GRPCCallOptions.h" -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCChannelPool.h" -#import "../../GRPCClient/private/GRPCCompletionQueue.h" -#import "../../GRPCClient/private/GRPCWrappedCall.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool.h" +#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCCore/GRPCWrappedCall.h" static NSString *kDummyHost = @"dummy.host"; static NSString *kDummyPath = @"/dummy/path"; diff --git a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m index 8a4f03a4460..74e5794c480 100644 --- a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m +++ b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m @@ -20,7 +20,7 @@ #import -#import "../../GRPCClient/private/NSError+GRPC.h" +#import "../../GRPCClient/private/GRPCCore/NSError+GRPC.h" @interface NSErrorUnitTests : XCTestCase diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index 457d2988036..e94f149ee4a 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -44,22 +44,40 @@ s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/ProtoRPC' + s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' - s.default_subspec = 'Main' + s.subspec 'Legacy-Header' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + end s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.dependency 'gRPC', version + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/Interface', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", + "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", + "src/objective-c/ProtoRPC/ProtoService.{h,m}" + end + + s.subspec 'Legacy' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "#{src_dir}/*.{h,m}" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", + "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy", version end s.pod_target_xcconfig = { diff --git a/templates/gRPC-RxLibrary.podspec.template b/templates/gRPC-RxLibrary.podspec.template index 9389c5ecd8d..772265dadda 100644 --- a/templates/gRPC-RxLibrary.podspec.template +++ b/templates/gRPC-RxLibrary.podspec.template @@ -44,6 +44,23 @@ s.module_name = name s.header_dir = name + s.default_subspec = 'Interface', 'Implementation' + + src_dir = 'src/objective-c/RxLibrary' + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.h" + ss.public_header_files = "#{src_dir}/*.h" + end + + s.subspec 'Implementation' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" + ss.private_header_files = "#{src_dir}/**/*.h" + + ss.dependency "#{s.name}/Interface" + end + src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 8cb380ede03..e705edc1748 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -43,13 +43,7 @@ s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/GRPCClient' - - s.dependency 'gRPC-RxLibrary', version - s.default_subspec = 'Main' - - # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -57,29 +51,103 @@ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - - ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" - ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" - - ss.dependency 'gRPC-Core', version + s.subspec 'Interface-Legacy' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + + ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + ss.dependency "gRPC-RxLibrary/Interface", version end - # CFStream is now default. Leaving this subspec only for compatibility purpose. - s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/version.h' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall.m', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.m', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.m', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/internal/*.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', + 'src/objective-c/GRPCClient/version.h' + + ss.dependency "#{s.name}/Interface-Legacy", version end - s.subspec 'GID' do |ss| - ss.ios.deployment_target = '7.0' + s.subspec 'GRPCCore' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/internal_testing/*.h' + ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', + 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.m', + 'src/objective-c/GRPCClient/GRPCCallLegacy.m' + + # Certificates, to be able to establish TLS connections: + ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + + ss.dependency "#{s.name}/Interface-Legacy", version + ss.dependency "#{s.name}/Interface", version + ss.dependency 'gRPC-Core', version + ss.dependency 'gRPC-RxLibrary', version + end - ss.header_mappings_dir = "#{src_dir}" + s.subspec 'GRPCCoreCronet' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' + ss.dependency "#{s.name}/GRPCCore", version + ss.dependency 'gRPC-Core/Cronet-Implementation', version + ss.dependency 'CronetFramework' + end - ss.dependency "#{s.name}/Main", version - ss.dependency 'Google/SignIn' + # CFStream is now default. Leaving this subspec only for compatibility purpose. + s.subspec 'CFStream' do |ss| + ss.dependency "#{s.name}/GRPCCore", version end end diff --git a/templates/src/objective-c/GRPCClient/private/version.h.template b/templates/src/objective-c/GRPCClient/version.h.template similarity index 100% rename from templates/src/objective-c/GRPCClient/private/version.h.template rename to templates/src/objective-c/GRPCClient/version.h.template From 29bb3ef9733fbe61aa9fd7078952f5af662d1aa0 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 27 Aug 2019 10:19:40 -0700 Subject: [PATCH 056/176] Remove redundant MethodHandler friend declarations --- include/grpcpp/impl/codegen/byte_buffer.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index 7fb678d5f7f..54886ae8086 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -173,8 +173,6 @@ class ByteBuffer final { friend class ::grpc_impl::internal::RpcMethodHandler; template friend class ::grpc_impl::internal::ServerStreamingHandler; - template - friend class ::grpc_impl::internal::RpcMethodHandler; template friend class ::grpc_impl::internal::CallbackUnaryHandler; template From 156a4cccdfe88580c6fb1b87a6a247e222b0fd3a Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 28 Aug 2019 18:00:38 -0700 Subject: [PATCH 057/176] Remove unusued arg --- src/core/lib/surface/call.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1331e57ab0c..7bb818b91c9 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1128,8 +1128,7 @@ static size_t batch_slot_for_op(grpc_op_type type) { } static batch_control* reuse_or_allocate_batch_control(grpc_call* call, - const grpc_op* ops, - size_t num_ops) { + const grpc_op* ops) { size_t slot_idx = batch_slot_for_op(ops[0].op); batch_control** pslot = &call->active_batches[slot_idx]; batch_control* bctl; @@ -1545,7 +1544,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, goto done; } - bctl = reuse_or_allocate_batch_control(call, ops, nops); + bctl = reuse_or_allocate_batch_control(call, ops); if (bctl == nullptr) { return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; } From cb6d3a0623bd19510610c07f7d114b33dc603793 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 14:52:19 +0200 Subject: [PATCH 058/176] address review feedback --- src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs | 2 +- src/csharp/ext/grpc_csharp_ext.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 77c14f1d9fb..9cbdce1cfe3 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -138,7 +138,7 @@ namespace Grpc.Core.Internal // if no hint is provided, keep the available space within some "reasonable" boundaries. // This is quite a naive approach which could use some fine-tuning, but currently in most case we know // the required buffer size in advance anyway, so this approach seems good enough for now. - if (tailSpaceLen < DefaultTailSpaceSize /2 ) + if (tailSpaceLen < DefaultTailSpaceSize / 2) { AdjustTailSpace(DefaultTailSpaceSize); } diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 2360c9e1d5f..d9bf85e02c7 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -44,8 +44,7 @@ static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices( grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); - memset(bb, 0, sizeof(grpc_byte_buffer)); + (grpc_byte_buffer*)gpr_zalloc(sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; grpc_slice_buffer_init(&bb->data.raw.slice_buffer); From 1444cd1dd31c81daa63477be445a941722a42f5d Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 29 Aug 2019 10:51:36 -0700 Subject: [PATCH 059/176] Revert "Revert "Merge pull request #20097 from gnossen/dual_version_python_tests"" This reverts commit 24c562dbaa95539031c45ab4bdce5070ca6c2af5. --- BUILD | 2 +- bazel/grpc_build_system.bzl | 11 +- bazel/grpc_deps.bzl | 15 +-- bazel/grpc_python_deps.bzl | 9 ++ bazel/python_rules.bzl | 26 +++++ examples/python/auth/BUILD.bazel | 3 + examples/python/cancellation/BUILD.bazel | 3 + examples/python/compression/BUILD.bazel | 3 + examples/python/debug/BUILD.bazel | 3 + examples/python/errors/BUILD.bazel | 1 + examples/python/multiprocessing/BUILD | 3 + examples/python/wait_for_ready/BUILD.bazel | 1 + .../grpcio_tests/tests/channelz/BUILD.bazel | 4 +- .../tests/health_check/BUILD.bazel | 3 +- .../grpcio_tests/tests/interop/BUILD.bazel | 5 +- .../grpcio_tests/tests/reflection/BUILD.bazel | 3 +- .../grpcio_tests/tests/status/BUILD.bazel | 3 +- .../grpcio_tests/tests/unit/BUILD.bazel | 4 +- .../tests/unit/_cython/BUILD.bazel | 3 +- .../unit/framework/foundation/BUILD.bazel | 3 +- templates/tools/dockerfile/bazel.include | 2 +- third_party/py/BUILD.tpl | 49 +++++---- third_party/py/python_configure.bzl | 104 +++++++++++------- third_party/py/remote.BUILD.tpl | 10 -- third_party/py/variety.tpl | 26 +++++ tools/bazel | 2 +- tools/bazel.rc | 4 - tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- .../linux/grpc_python_bazel_test_in_docker.sh | 3 - tools/remote_build/kokoro.bazelrc | 7 +- tools/remote_build/manual.bazelrc | 7 +- tools/remote_build/rbe_common.bazelrc | 2 +- 33 files changed, 214 insertions(+), 114 deletions(-) delete mode 100644 third_party/py/remote.BUILD.tpl create mode 100644 third_party/py/variety.tpl diff --git a/BUILD b/BUILD index 9198dd61282..e489bc2584a 100644 --- a/BUILD +++ b/BUILD @@ -65,7 +65,7 @@ config_setting( config_setting( name = "python3", - values = {"python_path": "python3"}, + flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, ) config_setting( diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f386b87b583..f4777e50bc1 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -269,13 +269,22 @@ def grpc_sh_binary(name, srcs, data = []): data = data, ) -def grpc_py_binary(name, srcs, data = [], deps = [], external_deps = [], testonly = False): +def grpc_py_binary(name, + srcs, + data = [], + deps = [], + external_deps = [], + testonly = False, + python_version = "PY2", + **kwargs): native.py_binary( name = name, srcs = srcs, testonly = testonly, data = data, deps = deps + _get_external_deps(external_deps), + python_version = python_version, + **kwargs ) def grpc_package(name, visibility = "private", features = []): diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 06323ff3f24..6bbb960b6c3 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -176,11 +176,11 @@ def grpc_deps(): if "bazel_toolchains" not in native.existing_rules(): http_archive( name = "bazel_toolchains", - sha256 = "d968b414b32aa99c86977e1171645d31da2b52ac88060de3ac1e49932d5dcbf1", - strip_prefix = "bazel-toolchains-4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47", + sha256 = "872955b658113924eb1a3594b04d43238da47f4f90c17b76e8785709490dc041", + strip_prefix = "bazel-toolchains-1083686fde6032378d52b4c98044922cebde364e", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", ], ) @@ -221,10 +221,11 @@ def grpc_deps(): ) if "build_bazel_rules_apple" not in native.existing_rules(): - git_repository( + http_archive( name = "build_bazel_rules_apple", - remote = "https://github.com/bazelbuild/rules_apple.git", - tag = "0.17.2", + url = "https://github.com/bazelbuild/rules_apple/archive/b869b0d3868d78a1d4ffd866ccb304fb68aa12c3.tar.gz", + strip_prefix = "rules_apple-b869b0d3868d78a1d4ffd866ccb304fb68aa12c3", + sha256 = "bdc8e66e70b8a75da23b79f1f8c6207356df07d041d96d2189add7ee0780cf4e", ) grpc_python_deps() diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index 4e7cc1537fa..2a439bdf226 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -47,6 +47,15 @@ def grpc_python_deps(): remote = "https://github.com/bazelbuild/rules_python.git", ) + + if "rules_python" not in native.existing_rules(): + http_archive( + name = "rules_python", + url = "https://github.com/bazelbuild/rules_python/archive/9d68f24659e8ce8b736590ba1e4418af06ec2552.zip", + sha256 = "f7402f11691d657161f871e11968a984e5b48b023321935f5a55d7e56cf4758a", + strip_prefix = "rules_python-9d68f24659e8ce8b736590ba1e4418af06ec2552", + ) + python_configure(name = "local_config_python") native.bind( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 12f51f8b172..e7e9e597b05 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -178,3 +178,29 @@ def py_grpc_library( deps = [Label("//src/python/grpcio/grpc:grpcio")] + deps, **kwargs ) + + +def py2and3_test(name, + py_test = native.py_test, + **kwargs): + if "python_version" in kwargs: + fail("Cannot specify 'python_version' in py2and3_test.") + + names = [name + suffix for suffix in (".python2", ".python3")] + python_versions = ["PY2", "PY3"] + for case_name, python_version in zip(names, python_versions): + py_test( + name = case_name, + python_version = python_version, + **kwargs + ) + + suite_kwargs = {} + if "visibility" in kwargs: + suite_kwargs["visibility"] = kwargs["visibility"] + + native.test_suite( + name = name, + tests = names, + **suite_kwargs + ) diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel index cc454fdfdfe..72620ee46c5 100644 --- a/examples/python/auth/BUILD.bazel +++ b/examples/python/auth/BUILD.bazel @@ -39,6 +39,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_binary( @@ -51,6 +52,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_test( @@ -63,4 +65,5 @@ py_test( ":customized_auth_server", ":_credentials", ], + python_version = "PY3", ) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 17b1b20168e..b4451f60711 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -45,6 +45,7 @@ py_binary( "//external:six" ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_library( @@ -68,6 +69,7 @@ py_binary( "//:python3": [], }), srcs_version = "PY2AND3", + python_version = "PY3", ) py_test( @@ -78,4 +80,5 @@ py_test( ":server" ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/compression/BUILD.bazel b/examples/python/compression/BUILD.bazel index 9d5f6bb83ed..4141eda2ffd 100644 --- a/examples/python/compression/BUILD.bazel +++ b/examples/python/compression/BUILD.bazel @@ -21,6 +21,7 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_binary( @@ -32,6 +33,7 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_test( @@ -43,4 +45,5 @@ py_test( ":server", ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel index 657ae860ae3..332991332f8 100644 --- a/examples/python/debug/BUILD.bazel +++ b/examples/python/debug/BUILD.bazel @@ -35,6 +35,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_binary( @@ -45,6 +46,7 @@ py_binary( "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", ], + python_version = "PY3", ) py_test( @@ -59,4 +61,5 @@ py_test( ":send_message", ":get_stats", ], + python_version = "PY3", ) diff --git a/examples/python/errors/BUILD.bazel b/examples/python/errors/BUILD.bazel index 4b779ddfcf1..367bd81925f 100644 --- a/examples/python/errors/BUILD.bazel +++ b/examples/python/errors/BUILD.bazel @@ -55,4 +55,5 @@ py_test( "../../../src/python/grpcio_status", "../../../src/python/grpcio_tests", ], + python_version = "PY3", ) diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 490aea0c1e6..2503970bc80 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -42,6 +42,7 @@ py_binary( ":prime_proto_pb2_grpc", ], srcs_version = "PY3", + python_version = "PY3", ) py_binary( @@ -57,6 +58,7 @@ py_binary( "//:python3": [], }), srcs_version = "PY3", + python_version = "PY3", ) py_test( @@ -67,4 +69,5 @@ py_test( ":server" ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/wait_for_ready/BUILD.bazel b/examples/python/wait_for_ready/BUILD.bazel index f074ae7bb7f..9cbddd1a6e3 100644 --- a/examples/python/wait_for_ready/BUILD.bazel +++ b/examples/python/wait_for_ready/BUILD.bazel @@ -30,4 +30,5 @@ py_test( srcs = ["test/_wait_for_ready_example_test.py"], deps = [":wait_for_ready_example",], size = "small", + python_version = "PY3", ) diff --git a/src/python/grpcio_tests/tests/channelz/BUILD.bazel b/src/python/grpcio_tests/tests/channelz/BUILD.bazel index 63513616e77..f4d246847f7 100644 --- a/src/python/grpcio_tests/tests/channelz/BUILD.bazel +++ b/src/python/grpcio_tests/tests/channelz/BUILD.bazel @@ -1,6 +1,8 @@ package(default_visibility = ["//visibility:public"]) -py_test( +load("//bazel:python_rules.bzl", "py2and3_test") + +py2and3_test( name = "channelz_servicer_test", srcs = ["_channelz_servicer_test.py"], main = "_channelz_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/health_check/BUILD.bazel b/src/python/grpcio_tests/tests/health_check/BUILD.bazel index 49f076be9a1..797b6a48e91 100644 --- a/src/python/grpcio_tests/tests/health_check/BUILD.bazel +++ b/src/python/grpcio_tests/tests/health_check/BUILD.bazel @@ -1,6 +1,7 @@ package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py2and3_test") -py_test( +py2and3_test( name = "health_servicer_test", srcs = ["_health_servicer_test.py"], main = "_health_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index 8ac3f7d52d5..4685852162b 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -1,4 +1,5 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -80,7 +81,7 @@ py_library( ], ) -py_test( +py2and3_test( name = "_insecure_intraop_test", size = "small", srcs = ["_insecure_intraop_test.py"], @@ -99,7 +100,7 @@ py_test( ], ) -py_test( +py2and3_test( name = "_secure_intraop_test", size = "small", srcs = ["_secure_intraop_test.py"], diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel index e9b56191df8..65a08c2a435 100644 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ b/src/python/grpcio_tests/tests/reflection/BUILD.bazel @@ -1,8 +1,9 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py_test( +py2and3_test( name="_reflection_servicer_test", size="small", timeout="moderate", diff --git a/src/python/grpcio_tests/tests/status/BUILD.bazel b/src/python/grpcio_tests/tests/status/BUILD.bazel index b163fe3975e..0868de01acf 100644 --- a/src/python/grpcio_tests/tests/status/BUILD.bazel +++ b/src/python/grpcio_tests/tests/status/BUILD.bazel @@ -1,8 +1,9 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py_test( +py2and3_test( name = "grpc_status_test", srcs = ["_grpc_status_test.py"], main = "_grpc_status_test.py", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index 49203b7fa16..587d8cb246f 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -1,3 +1,5 @@ +load("//bazel:python_rules.bzl", "py2and3_test") + package(default_visibility = ["//visibility:public"]) GRPCIO_TESTS_UNIT = [ @@ -80,7 +82,7 @@ py_library( ) [ - py_test( + py2and3_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel index 458a6b1fb8a..867649a6a50 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel @@ -1,4 +1,5 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -23,7 +24,7 @@ py_library( ) [ - py_test( + py2and3_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel index d69186e1fde..a93249301c4 100644 --- a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel @@ -1,11 +1,12 @@ package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py2and3_test") py_library( name = "stream_testing", srcs = ["stream_testing.py"], ) -py_test( +py2and3_test( name = "logging_pool_test", srcs = ["_logging_pool_test.py"], main = "_logging_pool_test.py", diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index adde6ed4787..12a22785623 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl index 2283c573bc3..8f010f85a03 100644 --- a/third_party/py/BUILD.tpl +++ b/third_party/py/BUILD.tpl @@ -2,35 +2,36 @@ package(default_visibility=["//visibility:public"]) -# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib -# See https://docs.python.org/3/extending/windows.html -cc_import( - name="python_lib", - interface_library=select({ - ":windows": ":python_import_lib", - # A placeholder for Unix platforms which makes --no_build happy. - "//conditions:default": "not-existing.lib", - }), - system_provided=1, -) - -cc_library( - name="python_headers", - hdrs=[":python_include"], - deps=select({ - ":windows": [":python_lib"], - "//conditions:default": [], - }), - includes=["python_include"], -) - config_setting( name="windows", values={"cpu": "x64_windows"}, visibility=["//visibility:public"], ) -%{PYTHON_INCLUDE_GENRULE} -%{PYTHON_IMPORT_LIB_GENRULE} +config_setting( + name="python2", + flag_values = {"@rules_python//python:python_version": "PY2"} +) + +config_setting( + name="python3", + flag_values = {"@rules_python//python:python_version": "PY3"} +) +cc_library( + name = "python_lib", + deps = select({ + ":python2": ["//_python2:_python2_lib"], + ":python3": ["//_python3:_python3_lib"], + "//conditions:default": ["not-existing.lib"], + }) +) +cc_library( + name = "python_headers", + deps = select({ + ":python2": ["//_python2:_python2_headers"], + ":python3": ["//_python3:_python3_headers"], + "//conditions:default": ["not-existing.headers"], + }) +) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index e6fa5ed10e9..6f9a178a057 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -3,14 +3,15 @@ `python_configure` depends on the following environment variables: - * `PYTHON_BIN_PATH`: location of python binary. - * `PYTHON_LIB_PATH`: Location of python libraries. + * `PYTHON2_BIN_PATH`: location of python binary. + * `PYTHON2_LIB_PATH`: Location of python libraries. """ _BAZEL_SH = "BAZEL_SH" -_PYTHON_BIN_PATH = "PYTHON_BIN_PATH" -_PYTHON_LIB_PATH = "PYTHON_LIB_PATH" -_PYTHON_CONFIG_REPO = "PYTHON_CONFIG_REPO" +_PYTHON2_BIN_PATH = "PYTHON2_BIN_PATH" +_PYTHON2_LIB_PATH = "PYTHON2_LIB_PATH" +_PYTHON3_BIN_PATH = "PYTHON3_BIN_PATH" +_PYTHON3_LIB_PATH = "PYTHON3_LIB_PATH" def _tpl(repository_ctx, tpl, substitutions={}, out=None): @@ -136,9 +137,9 @@ def _symlink_genrule_for_dir(repository_ctx, "\n".join(outs)) -def _get_python_bin(repository_ctx): +def _get_python_bin(repository_ctx, bin_path_key, default_bin_path): """Gets the python bin path.""" - python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH, 'python') + python_bin = repository_ctx.os.environ.get(bin_path_key, default_bin_path) if not repository_ctx.path(python_bin).exists: # It's a command, use 'which' to find its path. python_bin_path = repository_ctx.which(python_bin) @@ -150,7 +151,7 @@ def _get_python_bin(repository_ctx): _fail("Cannot find python in PATH, please make sure " + "python is installed and add its directory in PATH, or --define " + "%s='/something/else'.\nPATH=%s" % - (_PYTHON_BIN_PATH, repository_ctx.os.environ.get("PATH", ""))) + (bin_path_key, repository_ctx.os.environ.get("PATH", ""))) def _get_bash_bin(repository_ctx): @@ -170,9 +171,9 @@ def _get_bash_bin(repository_ctx): (_BAZEL_SH, repository_ctx.os.environ.get("PATH", ""))) -def _get_python_lib(repository_ctx, python_bin): +def _get_python_lib(repository_ctx, python_bin, lib_path_key): """Gets the python lib path.""" - python_lib = repository_ctx.os.environ.get(_PYTHON_LIB_PATH) + python_lib = repository_ctx.os.environ.get(lib_path_key) if python_lib != None: return python_lib print_lib = ( @@ -202,13 +203,13 @@ def _check_python_lib(repository_ctx, python_lib): _fail("Invalid python library path: %s" % python_lib) -def _check_python_bin(repository_ctx, python_bin): +def _check_python_bin(repository_ctx, python_bin, bin_path_key): """Checks the python bin path.""" cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) if result.return_code == 1: _fail("--define %s='%s' is not executable. Is it the python binary?" % - (_PYTHON_BIN_PATH, python_bin)) + (bin_path_key, python_bin)) def _get_python_include(repository_ctx, python_bin): @@ -222,11 +223,11 @@ def _get_python_include(repository_ctx, python_bin): error_msg="Problem getting python include path.", error_details=( "Is the Python binary path set up right? " + "(See ./configure or " - + _PYTHON_BIN_PATH + ".) " + "Is distutils installed?")) + + _PYTHON2_BIN_PATH + ".) " + "Is distutils installed?")) return result.stdout.splitlines()[0] -def _get_python_import_lib_name(repository_ctx, python_bin): +def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): """Get Python import library name (pythonXY.lib) on Windows.""" result = _execute( repository_ctx, [ @@ -236,66 +237,85 @@ def _get_python_import_lib_name(repository_ctx, python_bin): ], error_msg="Problem getting python import library.", error_details=("Is the Python binary path set up right? " + - "(See ./configure or " + _PYTHON_BIN_PATH + ".) ")) + "(See ./configure or " + bin_path_key + ".) ")) return result.stdout.splitlines()[0] -def _create_local_python_repository(repository_ctx): +def _create_single_version_package(repository_ctx, + variety_name, + bin_path_key, + default_bin_path, + lib_path_key): """Creates the repository containing files set up to build with Python.""" - python_bin = _get_python_bin(repository_ctx) - _check_python_bin(repository_ctx, python_bin) - python_lib = _get_python_lib(repository_ctx, python_bin) + python_bin = _get_python_bin(repository_ctx, bin_path_key, default_bin_path) + _check_python_bin(repository_ctx, python_bin, bin_path_key) + python_lib = _get_python_lib(repository_ctx, python_bin, lib_path_key) _check_python_lib(repository_ctx, python_lib) python_include = _get_python_include(repository_ctx, python_bin) python_include_rule = _symlink_genrule_for_dir( - repository_ctx, python_include, 'python_include', 'python_include') + repository_ctx, python_include, '{}_include'.format(variety_name), + '{}_include'.format(variety_name)) python_import_lib_genrule = "" # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib # See https://docs.python.org/3/extending/windows.html if _is_windows(repository_ctx): python_include = _normalize_path(python_include) - python_import_lib_name = _get_python_import_lib_name( + python_import_lib_name = _get_python_import_lib_name, bin_path_key( repository_ctx, python_bin) python_import_lib_src = python_include.rsplit( '/', 1)[0] + "/libs/" + python_import_lib_name python_import_lib_genrule = _symlink_genrule_for_dir( - repository_ctx, None, '', 'python_import_lib', + repository_ctx, None, '', '{}_import_lib'.format(variety_name), [python_import_lib_src], [python_import_lib_name]) _tpl( - repository_ctx, "BUILD", { + repository_ctx, "variety", { "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, - }) - - -def _create_remote_python_repository(repository_ctx, remote_config_repo): - """Creates pointers to a remotely configured repo set up to build with Python. - """ - _tpl(repository_ctx, "remote.BUILD", { - "%{REMOTE_PYTHON_REPO}": remote_config_repo, - }, "BUILD") + "%{VARIETY_NAME}": variety_name, + }, + out="{}/BUILD".format(variety_name)) def _python_autoconf_impl(repository_ctx): """Implementation of the python_autoconf repository rule.""" - if _PYTHON_CONFIG_REPO in repository_ctx.os.environ: - _create_remote_python_repository( - repository_ctx, repository_ctx.os.environ[_PYTHON_CONFIG_REPO]) - else: - _create_local_python_repository(repository_ctx) + _create_single_version_package(repository_ctx, + "_python2", + _PYTHON2_BIN_PATH, + "python", + _PYTHON2_LIB_PATH) + _create_single_version_package(repository_ctx, + "_python3", + _PYTHON3_BIN_PATH, + "python3", + _PYTHON3_LIB_PATH) + _tpl(repository_ctx, "BUILD") python_configure = repository_rule( - implementation=_python_autoconf_impl, - environ=[ + implementation = _python_autoconf_impl, + environ = [ _BAZEL_SH, - _PYTHON_BIN_PATH, - _PYTHON_LIB_PATH, - _PYTHON_CONFIG_REPO, + _PYTHON2_BIN_PATH, + _PYTHON2_LIB_PATH, + _PYTHON3_BIN_PATH, + _PYTHON3_LIB_PATH, ], + attrs={ + "_build_tpl": attr.label( + default = Label("//third_party/py:BUILD.tpl"), + allow_single_file = True, + ), + "_variety_tpl": attr.label( + default = Label("//third_party/py:variety.tpl"), + allow_single_file = True, + ), + }, ) """Detects and configures the local Python. +It is expected that the system have both a working Python 2 and python 3 +installation + Add the following to your WORKSPACE FILE: ```python diff --git a/third_party/py/remote.BUILD.tpl b/third_party/py/remote.BUILD.tpl deleted file mode 100644 index 1bfe1f0bf65..00000000000 --- a/third_party/py/remote.BUILD.tpl +++ /dev/null @@ -1,10 +0,0 @@ -# Adapted with modifications from tensorflow/third_party/py/ - -package(default_visibility=["//visibility:public"]) - -alias( - name="python_headers", - actual="%{REMOTE_PYTHON_REPO}:python_headers", -) - - diff --git a/third_party/py/variety.tpl b/third_party/py/variety.tpl new file mode 100644 index 00000000000..0c466d6d8f0 --- /dev/null +++ b/third_party/py/variety.tpl @@ -0,0 +1,26 @@ +package(default_visibility=["//visibility:public"]) + +# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +# See https://docs.python.org/3/extending/windows.html +cc_import( + name="%{VARIETY_NAME}_lib", + interface_library=select({ + "//:windows": ":%{VARIETY_NAME}_import_lib", + # A placeholder for Unix platforms which makes --no_build happy. + "//conditions:default": "not-existing.lib", + }), + system_provided=1, +) + +cc_library( + name="%{VARIETY_NAME}_headers", + hdrs=[":%{VARIETY_NAME}_include"], + deps=select({ + "//:windows": [":%{VARIETY_NAME}_lib"], + "//conditions:default": [], + }), + includes=["%{VARIETY_NAME}_include"], +) + +%{PYTHON_INCLUDE_GENRULE} +%{PYTHON_IMPORT_LIB_GENRULE} diff --git a/tools/bazel b/tools/bazel index 4f08d18c656..4d1d57f60d9 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.26.0 +VERSION=0.28.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/bazel.rc b/tools/bazel.rc index b24f603ddda..fcbe9337b9f 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -82,7 +82,3 @@ build:basicprof --copt=-DNDEBUG build:basicprof --copt=-O2 build:basicprof --copt=-DGRPC_BASIC_PROFILER build:basicprof --copt=-DGRPC_TIMERS_RDTSC - -build:python3 --python_path=python3 -build:python3 --python_version=PY3 -build:python3 --action_env=PYTHON_BIN_PATH=python3 diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7e7903359e7..7141fb9c5f1 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 675378b305b..badff52de34 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index f725eb7a3d7..4a48760aab1 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -26,9 +26,6 @@ ${name}') cd /var/local/git/grpc/test bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... -bazel clean --expunge -bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... -bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... # TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new Kokoro # job. diff --git a/tools/remote_build/kokoro.bazelrc b/tools/remote_build/kokoro.bazelrc index 064e94b2e15..5c1b061bce3 100644 --- a/tools/remote_build/kokoro.bazelrc +++ b/tools/remote_build/kokoro.bazelrc @@ -16,13 +16,12 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --auth_enabled=true -build --bes_backend=buildeventservice.googleapis.com +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=600s build --project_id=grpc-testing diff --git a/tools/remote_build/manual.bazelrc b/tools/remote_build/manual.bazelrc index fcd41f57521..c3c6af42877 100644 --- a/tools/remote_build/manual.bazelrc +++ b/tools/remote_build/manual.bazelrc @@ -17,9 +17,8 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com # Enable authentication. This will pick up application default credentials by # default. You can use --auth_credentials=some_file.json to use a service @@ -30,7 +29,7 @@ build --auth_enabled=true # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index 6baaf24732c..6236003fe17 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -87,4 +87,4 @@ build:ubsan --test_timeout=3600 # how to update the bazel toolchain for ubsan: # - check for the latest released version in https://github.com/bazelbuild/bazel-toolchains/tree/master/configs/experimental/ubuntu16_04_clang # - you might need to update the bazel_toolchains dependency in grpc_deps.bzl -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.28.0/ubsan:toolchain From 1077b3435c3bf6699e118800a9c0681c900d240b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 29 Aug 2019 11:27:00 -0700 Subject: [PATCH 060/176] Use range-based for on state rather than state.KeepRunning when possible --- test/cpp/microbenchmarks/bm_alarm.cc | 2 +- test/cpp/microbenchmarks/bm_arena.cc | 4 +- test/cpp/microbenchmarks/bm_byte_buffer.cc | 6 +-- test/cpp/microbenchmarks/bm_call_create.cc | 16 ++++---- test/cpp/microbenchmarks/bm_channel.cc | 2 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 4 +- test/cpp/microbenchmarks/bm_closure.cc | 38 +++++++++---------- test/cpp/microbenchmarks/bm_cq.cc | 16 ++++---- .../microbenchmarks/bm_cq_multiple_threads.cc | 2 +- test/cpp/microbenchmarks/bm_error.cc | 34 ++++++++--------- test/cpp/microbenchmarks/bm_metadata.cc | 38 +++++++++---------- test/cpp/microbenchmarks/bm_pollset.cc | 10 ++--- test/cpp/microbenchmarks/bm_timer.cc | 4 +- .../fullstack_streaming_ping_pong.h | 6 +-- .../fullstack_streaming_pump.h | 4 +- .../fullstack_unary_ping_pong.h | 2 +- test/cpp/microbenchmarks/noop-benchmark.cc | 2 +- 17 files changed, 95 insertions(+), 95 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_alarm.cc b/test/cpp/microbenchmarks/bm_alarm.cc index d95771a57c6..5411b222eab 100644 --- a/test/cpp/microbenchmarks/bm_alarm.cc +++ b/test/cpp/microbenchmarks/bm_alarm.cc @@ -37,7 +37,7 @@ static void BM_Alarm_Tag_Immediate(benchmark::State& state) { void* output_tag; bool ok; auto deadline = grpc_timeout_seconds_to_deadline(0); - while (state.KeepRunning()) { + for (auto _ : state) { alarm.Set(&cq, deadline, nullptr); cq.Next(&output_tag, &ok); } diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc index c3ded0d76f7..c0d76fa3d7d 100644 --- a/test/cpp/microbenchmarks/bm_arena.cc +++ b/test/cpp/microbenchmarks/bm_arena.cc @@ -26,7 +26,7 @@ using grpc_core::Arena; static void BM_Arena_NoOp(benchmark::State& state) { - while (state.KeepRunning()) { + for (auto _ : state) { Arena::Create(state.range(0))->Destroy(); } } @@ -49,7 +49,7 @@ static void BM_Arena_ManyAlloc(benchmark::State& state) { BENCHMARK(BM_Arena_ManyAlloc)->Ranges({{1, 1024 * 1024}, {1, 32 * 1024}}); static void BM_Arena_Batch(benchmark::State& state) { - while (state.KeepRunning()) { + for (auto _ : state) { Arena* a = Arena::Create(state.range(0)); for (int i = 0; i < state.range(1); i++) { a->Alloc(state.range(2)); diff --git a/test/cpp/microbenchmarks/bm_byte_buffer.cc b/test/cpp/microbenchmarks/bm_byte_buffer.cc index 595cc734b69..4dfa1326de9 100644 --- a/test/cpp/microbenchmarks/bm_byte_buffer.cc +++ b/test/cpp/microbenchmarks/bm_byte_buffer.cc @@ -40,7 +40,7 @@ static void BM_ByteBuffer_Copy(benchmark::State& state) { slices.emplace_back(buf.get(), slice_size); } grpc::ByteBuffer bb(slices.data(), num_slices); - while (state.KeepRunning()) { + for (auto _ : state) { grpc::ByteBuffer cc(bb); } } @@ -60,7 +60,7 @@ static void BM_ByteBufferReader_Next(benchmark::State& state) { grpc_byte_buffer_reader reader; GPR_ASSERT( g_core_codegen_interface->grpc_byte_buffer_reader_init(&reader, bb)); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice* slice; if (GPR_UNLIKELY(!g_core_codegen_interface->grpc_byte_buffer_reader_peek( &reader, &slice))) { @@ -93,7 +93,7 @@ static void BM_ByteBufferReader_Peek(benchmark::State& state) { grpc_byte_buffer_reader reader; GPR_ASSERT( g_core_codegen_interface->grpc_byte_buffer_reader_init(&reader, bb)); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice* slice; if (GPR_UNLIKELY(!g_core_codegen_interface->grpc_byte_buffer_reader_peek( &reader, &slice))) { diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 4eb717d82b5..99ea1e053e9 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -52,7 +52,7 @@ void BM_Zalloc(benchmark::State& state) { // sizes TrackCounters track_counters; size_t sz = state.range(0); - while (state.KeepRunning()) { + for (auto _ : state) { gpr_free(gpr_zalloc(sz)); } track_counters.Finish(state); @@ -107,7 +107,7 @@ static void BM_CallCreateDestroy(benchmark::State& state) { gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_call_unref(grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl, deadline, nullptr)); @@ -139,7 +139,7 @@ static void BM_LameChannelCallCreateCpp(benchmark::State& state) { grpc::testing::EchoRequest send_request; grpc::testing::EchoResponse recv_response; grpc::Status recv_status; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc::ClientContext cli_ctx; auto reader = stub->AsyncEcho(&cli_ctx, send_request, &cq); @@ -174,7 +174,7 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, @@ -248,7 +248,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, @@ -720,7 +720,7 @@ static void BM_IsolatedCall_NoOp(benchmark::State& state) { gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call_unref(grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), @@ -759,7 +759,7 @@ static void BM_IsolatedCall_Unary(benchmark::State& state) { ops[5].data.recv_status_on_client.status = &status_code; ops[5].data.recv_status_on_client.status_details = &status_details; ops[5].data.recv_status_on_client.trailing_metadata = &recv_trailing_metadata; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), @@ -802,7 +802,7 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_MESSAGE; ops[0].data.send_message.send_message = send_message; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call_start_batch(call, ops, 1, tag(2), nullptr); grpc_completion_queue_next(fixture.cq(), diff --git a/test/cpp/microbenchmarks/bm_channel.cc b/test/cpp/microbenchmarks/bm_channel.cc index 88856c3439b..224170b32e9 100644 --- a/test/cpp/microbenchmarks/bm_channel.cc +++ b/test/cpp/microbenchmarks/bm_channel.cc @@ -62,7 +62,7 @@ static void BM_InsecureChannelCreateDestroy(benchmark::State& state) { for (int i = 0; i < state.range(0); i++) { initial_channels[i].Init(); } - while (state.KeepRunning()) { + for (auto _ : state) { Fixture channel; channel.Init(); } diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 4950e7f7768..5d5be763d55 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -54,7 +54,7 @@ static void BM_HpackEncoderInitDestroy(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; std::unique_ptr c( new grpc_chttp2_hpack_compressor); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_chttp2_hpack_compressor_init(c.get()); grpc_chttp2_hpack_compressor_destroy(c.get()); grpc_core::ExecCtx::Get()->Flush(); @@ -435,7 +435,7 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) { grpc_chttp2_hpack_parser p; // Initial destruction so we don't leak memory in the loop. grpc_chttp2_hptbl_destroy(&p.table); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_chttp2_hpack_parser_init(&p); // Note that grpc_chttp2_hpack_parser_destroy frees the table dynamic // elements so we need to recreate it here. In actual operation, diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc index 84b1c536bf0..5133c2a0f43 100644 --- a/test/cpp/microbenchmarks/bm_closure.cc +++ b/test/cpp/microbenchmarks/bm_closure.cc @@ -32,7 +32,7 @@ static void BM_NoOpExecCtx(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_core::ExecCtx exec_ctx; } track_counters.Finish(state); @@ -42,7 +42,7 @@ BENCHMARK(BM_NoOpExecCtx); static void BM_WellFlushed(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_core::ExecCtx::Get()->Flush(); } @@ -55,7 +55,7 @@ static void DoNothing(void* arg, grpc_error* error) {} static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize( GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx)); } @@ -68,7 +68,7 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) { grpc_combiner* combiner = grpc_combiner_create(); grpc_closure c; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(GRPC_CLOSURE_INIT( &c, DoNothing, nullptr, grpc_combiner_scheduler(combiner))); } @@ -83,7 +83,7 @@ static void BM_ClosureRunOnExecCtx(benchmark::State& state) { grpc_closure c; GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); } @@ -95,7 +95,7 @@ BENCHMARK(BM_ClosureRunOnExecCtx); static void BM_ClosureCreateAndRun(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_RUN( GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); @@ -109,7 +109,7 @@ static void BM_ClosureInitAndRun(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; grpc_closure c; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_RUN( GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); @@ -124,7 +124,7 @@ static void BM_ClosureSchedOnExecCtx(benchmark::State& state) { grpc_closure c; GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); } @@ -140,7 +140,7 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) { GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); @@ -159,7 +159,7 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) { GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE); @@ -176,7 +176,7 @@ static void BM_AcquireMutex(benchmark::State& state) { gpr_mu mu; gpr_mu_init(&mu); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { gpr_mu_lock(&mu); DoNothing(nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); @@ -193,7 +193,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) { gpr_mu mu; gpr_mu_init(&mu); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { if (gpr_mu_trylock(&mu)) { DoNothing(nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); @@ -212,7 +212,7 @@ static void BM_AcquireSpinlock(benchmark::State& state) { // for comparison with the combiner stuff below gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { gpr_spinlock_lock(&mu); DoNothing(nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); @@ -227,7 +227,7 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) { // for comparison with the combiner stuff below gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { if (gpr_spinlock_trylock(&mu)) { DoNothing(nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); @@ -246,7 +246,7 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) { grpc_closure c; GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); } @@ -264,7 +264,7 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) { GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); @@ -285,7 +285,7 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) { GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE); @@ -308,7 +308,7 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) { GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); @@ -337,7 +337,7 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) { GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index edbff9c2be3..e72de05537c 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -34,7 +34,7 @@ namespace testing { static void BM_CreateDestroyCpp(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { CompletionQueue cq; } track_counters.Finish(state); @@ -44,7 +44,7 @@ BENCHMARK(BM_CreateDestroyCpp); /* Create cq using a different constructor */ static void BM_CreateDestroyCpp2(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_completion_queue* core_cq = grpc_completion_queue_create_for_next(nullptr); CompletionQueue cq(core_cq); @@ -55,7 +55,7 @@ BENCHMARK(BM_CreateDestroyCpp2); static void BM_CreateDestroyCore(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { // TODO: sreek Templatize this benchmark and pass completion type and // polling type as parameters grpc_completion_queue_destroy( @@ -77,7 +77,7 @@ static void BM_Pass1Cpp(benchmark::State& state) { TrackCounters track_counters; CompletionQueue cq; grpc_completion_queue* c_cq = cq.cq(); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_cq_completion completion; DummyTag dummy_tag; grpc_core::ExecCtx exec_ctx; @@ -98,7 +98,7 @@ static void BM_Pass1Core(benchmark::State& state) { // TODO: sreek Templatize this benchmark and pass polling_type as a param grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_cq_completion completion; grpc_core::ExecCtx exec_ctx; GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); @@ -117,7 +117,7 @@ static void BM_Pluck1Core(benchmark::State& state) { // TODO: sreek Templatize this benchmark and pass polling_type as a param grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_cq_completion completion; grpc_core::ExecCtx exec_ctx; GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); @@ -136,7 +136,7 @@ static void BM_EmptyCore(benchmark::State& state) { // TODO: sreek Templatize this benchmark and pass polling_type as a param grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_completion_queue_next(cq, deadline, nullptr); } grpc_completion_queue_destroy(cq); @@ -202,7 +202,7 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { ShutdownCallback shutdown_cb(&got_shutdown); grpc_completion_queue* cc = grpc_completion_queue_create_for_callback(&shutdown_cb, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; grpc_cq_completion completion; diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index 329eaf2434e..4dc471b1bc5 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -174,7 +174,7 @@ static void BM_Cq_Throughput(benchmark::State& state) { // (optionally including low-level counters) before and after the test TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type == GRPC_OP_COMPLETE); } diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index a71817f7e54..c58453be4f5 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -35,7 +35,7 @@ typedef std::unique_ptr ErrorPtr; static void BM_ErrorCreateFromStatic(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error")); } track_counters.Finish(state); @@ -44,7 +44,7 @@ BENCHMARK(BM_ErrorCreateFromStatic); static void BM_ErrorCreateFromCopied(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_CREATE_FROM_COPIED_STRING("Error not inline")); } track_counters.Finish(state); @@ -53,7 +53,7 @@ BENCHMARK(BM_ErrorCreateFromCopied); static void BM_ErrorCreateAndSetStatus(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF( grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_ABORTED)); @@ -64,7 +64,7 @@ BENCHMARK(BM_ErrorCreateAndSetStatus); static void BM_ErrorCreateAndSetIntAndStr(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(grpc_error_set_str( grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"), @@ -79,7 +79,7 @@ static void BM_ErrorCreateAndSetIntLoop(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"); int n = 0; - while (state.KeepRunning()) { + for (auto _ : state) { error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, n++); } GRPC_ERROR_UNREF(error); @@ -91,7 +91,7 @@ static void BM_ErrorCreateAndSetStrLoop(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"); const char* str = "hello"; - while (state.KeepRunning()) { + for (auto _ : state) { error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_static_string(str)); } @@ -103,7 +103,7 @@ BENCHMARK(BM_ErrorCreateAndSetStrLoop); static void BM_ErrorRefUnref(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_REF(error)); } GRPC_ERROR_UNREF(error); @@ -113,7 +113,7 @@ BENCHMARK(BM_ErrorRefUnref); static void BM_ErrorUnrefNone(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_NONE); } } @@ -121,7 +121,7 @@ BENCHMARK(BM_ErrorUnrefNone); static void BM_ErrorGetIntFromNoError(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { intptr_t value; grpc_error_get_int(GRPC_ERROR_NONE, GRPC_ERROR_INT_GRPC_STATUS, &value); } @@ -133,7 +133,7 @@ static void BM_ErrorGetMissingInt(benchmark::State& state) { TrackCounters track_counters; ErrorPtr error(grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_INDEX, 1)); - while (state.KeepRunning()) { + for (auto _ : state) { intptr_t value; grpc_error_get_int(error.get(), GRPC_ERROR_INT_OFFSET, &value); } @@ -145,7 +145,7 @@ static void BM_ErrorGetPresentInt(benchmark::State& state) { TrackCounters track_counters; ErrorPtr error(grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_OFFSET, 1)); - while (state.KeepRunning()) { + for (auto _ : state) { intptr_t value; grpc_error_get_int(error.get(), GRPC_ERROR_INT_OFFSET, &value); } @@ -224,7 +224,7 @@ class ErrorWithNestedGrpcStatus { template static void BM_ErrorStringOnNewError(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { Fixture fixture; grpc_error_string(fixture.error()); } @@ -235,7 +235,7 @@ template static void BM_ErrorStringRepeatedly(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_error_string(fixture.error()); } track_counters.Finish(state); @@ -246,7 +246,7 @@ static void BM_ErrorGetStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_status_code status; grpc_slice slice; grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice, @@ -261,7 +261,7 @@ static void BM_ErrorGetStatusCode(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_status_code status; grpc_error_get_status(fixture.error(), fixture.deadline(), &status, nullptr, nullptr, nullptr); @@ -275,7 +275,7 @@ static void BM_ErrorHttpError(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_http2_error_code error; grpc_error_get_status(fixture.error(), fixture.deadline(), nullptr, nullptr, &error, nullptr); @@ -288,7 +288,7 @@ template static void BM_HasClearGrpcStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_error_has_clear_grpc_status(fixture.error()); } track_counters.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index d472363eb87..d6ccee5ceef 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -30,7 +30,7 @@ static void BM_SliceFromStatic(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(grpc_core::ExternallyManagedSlice("abc")); } track_counters.Finish(state); @@ -39,7 +39,7 @@ BENCHMARK(BM_SliceFromStatic); static void BM_SliceFromCopied(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice_unref(grpc_core::UnmanagedMemorySlice("abc")); } track_counters.Finish(state); @@ -49,7 +49,7 @@ BENCHMARK(BM_SliceFromCopied); static void BM_SliceIntern(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExternallyManagedSlice slice("abc"); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice_unref(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); @@ -60,7 +60,7 @@ static void BM_SliceReIntern(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExternallyManagedSlice static_slice("abc"); grpc_core::ManagedMemorySlice slice(&static_slice); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice_unref(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); @@ -69,7 +69,7 @@ BENCHMARK(BM_SliceReIntern); static void BM_SliceInternStaticMetadata(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(grpc_core::ManagedMemorySlice(&GRPC_MDSTR_GZIP)); } track_counters.Finish(state); @@ -79,7 +79,7 @@ BENCHMARK(BM_SliceInternStaticMetadata); static void BM_SliceInternEqualToStaticMetadata(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExternallyManagedSlice slice("gzip"); - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); @@ -91,7 +91,7 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) { grpc_core::ExternallyManagedSlice k("key"); grpc_core::ExternallyManagedSlice v("value"); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } @@ -104,7 +104,7 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) { grpc_core::ManagedMemorySlice k("key"); grpc_core::ManagedMemorySlice v("value"); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } @@ -121,7 +121,7 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex( grpc_core::ManagedMemorySlice v("value"); grpc_core::ExecCtx exec_ctx; grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } GRPC_MDELEM_UNREF(seed); @@ -137,7 +137,7 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) { grpc_core::ManagedMemorySlice k("key"); grpc_core::ExternallyManagedSlice v("value"); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } @@ -153,7 +153,7 @@ static void BM_MetadataFromNonInternedSlicesWithBackingStore( grpc_core::ExternallyManagedSlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create( k, v, reinterpret_cast(backing_store))); } @@ -169,7 +169,7 @@ static void BM_MetadataFromInternedSlicesWithBackingStore( grpc_core::ManagedMemorySlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create( k, v, reinterpret_cast(backing_store))); } @@ -187,7 +187,7 @@ static void BM_MetadataFromInternedKeyWithBackingStore( grpc_core::ExternallyManagedSlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create( k, v, reinterpret_cast(backing_store))); } @@ -200,7 +200,7 @@ BENCHMARK(BM_MetadataFromInternedKeyWithBackingStore); static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF( grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr)); } @@ -213,7 +213,7 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed( benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF( grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_GZIP, nullptr)); } @@ -230,7 +230,7 @@ static void BM_MetadataRefUnrefExternal(benchmark::State& state) { grpc_mdelem_create(grpc_core::ExternallyManagedSlice("a"), grpc_core::ExternallyManagedSlice("b"), reinterpret_cast(backing_store)); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); @@ -249,7 +249,7 @@ static void BM_MetadataRefUnrefInterned(benchmark::State& state) { k, v, reinterpret_cast(backing_store)); grpc_slice_unref(k); grpc_slice_unref(v); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); @@ -264,7 +264,7 @@ static void BM_MetadataRefUnrefAllocated(benchmark::State& state) { grpc_mdelem el = grpc_mdelem_create(grpc_core::ExternallyManagedSlice("a"), grpc_core::ExternallyManagedSlice("b"), nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); @@ -278,7 +278,7 @@ static void BM_MetadataRefUnrefStatic(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; grpc_mdelem el = grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index f8e36f178e4..c360f02d466 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -53,7 +53,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) { grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); - while (state.KeepRunning()) { + for (auto _ : state) { memset(ps, 0, ps_sz); grpc_pollset_init(ps, &mu); gpr_mu_lock(mu); @@ -84,7 +84,7 @@ static void BM_PollEmptyPollset_SpeedOfLight(benchmark::State& state) { ev.events = EPOLLIN; epoll_ctl(epfd, EPOLL_CTL_ADD, fds.back(), &ev); } - while (state.KeepRunning()) { + for (auto _ : state) { epoll_wait(epfd, ev, nev, 0); } for (auto fd : fds) { @@ -115,7 +115,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) { grpc_pollset_init(ps, &mu); grpc_core::ExecCtx exec_ctx; gpr_mu_lock(mu); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0)); } grpc_closure shutdown_ps_closure; @@ -140,7 +140,7 @@ static void BM_PollAddFd(benchmark::State& state) { GPR_ASSERT( GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd))); grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx", false); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_pollset_add_fd(ps, fd); grpc_core::ExecCtx::Get()->Flush(); } @@ -188,7 +188,7 @@ static void BM_SingleThreadPollOneFd_SpeedOfLight(benchmark::State& state) { int fd = eventfd(0, EFD_NONBLOCK); ev[0].events = EPOLLIN; epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev[0]); - while (state.KeepRunning()) { + for (auto _ : state) { int err; do { err = eventfd_write(fd, 1); diff --git a/test/cpp/microbenchmarks/bm_timer.cc b/test/cpp/microbenchmarks/bm_timer.cc index 53aaead992d..7a493df5826 100644 --- a/test/cpp/microbenchmarks/bm_timer.cc +++ b/test/cpp/microbenchmarks/bm_timer.cc @@ -43,7 +43,7 @@ static void BM_InitCancelTimer(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; std::vector timer_closures(kTimerCount); int i = 0; - while (state.KeepRunning()) { + for (auto _ : state) { TimerClosure* timer_closure = &timer_closures[i++ % kTimerCount]; GRPC_CLOSURE_INIT(&timer_closure->closure, [](void* /*args*/, grpc_error* /*err*/) {}, nullptr, @@ -71,7 +71,7 @@ static void BM_TimerBatch(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; std::vector timer_closures(kTimerCount); - while (state.KeepRunning()) { + for (auto _ : state) { for (grpc_millis deadline = start; deadline != end; deadline += increment) { TimerClosure* timer_closure = &timer_closures[deadline % kTimerCount]; GRPC_CLOSURE_INIT(&timer_closure->closure, diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h index f399949a32f..db9be84fefb 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h @@ -65,7 +65,7 @@ static void BM_StreamingPingPong(benchmark::State& state) { std::unique_ptr stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + for (auto _ : state) { ServerContext svr_ctx; ServerContextMutator svr_ctx_mut(&svr_ctx); ServerAsyncReaderWriter response_rw(&svr_ctx); @@ -180,7 +180,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) { need_tags &= ~(1 << i); } - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); request_rw->Write(send_request, tag(0)); // Start client send response_rw.Read(&recv_request, tag(1)); // Start server recv @@ -262,7 +262,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { std::unique_ptr stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + for (auto _ : state) { ServerContext svr_ctx; ServerContextMutator svr_ctx_mut(&svr_ctx); ServerAsyncReaderWriter response_rw(&svr_ctx); diff --git a/test/cpp/microbenchmarks/fullstack_streaming_pump.h b/test/cpp/microbenchmarks/fullstack_streaming_pump.h index 3623e373f6f..cf72710ccb9 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_pump.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_pump.h @@ -67,7 +67,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) { need_tags &= ~(1 << i); } response_rw.Read(&recv_request, tag(0)); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); request_rw->Write(send_request, tag(1)); while (true) { @@ -136,7 +136,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) { need_tags &= ~(1 << i); } request_rw->Read(&recv_response, tag(0)); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); response_rw.Write(send_response, tag(1)); while (true) { diff --git a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h index 843c8e14862..604e0ed511e 100644 --- a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h @@ -71,7 +71,7 @@ static void BM_UnaryPingPong(benchmark::State& state) { fixture->cq(), tag(1)); std::unique_ptr stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); recv_response.Clear(); ClientContext cli_ctx; diff --git a/test/cpp/microbenchmarks/noop-benchmark.cc b/test/cpp/microbenchmarks/noop-benchmark.cc index 96605215dc6..49ffbf84bef 100644 --- a/test/cpp/microbenchmarks/noop-benchmark.cc +++ b/test/cpp/microbenchmarks/noop-benchmark.cc @@ -22,7 +22,7 @@ #include static void BM_NoOp(benchmark::State& state) { - while (state.KeepRunning()) { + for (auto _ : state) { } } BENCHMARK(BM_NoOp); From 88f5f130dd78bb18f683e7d410f427211500934a Mon Sep 17 00:00:00 2001 From: Steven E Wright Date: Thu, 29 Aug 2019 12:00:02 -0700 Subject: [PATCH 061/176] Fix `shorten-64-to-32` warning in `GRPCChannel` Per: https://github.com/grpc/grpc/issues/20122 this change avoids the `shorten-64-to-32` warning by calling the correct `NSNumber` factory method for an `NSUInteger` (the base type for the `GRPCCompressionAlgorithm` enum) --- src/objective-c/GRPCClient/private/GRPCChannel.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 1a79fb04a0d..2081d0534fa 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -103,7 +103,7 @@ if (_callOptions.compressionAlgorithm != GRPC_COMPRESS_NONE) { args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] = - [NSNumber numberWithInt:_callOptions.compressionAlgorithm]; + [NSNumber numberWithInteger:_callOptions.compressionAlgorithm]; } if (_callOptions.keepaliveInterval != 0) { From 9c4de3a983f54a23cbf574356c55be3704ce19f6 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 29 Aug 2019 12:16:36 -0700 Subject: [PATCH 062/176] Move reference to external workspace to OSS-specific file --- BUILD | 8 +++----- bazel/grpc_build_system.bzl | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index e489bc2584a..d911050b1be 100644 --- a/BUILD +++ b/BUILD @@ -31,6 +31,7 @@ load( "grpc_cc_library", "grpc_generate_one_off_targets", "grpc_upb_proto_library", + "python_config_settings", ) config_setting( @@ -63,11 +64,6 @@ config_setting( values = {"cpu": "x64_windows_msvc"}, ) -config_setting( - name = "python3", - flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, -) - config_setting( name = "mac_x86_64", values = {"cpu": "darwin"}, @@ -78,6 +74,8 @@ config_setting( values = {"define": "GRPC_USE_CPP_STD_LIB=1"}, ) +python_config_settings() + # This should be updated along with build.yaml g_stands_for = "ganges" diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f4777e50bc1..74a9c66ff67 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -342,3 +342,10 @@ def grpc_objc_library( def grpc_upb_proto_library(name, deps): upb_proto_library(name = name, deps = deps) + +def python_config_settings(): + native.config_setting( + name = "python3", + flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, + ) + From 8a352221646479bc60dcc4a7e1099cda6e36510c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 29 Aug 2019 15:52:42 -0700 Subject: [PATCH 063/176] fix Swift build --- src/objective-c/BUILD | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 5f53486d17e..be1cd09d0fa 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -101,7 +101,7 @@ grpc_objc_library( ) grpc_objc_library( - name = "grpc_objc_client_core", + name = "grpc_objc_client", hdrs = [ "GRPCClient/GRPCCall+ChannelCredentials.h", "GRPCClient/GRPCCall+Cronet.h", @@ -128,9 +128,11 @@ grpc_objc_library( ], ) +# TODO (mxyan): Switch "name" and "actual" when import is done +# Some internal Swift projects will need to be updated with the new name alias( - name = "grpc_objc_client", - actual = "grpc_objc_client_core", + name = "grpc_objc_client_core", + actual = "grpc_objc_client", ) grpc_objc_library( @@ -170,6 +172,7 @@ grpc_objc_library( ], hdrs = [ "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", "ProtoRPC/ProtoRPCLegacy.h", "ProtoRPC/ProtoService.h", ], From deee1f08268b78b16909e9767f5965aae1d2947a Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:24:38 +0800 Subject: [PATCH 064/176] Update: add offical guide link --- examples/python/data_transmission/README.cn.md | 10 +++++----- examples/python/data_transmission/README.en.md | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/python/data_transmission/README.cn.md b/examples/python/data_transmission/README.cn.md index 500e9bf95de..c5cbb71c41d 100644 --- a/examples/python/data_transmission/README.cn.md +++ b/examples/python/data_transmission/README.cn.md @@ -1,10 +1,10 @@ ## Data transmission demo for using gRPC in Python -在Python中使用gRPC时, 进行数据传输的四种方式。 +在Python中使用gRPC时, 进行数据传输的四种方式 [官方指南]() -- #### 简单模式 +- #### 一元模式 - 没啥好说的,跟调普通方法没差 + 在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应 `client.py - line:13 - simple_method` @@ -12,7 +12,7 @@ - #### 客户端流模式 - 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. + 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应 `clien.py - line:24 - client_streaming_method ` @@ -20,7 +20,7 @@ - #### 服务端流模式 - 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 + 在一次调用中, 客户端只能向服务器传输一次请求数据, 但是服务器可以多次返回响应 `clien.py - line:42 - server_streaming_method` diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md index 7fc527cf51a..f87682f2038 100644 --- a/examples/python/data_transmission/README.en.md +++ b/examples/python/data_transmission/README.en.md @@ -1,10 +1,10 @@ ## Data transmission demo for using gRPC in Python -Four ways of data transmission when gRPC is used in Python. +Four ways of data transmission when gRPC is used in Python. [Offical Guide]() - #### unary-unary - There's nothing to say. It's no different from the usual way. + In a single call, the client can only send request once, and the server can only respond once. `client.py - line:13 - simple_method` From 25a1caa9b08d03729dbd2cce3c2bacd493ef4ce0 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:30:07 +0800 Subject: [PATCH 065/176] Update: add proto3 document link, change chinese translation and comment of 'unary' --- examples/python/data_transmission/client.py | 7 ++++--- examples/python/data_transmission/demo.proto | 20 ++++++++++++-------- examples/python/data_transmission/server.py | 7 ++++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index 21c61d6cc6e..66bfc76450d 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -4,12 +4,13 @@ import grpc import demo_pb2_grpc import demo_pb2 -SERVER_ADDRESS = "localhost:23334" +SERVER_ADDRESS = "localhost:23333" CLIENT_ID = 1 -# 简单模式 -# unary-unary +# 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应) +# unary-unary(In a single call, the client can only send request once, and the server can +# only respond once.) def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") diff --git a/examples/python/data_transmission/demo.proto b/examples/python/data_transmission/demo.proto index dd29a178d77..d3d96b523d1 100644 --- a/examples/python/data_transmission/demo.proto +++ b/examples/python/data_transmission/demo.proto @@ -1,9 +1,11 @@ // 语法版本声明,必须放在非注释的第一行 // Syntax version declaration. Must be placed on the first line of non-commentary. + syntax = "proto3"; +// The document of proto3: https://developers.google.com/protocol-buffers/docs/proto3 -// 包名定义, Python中使用时可以省略不写(PS:我还要再Go中使用,所以留在这里了) -// Package name definition, which can be omitted in Python. (PS: I'll use it again in Go, so stay here) +// 包名定义, Python中使用时可以省略不写 +// Package name definition, which can be omitted in Python. package demo; /* @@ -12,8 +14,8 @@ package demo; 总体格式类似于Python中定义一个类或者Golang中定义一个结构体 */ /* -`message` is used to define the structure of the data to be transmitted, After the equal sign is the field number. -Each field in the message definition has a unique number. +`message` is used to define the structure of the data to be transmitted, after the equal sign +is the field number. Each field in the message definition has a unique number. The overall format is similar to defining a class in Python or a structure in Golang. */ message Request { @@ -26,11 +28,13 @@ message Response { string response_data = 2; } -// service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 -// `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang +// `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 +// `service` is used to define methods for gRPC services in a fixed format, similar to defining +//an interface in Golang service GRPCDemo { - // 简单模式 - // unary-unary + // 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应) + // unary-unary(In a single call, the client can only send request once, and the server can + // only respond once.) rpc SimpleMethod (Request) returns (Response); // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index e6e51e1b733..64c697dd952 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -6,14 +6,15 @@ from concurrent import futures import demo_pb2_grpc import demo_pb2 -SERVER_ADDRESS = 'localhost:23334' +SERVER_ADDRESS = 'localhost:23333' SERVER_ID = 1 class DemoServer(demo_pb2_grpc.GRPCDemoServicer): - # 简单模式 - # unary-unary + # 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应) + # unary-unary(In a single call, the client can only send request once, and the server can + # only respond once.) def SimpleMethod(self, request, context): print("SimpleMethod called by client(%d) the message: %s" % (request.client_id, request.request_data)) response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server SimpleMethod Ok!!!!") From 5c0fed241d8ac0f7a90899ed262759fc1f57b675 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:44:20 +0800 Subject: [PATCH 066/176] Fix: reformat code with YAPF script, and check with PyLint --- examples/python/data_transmission/client.py | 29 +++++++++++++------ examples/python/data_transmission/server.py | 32 ++++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index 66bfc76450d..0a9559ed79a 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -13,9 +13,11 @@ CLIENT_ID = 1 # only respond once.) def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") - request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + request = demo_pb2.Request( + client_id=CLIENT_ID, request_data="called by Python client") response = stub.SimpleMethod(request) - print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) + print("resp from server(%d), the message=%s" % (response.server_id, + response.response_data)) print("--------------Call SimpleMethod Over---------------") @@ -29,11 +31,14 @@ def client_streaming_method(stub): # create a generator def request_messages(): for i in range(5): - request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message:%d" % i)) + request = demo_pb2.Request( + client_id=CLIENT_ID, + request_data=("called by Python client, message:%d" % i)) yield request response = stub.ClientStreamingMethod(request_messages()) - print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) + print("resp from server(%d), the message=%s" % (response.server_id, + response.response_data)) print("--------------Call ClientStreamingMethod Over---------------") @@ -42,10 +47,12 @@ def client_streaming_method(stub): # but the server can return the response many times.) def server_streaming_method(stub): print("--------------Call ServerStreamingMethod Begin--------------") - request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + request = demo_pb2.Request( + client_id=CLIENT_ID, request_data="called by Python client") response_iterator = stub.ServerStreamingMethod(request) for response in response_iterator: - print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) + print("recv from server(%d), message=%s" % (response.server_id, + response.response_data)) print("--------------Call ServerStreamingMethod Over---------------") @@ -54,19 +61,23 @@ def server_streaming_method(stub): # stream-stream (In a single call, both client and server can send and receive data # to each other multiple times.) def bidirectional_streaming_method(stub): - print("--------------Call BidirectionalStreamingMethod Begin---------------") + print( + "--------------Call BidirectionalStreamingMethod Begin---------------") # 创建一个生成器 # create a generator def request_messages(): for i in range(5): - request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message: %d" % i)) + request = demo_pb2.Request( + client_id=CLIENT_ID, + request_data=("called by Python client, message: %d" % i)) yield request time.sleep(1) response_iterator = stub.BidirectionalStreamingMethod(request_messages()) for response in response_iterator: - print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) + print("recv from server(%d), message=%s" % (response.server_id, + response.response_data)) print("--------------Call BidirectionalStreamingMethod Over---------------") diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 64c697dd952..288c561382b 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,8 +1,7 @@ -import grpc - from threading import Thread from concurrent import futures +import grpc import demo_pb2_grpc import demo_pb2 @@ -16,8 +15,11 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # unary-unary(In a single call, the client can only send request once, and the server can # only respond once.) def SimpleMethod(self, request, context): - print("SimpleMethod called by client(%d) the message: %s" % (request.client_id, request.request_data)) - response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server SimpleMethod Ok!!!!") + print("SimpleMethod called by client(%d) the message: %s" % + (request.client_id, request.request_data)) + response = demo_pb2.Response( + server_id=SERVER_ID, + response_data="Python server SimpleMethod Ok!!!!") return response # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) @@ -26,22 +28,27 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): def ClientStreamingMethod(self, request_iterator, context): print("ClientStreamingMethod called by client...") for request in request_iterator: - print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) - response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server ClientStreamingMethod ok") + print("recv from client(%d), message= %s" % (request.client_id, + request.request_data)) + response = demo_pb2.Response( + server_id=SERVER_ID, + response_data="Python server ClientStreamingMethod ok") return response # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) # unary-stream (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def ServerStreamingMethod(self, request, context): - print("ServerStreamingMethod called by client(%d), message= %s" % (request.client_id, request.request_data)) + print("ServerStreamingMethod called by client(%d), message= %s" % + (request.client_id, request.request_data)) # 创建一个生成器 # create a generator def response_messages(): for i in range(5): - response = demo_pb2.Response(server_id=SERVER_ID, - response_data=("send by Python server, message=%d" % i)) + response = demo_pb2.Response( + server_id=SERVER_ID, + response_data=("send by Python server, message=%d" % i)) yield response return response_messages() @@ -56,13 +63,16 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # Open a sub thread to receive data def parse_request(): for request in request_iterator: - print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) + print("recv from client(%d), message= %s" % + (request.client_id, request.request_data)) t = Thread(target=parse_request) t.start() for i in range(5): - yield demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message= %d" % i)) + yield demo_pb2.Response( + server_id=SERVER_ID, + response_data=("send by Python server, message= %d" % i)) t.join() From 1859799ee326f06768ed7d0845cc1f0268a74d47 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:55:01 +0800 Subject: [PATCH 067/176] Fix: update README because code reformat by YAPF script --- examples/python/data_transmission/README.cn.md | 14 +++++++------- examples/python/data_transmission/README.en.md | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/python/data_transmission/README.cn.md b/examples/python/data_transmission/README.cn.md index c5cbb71c41d..812a8bbb7d6 100644 --- a/examples/python/data_transmission/README.cn.md +++ b/examples/python/data_transmission/README.cn.md @@ -6,7 +6,7 @@ 在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应 - `client.py - line:13 - simple_method` + `client.py - line:14 - simple_method` `server.py - line:17 - SimpleMethod` @@ -14,23 +14,23 @@ 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应 - `clien.py - line:24 - client_streaming_method ` + `clien.py - line:27 - client_streaming_method ` - `server.py - line:25 - ClientStreamingMethod` + `server.py - line:28 - ClientStreamingMethod` - #### 服务端流模式 在一次调用中, 客户端只能向服务器传输一次请求数据, 但是服务器可以多次返回响应 - `clien.py - line:42 - server_streaming_method` + `clien.py - line:48 - server_streaming_method` - `server.py - line:35 - ServerStreamingMethod` + `server.py - line:41 - ServerStreamingMethod` - #### 双向流模式 在一次调用中, 客户端和服务器都可以向对方多次收发数据 - `client.py - line:55 - bidirectional_streaming_method` + `client.py - line:63 - bidirectional_streaming_method` - `server.py - line:51 - BidirectionalStreamingMethod` + `server.py - line:59 - BidirectionalStreamingMethod` diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md index f87682f2038..fb834ab80c9 100644 --- a/examples/python/data_transmission/README.en.md +++ b/examples/python/data_transmission/README.en.md @@ -6,31 +6,31 @@ Four ways of data transmission when gRPC is used in Python. [Offical Guide]( Date: Fri, 30 Aug 2019 11:36:46 -0700 Subject: [PATCH 068/176] Don't run time_jump_test under sanitizers --- test/cpp/common/time_jump_test.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/cpp/common/time_jump_test.cc b/test/cpp/common/time_jump_test.cc index 86bf012f7c0..ea6711dfce3 100644 --- a/test/cpp/common/time_jump_test.cc +++ b/test/cpp/common/time_jump_test.cc @@ -53,10 +53,20 @@ void run_cmd(const char* cmd) { class TimeJumpTest : public ::testing::TestWithParam { protected: - void SetUp() override { grpc_init(); } + void SetUp() override { + // Skip test if slowdown factor > 1 + if (grpc_test_slowdown_factor() != 1) { + GTEST_SKIP(); + } else { + grpc_init(); + } + } void TearDown() override { - run_cmd("sudo sntp -sS pool.ntp.org"); - grpc_shutdown_blocking(); + // Skip test if slowdown factor > 1 + if (grpc_test_slowdown_factor() == 1) { + run_cmd("sudo sntp -sS pool.ntp.org"); + grpc_shutdown_blocking(); + } } const int kWaitTimeMs = 1500; From d6498800441e68e22854ee7daf94cadb709ffac9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 30 Aug 2019 16:39:02 -0700 Subject: [PATCH 069/176] Add strip_prefix to python protoc plugin and py_grpc_library --- bazel/python_rules.bzl | 11 +++++- examples/python/debug/get_stats.py | 9 ++--- src/compiler/generator_helpers.h | 9 ++--- src/compiler/python_generator.cc | 35 ++++++++++++++++--- .../grpc_channelz/v1/BUILD.bazel | 1 + .../grpc_channelz/v1/channelz.py | 9 ++--- .../grpc_health/v1/BUILD.bazel | 1 + .../grpc_health/v1/health.py | 9 ++--- .../grpc_reflection/v1alpha/BUILD.bazel | 1 + .../grpc_reflection/v1alpha/reflection.py | 11 ++---- .../tests/channelz/_channelz_servicer_test.py | 12 ++----- .../health_check/_health_servicer_test.py | 12 ++----- .../reflection/_reflection_servicer_test.py | 12 ++----- 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 12f51f8b172..0cdd2b9739c 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -93,11 +93,13 @@ def _generate_pb2_grpc_src_impl(context): proto_root = get_proto_root(context.label.workspace_root) out_files = declare_out_files(protos, context, _GENERATED_GRPC_PROTO_FORMAT) + plugin_flags = ["grpc_2_0"] + context.attr.strip_prefixes + arguments = [] tools = [context.executable._protoc, context.executable._plugin] arguments += get_plugin_args( context.executable._plugin, - [], + plugin_flags, context.genfiles_dir.path, False, ) @@ -127,6 +129,7 @@ _generate_pb2_grpc_src = rule( allow_empty = False, providers = [ProtoInfo], ), + "strip_prefixes": attr.string_list(), "_plugin": attr.label( executable = True, providers = ["files_to_run"], @@ -147,6 +150,7 @@ def py_grpc_library( name, srcs, deps, + strip_prefixes = [], **kwargs): """Generate python code for gRPC services defined in a protobuf. @@ -156,6 +160,10 @@ def py_grpc_library( schema of the service. deps: (List of `labels`) a single py_proto_library target for the proto_library in `srcs`. + strip_prefixes: (List of `strings`) If provided, this prefix will be + stripped from the beginning of foo_pb2 modules imported by the + generated stubs. This is useful in combination with the `imports` + attribute of the `py_library` rule. """ codegen_grpc_target = "_{}_grpc_codegen".format(name) if len(srcs) != 1: @@ -167,6 +175,7 @@ def py_grpc_library( _generate_pb2_grpc_src( name = codegen_grpc_target, deps = srcs, + strip_prefixes = strip_prefixes, **kwargs ) diff --git a/examples/python/debug/get_stats.py b/examples/python/debug/get_stats.py index 2da51d0efcf..d8cb08df55e 100644 --- a/examples/python/debug/get_stats.py +++ b/examples/python/debug/get_stats.py @@ -21,13 +21,8 @@ import logging import argparse import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc -except ImportError: - from grpc_channelz.v1 import channelz_pb2 - from grpc_channelz.v1 import channelz_pb2_grpc +from grpc_channelz.v1 import channelz_pb2 +from grpc_channelz.v1 import channelz_pb2_grpc def run(addr): diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h index 747096f0657..0f261fb5a83 100644 --- a/src/compiler/generator_helpers.h +++ b/src/compiler/generator_helpers.h @@ -168,10 +168,11 @@ inline MethodType GetMethodType( inline void Split(const grpc::string& s, char delim, std::vector* append_to) { - std::istringstream iss(s); - grpc::string piece; - while (std::getline(iss, piece)) { - append_to->push_back(piece); + auto current = s.begin(); + while (current <= s.end()) { + auto next = std::find(current, s.end(), delim); + append_to->emplace_back(current, next); + current = next + 1; } } diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 705aef1c884..7afb2c532e0 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -756,6 +756,28 @@ static bool GenerateGrpc(GeneratorContext* context, PrivateGenerator& generator, } } +static bool ParseParameters(const grpc::string& parameter, + grpc::string* grpc_version, + std::vector* strip_prefixes, + grpc::string* error) { + std::vector comma_delimited_parameters; + grpc_generator::Split(parameter, ',', &comma_delimited_parameters); + if (comma_delimited_parameters.empty()) { + *grpc_version = "grpc_2_0"; + } else if (comma_delimited_parameters.size() == 1) { + *grpc_version = comma_delimited_parameters[0]; + } else if (comma_delimited_parameters.size() == 2) { + *grpc_version = comma_delimited_parameters[0]; + std::copy(comma_delimited_parameters.begin() + 1, + comma_delimited_parameters.end(), + std::back_inserter(*strip_prefixes)); + } else { + *error = "--grpc_python_out received too many comma-delimited parameters."; + return false; + } + return true; +} + bool PythonGrpcGenerator::Generate(const FileDescriptor* file, const grpc::string& parameter, GeneratorContext* context, @@ -778,14 +800,19 @@ bool PythonGrpcGenerator::Generate(const FileDescriptor* file, generator_file_name = file->name(); ProtoBufFile pbfile(file); - PrivateGenerator generator(config_, &pbfile); - if (parameter == "" || parameter == "grpc_2_0") { + grpc::string grpc_version; + GeneratorConfiguration extended_config(config_); + bool success = ParseParameters(parameter, &grpc_version, + &(extended_config.prefixes_to_filter), error); + PrivateGenerator generator(extended_config, &pbfile); + if (!success) return false; + if (grpc_version == "grpc_2_0") { return GenerateGrpc(context, generator, pb2_grpc_file_name, true); - } else if (parameter == "grpc_1_0") { + } else if (grpc_version == "grpc_1_0") { return GenerateGrpc(context, generator, pb2_grpc_file_name, true) && GenerateGrpc(context, generator, pb2_file_name, false); } else { - *error = "Invalid parameter '" + parameter + "'."; + *error = "Invalid grpc version '" + grpc_version + "'."; return false; } } diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel index 5f4e512e9f4..c034297ff2d 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel +++ b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel @@ -10,6 +10,7 @@ py_grpc_library( name = "channelz_py_pb2_grpc", srcs = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], deps = [":channelz_py_pb2"], + strip_prefixes = ["src.python.grpcio_channelz."], ) py_library( diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py index 965797f89ec..00eca311dc1 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py +++ b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py @@ -16,13 +16,8 @@ import grpc from grpc._cython import cygrpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 as _channelz_pb2 - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc as _channelz_pb2_grpc -except ImportError: - import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 - import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc +import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 +import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc from google.protobuf import json_format diff --git a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel index 62a44df7707..a3e2c7dfe3d 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel +++ b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel @@ -10,6 +10,7 @@ py_grpc_library( name = "health_py_pb2_grpc", srcs = ["//src/proto/grpc/health/v1:health_proto_descriptor",], deps = [":health_py_pb2"], + strip_prefixes = ["src.python.grpcio_health_checking."], ) py_library( diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py index a0d55570990..15494fafdbc 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py @@ -18,13 +18,8 @@ import threading import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 as _health_pb2 - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc -except ImportError: - from grpc_health.v1 import health_pb2 as _health_pb2 - from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc +from grpc_health.v1 import health_pb2 as _health_pb2 +from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index 10077fd9568..bad54d06c63 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -12,6 +12,7 @@ py_grpc_library( name = "reflection_py_pb2_grpc", srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], deps = ["reflection_py_pb2"], + strip_prefixes = ["src.python.grpcio_reflection."], ) py_library( diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index 61153d9d625..6df1a364269 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -17,15 +17,8 @@ import grpc from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pool -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_reflection.grpc_reflection.v1alpha \ - import reflection_pb2 as _reflection_pb2 - from src.python.grpcio_reflection.grpc_reflection.v1alpha \ - import reflection_pb2_grpc as _reflection_pb2_grpc -except ImportError: - from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 - from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc +from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 +from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc _POOL = descriptor_pool.Default() SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[ diff --git a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py index f2357a4e4a3..48d25e99e35 100644 --- a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py +++ b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py @@ -19,15 +19,9 @@ from concurrent import futures import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc -except ImportError: - from grpc_channelz.v1 import channelz - from grpc_channelz.v1 import channelz_pb2 - from grpc_channelz.v1 import channelz_pb2_grpc +from grpc_channelz.v1 import channelz +from grpc_channelz.v1 import channelz_pb2 +from grpc_channelz.v1 import channelz_pb2_grpc from tests.unit import test_common from tests.unit.framework.common import test_constants diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py index 428806c71b0..8faffb448c3 100644 --- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py +++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py @@ -20,15 +20,9 @@ import unittest import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_health_checking.grpc_health.v1 import health - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc -except ImportError: - from grpc_health.v1 import health - from grpc_health.v1 import health_pb2 - from grpc_health.v1 import health_pb2_grpc +from grpc_health.v1 import health +from grpc_health.v1 import health_pb2 +from grpc_health.v1 import health_pb2_grpc from tests.unit import test_common from tests.unit import thread_pool diff --git a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py index e45f98abec6..169e55022da 100644 --- a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py +++ b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py @@ -17,15 +17,9 @@ import unittest import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2 - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2_grpc -except ImportError: - from grpc_reflection.v1alpha import reflection - from grpc_reflection.v1alpha import reflection_pb2 - from grpc_reflection.v1alpha import reflection_pb2_grpc +from grpc_reflection.v1alpha import reflection +from grpc_reflection.v1alpha import reflection_pb2 +from grpc_reflection.v1alpha import reflection_pb2_grpc from google.protobuf import descriptor_pool from google.protobuf import descriptor_pb2 From 358676db444d84db7412c695101c6b2f0e9774fd Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 30 Aug 2019 17:53:41 -0700 Subject: [PATCH 070/176] Alright. We'll do our own thing then --- src/compiler/generator_helpers.h | 9 ++++----- src/compiler/python_generator.cc | 2 +- src/compiler/python_generator_helpers.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h index 0f261fb5a83..747096f0657 100644 --- a/src/compiler/generator_helpers.h +++ b/src/compiler/generator_helpers.h @@ -168,11 +168,10 @@ inline MethodType GetMethodType( inline void Split(const grpc::string& s, char delim, std::vector* append_to) { - auto current = s.begin(); - while (current <= s.end()) { - auto next = std::find(current, s.end(), delim); - append_to->emplace_back(current, next); - current = next + 1; + std::istringstream iss(s); + grpc::string piece; + while (std::getline(iss, piece)) { + append_to->push_back(piece); } } diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 7afb2c532e0..0e76c95aed4 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -761,7 +761,7 @@ static bool ParseParameters(const grpc::string& parameter, std::vector* strip_prefixes, grpc::string* error) { std::vector comma_delimited_parameters; - grpc_generator::Split(parameter, ',', &comma_delimited_parameters); + grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); if (comma_delimited_parameters.empty()) { *grpc_version = "grpc_2_0"; } else if (comma_delimited_parameters.size() == 1) { diff --git a/src/compiler/python_generator_helpers.h b/src/compiler/python_generator_helpers.h index 171dd730a24..862292db475 100644 --- a/src/compiler/python_generator_helpers.h +++ b/src/compiler/python_generator_helpers.h @@ -136,6 +136,16 @@ StringVector get_all_comments(const DescriptorType* descriptor) { return comments; } +inline void Split(const grpc::string& s, char delim, + std::vector* append_to) { + auto current = s.begin(); + while (current <= s.end()) { + auto next = std::find(current, s.end(), delim); + append_to->emplace_back(current, next); + current = next + 1; + } +} + } // namespace } // namespace grpc_python_generator From e6fe85bc2ddb12bf2960fd27dc6f90a0e29d3ec5 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 30 Aug 2019 18:20:49 -0700 Subject: [PATCH 071/176] Properly handle default case --- src/compiler/python_generator.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 0e76c95aed4..f553d9e7a3c 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -762,7 +762,8 @@ static bool ParseParameters(const grpc::string& parameter, grpc::string* error) { std::vector comma_delimited_parameters; grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); - if (comma_delimited_parameters.empty()) { + if (comma_delimited_parameters.size() == 1 && + comma_delimited_parameters.empty()) { *grpc_version = "grpc_2_0"; } else if (comma_delimited_parameters.size() == 1) { *grpc_version = comma_delimited_parameters[0]; From e5e2b79c01cec333257ea5ec011128348e6d2a88 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sat, 31 Aug 2019 22:10:33 -0700 Subject: [PATCH 072/176] GRPCTransportId -> GRPCTransportID --- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 2 +- src/objective-c/GRPCClient/GRPCCallOptions.h | 4 ++-- src/objective-c/GRPCClient/GRPCCallOptions.m | 8 ++++---- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 4 ++-- src/objective-c/GRPCClient/GRPCTransport.h | 10 +++++----- src/objective-c/GRPCClient/GRPCTransport.m | 14 +++++++------- src/objective-c/GRPCClient/GRPCTypes.h | 2 +- .../GRPCClient/private/GRPCTransport+Private.h | 4 ++-- .../GRPCClient/private/GRPCTransport+Private.m | 4 ++-- .../CronetTests/InteropTestsRemoteWithCronet.m | 2 +- src/objective-c/tests/InteropTests/InteropTests.h | 2 +- src/objective-c/tests/InteropTests/InteropTests.m | 2 +- .../InteropTests/InteropTestsLocalCleartext.m | 2 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 2 +- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index d107ada3672..10cea963631 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -22,7 +22,7 @@ typedef struct stream_engine stream_engine; // Transport id for Cronet transport -extern const GRPCTransportId gGRPCCoreCronetId; +extern const GRPCTransportID gGRPCCoreCronetId; // Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index a732208e1f6..33b09136b33 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,7 @@ #import "GRPCCall+Cronet.h" -const GRPCTransportId gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; +const GRPCTransportID gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; static BOOL useCronet = NO; static stream_engine *globalCronetEngine; diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index e4261b5b5f9..adb4ecad48e 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -161,7 +161,7 @@ NS_ASSUME_NONNULL_BEGIN * * This is currently an experimental option. */ -@property(readonly) GRPCTransportId transport; +@property(readonly) GRPCTransportID transport; /** * Override the hostname during the TLS hostname validation process. @@ -339,7 +339,7 @@ NS_ASSUME_NONNULL_BEGIN * * An interceptor must not change the value of this option. */ -@property(readwrite) GRPCTransportId transport; +@property(readwrite) GRPCTransportID transport; /** * Override the hostname during the TLS hostname validation process. diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 7f88098eb6f..f9044ddcd34 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -42,7 +42,7 @@ static NSString *const kDefaultPEMCertificateChain = nil; static NSString *const kDefaultOauth2AccessToken = nil; static const id kDefaultAuthTokenProvider = nil; static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL; -static const GRPCTransportId kDefaultTransport = NULL; +static const GRPCTransportID kDefaultTransport = NULL; static NSString *const kDefaultHostNameOverride = nil; static const id kDefaultLogContext = nil; static NSString *const kDefaultChannelPoolDomain = nil; @@ -82,7 +82,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_PEMPrivateKey; NSString *_PEMCertificateChain; GRPCTransportType _transportType; - GRPCTransportId _transport; + GRPCTransportID _transport; NSString *_hostNameOverride; id _logContext; NSString *_channelPoolDomain; @@ -166,7 +166,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType - transport:(GRPCTransportId)transport + transport:(GRPCTransportID)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -553,7 +553,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _transportType = transportType; } -- (void)setTransport:(GRPCTransportId)transport { +- (void)setTransport:(GRPCTransportID)transport { _transport = transport; } diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 509749769b3..1794ef4b892 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithFactories:(nullable NSArray> *)factories previousInterceptor:(nullable id)previousInterceptor - transportId:(GRPCTransportId)transportId; + transportId:(GRPCTransportID)transportId; /** * Notify the manager that the interceptor has shut down and the manager should release references diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index a7ffe05bddc..abada5a80c1 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -31,13 +31,13 @@ GRPCInterceptor *_thisInterceptor; dispatch_queue_t _dispatchQueue; NSArray> *_factories; - GRPCTransportId _transportId; + GRPCTransportID _transportId; BOOL _shutDown; } - (instancetype)initWithFactories:(NSArray> *)factories previousInterceptor:(id)previousInterceptor - transportId:(nonnull GRPCTransportId)transportId { + transportId:(nonnull GRPCTransportID)transportId { if ((self = [super init])) { if (factories.count == 0) { [NSException raise:NSInternalInconsistencyException diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index d5637922152..d9f341d08a3 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -29,15 +29,15 @@ NS_ASSUME_NONNULL_BEGIN * by gRPC by default unless explicitly excluded. */ extern const struct GRPCDefaultTransportImplList { - const GRPCTransportId core_secure; - const GRPCTransportId core_insecure; + const GRPCTransportID core_secure; + const GRPCTransportID core_insecure; } GRPCDefaultTransportImplList; /** Returns whether two transport id's are identical. */ -BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); +BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs); /** Returns the hash value of a transport id. */ -NSUInteger TransportIdHash(GRPCTransportId); +NSUInteger TransportIdHash(GRPCTransportID); #pragma mark Transport and factory @@ -66,7 +66,7 @@ NSUInteger TransportIdHash(GRPCTransportId); * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory * object to create the corresponding transport instance. */ -- (void)registerTransportWithId:(GRPCTransportId)transportId +- (void)registerTransportWithId:(GRPCTransportID)transportId factory:(id)factory; @end diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 439acfb9cc2..966dc50d64d 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -18,24 +18,24 @@ #import "GRPCTransport.h" -static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; -static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; +static const GRPCTransportID gGRPCCoreSecureId = "io.grpc.transport.core.secure"; +static const GRPCTransportID gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; -static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; +static const GRPCTransportID gDefaultTransportId = gGRPCCoreSecureId; static GRPCTransportRegistry *gTransportRegistry = nil; static dispatch_once_t initTransportRegistry; -BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs) { +BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs) { // Directly comparing pointers works because we require users to use the id provided by each // implementation, not coming up with their own string. return lhs == rhs; } -NSUInteger TransportIdHash(GRPCTransportId transportId) { +NSUInteger TransportIdHash(GRPCTransportID transportId) { if (transportId == NULL) { transportId = gDefaultTransportId; } @@ -66,7 +66,7 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { return self; } -- (void)registerTransportWithId:(GRPCTransportId)transportId +- (void)registerTransportWithId:(GRPCTransportID)transportId factory:(id)factory { NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", @@ -83,7 +83,7 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { } } -- (id)getTransportFactoryWithId:(GRPCTransportId)transportId { +- (id)getTransportFactoryWithId:(GRPCTransportID)transportId { if (transportId == NULL) { if (_defaultFactory == nil) { [NSException raise:NSInvalidArgumentException diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index c804bca4eaa..8d434851aa6 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -171,7 +171,7 @@ extern NSString* _Nonnull const kGRPCHeadersKey; extern NSString* _Nonnull const kGRPCTrailersKey; /** The id of a transport implementation. */ -typedef char* _Nonnull GRPCTransportId; +typedef char* _Nonnull GRPCTransportID; /** * Implement this protocol to provide a token to gRPC when a call is initiated. diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 2dc7357c363..075d185e5d7 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -31,13 +31,13 @@ NS_ASSUME_NONNULL_BEGIN * registered with the registry, the default transport factory (core + secure) is returned. If the * default transport does not exist, an exception is thrown. */ -- (id)getTransportFactoryWithId:(GRPCTransportId)transportId; +- (id)getTransportFactoryWithId:(GRPCTransportID)transportId; @end @interface GRPCTransportManager : NSObject -- (instancetype)initWithTransportId:(GRPCTransportId)transportId +- (instancetype)initWithTransportId:(GRPCTransportID)transportId previousInterceptor:(id)previousInterceptor; /** diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 9072f7afbe2..5e9c2b52ab4 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -21,13 +21,13 @@ #import @implementation GRPCTransportManager { - GRPCTransportId _transportId; + GRPCTransportID _transportId; GRPCTransport *_transport; id _previousInterceptor; dispatch_queue_t _dispatchQueue; } -- (instancetype)initWithTransportId:(GRPCTransportId)transportId +- (instancetype)initWithTransportId:(GRPCTransportID)transportId previousInterceptor:(id)previousInterceptor { if ((self = [super init])) { id factory = diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index aa1af301b96..f4cd9e064d2 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -52,7 +52,7 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteSSLHost; } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return gGRPCCoreCronetId; } diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index a4adecd5415..4ebce5c961d 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -59,7 +59,7 @@ * The transport to be used. The base implementation returns NULL. Subclasses should override to * appropriate settings. */ -+ (GRPCTransportId)transport; ++ (GRPCTransportID)transport; /** * The root certificates to be used. The base implementation returns nil. Subclasses should override diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 21198f7bad9..0c7ef44e0fa 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -404,7 +404,7 @@ static dispatch_once_t initGlobalInterceptorFactory; return GRPCTransportTypeChttp2BoringSSL; } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return NULL; } diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index 2e638099e1e..23f39401230 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -61,7 +61,7 @@ static int32_t kLocalInteropServerOverhead = 10; [GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return GRPCDefaultTransportImplList.core_insecure; } diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index 30d8f4c34af..9c8ce7fe810 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -57,7 +57,7 @@ static int32_t kLocalInteropServerOverhead = 10; return kLocalInteropServerOverhead; // bytes } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return GRPCDefaultTransportImplList.core_secure; } From 8274502af8142a4581a199d94f451e1efe8c1c91 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Sun, 1 Sep 2019 23:01:30 -0700 Subject: [PATCH 073/176] Windows's STACKFRAME Frame Addr should be RBP, the base pointer, not RSP, the stack pointer. This is documented here: https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/ns-dbghelp-stackframe with the comment "AddrFrame x64: The frame pointer is RBP or RDI." Note that this is also what StackWalker uses: https://github.com/JochenKalmbach/StackWalker#initializing-the-stackframe64 and what Chromium uses: https://codesearch.chromium.org/chromium/src/v8/src/base/debug/stack_trace_win.cc?l=200&rcl=69d20d247f62a3378d15ce0956ed8bf9665e6a44 release notes: no --- test/core/util/test_config.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 5033dc7b66a..2216328dc08 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -114,7 +114,7 @@ static void print_stack_from_context(CONTEXT c) { imageType = IMAGE_FILE_MACHINE_AMD64; s.AddrPC.Offset = c.Rip; s.AddrPC.Mode = AddrModeFlat; - s.AddrFrame.Offset = c.Rsp; + s.AddrFrame.Offset = c.Rbp; s.AddrFrame.Mode = AddrModeFlat; s.AddrStack.Offset = c.Rsp; s.AddrStack.Mode = AddrModeFlat; From 406a2473a60a3ef78f73344724fabd20024775f2 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 2 Sep 2019 19:36:11 -0700 Subject: [PATCH 074/176] Enable stale bot --- .github/stale.yml | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000000..ff9049ddb96 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,59 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 180 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: 1 + +# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) +onlyLabels: [] + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - "disposition/never stale" + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: "disposition/stale" + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue/PR has been automatically marked as stale because it has not had any update (including + commits, comments, labels, milestones, etc) for 180 days. It will be closed automatically if no + further update occurs in 1 day. Thank you for your contributions! + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Comment to post when closing a stale Issue or Pull Request. +# closeComment: > +# Your comment here. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Limit to only `issues` or `pulls` +# only: issues + +# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': +# pulls: +# daysUntilStale: 30 +# markComment: > +# This pull request has been automatically marked as stale because it has not had +# recent activity. It will be closed if no further activity occurs. Thank you +# for your contributions. + +# issues: +# exemptLabels: +# - confirmed \ No newline at end of file From 647a9701f715a805da2bcefce49f8757c9dbcc9e Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 3 Sep 2019 09:23:56 -0700 Subject: [PATCH 075/176] Update debian:jessie docker to pin bundler version --- tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile index 57d6771f9db..077aa16a057 100644 --- a/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile @@ -16,4 +16,4 @@ FROM debian:jessie RUN apt-get update && apt-get install -y ruby-full -RUN gem install bundler +RUN gem install bundler -v 1.17.3 --no-document diff --git a/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile index 04cfa51069c..48fba1fc2a2 100644 --- a/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile @@ -16,4 +16,4 @@ FROM i386/debian:jessie RUN apt-get update && apt-get install -y ruby-full -RUN gem install bundler +RUN gem install bundler -v 1.17.3 --no-document From 49b9fb2b3ca8cc048db476b4b7aedb703dbb1734 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 12 Aug 2019 16:43:24 -0700 Subject: [PATCH 076/176] Enable C++ standard library --- CMakeLists.txt | 1034 --------------------- Makefile | 418 ++++----- config.m4 | 2 + include/grpc/impl/codegen/port_platform.h | 3 +- src/php/ext/grpc/config.m4 | 3 +- src/ruby/ext/grpc/rb_enable_cpp.cc | 22 + templates/CMakeLists.txt.template | 20 - templates/Makefile.template | 4 +- templates/config.m4.template | 2 + 9 files changed, 240 insertions(+), 1268 deletions(-) create mode 100644 src/ruby/ext/grpc/rb_enable_cpp.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index c5cdfff7f56..599f1441583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,11 +125,6 @@ if(gRPC_BACKWARDS_COMPATIBILITY_MODE) endif() if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) - # C core has C++ source code, but should not depend on libstc++ (for better portability). - # We need to use a few tricks to convince cmake to do that. - # https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc - set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") - # Exceptions and RTTI must be off to avoid dependency on libstdc++ set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti) else() set(_gRPC_CORE_NOSTDCXX_FLAGS "") @@ -797,12 +792,6 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(address_sorting PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(address_sorting PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(address_sorting ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -851,12 +840,6 @@ target_include_directories(alts_test_util PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alts_test_util PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(alts_test_util PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(alts_test_util ${_gRPC_SSL_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -935,12 +918,6 @@ target_include_directories(gpr PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(gpr PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(gpr ${_gRPC_ALLTARGETS_LIBRARIES} ) @@ -1404,12 +1381,6 @@ target_include_directories(grpc PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_SSL_LIBRARIES} @@ -1824,12 +1795,6 @@ target_include_directories(grpc_cronet PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_cronet PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_cronet PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_cronet ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_SSL_LIBRARIES} @@ -2181,12 +2146,6 @@ target_include_directories(grpc_test_util PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_test_util PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_test_util PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_test_util ${_gRPC_ALLTARGETS_LIBRARIES} gpr @@ -2535,12 +2494,6 @@ target_include_directories(grpc_test_util_unsecure PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_test_util_unsecure PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_test_util_unsecure PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_test_util_unsecure ${_gRPC_ALLTARGETS_LIBRARIES} gpr @@ -2929,12 +2882,6 @@ target_include_directories(grpc_unsecure PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_unsecure PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_unsecure PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_unsecure ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} @@ -3032,12 +2979,6 @@ target_include_directories(reconnect_server PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(reconnect_server PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(reconnect_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(reconnect_server ${_gRPC_ALLTARGETS_LIBRARIES} test_tcp_server @@ -3080,12 +3021,6 @@ target_include_directories(test_tcp_server PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(test_tcp_server PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(test_tcp_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(test_tcp_server ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util @@ -5445,12 +5380,6 @@ target_include_directories(grpc_csharp_ext PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_csharp_ext PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_csharp_ext PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_csharp_ext ${_gRPC_ALLTARGETS_LIBRARIES} grpc @@ -5548,12 +5477,6 @@ target_include_directories(bad_ssl_test_server PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_ssl_test_server PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(bad_ssl_test_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(bad_ssl_test_server ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util @@ -5674,12 +5597,6 @@ target_include_directories(end2end_tests PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(end2end_tests PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(end2end_tests PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(end2end_tests ${_gRPC_SSL_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -5800,12 +5717,6 @@ target_include_directories(end2end_nosec_tests PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(end2end_nosec_tests PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(end2end_nosec_tests PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(end2end_nosec_tests ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util_unsecure @@ -5845,11 +5756,6 @@ target_link_libraries(algorithm_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(algorithm_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(algorithm_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5881,11 +5787,6 @@ target_link_libraries(alloc_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alloc_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(alloc_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5917,11 +5818,6 @@ target_link_libraries(alpn_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alpn_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(alpn_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5953,11 +5849,6 @@ target_link_libraries(arena_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(arena_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(arena_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5989,11 +5880,6 @@ target_link_libraries(avl_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(avl_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(avl_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6026,11 +5912,6 @@ target_link_libraries(bad_server_response_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_server_response_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bad_server_response_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6061,11 +5942,6 @@ target_link_libraries(bin_decoder_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bin_decoder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bin_decoder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6096,11 +5972,6 @@ target_link_libraries(bin_encoder_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bin_encoder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bin_encoder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6133,11 +6004,6 @@ target_link_libraries(buffer_list_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(buffer_list_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(buffer_list_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6170,11 +6036,6 @@ target_link_libraries(channel_create_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(channel_create_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(channel_create_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -6204,11 +6065,6 @@ target_link_libraries(check_epollexclusive gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(check_epollexclusive PROPERTIES LINKER_LANGUAGE C) - target_compile_options(check_epollexclusive PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) @@ -6239,11 +6095,6 @@ target_link_libraries(chttp2_hpack_encoder_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(chttp2_hpack_encoder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(chttp2_hpack_encoder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6275,11 +6126,6 @@ target_link_libraries(chttp2_stream_map_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(chttp2_stream_map_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(chttp2_stream_map_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6311,11 +6157,6 @@ target_link_libraries(chttp2_varint_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(chttp2_varint_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(chttp2_varint_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6348,11 +6189,6 @@ target_link_libraries(close_fd_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(close_fd_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(close_fd_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6385,11 +6221,6 @@ target_link_libraries(cmdline_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(cmdline_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(cmdline_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6421,11 +6252,6 @@ target_link_libraries(combiner_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(combiner_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(combiner_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6457,11 +6283,6 @@ target_link_libraries(compression_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(compression_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(compression_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6493,11 +6314,6 @@ target_link_libraries(concurrent_connectivity_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(concurrent_connectivity_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(concurrent_connectivity_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6529,11 +6345,6 @@ target_link_libraries(connection_refused_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(connection_refused_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(connection_refused_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6565,11 +6376,6 @@ target_link_libraries(dns_resolver_connectivity_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_connectivity_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_connectivity_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6601,11 +6407,6 @@ target_link_libraries(dns_resolver_cooldown_using_ares_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_cooldown_using_ares_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_cooldown_using_ares_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6637,11 +6438,6 @@ target_link_libraries(dns_resolver_cooldown_using_native_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_cooldown_using_native_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_cooldown_using_native_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6673,11 +6469,6 @@ target_link_libraries(dns_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6710,11 +6501,6 @@ target_link_libraries(dualstack_socket_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dualstack_socket_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dualstack_socket_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6747,11 +6533,6 @@ target_link_libraries(endpoint_pair_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(endpoint_pair_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(endpoint_pair_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6783,11 +6564,6 @@ target_link_libraries(error_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(error_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(error_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6820,11 +6596,6 @@ target_link_libraries(ev_epollex_linux_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(ev_epollex_linux_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(ev_epollex_linux_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6857,11 +6628,6 @@ target_link_libraries(fake_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fake_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fake_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6895,11 +6661,6 @@ target_link_libraries(fake_transport_security_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fake_transport_security_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fake_transport_security_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6933,11 +6694,6 @@ target_link_libraries(fd_conservation_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fd_conservation_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fd_conservation_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6971,11 +6727,6 @@ target_link_libraries(fd_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fd_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fd_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7008,11 +6759,6 @@ target_link_libraries(fling_client gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_client PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_client PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7044,11 +6790,6 @@ target_link_libraries(fling_server gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_server PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7081,11 +6822,6 @@ target_link_libraries(fling_stream_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_stream_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_stream_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7119,11 +6855,6 @@ target_link_libraries(fling_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7157,11 +6888,6 @@ target_link_libraries(fork_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fork_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fork_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7195,11 +6921,6 @@ target_link_libraries(goaway_server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(goaway_server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(goaway_server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7232,11 +6953,6 @@ target_link_libraries(gpr_cpu_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_cpu_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_cpu_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7268,11 +6984,6 @@ target_link_libraries(gpr_env_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_env_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_env_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7304,11 +7015,6 @@ target_link_libraries(gpr_host_port_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_host_port_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_host_port_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7340,11 +7046,6 @@ target_link_libraries(gpr_log_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_log_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_log_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7376,11 +7077,6 @@ target_link_libraries(gpr_manual_constructor_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_manual_constructor_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_manual_constructor_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7412,11 +7108,6 @@ target_link_libraries(gpr_mpscq_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_mpscq_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_mpscq_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7448,11 +7139,6 @@ target_link_libraries(gpr_spinlock_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_spinlock_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_spinlock_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7484,11 +7170,6 @@ target_link_libraries(gpr_string_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_string_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_string_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7520,11 +7201,6 @@ target_link_libraries(gpr_sync_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_sync_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_sync_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7556,11 +7232,6 @@ target_link_libraries(gpr_thd_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_thd_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_thd_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7592,11 +7263,6 @@ target_link_libraries(gpr_time_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_time_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_time_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7628,11 +7294,6 @@ target_link_libraries(gpr_tls_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_tls_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_tls_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7664,11 +7325,6 @@ target_link_libraries(gpr_useful_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_useful_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_useful_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7700,11 +7356,6 @@ target_link_libraries(grpc_auth_context_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_auth_context_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_auth_context_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7736,11 +7387,6 @@ target_link_libraries(grpc_b64_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_b64_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_b64_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7772,11 +7418,6 @@ target_link_libraries(grpc_byte_buffer_reader_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_byte_buffer_reader_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_byte_buffer_reader_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7808,11 +7449,6 @@ target_link_libraries(grpc_channel_args_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_channel_args_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_channel_args_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7844,11 +7480,6 @@ target_link_libraries(grpc_channel_stack_builder_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_channel_stack_builder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_channel_stack_builder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7880,11 +7511,6 @@ target_link_libraries(grpc_channel_stack_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_channel_stack_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_channel_stack_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7916,11 +7542,6 @@ target_link_libraries(grpc_completion_queue_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_completion_queue_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_completion_queue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7952,11 +7573,6 @@ target_link_libraries(grpc_completion_queue_threading_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_completion_queue_threading_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_completion_queue_threading_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7988,11 +7604,6 @@ target_link_libraries(grpc_control_plane_credentials_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_control_plane_credentials_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_control_plane_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -8024,11 +7635,6 @@ target_link_libraries(grpc_create_jwt gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_create_jwt PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_create_jwt PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) @@ -8059,11 +7665,6 @@ target_link_libraries(grpc_credentials_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_credentials_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8095,11 +7696,6 @@ target_link_libraries(grpc_ipv6_loopback_available_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_ipv6_loopback_available_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_ipv6_loopback_available_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8132,11 +7728,6 @@ target_link_libraries(grpc_json_token_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_json_token_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_json_token_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8169,11 +7760,6 @@ target_link_libraries(grpc_jwt_verifier_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_jwt_verifier_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_jwt_verifier_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -8204,11 +7790,6 @@ target_link_libraries(grpc_print_google_default_creds_token gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_print_google_default_creds_token PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_print_google_default_creds_token PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) @@ -8239,11 +7820,6 @@ target_link_libraries(grpc_security_connector_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_security_connector_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_security_connector_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8275,11 +7851,6 @@ target_link_libraries(grpc_ssl_credentials_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_ssl_credentials_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_ssl_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -8310,11 +7881,6 @@ target_link_libraries(grpc_verify_jwt gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_verify_jwt PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_verify_jwt PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX) @@ -8347,11 +7913,6 @@ target_link_libraries(handshake_client_ssl gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_client_ssl PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_client_ssl PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8387,11 +7948,6 @@ target_link_libraries(handshake_server_ssl gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_server_ssl PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_server_ssl PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8427,11 +7983,6 @@ target_link_libraries(handshake_server_with_readahead_handshaker gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_server_with_readahead_handshaker PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_server_with_readahead_handshaker PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8466,11 +8017,6 @@ target_link_libraries(handshake_verify_peer_options gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_verify_peer_options PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_verify_peer_options PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8502,11 +8048,6 @@ target_link_libraries(histogram_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(histogram_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(histogram_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8538,11 +8079,6 @@ target_link_libraries(hpack_parser_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(hpack_parser_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(hpack_parser_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8574,11 +8110,6 @@ target_link_libraries(hpack_table_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(hpack_table_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(hpack_table_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8610,11 +8141,6 @@ target_link_libraries(http_parser_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(http_parser_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(http_parser_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8646,11 +8172,6 @@ target_link_libraries(httpcli_format_request_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(httpcli_format_request_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(httpcli_format_request_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8683,11 +8204,6 @@ target_link_libraries(httpcli_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(httpcli_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(httpcli_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8721,11 +8237,6 @@ target_link_libraries(httpscli_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(httpscli_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(httpscli_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8758,11 +8269,6 @@ target_link_libraries(init_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(init_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(init_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8794,11 +8300,6 @@ target_link_libraries(inproc_callback_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(inproc_callback_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(inproc_callback_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8830,11 +8331,6 @@ target_link_libraries(invalid_call_argument_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(invalid_call_argument_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(invalid_call_argument_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8866,11 +8362,6 @@ target_link_libraries(json_rewrite gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_rewrite PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_rewrite PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8902,11 +8393,6 @@ target_link_libraries(json_rewrite_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_rewrite_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_rewrite_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8938,11 +8424,6 @@ target_link_libraries(json_stream_error_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_stream_error_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_stream_error_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8974,11 +8455,6 @@ target_link_libraries(json_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9010,11 +8486,6 @@ target_link_libraries(lame_client_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(lame_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(lame_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9046,11 +8517,6 @@ target_link_libraries(load_file_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(load_file_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(load_file_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9082,11 +8548,6 @@ target_link_libraries(memory_usage_client gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(memory_usage_client PROPERTIES LINKER_LANGUAGE C) - target_compile_options(memory_usage_client PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9118,11 +8579,6 @@ target_link_libraries(memory_usage_server gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(memory_usage_server PROPERTIES LINKER_LANGUAGE C) - target_compile_options(memory_usage_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9155,11 +8611,6 @@ target_link_libraries(memory_usage_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(memory_usage_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(memory_usage_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9192,11 +8643,6 @@ target_link_libraries(message_compress_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(message_compress_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(message_compress_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9228,11 +8674,6 @@ target_link_libraries(minimal_stack_is_minimal_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(minimal_stack_is_minimal_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(minimal_stack_is_minimal_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9264,11 +8705,6 @@ target_link_libraries(mpmcqueue_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(mpmcqueue_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(mpmcqueue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9300,11 +8736,6 @@ target_link_libraries(multiple_server_queues_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(multiple_server_queues_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(multiple_server_queues_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9336,11 +8767,6 @@ target_link_libraries(murmur_hash_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(murmur_hash_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(murmur_hash_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9372,11 +8798,6 @@ target_link_libraries(no_server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(no_server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(no_server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9408,11 +8829,6 @@ target_link_libraries(num_external_connectivity_watchers_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(num_external_connectivity_watchers_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(num_external_connectivity_watchers_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9444,11 +8860,6 @@ target_link_libraries(parse_address_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(parse_address_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(parse_address_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9481,11 +8892,6 @@ target_link_libraries(parse_address_with_named_scope_id_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(parse_address_with_named_scope_id_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(parse_address_with_named_scope_id_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9518,11 +8924,6 @@ target_link_libraries(percent_encoding_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(percent_encoding_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(percent_encoding_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9555,11 +8956,6 @@ target_link_libraries(resolve_address_using_ares_resolver_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_ares_resolver_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_ares_resolver_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9592,11 +8988,6 @@ target_link_libraries(resolve_address_using_ares_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_ares_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_ares_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9629,11 +9020,6 @@ target_link_libraries(resolve_address_using_native_resolver_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_native_resolver_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_native_resolver_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9666,11 +9052,6 @@ target_link_libraries(resolve_address_using_native_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_native_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_native_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9702,11 +9083,6 @@ target_link_libraries(resource_quota_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resource_quota_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resource_quota_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9738,11 +9114,6 @@ target_link_libraries(secure_channel_create_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(secure_channel_create_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(secure_channel_create_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9774,11 +9145,6 @@ target_link_libraries(secure_endpoint_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(secure_endpoint_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(secure_endpoint_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9810,11 +9176,6 @@ target_link_libraries(sequential_connectivity_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(sequential_connectivity_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(sequential_connectivity_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9846,11 +9207,6 @@ target_link_libraries(server_chttp2_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_chttp2_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_chttp2_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9882,11 +9238,6 @@ target_link_libraries(server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9918,11 +9269,6 @@ target_link_libraries(slice_buffer_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(slice_buffer_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(slice_buffer_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9954,11 +9300,6 @@ target_link_libraries(slice_string_helpers_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(slice_string_helpers_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(slice_string_helpers_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9990,11 +9331,6 @@ target_link_libraries(slice_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(slice_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(slice_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10026,11 +9362,6 @@ target_link_libraries(sockaddr_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(sockaddr_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(sockaddr_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10062,11 +9393,6 @@ target_link_libraries(sockaddr_utils_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(sockaddr_utils_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(sockaddr_utils_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10099,11 +9425,6 @@ target_link_libraries(socket_utils_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(socket_utils_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(socket_utils_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10138,11 +9459,6 @@ target_link_libraries(ssl_transport_security_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(ssl_transport_security_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(ssl_transport_security_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10175,11 +9491,6 @@ target_link_libraries(status_conversion_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(status_conversion_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(status_conversion_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10211,11 +9522,6 @@ target_link_libraries(stream_compression_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(stream_compression_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(stream_compression_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10247,11 +9553,6 @@ target_link_libraries(stream_owned_slice_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(stream_owned_slice_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(stream_owned_slice_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10284,11 +9585,6 @@ target_link_libraries(tcp_client_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_client_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_client_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10321,11 +9617,6 @@ target_link_libraries(tcp_client_uv_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_client_uv_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_client_uv_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10358,11 +9649,6 @@ target_link_libraries(tcp_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10396,11 +9682,6 @@ target_link_libraries(tcp_server_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_server_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_server_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10433,11 +9714,6 @@ target_link_libraries(tcp_server_uv_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_server_uv_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_server_uv_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10469,11 +9745,6 @@ target_link_libraries(threadpool_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(threadpool_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(threadpool_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10505,11 +9776,6 @@ target_link_libraries(time_averaged_stats_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(time_averaged_stats_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(time_averaged_stats_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10541,11 +9807,6 @@ target_link_libraries(timeout_encoding_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(timeout_encoding_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(timeout_encoding_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10577,11 +9838,6 @@ target_link_libraries(timer_heap_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(timer_heap_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(timer_heap_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10613,11 +9869,6 @@ target_link_libraries(timer_list_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(timer_list_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(timer_list_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10649,11 +9900,6 @@ target_link_libraries(transport_connectivity_state_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(transport_connectivity_state_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(transport_connectivity_state_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10685,11 +9931,6 @@ target_link_libraries(transport_metadata_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(transport_metadata_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(transport_metadata_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10722,11 +9963,6 @@ target_link_libraries(transport_security_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(transport_security_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(transport_security_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10760,11 +9996,6 @@ target_link_libraries(udp_server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(udp_server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(udp_server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10797,11 +10028,6 @@ target_link_libraries(uri_parser_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(uri_parser_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(uri_parser_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18226,11 +17452,6 @@ target_link_libraries(bad_ssl_cert_server gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_ssl_cert_server PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bad_ssl_cert_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18264,11 +17485,6 @@ target_link_libraries(bad_ssl_cert_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_ssl_cert_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bad_ssl_cert_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18302,11 +17518,6 @@ target_link_libraries(h2_census_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_census_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_census_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18339,11 +17550,6 @@ target_link_libraries(h2_compress_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_compress_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_compress_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18376,11 +17582,6 @@ target_link_libraries(h2_fakesec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_fakesec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_fakesec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18414,11 +17615,6 @@ target_link_libraries(h2_fd_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_fd_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_fd_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18452,11 +17648,6 @@ target_link_libraries(h2_full_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18490,11 +17681,6 @@ target_link_libraries(h2_full+pipe_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+pipe_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+pipe_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18528,11 +17714,6 @@ target_link_libraries(h2_full+trace_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+trace_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+trace_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18565,11 +17746,6 @@ target_link_libraries(h2_full+workarounds_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+workarounds_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+workarounds_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18602,11 +17778,6 @@ target_link_libraries(h2_http_proxy_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_http_proxy_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_http_proxy_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18640,11 +17811,6 @@ target_link_libraries(h2_local_ipv4_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_local_ipv4_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_local_ipv4_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18679,11 +17845,6 @@ target_link_libraries(h2_local_ipv6_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_local_ipv6_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_local_ipv6_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18718,11 +17879,6 @@ target_link_libraries(h2_local_uds_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_local_uds_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_local_uds_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18756,11 +17912,6 @@ target_link_libraries(h2_oauth2_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_oauth2_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_oauth2_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18793,11 +17944,6 @@ target_link_libraries(h2_proxy_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_proxy_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_proxy_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18830,11 +17976,6 @@ target_link_libraries(h2_sockpair_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18867,11 +18008,6 @@ target_link_libraries(h2_sockpair+trace_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair+trace_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair+trace_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18904,11 +18040,6 @@ target_link_libraries(h2_sockpair_1byte_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_1byte_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_1byte_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18941,11 +18072,6 @@ target_link_libraries(h2_spiffe_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_spiffe_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_spiffe_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18978,11 +18104,6 @@ target_link_libraries(h2_ssl_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_ssl_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_ssl_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19015,11 +18136,6 @@ target_link_libraries(h2_ssl_cred_reload_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_ssl_cred_reload_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_ssl_cred_reload_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19052,11 +18168,6 @@ target_link_libraries(h2_ssl_proxy_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_ssl_proxy_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_ssl_proxy_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19090,11 +18201,6 @@ target_link_libraries(h2_uds_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_uds_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_uds_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19128,11 +18234,6 @@ target_link_libraries(inproc_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(inproc_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(inproc_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19165,11 +18266,6 @@ target_link_libraries(h2_census_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_census_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_census_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19202,11 +18298,6 @@ target_link_libraries(h2_compress_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_compress_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_compress_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19240,11 +18331,6 @@ target_link_libraries(h2_fd_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_fd_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_fd_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19278,11 +18364,6 @@ target_link_libraries(h2_full_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19316,11 +18397,6 @@ target_link_libraries(h2_full+pipe_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+pipe_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+pipe_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19354,11 +18430,6 @@ target_link_libraries(h2_full+trace_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+trace_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+trace_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19391,11 +18462,6 @@ target_link_libraries(h2_full+workarounds_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+workarounds_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+workarounds_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19428,11 +18494,6 @@ target_link_libraries(h2_http_proxy_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_http_proxy_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_http_proxy_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19465,11 +18526,6 @@ target_link_libraries(h2_proxy_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_proxy_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_proxy_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19502,11 +18558,6 @@ target_link_libraries(h2_sockpair_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19539,11 +18590,6 @@ target_link_libraries(h2_sockpair+trace_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair+trace_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair+trace_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19576,11 +18622,6 @@ target_link_libraries(h2_sockpair_1byte_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_1byte_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_1byte_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19614,11 +18655,6 @@ target_link_libraries(h2_uds_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_uds_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_uds_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19960,11 +18996,6 @@ target_link_libraries(alts_credentials_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alts_credentials_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(alts_credentials_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19997,11 +19028,6 @@ target_link_libraries(api_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(api_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(api_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20034,11 +19060,6 @@ target_link_libraries(client_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(client_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(client_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20071,11 +19092,6 @@ target_link_libraries(hpack_parser_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(hpack_parser_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(hpack_parser_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20108,11 +19124,6 @@ target_link_libraries(http_request_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(http_request_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(http_request_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20145,11 +19156,6 @@ target_link_libraries(http_response_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(http_response_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(http_response_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20182,11 +19188,6 @@ target_link_libraries(json_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20219,11 +19220,6 @@ target_link_libraries(nanopb_fuzzer_response_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(nanopb_fuzzer_response_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(nanopb_fuzzer_response_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20256,11 +19252,6 @@ target_link_libraries(nanopb_fuzzer_serverlist_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(nanopb_fuzzer_serverlist_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(nanopb_fuzzer_serverlist_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20293,11 +19284,6 @@ target_link_libraries(percent_decode_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(percent_decode_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(percent_decode_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20330,11 +19316,6 @@ target_link_libraries(percent_encode_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(percent_encode_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(percent_encode_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20367,11 +19348,6 @@ target_link_libraries(server_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20404,11 +19380,6 @@ target_link_libraries(ssl_server_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(ssl_server_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(ssl_server_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20441,11 +19412,6 @@ target_link_libraries(uri_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(uri_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(uri_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 4ebf5b36cf8..9ac8955d33c 100644 --- a/Makefile +++ b/Makefile @@ -3339,15 +3339,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBADDRESS_SORTING_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBADDRESS_SORTING_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.8 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.8 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so endif @@ -3535,15 +3535,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.8 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.8 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif @@ -3997,15 +3997,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif @@ -4395,15 +4395,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_CRONET_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_CRONET_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so endif @@ -5438,15 +5438,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif @@ -7679,15 +7679,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.2 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.2 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so.2 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so endif @@ -8525,7 +8525,7 @@ else $(BINDIR)/$(CONFIG)/algorithm_test: $(ALGORITHM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALGORITHM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/algorithm_test + $(Q) $(LDXX) $(LDFLAGS) $(ALGORITHM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/algorithm_test endif @@ -8557,7 +8557,7 @@ else $(BINDIR)/$(CONFIG)/alloc_test: $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alloc_test + $(Q) $(LDXX) $(LDFLAGS) $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alloc_test endif @@ -8589,7 +8589,7 @@ else $(BINDIR)/$(CONFIG)/alpn_test: $(ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alpn_test + $(Q) $(LDXX) $(LDFLAGS) $(ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alpn_test endif @@ -8685,7 +8685,7 @@ else $(BINDIR)/$(CONFIG)/arena_test: $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/arena_test + $(Q) $(LDXX) $(LDFLAGS) $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/arena_test endif @@ -8717,7 +8717,7 @@ else $(BINDIR)/$(CONFIG)/avl_test: $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/avl_test + $(Q) $(LDXX) $(LDFLAGS) $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/avl_test endif @@ -8749,7 +8749,7 @@ else $(BINDIR)/$(CONFIG)/bad_server_response_test: $(BAD_SERVER_RESPONSE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BAD_SERVER_RESPONSE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_server_response_test + $(Q) $(LDXX) $(LDFLAGS) $(BAD_SERVER_RESPONSE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_server_response_test endif @@ -8781,7 +8781,7 @@ 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 + $(Q) $(LDXX) $(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 @@ -8813,7 +8813,7 @@ else $(BINDIR)/$(CONFIG)/bin_encoder_test: $(BIN_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BIN_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_encoder_test + $(Q) $(LDXX) $(LDFLAGS) $(BIN_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_encoder_test endif @@ -8845,7 +8845,7 @@ else $(BINDIR)/$(CONFIG)/buffer_list_test: $(BUFFER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BUFFER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/buffer_list_test + $(Q) $(LDXX) $(LDFLAGS) $(BUFFER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/buffer_list_test endif @@ -8877,7 +8877,7 @@ else $(BINDIR)/$(CONFIG)/channel_create_test: $(CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/channel_create_test + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/channel_create_test endif @@ -8909,7 +8909,7 @@ else $(BINDIR)/$(CONFIG)/check_epollexclusive: $(CHECK_EPOLLEXCLUSIVE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHECK_EPOLLEXCLUSIVE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/check_epollexclusive + $(Q) $(LDXX) $(LDFLAGS) $(CHECK_EPOLLEXCLUSIVE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/check_epollexclusive endif @@ -8941,7 +8941,7 @@ else $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test: $(CHTTP2_HPACK_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHTTP2_HPACK_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test + $(Q) $(LDXX) $(LDFLAGS) $(CHTTP2_HPACK_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test endif @@ -8973,7 +8973,7 @@ else $(BINDIR)/$(CONFIG)/chttp2_stream_map_test: $(CHTTP2_STREAM_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHTTP2_STREAM_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_stream_map_test + $(Q) $(LDXX) $(LDFLAGS) $(CHTTP2_STREAM_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_stream_map_test endif @@ -9005,7 +9005,7 @@ else $(BINDIR)/$(CONFIG)/chttp2_varint_test: $(CHTTP2_VARINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHTTP2_VARINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_varint_test + $(Q) $(LDXX) $(LDFLAGS) $(CHTTP2_VARINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_varint_test endif @@ -9069,7 +9069,7 @@ else $(BINDIR)/$(CONFIG)/close_fd_test: $(CLOSE_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CLOSE_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/close_fd_test + $(Q) $(LDXX) $(LDFLAGS) $(CLOSE_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/close_fd_test endif @@ -9101,7 +9101,7 @@ else $(BINDIR)/$(CONFIG)/cmdline_test: $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/cmdline_test + $(Q) $(LDXX) $(LDFLAGS) $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/cmdline_test endif @@ -9133,7 +9133,7 @@ else $(BINDIR)/$(CONFIG)/combiner_test: $(COMBINER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(COMBINER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/combiner_test + $(Q) $(LDXX) $(LDFLAGS) $(COMBINER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/combiner_test endif @@ -9165,7 +9165,7 @@ else $(BINDIR)/$(CONFIG)/compression_test: $(COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/compression_test + $(Q) $(LDXX) $(LDFLAGS) $(COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/compression_test endif @@ -9197,7 +9197,7 @@ else $(BINDIR)/$(CONFIG)/concurrent_connectivity_test: $(CONCURRENT_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CONCURRENT_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/concurrent_connectivity_test + $(Q) $(LDXX) $(LDFLAGS) $(CONCURRENT_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/concurrent_connectivity_test endif @@ -9229,7 +9229,7 @@ else $(BINDIR)/$(CONFIG)/connection_refused_test: $(CONNECTION_REFUSED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CONNECTION_REFUSED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/connection_refused_test + $(Q) $(LDXX) $(LDFLAGS) $(CONNECTION_REFUSED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/connection_refused_test endif @@ -9261,7 +9261,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test: $(DNS_RESOLVER_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test endif @@ -9293,7 +9293,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test endif @@ -9325,7 +9325,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test endif @@ -9357,7 +9357,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_test: $(DNS_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_test endif @@ -9389,7 +9389,7 @@ else $(BINDIR)/$(CONFIG)/dualstack_socket_test: $(DUALSTACK_SOCKET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DUALSTACK_SOCKET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dualstack_socket_test + $(Q) $(LDXX) $(LDFLAGS) $(DUALSTACK_SOCKET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dualstack_socket_test endif @@ -9421,7 +9421,7 @@ else $(BINDIR)/$(CONFIG)/endpoint_pair_test: $(ENDPOINT_PAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ENDPOINT_PAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/endpoint_pair_test + $(Q) $(LDXX) $(LDFLAGS) $(ENDPOINT_PAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/endpoint_pair_test endif @@ -9453,7 +9453,7 @@ else $(BINDIR)/$(CONFIG)/error_test: $(ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/error_test + $(Q) $(LDXX) $(LDFLAGS) $(ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/error_test endif @@ -9485,7 +9485,7 @@ else $(BINDIR)/$(CONFIG)/ev_epollex_linux_test: $(EV_EPOLLEX_LINUX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(EV_EPOLLEX_LINUX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ev_epollex_linux_test + $(Q) $(LDXX) $(LDFLAGS) $(EV_EPOLLEX_LINUX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ev_epollex_linux_test endif @@ -9517,7 +9517,7 @@ else $(BINDIR)/$(CONFIG)/fake_resolver_test: $(FAKE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FAKE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(FAKE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_resolver_test endif @@ -9550,7 +9550,7 @@ else $(BINDIR)/$(CONFIG)/fake_transport_security_test: $(FAKE_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FAKE_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_transport_security_test + $(Q) $(LDXX) $(LDFLAGS) $(FAKE_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_transport_security_test endif @@ -9584,7 +9584,7 @@ else $(BINDIR)/$(CONFIG)/fd_conservation_posix_test: $(FD_CONSERVATION_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FD_CONSERVATION_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_conservation_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(FD_CONSERVATION_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_conservation_posix_test endif @@ -9616,7 +9616,7 @@ else $(BINDIR)/$(CONFIG)/fd_posix_test: $(FD_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FD_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(FD_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_posix_test endif @@ -9648,7 +9648,7 @@ else $(BINDIR)/$(CONFIG)/fling_client: $(FLING_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_client + $(Q) $(LDXX) $(LDFLAGS) $(FLING_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_client endif @@ -9680,7 +9680,7 @@ else $(BINDIR)/$(CONFIG)/fling_server: $(FLING_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_server + $(Q) $(LDXX) $(LDFLAGS) $(FLING_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_server endif @@ -9712,7 +9712,7 @@ else $(BINDIR)/$(CONFIG)/fling_stream_test: $(FLING_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_stream_test + $(Q) $(LDXX) $(LDFLAGS) $(FLING_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_stream_test endif @@ -9744,7 +9744,7 @@ else $(BINDIR)/$(CONFIG)/fling_test: $(FLING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_test + $(Q) $(LDXX) $(LDFLAGS) $(FLING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_test endif @@ -9776,7 +9776,7 @@ else $(BINDIR)/$(CONFIG)/fork_test: $(FORK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FORK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fork_test + $(Q) $(LDXX) $(LDFLAGS) $(FORK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fork_test endif @@ -9808,7 +9808,7 @@ else $(BINDIR)/$(CONFIG)/goaway_server_test: $(GOAWAY_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GOAWAY_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/goaway_server_test + $(Q) $(LDXX) $(LDFLAGS) $(GOAWAY_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/goaway_server_test endif @@ -9840,7 +9840,7 @@ else $(BINDIR)/$(CONFIG)/gpr_cpu_test: $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_cpu_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_cpu_test endif @@ -9872,7 +9872,7 @@ else $(BINDIR)/$(CONFIG)/gpr_env_test: $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_env_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_env_test endif @@ -9904,7 +9904,7 @@ else $(BINDIR)/$(CONFIG)/gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_host_port_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_host_port_test endif @@ -9936,7 +9936,7 @@ else $(BINDIR)/$(CONFIG)/gpr_log_test: $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_log_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_log_test endif @@ -9968,7 +9968,7 @@ else $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test: $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test endif @@ -10000,7 +10000,7 @@ else $(BINDIR)/$(CONFIG)/gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test endif @@ -10032,7 +10032,7 @@ else $(BINDIR)/$(CONFIG)/gpr_spinlock_test: $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_spinlock_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_spinlock_test endif @@ -10064,7 +10064,7 @@ else $(BINDIR)/$(CONFIG)/gpr_string_test: $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_string_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_string_test endif @@ -10096,7 +10096,7 @@ else $(BINDIR)/$(CONFIG)/gpr_sync_test: $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_sync_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_sync_test endif @@ -10128,7 +10128,7 @@ else $(BINDIR)/$(CONFIG)/gpr_thd_test: $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_thd_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_thd_test endif @@ -10160,7 +10160,7 @@ else $(BINDIR)/$(CONFIG)/gpr_time_test: $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_time_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_time_test endif @@ -10192,7 +10192,7 @@ else $(BINDIR)/$(CONFIG)/gpr_tls_test: $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_tls_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_tls_test endif @@ -10224,7 +10224,7 @@ else $(BINDIR)/$(CONFIG)/gpr_useful_test: $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_useful_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_useful_test endif @@ -10256,7 +10256,7 @@ else $(BINDIR)/$(CONFIG)/grpc_auth_context_test: $(GRPC_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_auth_context_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_auth_context_test endif @@ -10288,7 +10288,7 @@ else $(BINDIR)/$(CONFIG)/grpc_b64_test: $(GRPC_B64_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_B64_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_b64_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_B64_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_b64_test endif @@ -10320,7 +10320,7 @@ else $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test: $(GRPC_BYTE_BUFFER_READER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_BYTE_BUFFER_READER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_BYTE_BUFFER_READER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test endif @@ -10352,7 +10352,7 @@ else $(BINDIR)/$(CONFIG)/grpc_channel_args_test: $(GRPC_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_args_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_args_test endif @@ -10384,7 +10384,7 @@ else $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test: $(GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test endif @@ -10416,7 +10416,7 @@ else $(BINDIR)/$(CONFIG)/grpc_channel_stack_test: $(GRPC_CHANNEL_STACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_STACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CHANNEL_STACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_test endif @@ -10448,7 +10448,7 @@ else $(BINDIR)/$(CONFIG)/grpc_completion_queue_test: $(GRPC_COMPLETION_QUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_test endif @@ -10480,7 +10480,7 @@ else $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test: $(GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test endif @@ -10512,7 +10512,7 @@ else $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test: $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test endif @@ -10545,7 +10545,7 @@ else $(BINDIR)/$(CONFIG)/grpc_create_jwt: $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_create_jwt + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_create_jwt endif @@ -10579,7 +10579,7 @@ else $(BINDIR)/$(CONFIG)/grpc_credentials_test: $(GRPC_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_credentials_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_credentials_test endif @@ -10611,7 +10611,7 @@ else $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test: $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test endif @@ -10643,7 +10643,7 @@ else $(BINDIR)/$(CONFIG)/grpc_json_token_test: $(GRPC_JSON_TOKEN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_JSON_TOKEN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_json_token_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_JSON_TOKEN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_json_token_test endif @@ -10675,7 +10675,7 @@ else $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test: $(GRPC_JWT_VERIFIER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_JWT_VERIFIER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_JWT_VERIFIER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test endif @@ -10708,7 +10708,7 @@ else $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token: $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token endif @@ -10742,7 +10742,7 @@ else $(BINDIR)/$(CONFIG)/grpc_security_connector_test: $(GRPC_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_security_connector_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_security_connector_test endif @@ -10774,7 +10774,7 @@ else $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test: $(GRPC_SSL_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_SSL_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_SSL_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test endif @@ -10807,7 +10807,7 @@ else $(BINDIR)/$(CONFIG)/grpc_verify_jwt: $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_verify_jwt + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_verify_jwt endif @@ -10841,7 +10841,7 @@ else $(BINDIR)/$(CONFIG)/handshake_client_ssl: $(HANDSHAKE_CLIENT_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_CLIENT_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_client_ssl + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_CLIENT_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_client_ssl endif @@ -10874,7 +10874,7 @@ else $(BINDIR)/$(CONFIG)/handshake_server_ssl: $(HANDSHAKE_SERVER_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_SERVER_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_ssl + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_SERVER_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_ssl endif @@ -10909,7 +10909,7 @@ else $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker: $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker endif @@ -10943,7 +10943,7 @@ else $(BINDIR)/$(CONFIG)/handshake_verify_peer_options: $(HANDSHAKE_VERIFY_PEER_OPTIONS_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_VERIFY_PEER_OPTIONS_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_verify_peer_options + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_VERIFY_PEER_OPTIONS_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_verify_peer_options endif @@ -10975,7 +10975,7 @@ else $(BINDIR)/$(CONFIG)/histogram_test: $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/histogram_test + $(Q) $(LDXX) $(LDFLAGS) $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/histogram_test endif @@ -11039,7 +11039,7 @@ else $(BINDIR)/$(CONFIG)/hpack_parser_test: $(HPACK_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HPACK_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_test + $(Q) $(LDXX) $(LDFLAGS) $(HPACK_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_test endif @@ -11071,7 +11071,7 @@ else $(BINDIR)/$(CONFIG)/hpack_table_test: $(HPACK_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HPACK_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_table_test + $(Q) $(LDXX) $(LDFLAGS) $(HPACK_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_table_test endif @@ -11103,7 +11103,7 @@ else $(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test endif @@ -11199,7 +11199,7 @@ else $(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test endif @@ -11231,7 +11231,7 @@ else $(BINDIR)/$(CONFIG)/httpcli_test: $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_test endif @@ -11263,7 +11263,7 @@ else $(BINDIR)/$(CONFIG)/httpscli_test: $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpscli_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpscli_test endif @@ -11295,7 +11295,7 @@ else $(BINDIR)/$(CONFIG)/init_test: $(INIT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INIT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/init_test + $(Q) $(LDXX) $(LDFLAGS) $(INIT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/init_test endif @@ -11327,7 +11327,7 @@ else $(BINDIR)/$(CONFIG)/inproc_callback_test: $(INPROC_CALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INPROC_CALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_callback_test + $(Q) $(LDXX) $(LDFLAGS) $(INPROC_CALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_callback_test endif @@ -11359,7 +11359,7 @@ else $(BINDIR)/$(CONFIG)/invalid_call_argument_test: $(INVALID_CALL_ARGUMENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INVALID_CALL_ARGUMENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/invalid_call_argument_test + $(Q) $(LDXX) $(LDFLAGS) $(INVALID_CALL_ARGUMENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/invalid_call_argument_test endif @@ -11423,7 +11423,7 @@ else $(BINDIR)/$(CONFIG)/json_rewrite: $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite + $(Q) $(LDXX) $(LDFLAGS) $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite endif @@ -11455,7 +11455,7 @@ else $(BINDIR)/$(CONFIG)/json_rewrite_test: $(JSON_REWRITE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_REWRITE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite_test + $(Q) $(LDXX) $(LDFLAGS) $(JSON_REWRITE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite_test endif @@ -11487,7 +11487,7 @@ else $(BINDIR)/$(CONFIG)/json_stream_error_test: $(JSON_STREAM_ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_STREAM_ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_stream_error_test + $(Q) $(LDXX) $(LDFLAGS) $(JSON_STREAM_ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_stream_error_test endif @@ -11519,7 +11519,7 @@ else $(BINDIR)/$(CONFIG)/json_test: $(JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_test + $(Q) $(LDXX) $(LDFLAGS) $(JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_test endif @@ -11551,7 +11551,7 @@ else $(BINDIR)/$(CONFIG)/lame_client_test: $(LAME_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LAME_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/lame_client_test + $(Q) $(LDXX) $(LDFLAGS) $(LAME_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/lame_client_test endif @@ -11583,7 +11583,7 @@ else $(BINDIR)/$(CONFIG)/load_file_test: $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/load_file_test + $(Q) $(LDXX) $(LDFLAGS) $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/load_file_test endif @@ -11615,7 +11615,7 @@ else $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark: $(LOW_LEVEL_PING_PONG_BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LOW_LEVEL_PING_PONG_BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark + $(Q) $(LDXX) $(LDFLAGS) $(LOW_LEVEL_PING_PONG_BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark endif @@ -11647,7 +11647,7 @@ else $(BINDIR)/$(CONFIG)/memory_usage_client: $(MEMORY_USAGE_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MEMORY_USAGE_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_client + $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_USAGE_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_client endif @@ -11679,7 +11679,7 @@ else $(BINDIR)/$(CONFIG)/memory_usage_server: $(MEMORY_USAGE_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MEMORY_USAGE_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_server + $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_USAGE_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_server endif @@ -11711,7 +11711,7 @@ else $(BINDIR)/$(CONFIG)/memory_usage_test: $(MEMORY_USAGE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MEMORY_USAGE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_test + $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_USAGE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_test endif @@ -11743,7 +11743,7 @@ else $(BINDIR)/$(CONFIG)/message_compress_test: $(MESSAGE_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MESSAGE_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/message_compress_test + $(Q) $(LDXX) $(LDFLAGS) $(MESSAGE_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/message_compress_test endif @@ -11775,7 +11775,7 @@ else $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test: $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test + $(Q) $(LDXX) $(LDFLAGS) $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test endif @@ -11807,7 +11807,7 @@ else $(BINDIR)/$(CONFIG)/mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test + $(Q) $(LDXX) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test endif @@ -11839,7 +11839,7 @@ else $(BINDIR)/$(CONFIG)/multiple_server_queues_test: $(MULTIPLE_SERVER_QUEUES_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MULTIPLE_SERVER_QUEUES_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/multiple_server_queues_test + $(Q) $(LDXX) $(LDFLAGS) $(MULTIPLE_SERVER_QUEUES_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/multiple_server_queues_test endif @@ -11871,7 +11871,7 @@ else $(BINDIR)/$(CONFIG)/murmur_hash_test: $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/murmur_hash_test + $(Q) $(LDXX) $(LDFLAGS) $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/murmur_hash_test endif @@ -11967,7 +11967,7 @@ else $(BINDIR)/$(CONFIG)/no_server_test: $(NO_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NO_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/no_server_test + $(Q) $(LDXX) $(LDFLAGS) $(NO_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/no_server_test endif @@ -11999,7 +11999,7 @@ else $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test: $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test + $(Q) $(LDXX) $(LDFLAGS) $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test endif @@ -12031,7 +12031,7 @@ else $(BINDIR)/$(CONFIG)/parse_address_test: $(PARSE_ADDRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PARSE_ADDRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_test + $(Q) $(LDXX) $(LDFLAGS) $(PARSE_ADDRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_test endif @@ -12063,7 +12063,7 @@ else $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test: $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test + $(Q) $(LDXX) $(LDFLAGS) $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test endif @@ -12159,7 +12159,7 @@ else $(BINDIR)/$(CONFIG)/percent_encoding_test: $(PERCENT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PERCENT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encoding_test + $(Q) $(LDXX) $(LDFLAGS) $(PERCENT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encoding_test endif @@ -12191,7 +12191,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test: $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test endif @@ -12223,7 +12223,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test: $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test endif @@ -12255,7 +12255,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test: $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test endif @@ -12287,7 +12287,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test: $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test endif @@ -12319,7 +12319,7 @@ else $(BINDIR)/$(CONFIG)/resource_quota_test: $(RESOURCE_QUOTA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOURCE_QUOTA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resource_quota_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOURCE_QUOTA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resource_quota_test endif @@ -12351,7 +12351,7 @@ else $(BINDIR)/$(CONFIG)/secure_channel_create_test: $(SECURE_CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SECURE_CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_channel_create_test + $(Q) $(LDXX) $(LDFLAGS) $(SECURE_CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_channel_create_test endif @@ -12383,7 +12383,7 @@ else $(BINDIR)/$(CONFIG)/secure_endpoint_test: $(SECURE_ENDPOINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SECURE_ENDPOINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_endpoint_test + $(Q) $(LDXX) $(LDFLAGS) $(SECURE_ENDPOINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_endpoint_test endif @@ -12415,7 +12415,7 @@ else $(BINDIR)/$(CONFIG)/sequential_connectivity_test: $(SEQUENTIAL_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SEQUENTIAL_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sequential_connectivity_test + $(Q) $(LDXX) $(LDFLAGS) $(SEQUENTIAL_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sequential_connectivity_test endif @@ -12447,7 +12447,7 @@ else $(BINDIR)/$(CONFIG)/server_chttp2_test: $(SERVER_CHTTP2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_CHTTP2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_chttp2_test + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_CHTTP2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_chttp2_test endif @@ -12511,7 +12511,7 @@ else $(BINDIR)/$(CONFIG)/server_test: $(SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_test + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_test endif @@ -12543,7 +12543,7 @@ else $(BINDIR)/$(CONFIG)/slice_buffer_test: $(SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_buffer_test + $(Q) $(LDXX) $(LDFLAGS) $(SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_buffer_test endif @@ -12575,7 +12575,7 @@ else $(BINDIR)/$(CONFIG)/slice_string_helpers_test: $(SLICE_STRING_HELPERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SLICE_STRING_HELPERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_string_helpers_test + $(Q) $(LDXX) $(LDFLAGS) $(SLICE_STRING_HELPERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_string_helpers_test endif @@ -12607,7 +12607,7 @@ else $(BINDIR)/$(CONFIG)/slice_test: $(SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_test + $(Q) $(LDXX) $(LDFLAGS) $(SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_test endif @@ -12639,7 +12639,7 @@ else $(BINDIR)/$(CONFIG)/sockaddr_resolver_test: $(SOCKADDR_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SOCKADDR_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(SOCKADDR_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_resolver_test endif @@ -12671,7 +12671,7 @@ else $(BINDIR)/$(CONFIG)/sockaddr_utils_test: $(SOCKADDR_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SOCKADDR_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_utils_test + $(Q) $(LDXX) $(LDFLAGS) $(SOCKADDR_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_utils_test endif @@ -12703,7 +12703,7 @@ else $(BINDIR)/$(CONFIG)/socket_utils_test: $(SOCKET_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SOCKET_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/socket_utils_test + $(Q) $(LDXX) $(LDFLAGS) $(SOCKET_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/socket_utils_test endif @@ -12768,7 +12768,7 @@ else $(BINDIR)/$(CONFIG)/ssl_transport_security_test: $(SSL_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SSL_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_transport_security_test + $(Q) $(LDXX) $(LDFLAGS) $(SSL_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_transport_security_test endif @@ -12802,7 +12802,7 @@ else $(BINDIR)/$(CONFIG)/status_conversion_test: $(STATUS_CONVERSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(STATUS_CONVERSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/status_conversion_test + $(Q) $(LDXX) $(LDFLAGS) $(STATUS_CONVERSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/status_conversion_test endif @@ -12834,7 +12834,7 @@ else $(BINDIR)/$(CONFIG)/stream_compression_test: $(STREAM_COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(STREAM_COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_compression_test + $(Q) $(LDXX) $(LDFLAGS) $(STREAM_COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_compression_test endif @@ -12866,7 +12866,7 @@ else $(BINDIR)/$(CONFIG)/stream_owned_slice_test: $(STREAM_OWNED_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(STREAM_OWNED_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_owned_slice_test + $(Q) $(LDXX) $(LDFLAGS) $(STREAM_OWNED_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_owned_slice_test endif @@ -12898,7 +12898,7 @@ else $(BINDIR)/$(CONFIG)/tcp_client_posix_test: $(TCP_CLIENT_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_CLIENT_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_CLIENT_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_posix_test endif @@ -12930,7 +12930,7 @@ else $(BINDIR)/$(CONFIG)/tcp_client_uv_test: $(TCP_CLIENT_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_CLIENT_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_uv_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_CLIENT_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_uv_test endif @@ -12962,7 +12962,7 @@ else $(BINDIR)/$(CONFIG)/tcp_posix_test: $(TCP_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_posix_test endif @@ -12994,7 +12994,7 @@ else $(BINDIR)/$(CONFIG)/tcp_server_posix_test: $(TCP_SERVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_SERVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_SERVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_posix_test endif @@ -13026,7 +13026,7 @@ else $(BINDIR)/$(CONFIG)/tcp_server_uv_test: $(TCP_SERVER_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_SERVER_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_uv_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_SERVER_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_uv_test endif @@ -13058,7 +13058,7 @@ else $(BINDIR)/$(CONFIG)/threadpool_test: $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/threadpool_test + $(Q) $(LDXX) $(LDFLAGS) $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/threadpool_test endif @@ -13090,7 +13090,7 @@ else $(BINDIR)/$(CONFIG)/time_averaged_stats_test: $(TIME_AVERAGED_STATS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIME_AVERAGED_STATS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/time_averaged_stats_test + $(Q) $(LDXX) $(LDFLAGS) $(TIME_AVERAGED_STATS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/time_averaged_stats_test endif @@ -13122,7 +13122,7 @@ else $(BINDIR)/$(CONFIG)/timeout_encoding_test: $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timeout_encoding_test + $(Q) $(LDXX) $(LDFLAGS) $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timeout_encoding_test endif @@ -13154,7 +13154,7 @@ else $(BINDIR)/$(CONFIG)/timer_heap_test: $(TIMER_HEAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIMER_HEAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_heap_test + $(Q) $(LDXX) $(LDFLAGS) $(TIMER_HEAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_heap_test endif @@ -13186,7 +13186,7 @@ else $(BINDIR)/$(CONFIG)/timer_list_test: $(TIMER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIMER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_list_test + $(Q) $(LDXX) $(LDFLAGS) $(TIMER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_list_test endif @@ -13218,7 +13218,7 @@ else $(BINDIR)/$(CONFIG)/transport_connectivity_state_test: $(TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_connectivity_state_test + $(Q) $(LDXX) $(LDFLAGS) $(TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_connectivity_state_test endif @@ -13250,7 +13250,7 @@ else $(BINDIR)/$(CONFIG)/transport_metadata_test: $(TRANSPORT_METADATA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TRANSPORT_METADATA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_metadata_test + $(Q) $(LDXX) $(LDFLAGS) $(TRANSPORT_METADATA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_metadata_test endif @@ -13282,7 +13282,7 @@ else $(BINDIR)/$(CONFIG)/transport_security_test: $(TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_security_test + $(Q) $(LDXX) $(LDFLAGS) $(TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_security_test endif @@ -13314,7 +13314,7 @@ else $(BINDIR)/$(CONFIG)/udp_server_test: $(UDP_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(UDP_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/udp_server_test + $(Q) $(LDXX) $(LDFLAGS) $(UDP_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/udp_server_test endif @@ -13378,7 +13378,7 @@ else $(BINDIR)/$(CONFIG)/uri_parser_test: $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_parser_test + $(Q) $(LDXX) $(LDFLAGS) $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_parser_test endif @@ -20127,7 +20127,7 @@ else $(BINDIR)/$(CONFIG)/public_headers_must_be_c89: $(PUBLIC_HEADERS_MUST_BE_C89_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PUBLIC_HEADERS_MUST_BE_C89_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 + $(Q) $(LDXX) $(LDFLAGS) $(PUBLIC_HEADERS_MUST_BE_C89_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 endif @@ -20796,7 +20796,7 @@ else $(BINDIR)/$(CONFIG)/bad_ssl_cert_server: $(BAD_SSL_CERT_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BAD_SSL_CERT_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_server + $(Q) $(LDXX) $(LDFLAGS) $(BAD_SSL_CERT_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_server endif @@ -20828,7 +20828,7 @@ else $(BINDIR)/$(CONFIG)/bad_ssl_cert_test: $(BAD_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BAD_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_test + $(Q) $(LDXX) $(LDFLAGS) $(BAD_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_test endif @@ -20860,7 +20860,7 @@ else $(BINDIR)/$(CONFIG)/h2_census_test: $(H2_CENSUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_CENSUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_census_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_CENSUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_census_test endif @@ -20892,7 +20892,7 @@ else $(BINDIR)/$(CONFIG)/h2_compress_test: $(H2_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_compress_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_compress_test endif @@ -20924,7 +20924,7 @@ else $(BINDIR)/$(CONFIG)/h2_fakesec_test: $(H2_FAKESEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FAKESEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fakesec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FAKESEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fakesec_test endif @@ -20956,7 +20956,7 @@ 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.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.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fd_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fd_test endif @@ -20988,7 +20988,7 @@ else $(BINDIR)/$(CONFIG)/h2_full_test: $(H2_FULL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full_test endif @@ -21020,7 +21020,7 @@ else $(BINDIR)/$(CONFIG)/h2_full+pipe_test: $(H2_FULL+PIPE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+PIPE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+PIPE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_test endif @@ -21052,7 +21052,7 @@ else $(BINDIR)/$(CONFIG)/h2_full+trace_test: $(H2_FULL+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+trace_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+trace_test endif @@ -21084,7 +21084,7 @@ else $(BINDIR)/$(CONFIG)/h2_full+workarounds_test: $(H2_FULL+WORKAROUNDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_test endif @@ -21116,7 +21116,7 @@ else $(BINDIR)/$(CONFIG)/h2_http_proxy_test: $(H2_HTTP_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_HTTP_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_HTTP_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_test endif @@ -21148,7 +21148,7 @@ else $(BINDIR)/$(CONFIG)/h2_local_ipv4_test: $(H2_LOCAL_IPV4_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_LOCAL_IPV4_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv4_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_LOCAL_IPV4_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv4_test endif @@ -21180,7 +21180,7 @@ else $(BINDIR)/$(CONFIG)/h2_local_ipv6_test: $(H2_LOCAL_IPV6_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_LOCAL_IPV6_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv6_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_LOCAL_IPV6_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv6_test endif @@ -21212,7 +21212,7 @@ else $(BINDIR)/$(CONFIG)/h2_local_uds_test: $(H2_LOCAL_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_LOCAL_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_uds_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_LOCAL_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_uds_test endif @@ -21244,7 +21244,7 @@ else $(BINDIR)/$(CONFIG)/h2_oauth2_test: $(H2_OAUTH2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_OAUTH2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_oauth2_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_OAUTH2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_oauth2_test endif @@ -21276,7 +21276,7 @@ else $(BINDIR)/$(CONFIG)/h2_proxy_test: $(H2_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_proxy_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_proxy_test endif @@ -21308,7 +21308,7 @@ else $(BINDIR)/$(CONFIG)/h2_sockpair_test: $(H2_SOCKPAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_test endif @@ -21340,7 +21340,7 @@ else $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test: $(H2_SOCKPAIR+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test endif @@ -21372,7 +21372,7 @@ else $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test: $(H2_SOCKPAIR_1BYTE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test endif @@ -21404,7 +21404,7 @@ else $(BINDIR)/$(CONFIG)/h2_spiffe_test: $(H2_SPIFFE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SPIFFE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_spiffe_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SPIFFE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_spiffe_test endif @@ -21436,7 +21436,7 @@ else $(BINDIR)/$(CONFIG)/h2_ssl_test: $(H2_SSL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_test endif @@ -21468,7 +21468,7 @@ else $(BINDIR)/$(CONFIG)/h2_ssl_cred_reload_test: $(H2_SSL_CRED_RELOAD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_CRED_RELOAD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_cred_reload_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_CRED_RELOAD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_cred_reload_test endif @@ -21500,7 +21500,7 @@ else $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test: $(H2_SSL_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test endif @@ -21532,7 +21532,7 @@ else $(BINDIR)/$(CONFIG)/h2_uds_test: $(H2_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_uds_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_uds_test endif @@ -21564,7 +21564,7 @@ else $(BINDIR)/$(CONFIG)/inproc_test: $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_test + $(Q) $(LDXX) $(LDFLAGS) $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_test endif @@ -21588,7 +21588,7 @@ H2_CENSUS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $( $(BINDIR)/$(CONFIG)/h2_census_nosec_test: $(H2_CENSUS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_CENSUS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_census_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_CENSUS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_census_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_census.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21608,7 +21608,7 @@ H2_COMPRESS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(BINDIR)/$(CONFIG)/h2_compress_nosec_test: $(H2_COMPRESS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_COMPRESS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_compress_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_COMPRESS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_compress_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_compress.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21628,7 +21628,7 @@ H2_FD_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(base $(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.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.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_fd_nosec_test + $(Q) $(LDXX) $(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.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.a @@ -21648,7 +21648,7 @@ H2_FULL_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(ba $(BINDIR)/$(CONFIG)/h2_full_nosec_test: $(H2_FULL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21668,7 +21668,7 @@ H2_FULL+PIPE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test: $(H2_FULL+PIPE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+PIPE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+PIPE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full+pipe.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21688,7 +21688,7 @@ H2_FULL+TRACE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test: $(H2_FULL+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full+trace.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21708,7 +21708,7 @@ H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuf $(BINDIR)/$(CONFIG)/h2_full+workarounds_nosec_test: $(H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full+workarounds.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21728,7 +21728,7 @@ H2_HTTP_PROXY_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o $(BINDIR)/$(CONFIG)/h2_http_proxy_nosec_test: $(H2_HTTP_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_HTTP_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_HTTP_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_http_proxy.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21748,7 +21748,7 @@ H2_PROXY_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(b $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test: $(H2_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_proxy.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21768,7 +21768,7 @@ H2_SOCKPAIR_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test: $(H2_SOCKPAIR_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_sockpair.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21788,7 +21788,7 @@ H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffi $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test: $(H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_sockpair+trace.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21808,7 +21808,7 @@ H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffi $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test: $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_sockpair_1byte.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21828,7 +21828,7 @@ H2_UDS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(bas $(BINDIR)/$(CONFIG)/h2_uds_nosec_test: $(H2_UDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_UDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_uds_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_UDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_uds_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_uds.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -22158,7 +22158,7 @@ else $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry: $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry endif @@ -22193,7 +22193,7 @@ else $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry: $(API_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(API_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(API_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry endif @@ -22228,7 +22228,7 @@ else $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry: $(CLIENT_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CLIENT_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(CLIENT_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry endif @@ -22263,7 +22263,7 @@ else $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry: $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry endif @@ -22298,7 +22298,7 @@ else $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry: $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry endif @@ -22333,7 +22333,7 @@ else $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry: $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry endif @@ -22368,7 +22368,7 @@ else $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry: $(JSON_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(JSON_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry endif @@ -22403,7 +22403,7 @@ else $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry: $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry endif @@ -22438,7 +22438,7 @@ else $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry: $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry endif @@ -22473,7 +22473,7 @@ else $(BINDIR)/$(CONFIG)/percent_decode_fuzzer_one_entry: $(PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_decode_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_decode_fuzzer_one_entry endif @@ -22508,7 +22508,7 @@ else $(BINDIR)/$(CONFIG)/percent_encode_fuzzer_one_entry: $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encode_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encode_fuzzer_one_entry endif @@ -22543,7 +22543,7 @@ else $(BINDIR)/$(CONFIG)/server_fuzzer_one_entry: $(SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_fuzzer_one_entry endif @@ -22578,7 +22578,7 @@ else $(BINDIR)/$(CONFIG)/ssl_server_fuzzer_one_entry: $(SSL_SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SSL_SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_server_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(SSL_SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_server_fuzzer_one_entry endif @@ -22613,7 +22613,7 @@ else $(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry: $(URI_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(URI_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(URI_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry endif diff --git a/config.m4 b/config.m4 index effefa9b561..4a8651dae38 100644 --- a/config.m4 +++ b/config.m4 @@ -24,8 +24,10 @@ if test "$PHP_GRPC" != "no"; then case $host in *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) ;; *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index bab57657a00..ca1d0aeef72 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -32,8 +32,7 @@ * in-house library if possible. (e.g. std::map) */ #ifndef GRPC_USE_CPP_STD_LIB -/* Default value will be 1 once all tests become green. */ -#define GRPC_USE_CPP_STD_LIB 0 +#define GRPC_USE_CPP_STD_LIB 1 #endif /* Get windows.h included everywhere (we need it) */ diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index 9ec2c7cf04c..1af93ceecad 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -42,7 +42,8 @@ if test "$PHP_GRPC" != "no"; then dnl PHP_ADD_LIBRARY(pthread,,GRPC_SHARED_LIBADD) GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" PHP_ADD_LIBRARY(pthread) - + PHP_ADD_LIBRARY(stdc++,,GRPC_SHARED_LIBADD) + PHP_ADD_LIBRARY(stdc++) PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(dl) diff --git a/src/ruby/ext/grpc/rb_enable_cpp.cc b/src/ruby/ext/grpc/rb_enable_cpp.cc new file mode 100644 index 00000000000..f44e4f515a7 --- /dev/null +++ b/src/ruby/ext/grpc/rb_enable_cpp.cc @@ -0,0 +1,22 @@ +/* + * + * Copyright 2019 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 + +// This is a dummy C++ source file to trigger ruby extension builder to +// pick C++ rather than C linker to link with c++ library properly. diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index b6a0e83056f..16fc78d99ae 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -174,11 +174,6 @@ endif() if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) - # C core has C++ source code, but should not depend on libstc++ (for better portability). - # We need to use a few tricks to convince cmake to do that. - # https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc - set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") - # Exceptions and RTTI must be off to avoid dependency on libstdc++ set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti) else() set(_gRPC_CORE_NOSTDCXX_FLAGS "") @@ -444,14 +439,6 @@ PRIVATE <%text>${_gRPC_PROTO_GENS_DIR} % endif ) - % if lib.language in ['c', 'csharp']: - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(${lib.name} PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(${lib.name} PRIVATE <%text>$<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() - % endif % if len(get_deps(lib)) > 0: target_link_libraries(${lib.name} % for dep in get_deps(lib): @@ -550,13 +537,6 @@ % endfor ) - % if tgt.language in ['c', 'csharp']: - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(${tgt.name} PROPERTIES LINKER_LANGUAGE C) - target_compile_options(${tgt.name} PRIVATE <%text>$<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() - % endif % endif diff --git a/templates/Makefile.template b/templates/Makefile.template index b17423cc4aa..bd8874c8154 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -1588,7 +1588,7 @@ if lib.language == 'c++': ld = '$(LDXX)' else: - ld = '$(LD)' + ld = '$(LDXX)' out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' @@ -1781,7 +1781,7 @@ ## C-only targets specificities. $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) \ + $(Q) $(LDXX) $(LDFLAGS) \ % if not has_no_sources: $(${tgt.name.upper()}_OBJS)\ % endif diff --git a/templates/config.m4.template b/templates/config.m4.template index 4dbeeafb86a..f13ac75914f 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -26,8 +26,10 @@ case $host in *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) ;; *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; From db7365753e7e590e5bed13ac8cb0db1565d1fc84 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 3 Sep 2019 16:08:48 -0700 Subject: [PATCH 077/176] Fix the compile error due to ByteBuffer in method_handler_impl.h --- include/grpcpp/impl/codegen/method_handler_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 232580cf839..f65a1736ad2 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -207,7 +207,7 @@ class ServerStreamingHandler : public ::grpc::internal::MethodHandler { void* Deserialize(grpc_call* call, grpc_byte_buffer* req, ::grpc::Status* status, void** /*handler_data*/) final { - ByteBuffer buf; + ::grpc::ByteBuffer buf; buf.set_buffer(req); auto* request = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( From c831a28dbd694f929fbbc0a4ac88fc4656d0caf3 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 2 Sep 2019 20:44:32 -0700 Subject: [PATCH 078/176] Organize test cases for xds test --- test/cpp/end2end/xds_end2end_test.cc | 413 ++++++++++++++------------- 1 file changed, 218 insertions(+), 195 deletions(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 1c073de1b12..17436bbc13a 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -914,6 +914,8 @@ class XdsResolverTest : public XdsEnd2endTest { XdsResolverTest() : XdsEnd2endTest(0, 0, 0) {} }; +// Tests that if the "xds-experimental" scheme is used, xDS resolver will be +// used. TEST_F(XdsResolverTest, XdsResolverIsUsed) { // Use xds-experimental scheme in URI. ResetStub(0, "", "xds-experimental"); @@ -923,12 +925,14 @@ TEST_F(XdsResolverTest, XdsResolverIsUsed) { EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); } -class SingleBalancerTest : public XdsEnd2endTest { +class BasicTest : public XdsEnd2endTest { public: - SingleBalancerTest() : XdsEnd2endTest(4, 1, 0) {} + BasicTest() : XdsEnd2endTest(4, 1, 0) {} }; -TEST_F(SingleBalancerTest, Vanilla) { +// Tests that the balancer sends the correct response to the client, and the +// client sends RPCs to the backends using the default child policy. +TEST_F(BasicTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcsPerAddress = 100; @@ -954,7 +958,9 @@ TEST_F(SingleBalancerTest, Vanilla) { EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); } -TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { +// Tests that subchannel sharing works when the same backend is listed multiple +// times. +TEST_F(BasicTest, SameBackendListedMultipleTimes) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Same backend listed twice. @@ -976,55 +982,8 @@ TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { EXPECT_EQ(1UL, backends_[0]->backend_service()->clients().size()); } -TEST_F(SingleBalancerTest, SecureNaming) { - // TODO(juanlishen): Use separate fake creds for the balancer channel. - ResetStub(0, kApplicationTargetName_ + ";lb"); - SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannel({balancers_[0]->port()}); - const size_t kNumRpcsPerAddress = 100; - EdsServiceImpl::ResponseArgs args({ - {"locality0", GetBackendPorts()}, - }); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); - // Make sure that trying to connect works without a call. - channel_->GetState(true /* try_to_connect */); - // We need to wait for all backends to come online. - WaitForAllBackends(); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); - - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, - backends_[i]->backend_service()->request_count()); - } - // The EDS service got a single request, and sent a single response. - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); -} - -TEST_F(SingleBalancerTest, SecureNamingDeathTest) { - ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - // Make sure that we blow up (via abort() from the security connector) when - // the name from the balancer doesn't match expectations. - ASSERT_DEATH_IF_SUPPORTED( - { - ResetStub(0, kApplicationTargetName_ + ";lb"); - SetNextResolution({}, - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"xds_experimental\":{ \"balancerName\": " - "\"fake:///wrong_lb\" } }\n" - " ]\n" - "}"); - SetNextResolutionForLbChannel({balancers_[0]->port()}); - channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); - }, - ""); -} - -TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { +// Tests that RPCs will be blocked until a non-empty serverlist is received. +TEST_F(BasicTest, InitiallyEmptyServerlist) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); @@ -1058,7 +1017,9 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { +// Tests that RPCs will fail with UNAVAILABLE instead of DEADLINE_EXCEEDED if +// all the servers are unreachable. +TEST_F(BasicTest, AllServersUnreachableFailFast) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumUnreachableServers = 5; @@ -1078,7 +1039,81 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, LocalityMapWeightedRoundRobin) { +// Tests that RPCs fail when the backends are down, and will succeed again after +// the backends are restarted. +TEST_F(BasicTest, BackendsRestart) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + WaitForAllBackends(); + // Stop backends. RPCs should fail. + ShutdownAllBackends(); + CheckRpcSendFailure(); + // Restart all backends. RPCs should start succeeding again. + StartAllBackends(); + CheckRpcSendOk(1 /* times */, 2000 /* timeout_ms */, + true /* wait_for_ready */); +} + +using SecureNamingTest = BasicTest; + +// Tests that secure naming check passes if target name is expected. +TEST_F(SecureNamingTest, TargetNameIsExpected) { + // TODO(juanlishen): Use separate fake creds for the balancer channel. + ResetStub(0, kApplicationTargetName_ + ";lb"); + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannel({balancers_[0]->port()}); + const size_t kNumRpcsPerAddress = 100; + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + // Make sure that trying to connect works without a call. + channel_->GetState(true /* try_to_connect */); + // We need to wait for all backends to come online. + WaitForAllBackends(); + // Send kNumRpcsPerAddress RPCs per server. + CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); + // Each backend should have gotten 100 requests. + for (size_t i = 0; i < backends_.size(); ++i) { + EXPECT_EQ(kNumRpcsPerAddress, + backends_[i]->backend_service()->request_count()); + } + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + +// Tests that secure naming check fails if target name is unexpected. +TEST_F(SecureNamingTest, TargetNameIsUnexpected) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + // Make sure that we blow up (via abort() from the security connector) when + // the name from the balancer doesn't match expectations. + ASSERT_DEATH_IF_SUPPORTED( + { + ResetStub(0, kApplicationTargetName_ + ";lb"); + SetNextResolution({}, + "{\n" + " \"loadBalancingConfig\":[\n" + " { \"does_not_exist\":{} },\n" + " { \"xds_experimental\":{ \"balancerName\": " + "\"fake:///wrong_lb\" } }\n" + " ]\n" + "}"); + SetNextResolutionForLbChannel({balancers_[0]->port()}); + channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); + }, + ""); +} + +using LocalityMapTest = BasicTest; + +// Tests that the localities in a locality map are picked according to their +// weights. +TEST_F(LocalityMapTest, WeightedRoundRobin) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1120,7 +1155,9 @@ TEST_F(SingleBalancerTest, LocalityMapWeightedRoundRobin) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, LocalityMapStressTest) { +// Tests that the locality map can work properly even when it contains a large +// number of localities. +TEST_F(LocalityMapTest, StressTest) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumLocalities = 100; @@ -1153,7 +1190,9 @@ TEST_F(SingleBalancerTest, LocalityMapStressTest) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, LocalityMapUpdate) { +// Tests that the localities in a locality map are picked correctly after update +// (addition, modification, deletion). +TEST_F(LocalityMapTest, UpdateMap) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 1000; @@ -1244,7 +1283,10 @@ TEST_F(SingleBalancerTest, LocalityMapUpdate) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, Drop) { +using DropTest = BasicTest; + +// Tests that RPCs are dropped according to the drop config. +TEST_F(DropTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1289,7 +1331,8 @@ TEST_F(SingleBalancerTest, Drop) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropPerHundred) { +// Tests that drop config is converted correctly from per hundred. +TEST_F(DropTest, DropPerHundred) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1329,7 +1372,8 @@ TEST_F(SingleBalancerTest, DropPerHundred) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropPerTenThousand) { +// Tests that drop config is converted correctly from per ten thousand. +TEST_F(DropTest, DropPerTenThousand) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1369,7 +1413,8 @@ TEST_F(SingleBalancerTest, DropPerTenThousand) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropUpdate) { +// Tests that drop is working correctly after update. +TEST_F(DropTest, Update) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1464,7 +1509,8 @@ TEST_F(SingleBalancerTest, DropUpdate) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropAll) { +// Tests that all the RPCs are dropped if any drop category drops 100%. +TEST_F(DropTest, DropAll) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 1000; @@ -1489,7 +1535,11 @@ TEST_F(SingleBalancerTest, DropAll) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, Fallback) { +using FallbackTest = BasicTest; + +// Tests that RPCs are handled by the fallback backends before the serverlist is +// received, but will be handled by the serverlist after it's received. +TEST_F(FallbackTest, Vanilla) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const size_t kNumBackendsInResolution = backends_.size() / 2; @@ -1537,7 +1587,9 @@ TEST_F(SingleBalancerTest, Fallback) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, FallbackUpdate) { +// Tests that RPCs are handled by the updated fallback backends before +// serverlist is received, +TEST_F(FallbackTest, Update) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const size_t kNumBackendsInResolution = backends_.size() / 3; @@ -1617,7 +1669,8 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerChannelFails) { +// Tests that fallback will kick in immediately if the balancer channel fails. +TEST_F(FallbackTest, FallbackEarlyWhenBalancerChannelFails) { const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); // Return an unreachable balancer and one fallback backend. @@ -1629,7 +1682,8 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerChannelFails) { /* wait_for_ready */ false); } -TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { +// Tests that fallback will kick in immediately if the balancer call fails. +TEST_F(FallbackTest, FallbackEarlyWhenBalancerCallFails) { const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); // Return one balancer and one fallback backend. @@ -1643,7 +1697,9 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { /* wait_for_ready */ false); } -TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { +// Tests that fallback mode is entered if balancer response is received but the +// backends can't be reached. +TEST_F(FallbackTest, FallbackIfResponseReceivedButChildNotReady) { const int kFallbackTimeoutMs = 500 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); @@ -1659,7 +1715,9 @@ TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { WaitForBackend(0); } -TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { +// Tests that fallback mode is exited if the balancer tells the client to drop +// all the calls. +TEST_F(FallbackTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Return an unreachable balancer and one fallback backend. SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); @@ -1682,7 +1740,8 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { CheckRpcSendFailure(); } -TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { +// Tests that fallback mode is exited if the child policy becomes ready. +TEST_F(FallbackTest, FallbackModeIsExitedAfterChildRready) { // Return an unreachable balancer and one fallback backend. SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); @@ -1714,29 +1773,14 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { EXPECT_EQ(100U, backends_[1]->backend_service()->request_count()); } -TEST_F(SingleBalancerTest, BackendsRestart) { - SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannelAllBalancers(); - EdsServiceImpl::ResponseArgs args({ - {"locality0", GetBackendPorts()}, - }); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); - WaitForAllBackends(); - // Stop backends. RPCs should fail. - ShutdownAllBackends(); - CheckRpcSendFailure(); - // Restart all backends. RPCs should start succeeding again. - StartAllBackends(); - CheckRpcSendOk(1 /* times */, 2000 /* timeout_ms */, - true /* wait_for_ready */); -} - -class UpdatesTest : public XdsEnd2endTest { +class BalancerUpdateTest : public XdsEnd2endTest { public: - UpdatesTest() : XdsEnd2endTest(4, 3, 0) {} + BalancerUpdateTest() : XdsEnd2endTest(4, 3, 0) {} }; -TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { +// Tests that the old LB call is still used after the balancer address update as +// long as that call is still alive. +TEST_F(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); EdsServiceImpl::ResponseArgs args({ @@ -1747,18 +1791,14 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Wait until the first backend is ready. WaitForBackend(0); - // Send 10 requests. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1767,11 +1807,9 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); SetNextResolutionForLbChannel({balancers_[1]->port()}); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); gpr_timespec deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); @@ -1782,7 +1820,6 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { // The current LB call is still working, so xds continued using it to the // first balancer, which doesn't assign the second backend. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); @@ -1791,7 +1828,12 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } -TEST_F(UpdatesTest, UpdateBalancerName) { +// Tests that the old LB call is still used after multiple balancer address +// updates as long as that call is still alive. Send an update with the same set +// of LBs as the one in SetUp() in order to verify that the LB channel inside +// xds keeps the initial connection (which by definition is also present in the +// update). +TEST_F(BalancerUpdateTest, Repeated) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); EdsServiceImpl::ResponseArgs args({ @@ -1802,18 +1844,14 @@ TEST_F(UpdatesTest, UpdateBalancerName) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Wait until the first backend is ready. WaitForBackend(0); - // Send 10 requests. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1822,49 +1860,44 @@ TEST_F(UpdatesTest, UpdateBalancerName) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - std::vector ports; + ports.emplace_back(balancers_[0]->port()); ports.emplace_back(balancers_[1]->port()); - auto new_lb_channel_response_generator = - grpc_core::MakeRefCounted(); - SetNextResolutionForLbChannel(ports, nullptr, - new_lb_channel_response_generator.get()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE BALANCER NAME =========="); - SetNextResolution({}, - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"xds_experimental\":{ \"balancerName\": " - "\"fake:///updated_lb\" } }\n" - " ]\n" - "}", - new_lb_channel_response_generator.get()); - gpr_log(GPR_INFO, "========= UPDATED BALANCER NAME =========="); - - // Wait until update has been processed, as signaled by the second backend - // receiving a request. + ports.emplace_back(balancers_[2]->port()); + gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); + SetNextResolutionForLbChannel(ports); + gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + gpr_timespec deadline = gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); + // Send 10 seconds worth of RPCs + do { + CheckRpcSendOk(); + } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); + // xds continued using the original LB call to the first balancer, which + // doesn't assign the second backend. + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + ports.clear(); + ports.emplace_back(balancers_[0]->port()); + ports.emplace_back(balancers_[1]->port()); + gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 2 =========="); + SetNextResolutionForLbChannel(ports); + gpr_log(GPR_INFO, "========= UPDATE 2 DONE =========="); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_millis(10000, GPR_TIMESPAN)); + // Send 10 seconds worth of RPCs + do { + CheckRpcSendOk(); + } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); + // xds continued using the original LB call to the first balancer, which + // doesn't assign the second backend. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - WaitForBackend(1); - - backends_[1]->backend_service()->ResetCounters(); - gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); - // All 10 requests should have gone to the second backend. - EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); - - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); - EXPECT_EQ(1U, balancers_[1]->eds_service()->request_count()); - EXPECT_EQ(1U, balancers_[1]->eds_service()->response_count()); - EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); - EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } -// Send an update with the same set of LBs as the one in SetUp() in order to -// verify that the LB channel inside xds keeps the initial connection (which -// by definition is also present in the update). -TEST_F(UpdatesTest, UpdateBalancersRepeated) { +// Tests that if the balancer name changes, a new LB channel will be created to +// replace the old one. +TEST_F(BalancerUpdateTest, UpdateBalancerName) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); EdsServiceImpl::ResponseArgs args({ @@ -1875,18 +1908,14 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Wait until the first backend is ready. WaitForBackend(0); - // Send 10 requests. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1895,46 +1924,45 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - std::vector ports; - ports.emplace_back(balancers_[0]->port()); ports.emplace_back(balancers_[1]->port()); - ports.emplace_back(balancers_[2]->port()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolutionForLbChannel(ports); - gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - gpr_timespec deadline = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // xds continued using the original LB call to the first balancer, which - // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - - ports.clear(); - ports.emplace_back(balancers_[0]->port()); - ports.emplace_back(balancers_[1]->port()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 2 =========="); - SetNextResolutionForLbChannel(ports); - gpr_log(GPR_INFO, "========= UPDATE 2 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // xds continued using the original LB call to the first balancer, which - // doesn't assign the second backend. + auto new_lb_channel_response_generator = + grpc_core::MakeRefCounted(); + SetNextResolutionForLbChannel(ports, nullptr, + new_lb_channel_response_generator.get()); + gpr_log(GPR_INFO, "========= ABOUT TO UPDATE BALANCER NAME =========="); + SetNextResolution({}, + "{\n" + " \"loadBalancingConfig\":[\n" + " { \"does_not_exist\":{} },\n" + " { \"xds_experimental\":{ \"balancerName\": " + "\"fake:///updated_lb\" } }\n" + " ]\n" + "}", + new_lb_channel_response_generator.get()); + gpr_log(GPR_INFO, "========= UPDATED BALANCER NAME =========="); + // Wait until update has been processed, as signaled by the second backend + // receiving a request. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + WaitForBackend(1); + backends_[1]->backend_service()->ResetCounters(); + gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); + CheckRpcSendOk(10); + gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); + // All 10 requests should have gone to the second backend. + EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(1U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } -TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { +// Tests that if the balancer is down, the RPCs will still be sent to the +// backends according to the last balancer response, until a new balancer is +// reachable. +TEST_F(BalancerUpdateTest, DeadUpdate) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); EdsServiceImpl::ResponseArgs args({ @@ -1945,19 +1973,16 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Start servers and send 10 RPCs per server. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // Kill balancer 0 gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************"); balancers_[0]->Shutdown(); gpr_log(GPR_INFO, "********** KILLED BALANCER 0 *************"); - // This is serviced by the existing child policy. gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); CheckRpcSendOk(10); @@ -1965,7 +1990,6 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { // All 10 requests should again have gone to the first backend. EXPECT_EQ(20U, backends_[0]->backend_service()->request_count()); EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1974,17 +1998,14 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); SetNextResolutionForLbChannel({balancers_[1]->port()}); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - // Wait until update has been processed, as signaled by the second backend // receiving a request. In the meantime, the client continues to be serviced // (by the first backend) without interruption. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); WaitForBackend(1); - // This is serviced by the updated RR policy backends_[1]->backend_service()->ResetCounters(); gpr_log(GPR_INFO, "========= BEFORE THIRD BATCH =========="); @@ -1992,7 +2013,6 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { gpr_log(GPR_INFO, "========= DONE WITH THIRD BATCH =========="); // All 10 requests should have gone to the second backend. EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); // The second balancer, published as part of the first update, may end up @@ -2010,17 +2030,18 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { // The re-resolution tests are deferred because they rely on the fallback mode, // which hasn't been supported. -// TODO(juanlishen): Add TEST_F(UpdatesTest, ReresolveDeadBackend). +// TODO(juanlishen): Add TEST_F(BalancerUpdateTest, ReresolveDeadBackend). // TODO(juanlishen): Add TEST_F(UpdatesWithClientLoadReportingTest, // ReresolveDeadBalancer) -class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { +class ClientLoadReportingTest : public XdsEnd2endTest { public: - SingleBalancerWithClientLoadReportingTest() : XdsEnd2endTest(4, 1, 3) {} + ClientLoadReportingTest() : XdsEnd2endTest(4, 1, 3) {} }; -TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { +// Tests that the load report received at the balancer is correct. +TEST_F(ClientLoadReportingTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 100; @@ -2059,7 +2080,9 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { EXPECT_EQ(0U, client_stats->total_dropped_requests()); } -TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { +// Tests that if the balancer restarts, the client load report contains the +// stats before and after the restart correctly. +TEST_F(ClientLoadReportingTest, BalancerRestart) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumBackendsFirstPass = backends_.size() / 2; @@ -2116,13 +2139,13 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { EXPECT_EQ(0U, client_stats->total_dropped_requests()); } -class SingleBalancerWithClientLoadReportingAndDropTest : public XdsEnd2endTest { +class ClientLoadReportingWithDropTest : public XdsEnd2endTest { public: - SingleBalancerWithClientLoadReportingAndDropTest() - : XdsEnd2endTest(4, 1, 20) {} + ClientLoadReportingWithDropTest() : XdsEnd2endTest(4, 1, 20) {} }; -TEST_F(SingleBalancerWithClientLoadReportingAndDropTest, Vanilla) { +// Tests that the drop stats are correctly reported by client load reporting. +TEST_F(ClientLoadReportingWithDropTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 3000; From 88aef7cd75bcdb703d041317a5b719619fc71da8 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 3 Sep 2019 17:12:28 -0700 Subject: [PATCH 079/176] Fix default case --- src/compiler/python_generator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index f553d9e7a3c..8935a516f8a 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -763,7 +763,7 @@ static bool ParseParameters(const grpc::string& parameter, std::vector comma_delimited_parameters; grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); if (comma_delimited_parameters.size() == 1 && - comma_delimited_parameters.empty()) { + comma_delimited_parameters[0].empty()) { *grpc_version = "grpc_2_0"; } else if (comma_delimited_parameters.size() == 1) { *grpc_version = comma_delimited_parameters[0]; From ce9e6376149a82840645e8b7cef152033f71c741 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 13:53:37 +0200 Subject: [PATCH 080/176] enable server compression tests for grpc.aspnetcore.server --- tools/run_tests/run_interop_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 0847d8426b8..099b8c7b1a5 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -211,7 +211,7 @@ class AspNetCoreLanguage: _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS def unimplemented_test_cases_server(self): - return _SKIP_SERVER_COMPRESSION + return [] def __str__(self): return 'aspnetcore' From 36574888be8cabfb66345be8ffd1c152d80e0183 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 09:53:41 -0400 Subject: [PATCH 081/176] upgrade bazel to 0.29 --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 12a22785623..9762bdcb85f 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index 4d1d57f60d9..cfa875b0e63 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.28.1 +VERSION=0.29.0 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7141fb9c5f1..fde54bae877 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index badff52de34..4d3691f32bd 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 From 0c3a5990b1c3117f5808eed8933607772ef37e69 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 03:48:40 -0400 Subject: [PATCH 082/176] upgrade windows RBE to bazel 0.29 --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 153b2d59687..e55534e2e84 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.26.0 --limit-output +choco install bazel -y --version 0.29.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 08dc3310191031cf6eccb98c49216a407d4d0c0f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 04:09:21 -0400 Subject: [PATCH 083/176] try fix win RBE build --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- tools/remote_build/windows.bazelrc | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index e55534e2e84..8d8ea118ebd 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE. -bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --incompatible_disallow_filetype=false --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json +bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json set BAZEL_EXITCODE=%errorlevel% @rem TODO(jtattermusch): upload results to bigquery diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 9fd3071e79f..825d6765de9 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -1,8 +1,7 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain @@ -38,7 +37,7 @@ test --test_env=GRPC_VERBOSITY=debug # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing From 0040bb9353f782b788e4bbbe20efdc87b36aa619 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 21 Nov 2018 10:55:41 +0100 Subject: [PATCH 084/176] attempt to add alpine C# distribtest --- .../DistribTest/DistribTestDotNet.csproj | 2 +- .../csharp/run_distrib_test_dotnetcli.sh | 17 ++++++++----- .../distribtest/csharp_alpine_x64/Dockerfile | 24 +++++++++++++++++++ .../artifacts/distribtest_targets.py | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile diff --git a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj index d19eac91ba4..8cdf926f07f 100644 --- a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj +++ b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp1.0;net45 + netcoreapp2.1 false false false diff --git a/test/distrib/csharp/run_distrib_test_dotnetcli.sh b/test/distrib/csharp/run_distrib_test_dotnetcli.sh index 86c2d5231e1..357ce136cb7 100755 --- a/test/distrib/csharp/run_distrib_test_dotnetcli.sh +++ b/test/distrib/csharp/run_distrib_test_dotnetcli.sh @@ -28,19 +28,24 @@ cd DistribTest dotnet restore DistribTestDotNet.csproj dotnet build DistribTestDotNet.csproj -dotnet publish -f netcoreapp1.0 DistribTestDotNet.csproj -dotnet publish -f net45 DistribTestDotNet.csproj +dotnet publish -f netcoreapp2.1 DistribTestDotNet.csproj +#dotnet publish -f net45 DistribTestDotNet.csproj ls -R bin +#ldd /root/.nuget/packages/grpc.core/*/lib/netstandard1.5/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so + +#ldd /root/.nuget/packages/grpc.tools/*/tools/linux_x64/grpc_csharp_plugin + +#exit 1 # .NET 4.5 target after dotnet build -mono bin/Debug/net45/publish/DistribTestDotNet.exe +#mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET 4.5 target after dotnet publish -mono bin/Debug/net45/publish/DistribTestDotNet.exe +#mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET Core target after dotnet build -dotnet exec bin/Debug/netcoreapp1.0/DistribTestDotNet.dll +dotnet exec bin/Debug/netcoreapp2.1/DistribTestDotNet.dll # .NET Core target after dotnet publish -dotnet exec bin/Debug/netcoreapp1.0/publish/DistribTestDotNet.dll +dotnet exec bin/Debug/netcoreapp2.1/publish/DistribTestDotNet.dll diff --git a/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile new file mode 100644 index 00000000000..aa5034872c3 --- /dev/null +++ b/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile @@ -0,0 +1,24 @@ +# 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. + +FROM microsoft/dotnet:2.1-sdk-alpine + +RUN apk update && apk add bash +RUN apk update && apk add unzip + +# needed to satisfy the "ld-linux-x86-64.so.2" dependency +RUN apk add libc6-compat + +#RUN apk add libnsl +#RUN cp /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 35a561ea928..d45abdcbd41 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -309,6 +309,7 @@ def targets(): CSharpDistribTest('linux', 'x64', 'ubuntu1404'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True), + CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), CSharpDistribTest('windows', 'x86'), CSharpDistribTest('windows', 'x64'), From 32dbe30b3517c8f4d93b6141d1f9066c2b53d960 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:04:04 -0400 Subject: [PATCH 085/176] add .NET Core distribtest for ubuntu 16.04 --- .../distribtest/csharp_ubuntu1604_x64/Dockerfile | 10 ++++++++++ tools/run_tests/artifacts/distribtest_targets.py | 1 + 2 files changed, 11 insertions(+) diff --git a/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile index 93ee75cfcd4..e0d8c458d0a 100644 --- a/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile @@ -24,6 +24,16 @@ RUN apt-get update && apt-get install -y \ nuget \ && apt-get clean +RUN apt-get update && apt-get install -y curl && apt-get clean + +# Install dotnet SDK +ENV DOTNET_SDK_VERSION 2.1.500 +RUN curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \ + && mkdir -p /usr/share/dotnet \ + && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ + && rm dotnet.tar.gz \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + RUN apt-get update && apt-get install -y unzip && apt-get clean # Make sure the mono certificate store is up-to-date to prevent issues with nuget restore diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index d45abdcbd41..e221dee3ab8 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -308,6 +308,7 @@ def targets(): CSharpDistribTest('linux', 'x64', 'centos7'), CSharpDistribTest('linux', 'x64', 'ubuntu1404'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), + CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), From f4c723556650dd49df1c1ad0c93eab4e7d86e5ca Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:06:23 -0400 Subject: [PATCH 086/176] get rid of ubuntu14.04 C# distribtests --- .../csharp_ubuntu1404_x64/Dockerfile | 44 ------------------- .../artifacts/distribtest_targets.py | 2 - 2 files changed, 46 deletions(-) delete mode 100644 tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile diff --git a/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile deleted file mode 100644 index 61ca1a08a46..00000000000 --- a/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# 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. - -FROM ubuntu:14.04 - -RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean - -RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-trusty main" | tee /etc/apt/sources.list.d/mono-official-stable.list - -RUN apt-get update && apt-get install -y \ - mono-devel \ - nuget \ - && apt-get clean - -RUN apt-get update && apt-get install -y unzip && apt-get clean - -# Install dotnet CLI -RUN apt-get install -y apt-transport-https -RUN sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' -RUN apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 -RUN apt-get update && apt-get install -y dotnet-dev-1.0.4 - -# Trigger the population of the local package cache for dotnet CLI -RUN mkdir warmup \ - && cd warmup \ - && dotnet new \ - && cd .. \ - && rm -rf warmup - -# Make sure the mono certificate store is up-to-date to prevent issues with nuget restore -RUN apt-get update && apt-get install -y curl && apt-get clean -RUN curl https://curl.haxx.se/ca/cacert.pem > ~/cacert.pem && cert-sync ~/cacert.pem && rm -f ~/cacert.pem diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index e221dee3ab8..2c7af6e37fc 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -306,10 +306,8 @@ def targets(): CSharpDistribTest('linux', 'x64', 'jessie'), CSharpDistribTest('linux', 'x86', 'jessie'), CSharpDistribTest('linux', 'x64', 'centos7'), - CSharpDistribTest('linux', 'x64', 'ubuntu1404'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), - CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), CSharpDistribTest('windows', 'x86'), From e0b87cd4a13bb29eb68350b0207b75fdb9f8cd9f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:26:27 -0400 Subject: [PATCH 087/176] add debian stretch distribtest --- .../distribtest/csharp_stretch_x64/Dockerfile | 41 +++++++++++++++++++ .../artifacts/distribtest_targets.py | 2 + 2 files changed, 43 insertions(+) create mode 100644 tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile diff --git a/tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile new file mode 100644 index 00000000000..97779c52f8b --- /dev/null +++ b/tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile @@ -0,0 +1,41 @@ +# Copyright 2019 The 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. + +FROM debian:stretch + +RUN apt-get update && apt-get install -y apt-transport-https dirmngr gnupg ca-certificates && apt-get clean + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +RUN echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | tee /etc/apt/sources.list.d/mono-official-stable.list + +RUN apt-get update && apt-get install -y \ + mono-devel \ + nuget \ + && apt-get clean + +RUN apt-get update && apt-get install -y curl && apt-get clean + +# Install dotnet SDK +ENV DOTNET_SDK_VERSION 2.1.500 +RUN curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \ + && mkdir -p /usr/share/dotnet \ + && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ + && rm dotnet.tar.gz \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + +RUN apt-get update && apt-get install -y unzip && apt-get clean + +# Make sure the mono certificate store is up-to-date to prevent issues with nuget restore +RUN apt-get update && apt-get install -y curl && apt-get clean +RUN curl https://curl.haxx.se/ca/cacert.pem > ~/cacert.pem && cert-sync ~/cacert.pem && rm -f ~/cacert.pem diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 2c7af6e37fc..5baf9d6c298 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -305,6 +305,8 @@ def targets(): CppDistribTest('windows', 'x86', testcase='cmake_as_externalproject'), CSharpDistribTest('linux', 'x64', 'jessie'), CSharpDistribTest('linux', 'x86', 'jessie'), + CSharpDistribTest('linux', 'x64', 'stretch'), + CSharpDistribTest('linux', 'x64', 'stretch', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'centos7'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), From 21104ec1ee26d2f89affaa76a737ec23fb185e61 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:29:22 -0400 Subject: [PATCH 088/176] remove BOM --- test/distrib/csharp/DistribTest/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/distrib/csharp/DistribTest/Program.cs b/test/distrib/csharp/DistribTest/Program.cs index 0ea7211fc45..92f416785a6 100644 --- a/test/distrib/csharp/DistribTest/Program.cs +++ b/test/distrib/csharp/DistribTest/Program.cs @@ -16,7 +16,7 @@ #endregion -using System; +using System; using Grpc.Core; namespace TestGrpcPackage From 504c4ace804ba7e18c84125501628cf5cb327e97 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:32:31 -0400 Subject: [PATCH 089/176] remove legacy c# testcodegen --- test/distrib/csharp/run_distrib_test.sh | 3 -- .../csharp/test_codegen/test_codegen.sh | 38 ------------------- .../csharp/test_codegen/testcodegen.proto | 29 -------------- test/distrib/csharp/update_version.sh | 2 +- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100755 test/distrib/csharp/test_codegen/test_codegen.sh delete mode 100644 test/distrib/csharp/test_codegen/testcodegen.proto diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh index 45911cd91a7..824e33e2876 100755 --- a/test/distrib/csharp/run_distrib_test.sh +++ b/test/distrib/csharp/run_distrib_test.sh @@ -27,6 +27,3 @@ nuget restore || nuget restore || nuget restore msbuild DistribTest.sln mono DistribTest/bin/Debug/DistribTest.exe - -# test that codegen work -test_codegen/test_codegen.sh diff --git a/test/distrib/csharp/test_codegen/test_codegen.sh b/test/distrib/csharp/test_codegen/test_codegen.sh deleted file mode 100755 index fa101889f68..00000000000 --- a/test/distrib/csharp/test_codegen/test_codegen.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Copyright 2018 The 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. - -set -ex - -cd "$(dirname "$0")" - -ls -lR "../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools" - -PLATFORM_ARCH=linux_x64 -if [ "$(uname)" == "Darwin" ] -then - PLATFORM_ARCH=macosx_x64 -elif [ "$(getconf LONG_BIT)" == "32" ] -then - PLATFORM_ARCH=linux_x86 -fi - -PROTOC=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/protoc -PLUGIN=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/grpc_csharp_plugin - -"${PROTOC}" --plugin="protoc-gen-grpc=${PLUGIN}" --csharp_out=. --grpc_out=. -I . testcodegen.proto - -ls ./*.cs - -echo 'Code generation works.' diff --git a/test/distrib/csharp/test_codegen/testcodegen.proto b/test/distrib/csharp/test_codegen/testcodegen.proto deleted file mode 100644 index 5c228b81dba..00000000000 --- a/test/distrib/csharp/test_codegen/testcodegen.proto +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The 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. - -syntax = "proto3"; - -package testcodegen; - -service Greeter { - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -message HelloRequest { - string name = 1; -} - -message HelloReply { - string message = 1; -} diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh index 0e47ed3abd5..9759cc56481 100755 --- a/test/distrib/csharp/update_version.sh +++ b/test/distrib/csharp/update_version.sh @@ -28,4 +28,4 @@ then fi # Replaces version placeholder with value provided as first argument. -sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj test_codegen/test_codegen.sh +sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj From aeb04913adfcbf90cf3dd4c2cb1aa8f55ac54508 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 9 Apr 2019 12:41:27 -0400 Subject: [PATCH 090/176] improved C# distribtest --- test/distrib/csharp/DistribTest/Program.cs | 44 +++++++++++++++---- .../csharp/DistribTest/testcodegen.proto | 2 +- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/test/distrib/csharp/DistribTest/Program.cs b/test/distrib/csharp/DistribTest/Program.cs index 92f416785a6..bda7b2104d6 100644 --- a/test/distrib/csharp/DistribTest/Program.cs +++ b/test/distrib/csharp/DistribTest/Program.cs @@ -17,7 +17,10 @@ #endregion using System; +using System.Linq; +using System.Threading.Tasks; using Grpc.Core; +using Helloworld; namespace TestGrpcPackage { @@ -25,14 +28,39 @@ namespace TestGrpcPackage { public static void Main(string[] args) { - // test codegen works - var reply = new Testcodegen.HelloReply(); - - // This code doesn't do much but makes sure the native extension is loaded - // which is what we are testing here. - Channel c = new Channel("127.0.0.1:1000", ChannelCredentials.Insecure); - c.ShutdownAsync().Wait(); - Console.WriteLine("Success!"); + // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 + Server server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) + { + Services = { Greeter.BindService(new GreeterImpl()) }, + Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) } + }; + server.Start(); + + Channel channel = new Channel("localhost", server.Ports.Single().BoundPort, ChannelCredentials.Insecure); + + try + { + var client = new Greeter.GreeterClient(channel); + String user = "you"; + + var reply = client.SayHello(new HelloRequest { Name = user }); + Console.WriteLine("Greeting: " + reply.Message); + Console.WriteLine("Success!"); + } + finally + { + channel.ShutdownAsync().Wait(); + server.ShutdownAsync().Wait(); + } + } + } + + class GreeterImpl : Greeter.GreeterBase + { + // Server side handler of the SayHello RPC + public override Task SayHello(HelloRequest request, ServerCallContext context) + { + return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); } } } diff --git a/test/distrib/csharp/DistribTest/testcodegen.proto b/test/distrib/csharp/DistribTest/testcodegen.proto index 7845ac92c49..61444fc080e 100644 --- a/test/distrib/csharp/DistribTest/testcodegen.proto +++ b/test/distrib/csharp/DistribTest/testcodegen.proto @@ -14,7 +14,7 @@ syntax = "proto3"; -package testcodegen; +package helloworld; service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} From a5560e8f7300463d4cb3506bb5fee73446affd8c Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 4 Sep 2019 09:20:33 -0700 Subject: [PATCH 091/176] Fix PHP build error --- config.m4 | 2 ++ src/php/ext/grpc/config.m4 | 7 ++++--- templates/config.m4.template | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.m4 b/config.m4 index 4a8651dae38..efa86576f84 100644 --- a/config.m4 +++ b/config.m4 @@ -33,6 +33,8 @@ if test "$PHP_GRPC" != "no"; then ;; esac + PHP_SUBST(GRPC_SHARED_LIBADD) + PHP_NEW_EXTENSION(grpc, src/php/ext/grpc/byte_buffer.c \ src/php/ext/grpc/call.c \ diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index 1af93ceecad..ed62dee71cc 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -42,14 +42,15 @@ if test "$PHP_GRPC" != "no"; then dnl PHP_ADD_LIBRARY(pthread,,GRPC_SHARED_LIBADD) GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" PHP_ADD_LIBRARY(pthread) - PHP_ADD_LIBRARY(stdc++,,GRPC_SHARED_LIBADD) - PHP_ADD_LIBRARY(stdc++) PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(dl) case $host in - *darwin*) ;; + *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) + ;; *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; diff --git a/templates/config.m4.template b/templates/config.m4.template index f13ac75914f..edb6a99dc67 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -35,6 +35,8 @@ ;; esac + PHP_SUBST(GRPC_SHARED_LIBADD) + PHP_NEW_EXTENSION(grpc, % for source in php_config_m4.src: ${source} ${"\\"} From 539b422708be9fc4ced914bf6738de49dc794852 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 4 Sep 2019 17:26:26 -0700 Subject: [PATCH 092/176] Trim trailing spaces --- src/php/ext/grpc/config.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index ed62dee71cc..7260dbc72ef 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -46,7 +46,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_LIBRARY(dl) case $host in - *darwin*) + *darwin*) PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) ;; *) @@ -94,7 +94,7 @@ if test "$PHP_COVERAGE" = "yes"; then if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-coverage]) fi - + dnl Check if ccache is being used case `$php_shtool path $CC` in *ccache*[)] gcc_ccache=yes;; @@ -104,7 +104,7 @@ if test "$PHP_COVERAGE" = "yes"; then if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi - + lcov_version_list="1.5 1.6 1.7 1.9 1.10 1.11 1.12 1.13" AC_CHECK_PROG(LCOV, lcov, lcov) @@ -123,7 +123,7 @@ if test "$PHP_COVERAGE" = "yes"; then done ]) else - lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list" + lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi From 1a331967102a7741369ee7f333a50e6418bb50ed Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 09:50:21 +0200 Subject: [PATCH 093/176] upgrade helloworld example to 2.23.0 --- examples/csharp/Helloworld/Greeter/Greeter.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/csharp/Helloworld/Greeter/Greeter.csproj b/examples/csharp/Helloworld/Greeter/Greeter.csproj index 7989f795418..223b7fe1242 100644 --- a/examples/csharp/Helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/Helloworld/Greeter/Greeter.csproj @@ -5,9 +5,9 @@ - - - + + + From cbac0b43616a1cb121923a70748be821c1cd02be Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 09:50:41 +0200 Subject: [PATCH 094/176] upgrade routeguide example to 2.23.0 --- examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj index 4c6949488c7..bd374a887c1 100644 --- a/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj +++ b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj @@ -5,9 +5,9 @@ - - - + + + From 10156898ea52c46e628aee42cd4c29d16ae21364 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 09:58:11 +0200 Subject: [PATCH 095/176] upgrade helloworld classic example to 2.23.0 --- .../Greeter/Greeter.csproj | 30 ++++++++++++------- .../Greeter/packages.config | 15 ++++++---- .../GreeterClient/GreeterClient.csproj | 28 ++++++++++------- .../GreeterClient/packages.config | 13 ++++---- .../GreeterServer/GreeterServer.csproj | 28 ++++++++++------- .../GreeterServer/packages.config | 13 ++++---- 6 files changed, 80 insertions(+), 47 deletions(-) diff --git a/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj b/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj index da15ba3954b..adb2c7ac2c9 100644 --- a/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj @@ -1,4 +1,4 @@ - + @@ -33,18 +33,26 @@ false - - ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - - ..\packages\Grpc.Core.1.17.0\lib\net45\Grpc.Core.dll + + ..\packages\Grpc.Core.2.23.0\lib\net45\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\net45\Grpc.Core.Api.dll - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -57,14 +65,14 @@ - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config b/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config index 154b5993213..418bfaba736 100644 --- a/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config @@ -1,8 +1,11 @@ - + - - - + + + + - - + + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj index 31a3a90345b..ec860440cfb 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj @@ -1,4 +1,4 @@ - + Debug @@ -32,18 +32,26 @@ true - - ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - - ..\packages\Grpc.Core.1.17.0\lib\net45\Grpc.Core.dll + + ..\packages\Grpc.Core.2.23.0\lib\net45\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\net45\Grpc.Core.Api.dll - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -59,11 +67,11 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config index 2fd8228689d..1f648dd06b8 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config @@ -1,7 +1,10 @@ - + - - - - + + + + + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj index 27ca9630401..e4685a6fc07 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj @@ -1,4 +1,4 @@ - + Debug @@ -32,18 +32,26 @@ true - - ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - - ..\packages\Grpc.Core.1.17.0\lib\net45\Grpc.Core.dll + + ..\packages\Grpc.Core.2.23.0\lib\net45\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\net45\Grpc.Core.Api.dll - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -59,11 +67,11 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config index 2fd8228689d..1f648dd06b8 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config @@ -1,7 +1,10 @@ - + - - - - + + + + + + + \ No newline at end of file From 12dc0da99db8da3d399d1acd77bb8f190b978c7d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 10:14:10 +0200 Subject: [PATCH 096/176] upgrade HelloworldXamarin example to 2.23.0 --- .../Droid/HelloworldXamarin.Droid.csproj | 38 ++++++++++++---- .../Droid/Properties/AndroidManifest.xml | 7 ++- .../HelloworldXamarin/Droid/packages.config | 8 +++- .../HelloworldXamarin/HelloworldXamarin.sln | 36 ++++++++++----- .../iOS/HelloworldXamarin.iOS.csproj | 45 ++++++++++++++----- .../HelloworldXamarin/iOS/packages.config | 8 +++- 6 files changed, 103 insertions(+), 39 deletions(-) diff --git a/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj b/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj index 991fa0c9bcc..a25dfdf92d0 100644 --- a/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj +++ b/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj @@ -1,4 +1,4 @@ - + Debug @@ -15,7 +15,8 @@ Properties\AndroidManifest.xml Resources Assets - true + + true @@ -38,7 +39,25 @@ false + + ..\packages\Google.Protobuf.3.8.0\lib\netstandard2.0\Google.Protobuf.dll + + + ..\packages\Grpc.Core.2.23.0\lib\netstandard2.0\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\netstandard2.0\Grpc.Core.Api.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -50,12 +69,6 @@ ..\packages\System.Interactive.Async.3.1.1\lib\netstandard1.3\System.Interactive.Async.dll - - ..\packages\Google.Protobuf.3.6.0\lib\netstandard1.0\Google.Protobuf.dll - - - ..\packages\Grpc.Core.1.18.0\lib\netstandard1.5\Grpc.Core.dll - @@ -63,6 +76,7 @@ + @@ -79,5 +93,11 @@ - + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml b/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml index 4f2167a1a03..9d767ff323d 100644 --- a/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml +++ b/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml @@ -1,6 +1,5 @@  - - - - + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/Droid/packages.config b/examples/csharp/HelloworldXamarin/Droid/packages.config index 29201117298..d56f8b7d22e 100644 --- a/examples/csharp/HelloworldXamarin/Droid/packages.config +++ b/examples/csharp/HelloworldXamarin/Droid/packages.config @@ -1,11 +1,13 @@  - - + + + + @@ -22,6 +24,7 @@ + @@ -31,6 +34,7 @@ + diff --git a/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln b/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln index e2a738f157e..ee3ea5c95d6 100644 --- a/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln +++ b/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln @@ -1,6 +1,7 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.329 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "HelloworldXamarin", "HelloworldXamarin\HelloworldXamarin.shproj", "{42FFF3D8-934F-4475-8E68-08DA340BF6E8}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloworldXamarin.Droid", "Droid\HelloworldXamarin.Droid.csproj", "{B9B0D41C-1C07-4590-A919-5865E741B2EA}" @@ -8,38 +9,49 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloworldXamarin.iOS", "iOS\HelloworldXamarin.iOS.csproj", "{62336DF0-60D8-478F-8140-B3CB089B417E}" EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + HelloworldXamarin\HelloworldXamarin.projitems*{42fff3d8-934f-4475-8e68-08da340bf6e8}*SharedItemsImports = 13 + HelloworldXamarin\HelloworldXamarin.projitems*{62336df0-60d8-478f-8140-b3cb089b417e}*SharedItemsImports = 4 + HelloworldXamarin\HelloworldXamarin.projitems*{b9b0d41c-1c07-4590-a919-5865e741b2ea}*SharedItemsImports = 4 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + Debug|iPhone = Debug|iPhone Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|Any CPU = Release|Any CPU Release|iPhone = Release|iPhone Release|iPhoneSimulator = Release|iPhoneSimulator - Debug|iPhone = Debug|iPhone EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.Build.0 = Release|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.Build.0 = Debug|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.Build.0 = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhone.ActiveCfg = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhone.Build.0 = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.Build.0 = Debug|Any CPU {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator - {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.ActiveCfg = Release|iPhone - {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.Build.0 = Release|iPhone + {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.ActiveCfg = Debug|iPhone + {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.Build.0 = Debug|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.ActiveCfg = Release|iPhone + {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.Build.0 = Release|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhone.ActiveCfg = Release|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhone.Build.0 = Release|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator - {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.ActiveCfg = Debug|iPhone - {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.Build.0 = Debug|iPhone + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CDC6F6DC-E1C6-45A7-ACC2-A61CDCCA1436} EndGlobalSection EndGlobal diff --git a/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj b/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj index 9154bf33527..844e06c24c6 100644 --- a/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj +++ b/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj @@ -1,4 +1,4 @@ - + Debug @@ -9,6 +9,8 @@ HelloworldXamarin.iOS HelloworldXamarin.iOS Resources + + true @@ -77,7 +79,25 @@ x86 + + ..\packages\Google.Protobuf.3.8.0\lib\netstandard2.0\Google.Protobuf.dll + + + ..\packages\Grpc.Core.2.23.0\lib\netstandard2.0\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\netstandard2.0\Grpc.Core.Api.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -89,16 +109,14 @@ ..\packages\System.Interactive.Async.3.1.1\lib\netstandard1.3\System.Interactive.Async.dll - - ..\packages\Google.Protobuf.3.6.0\lib\netstandard1.0\Google.Protobuf.dll - - - ..\packages\Grpc.Core.1.18.0\lib\netstandard1.5\Grpc.Core.dll - - - + + false + + + false + @@ -108,6 +126,7 @@ + @@ -122,5 +141,11 @@ - + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/iOS/packages.config b/examples/csharp/HelloworldXamarin/iOS/packages.config index 055222ba48f..80802a8d124 100644 --- a/examples/csharp/HelloworldXamarin/iOS/packages.config +++ b/examples/csharp/HelloworldXamarin/iOS/packages.config @@ -1,11 +1,13 @@  - - + + + + @@ -22,6 +24,7 @@ + @@ -31,6 +34,7 @@ + From b876b35457121878345de26a1542d24cbb2d56a4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 13:48:31 +0200 Subject: [PATCH 097/176] address review comments --- src/csharp/Grpc.Core.Api/SerializationContext.cs | 4 ++-- .../Internal/DefaultSerializationContextTest.cs | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/SerializationContext.cs b/src/csharp/Grpc.Core.Api/SerializationContext.cs index 76f1951b68e..59e14c12e3b 100644 --- a/src/csharp/Grpc.Core.Api/SerializationContext.cs +++ b/src/csharp/Grpc.Core.Api/SerializationContext.cs @@ -28,7 +28,7 @@ namespace Grpc.Core { /// /// Use the byte array as serialized form of current message and mark serialization process as complete. - /// Complete() can only be called once. By calling this method the caller gives up the ownership of the + /// Complete(byte[]) can only be called once. By calling this method the caller gives up the ownership of the /// payload which must not be accessed afterwards. /// /// the serialized form of current message @@ -47,7 +47,7 @@ namespace Grpc.Core } /// - /// Complete the payload written to the buffer writer. Complete() can only be called once. + /// Complete the payload written to the buffer writer. Complete() can only be called once. /// public virtual void Complete() { diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs index fcb12ae6656..061230d8ca4 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -189,9 +189,6 @@ namespace Grpc.Core.Internal.Tests } } - // other ideas: - // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) - private DefaultSerializationContext.UsageScope NewDefaultSerializationContextScope() { return new DefaultSerializationContext.UsageScope(new DefaultSerializationContext()); From 91716467138c03fb97391c68cab3365ccf14a122 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 08:05:36 -0400 Subject: [PATCH 098/176] fix dependencies for classic .csproj --- test/distrib/csharp/DistribTest/DistribTest.csproj | 10 ++++++++-- test/distrib/csharp/DistribTest/packages.config | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/distrib/csharp/DistribTest/DistribTest.csproj b/test/distrib/csharp/DistribTest/DistribTest.csproj index e3fc94b4f23..a7f48146a5d 100644 --- a/test/distrib/csharp/DistribTest/DistribTest.csproj +++ b/test/distrib/csharp/DistribTest/DistribTest.csproj @@ -68,8 +68,14 @@ - - ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll diff --git a/test/distrib/csharp/DistribTest/packages.config b/test/distrib/csharp/DistribTest/packages.config index 5e09d5dad01..b6c6730e34b 100644 --- a/test/distrib/csharp/DistribTest/packages.config +++ b/test/distrib/csharp/DistribTest/packages.config @@ -9,6 +9,8 @@ - + + + \ No newline at end of file From ece5fbdcb0aecc152da6cce81b33695c7adad453 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 08:06:39 -0400 Subject: [PATCH 099/176] partially revert alpine distribtest attempts --- .../csharp/DistribTest/DistribTestDotNet.csproj | 12 +++++------- test/distrib/csharp/run_distrib_test_dotnetcli.sh | 11 +++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj index 8cdf926f07f..c855feb3fb3 100644 --- a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj +++ b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + net45;netcoreapp2.1 false false false @@ -23,10 +23,8 @@ - - - /usr/lib/mono/4.5-api - /usr/local/lib/mono/4.5-api - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api - + + + + \ No newline at end of file diff --git a/test/distrib/csharp/run_distrib_test_dotnetcli.sh b/test/distrib/csharp/run_distrib_test_dotnetcli.sh index 357ce136cb7..ca22bce9d85 100755 --- a/test/distrib/csharp/run_distrib_test_dotnetcli.sh +++ b/test/distrib/csharp/run_distrib_test_dotnetcli.sh @@ -29,20 +29,15 @@ dotnet restore DistribTestDotNet.csproj dotnet build DistribTestDotNet.csproj dotnet publish -f netcoreapp2.1 DistribTestDotNet.csproj -#dotnet publish -f net45 DistribTestDotNet.csproj +dotnet publish -f net45 DistribTestDotNet.csproj ls -R bin -#ldd /root/.nuget/packages/grpc.core/*/lib/netstandard1.5/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so - -#ldd /root/.nuget/packages/grpc.tools/*/tools/linux_x64/grpc_csharp_plugin - -#exit 1 # .NET 4.5 target after dotnet build -#mono bin/Debug/net45/publish/DistribTestDotNet.exe +mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET 4.5 target after dotnet publish -#mono bin/Debug/net45/publish/DistribTestDotNet.exe +mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET Core target after dotnet build dotnet exec bin/Debug/netcoreapp2.1/DistribTestDotNet.dll From 54c02148664047d610cd60178a5dc2faaa654252 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 08:08:46 -0400 Subject: [PATCH 100/176] protoc cannot be run on alpine linux --- .../distribtest/csharp_alpine_x64/Dockerfile | 24 ------------------- .../artifacts/distribtest_targets.py | 1 - 2 files changed, 25 deletions(-) delete mode 100644 tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile diff --git a/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile deleted file mode 100644 index aa5034872c3..00000000000 --- a/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -FROM microsoft/dotnet:2.1-sdk-alpine - -RUN apk update && apk add bash -RUN apk update && apk add unzip - -# needed to satisfy the "ld-linux-x86-64.so.2" dependency -RUN apk add libc6-compat - -#RUN apk add libnsl -#RUN cp /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 5baf9d6c298..0674fc4c689 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -310,7 +310,6 @@ def targets(): CSharpDistribTest('linux', 'x64', 'centos7'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), - CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), CSharpDistribTest('windows', 'x86'), CSharpDistribTest('windows', 'x64'), From d3f50ace3953651c1f67a3c9da84821abae747fe Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 5 Sep 2019 08:13:59 -0700 Subject: [PATCH 101/176] Use mutex instead of combiner in client channel data plane. --- .../filters/client_channel/client_channel.cc | 450 +++++++++--------- src/core/lib/gprpp/ref_counted_ptr.h | 2 + test/core/gprpp/ref_counted_ptr_test.cc | 14 + 3 files changed, 229 insertions(+), 237 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 8a0fabfa6fd..40ac1f22059 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -130,7 +130,7 @@ class ChannelData { return disconnect_error_.Load(MemoryOrder::ACQUIRE); } - grpc_combiner* data_plane_combiner() const { return data_plane_combiner_; } + Mutex* data_plane_mu() const { return &data_plane_mu_; } LoadBalancingPolicy::SubchannelPicker* picker() const { return picker_.get(); @@ -166,8 +166,6 @@ class ChannelData { private: class SubchannelWrapper; - class ConnectivityStateAndPickerSetter; - class ServiceConfigSetter; class ClientChannelControlHelper; class ExternalConnectivityWatcher { @@ -214,6 +212,14 @@ class ChannelData { ChannelData(grpc_channel_element_args* args, grpc_error** error); ~ChannelData(); + void UpdateStateAndPickerLocked( + grpc_connectivity_state state, const char* reason, + UniquePtr picker); + + void UpdateServiceConfigLocked( + RefCountedPtr retry_throttle_data, + RefCountedPtr service_config); + void CreateResolvingLoadBalancingPolicyLocked(); void DestroyResolvingLoadBalancingPolicyLocked(); @@ -250,9 +256,9 @@ class ChannelData { channelz::ChannelNode* channelz_node_; // - // Fields used in the data plane. Guarded by data_plane_combiner. + // Fields used in the data plane. Guarded by data_plane_mu. // - grpc_combiner* data_plane_combiner_; + mutable Mutex data_plane_mu_; UniquePtr picker_; QueuedPick* queued_picks_ = nullptr; // Linked list of queued picks. // Data from service config. @@ -282,13 +288,13 @@ class ChannelData { Map subchannel_wrappers_; // Pending ConnectedSubchannel updates for each SubchannelWrapper. // Updates are queued here in the control plane combiner and then applied - // in the data plane combiner when the picker is updated. + // in the data plane mutex when the picker is updated. Map, RefCountedPtr, RefCountedPtrLess> pending_subchannel_updates_; // - // Fields accessed from both data plane and control plane combiners. + // Fields accessed from both data plane mutex and control plane combiner. // Atomic disconnect_error_; @@ -322,7 +328,16 @@ class CallData { void MaybeApplyServiceConfigToCallLocked(grpc_call_element* elem); // Invoked by channel for queued picks when the picker is updated. - static void StartPickLocked(void* arg, grpc_error* error); + static void PickSubchannel(void* arg, grpc_error* error); + + // Helper function for performing a pick while holding the data plane + // mutex. Returns true if the pick is complete, in which case the caller + // must invoke PickDone() or AsyncPickDone() with the returned error. + bool PickSubchannelLocked(grpc_call_element* elem, grpc_error** error); + + // Schedules a callback to process the completed pick. The callback + // will not run until after this method returns. + void AsyncPickDone(grpc_call_element* elem, grpc_error* error); private: class QueuedPickCanceller; @@ -931,7 +946,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { return connected_subchannel_.get(); } - // Caller must be holding the data-plane combiner. + // Caller must be holding the data-plane mutex. ConnectedSubchannel* connected_subchannel_in_data_plane() const { return connected_subchannel_in_data_plane_.get(); } @@ -1059,7 +1074,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { // Update the connected subchannel only if the channel is not shutting // down. This is because once the channel is shutting down, we // ignore picker updates from the LB policy, which means that - // ConnectivityStateAndPickerSetter will never process the entries + // UpdateStateAndPickerLocked() will never process the entries // in chand_->pending_subchannel_updates_. So we don't want to add // entries there that will never be processed, since that would // leave dangling refs to the channel and prevent its destruction. @@ -1069,7 +1084,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { if (connected_subchannel_ != connected_subchannel) { connected_subchannel_ = std::move(connected_subchannel); // Record the new connected subchannel so that it can be updated - // in the data plane combiner the next time the picker is updated. + // in the data plane mutex the next time the picker is updated. chand_->pending_subchannel_updates_[Ref( DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_; } @@ -1086,159 +1101,10 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { Map watcher_map_; // To be accessed only in the control plane combiner. RefCountedPtr connected_subchannel_; - // To be accessed only in the data plane combiner. + // To be accessed only in the data plane mutex. RefCountedPtr connected_subchannel_in_data_plane_; }; -// -// ChannelData::ConnectivityStateAndPickerSetter -// - -// A fire-and-forget class that sets the channel's connectivity state -// and then hops into the data plane combiner to update the picker. -// Must be instantiated while holding the control plane combiner. -// Deletes itself when done. -class ChannelData::ConnectivityStateAndPickerSetter { - public: - ConnectivityStateAndPickerSetter( - ChannelData* chand, grpc_connectivity_state state, const char* reason, - UniquePtr picker) - : chand_(chand), picker_(std::move(picker)) { - // Clean the control plane when entering IDLE, while holding control plane - // combiner. - if (picker_ == nullptr) { - chand->health_check_service_name_.reset(); - chand->saved_service_config_.reset(); - chand->received_first_resolver_result_ = false; - } - // Update connectivity state here, while holding control plane combiner. - grpc_connectivity_state_set(&chand->state_tracker_, state, reason); - if (chand->channelz_node_ != nullptr) { - chand->channelz_node_->SetConnectivityState(state); - chand->channelz_node_->AddTraceEvent( - channelz::ChannelTrace::Severity::Info, - grpc_slice_from_static_string( - channelz::ChannelNode::GetChannelConnectivityStateChangeString( - state))); - } - // Grab any pending subchannel updates. - pending_subchannel_updates_ = - std::move(chand_->pending_subchannel_updates_); - // Bounce into the data plane combiner to reset the picker. - GRPC_CHANNEL_STACK_REF(chand->owning_stack_, - "ConnectivityStateAndPickerSetter"); - GRPC_CLOSURE_INIT(&closure_, SetPickerInDataPlane, this, - grpc_combiner_scheduler(chand->data_plane_combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); - } - - private: - static void SetPickerInDataPlane(void* arg, grpc_error* ignored) { - auto* self = static_cast(arg); - // Handle subchannel updates. - for (auto& p : self->pending_subchannel_updates_) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: updating subchannel wrapper %p data plane " - "connected_subchannel to %p", - self->chand_, p.first.get(), p.second.get()); - } - p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); - } - // Swap out the picker. We hang on to the old picker so that it can - // be deleted in the control-plane combiner, since that's where we need - // to unref the subchannel wrappers that are reffed by the picker. - self->picker_.swap(self->chand_->picker_); - // Clean the data plane if the updated picker is nullptr. - if (self->chand_->picker_ == nullptr) { - self->chand_->received_service_config_data_ = false; - self->chand_->retry_throttle_data_.reset(); - self->chand_->service_config_.reset(); - } - // Re-process queued picks. - for (QueuedPick* pick = self->chand_->queued_picks_; pick != nullptr; - pick = pick->next) { - CallData::StartPickLocked(pick->elem, GRPC_ERROR_NONE); - } - // Pop back into the control plane combiner to delete ourself, so - // that we make sure to unref subchannel wrappers there. This - // includes both the ones reffed by the old picker (now stored in - // self->picker_) and the ones in self->pending_subchannel_updates_. - GRPC_CLOSURE_INIT(&self->closure_, CleanUpInControlPlane, self, - grpc_combiner_scheduler(self->chand_->combiner_)); - GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE); - } - - static void CleanUpInControlPlane(void* arg, grpc_error* ignored) { - auto* self = static_cast(arg); - GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, - "ConnectivityStateAndPickerSetter"); - Delete(self); - } - - ChannelData* chand_; - UniquePtr picker_; - Map, RefCountedPtr, - RefCountedPtrLess> - pending_subchannel_updates_; - grpc_closure closure_; -}; - -// -// ChannelData::ServiceConfigSetter -// - -// A fire-and-forget class that sets the channel's service config data -// in the data plane combiner. Deletes itself when done. -class ChannelData::ServiceConfigSetter { - public: - ServiceConfigSetter( - ChannelData* chand, - Optional - retry_throttle_data, - RefCountedPtr service_config) - : chand_(chand), - retry_throttle_data_(retry_throttle_data), - service_config_(std::move(service_config)) { - GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ServiceConfigSetter"); - GRPC_CLOSURE_INIT(&closure_, SetServiceConfigData, this, - grpc_combiner_scheduler(chand->data_plane_combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); - } - - private: - static void SetServiceConfigData(void* arg, grpc_error* ignored) { - ServiceConfigSetter* self = static_cast(arg); - ChannelData* chand = self->chand_; - // Update channel state. - chand->received_service_config_data_ = true; - if (self->retry_throttle_data_.has_value()) { - chand->retry_throttle_data_ = - internal::ServerRetryThrottleMap::GetDataForServer( - chand->server_name_.get(), - self->retry_throttle_data_.value().max_milli_tokens, - self->retry_throttle_data_.value().milli_token_ratio); - } - chand->service_config_ = std::move(self->service_config_); - // Apply service config to queued picks. - for (QueuedPick* pick = chand->queued_picks_; pick != nullptr; - pick = pick->next) { - CallData* calld = static_cast(pick->elem->call_data); - calld->MaybeApplyServiceConfigToCallLocked(pick->elem); - } - // Clean up. - GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, - "ServiceConfigSetter"); - Delete(self); - } - - ChannelData* chand_; - Optional - retry_throttle_data_; - RefCountedPtr service_config_; - grpc_closure closure_; -}; - // // ChannelData::ExternalConnectivityWatcher::WatcherList // @@ -1409,9 +1275,7 @@ class ChannelData::ClientChannelControlHelper } // Do update only if not shutting down. if (disconnect_error == GRPC_ERROR_NONE) { - // Will delete itself. - New(chand_, state, "helper", - std::move(picker)); + chand_->UpdateStateAndPickerLocked(state, "helper", std::move(picker)); } } @@ -1495,7 +1359,6 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) client_channel_factory_( ClientChannelFactory::GetFromChannelArgs(args->channel_args)), channelz_node_(GetChannelzNode(args->channel_args)), - data_plane_combiner_(grpc_combiner_create()), combiner_(grpc_combiner_create()), interested_parties_(grpc_pollset_set_create()), subchannel_pool_(GetSubchannelPool(args->channel_args)), @@ -1568,13 +1431,108 @@ ChannelData::~ChannelData() { // Stop backup polling. grpc_client_channel_stop_backup_polling(interested_parties_); grpc_pollset_set_destroy(interested_parties_); - GRPC_COMBINER_UNREF(data_plane_combiner_, "client_channel"); GRPC_COMBINER_UNREF(combiner_, "client_channel"); GRPC_ERROR_UNREF(disconnect_error_.Load(MemoryOrder::RELAXED)); grpc_connectivity_state_destroy(&state_tracker_); gpr_mu_destroy(&info_mu_); } +void ChannelData::UpdateStateAndPickerLocked( + grpc_connectivity_state state, const char* reason, + UniquePtr picker) { + // Clean the control plane when entering IDLE. + if (picker_ == nullptr) { + health_check_service_name_.reset(); + saved_service_config_.reset(); + received_first_resolver_result_ = false; + } + // Update connectivity state. + grpc_connectivity_state_set(&state_tracker_, state, reason); + if (channelz_node_ != nullptr) { + channelz_node_->SetConnectivityState(state); + channelz_node_->AddTraceEvent( + channelz::ChannelTrace::Severity::Info, + grpc_slice_from_static_string( + channelz::ChannelNode::GetChannelConnectivityStateChangeString( + state))); + } + // Grab data plane lock to do subchannel updates and update the picker. + // + // Note that we want to minimize the work done while holding the data + // plane lock, to keep the critical section small. So, for all of the + // objects that we might wind up unreffing here, we actually hold onto + // the refs until after we release the lock, and then unref them at + // that point. This includes the following: + // - refs to subchannel wrappers in the keys of pending_subchannel_updates_ + // - ref stored in retry_throttle_data_ + // - ref stored in service_config_ + // - ownership of the existing picker in picker_ + RefCountedPtr retry_throttle_data_to_unref; + RefCountedPtr service_config_to_unref; + { + MutexLock lock(&data_plane_mu_); + // Handle subchannel updates. + for (auto& p : pending_subchannel_updates_) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: updating subchannel wrapper %p data plane " + "connected_subchannel to %p", + this, p.first.get(), p.second.get()); + } + // Note: We do not remove the entry from pending_subchannel_updates_ + // here, since this would unref the subchannel wrapper; instead, + // we wait until we've released the lock to clear the map. + p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); + } + // Swap out the picker. + // Note: Original value will be destroyed after the lock is released. + picker_.swap(picker); + // Clean the data plane if the updated picker is nullptr. + if (picker_ == nullptr) { + received_service_config_data_ = false; + // Note: We save the objects to unref until after the lock is released. + retry_throttle_data_to_unref = std::move(retry_throttle_data_); + service_config_to_unref = std::move(service_config_); + } + // Re-process queued picks. + for (QueuedPick* pick = queued_picks_; pick != nullptr; pick = pick->next) { + grpc_call_element* elem = pick->elem; + CallData* calld = static_cast(elem->call_data); + grpc_error* error = GRPC_ERROR_NONE; + if (calld->PickSubchannelLocked(elem, &error)) { + calld->AsyncPickDone(elem, error); + } + } + } + // Clear the pending update map after releasing the lock, to keep the + // critical section small. + pending_subchannel_updates_.clear(); +} + +void ChannelData::UpdateServiceConfigLocked( + RefCountedPtr retry_throttle_data, + RefCountedPtr service_config) { + // Grab data plane lock to update service config. + // + // We defer unreffing the old values (and deallocating memory) until + // after releasing the lock to keep the critical section small. + { + MutexLock lock(&data_plane_mu_); + // Update service config. + received_service_config_data_ = true; + // Old values will be unreffed after lock is released. + retry_throttle_data_.swap(retry_throttle_data); + service_config_.swap(service_config); + // Apply service config to queued picks. + for (QueuedPick* pick = queued_picks_; pick != nullptr; pick = pick->next) { + CallData* calld = static_cast(pick->elem->call_data); + calld->MaybeApplyServiceConfigToCallLocked(pick->elem); + } + } + // Old values will be unreffed after lock is released when they go out + // of scope. +} + void ChannelData::CreateResolvingLoadBalancingPolicyLocked() { // Instantiate resolving LB policy. LoadBalancingPolicy::Args lb_args; @@ -1746,15 +1704,20 @@ bool ChannelData::ProcessResolverResultLocked( // if we feel it is unnecessary. if (service_config_changed || !chand->received_first_resolver_result_) { chand->received_first_resolver_result_ = true; - Optional - retry_throttle_data; + RefCountedPtr retry_throttle_data; if (parsed_service_config != nullptr) { - retry_throttle_data = parsed_service_config->retry_throttling(); + Optional + retry_throttle_config = parsed_service_config->retry_throttling(); + if (retry_throttle_config.has_value()) { + retry_throttle_data = + internal::ServerRetryThrottleMap::GetDataForServer( + chand->server_name_.get(), + retry_throttle_config.value().max_milli_tokens, + retry_throttle_config.value().milli_token_ratio); + } } - // Create service config setter to update channel state in the data - // plane combiner. Destroys itself when done. - New(chand, retry_throttle_data, - chand->saved_service_config_); + chand->UpdateServiceConfigLocked(std::move(retry_throttle_data), + chand->saved_service_config_); } UniquePtr processed_lb_policy_name; chand->ProcessLbPolicy(result, parsed_service_config, @@ -1838,8 +1801,8 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { static_cast(value) == GRPC_CHANNEL_IDLE) { if (chand->disconnect_error() == GRPC_ERROR_NONE) { // Enter IDLE state. - New(chand, GRPC_CHANNEL_IDLE, - "channel entering IDLE", nullptr); + chand->UpdateStateAndPickerLocked(GRPC_CHANNEL_IDLE, + "channel entering IDLE", nullptr); } GRPC_ERROR_UNREF(op->disconnect_with_error); } else { @@ -1848,8 +1811,8 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { GRPC_ERROR_NONE); chand->disconnect_error_.Store(op->disconnect_with_error, MemoryOrder::RELEASE); - New( - chand, GRPC_CHANNEL_SHUTDOWN, "shutdown from API", + chand->UpdateStateAndPickerLocked( + GRPC_CHANNEL_SHUTDOWN, "shutdown from API", UniquePtr( New( GRPC_ERROR_REF(op->disconnect_with_error)))); @@ -2092,8 +2055,8 @@ void CallData::StartTransportStreamOpBatch( // Add the batch to the pending list. calld->PendingBatchesAdd(elem, batch); // Check if we've already gotten a subchannel call. - // Note that once we have completed the pick, we do not need to enter - // the channel combiner, which is more efficient (especially for + // Note that once we have picked a subchannel, we do not need to acquire + // the channel's data plane mutex, which is more efficient (especially for // streaming calls). if (calld->subchannel_call_ != nullptr) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { @@ -2105,18 +2068,15 @@ void CallData::StartTransportStreamOpBatch( return; } // We do not yet have a subchannel call. - // For batches containing a send_initial_metadata op, enter the channel - // combiner to start a pick. + // For batches containing a send_initial_metadata op, acquire the + // channel's data plane mutex to pick a subchannel. if (GPR_LIKELY(batch->send_initial_metadata)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { - gpr_log(GPR_INFO, "chand=%p calld=%p: entering client_channel combiner", + gpr_log(GPR_INFO, + "chand=%p calld=%p: grabbing data plane mutex to perform pick", chand, calld); } - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT( - &batch->handler_private.closure, StartPickLocked, elem, - grpc_combiner_scheduler(chand->data_plane_combiner())), - GRPC_ERROR_NONE); + PickSubchannel(elem, GRPC_ERROR_NONE); } else { // For all other batches, release the call combiner. if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { @@ -2544,8 +2504,8 @@ void CallData::DoRetry(grpc_call_element* elem, this, next_attempt_time - ExecCtx::Get()->Now()); } // Schedule retry after computed delay. - GRPC_CLOSURE_INIT(&pick_closure_, StartPickLocked, elem, - grpc_combiner_scheduler(chand->data_plane_combiner())); + GRPC_CLOSURE_INIT(&pick_closure_, PickSubchannel, elem, + grpc_schedule_on_exec_ctx); grpc_timer_init(&retry_timer_, next_attempt_time, &pick_closure_); // Update bookkeeping. if (retry_state != nullptr) retry_state->retry_dispatched = true; @@ -3660,6 +3620,11 @@ void CallData::CreateSubchannelCall(grpc_call_element* elem) { } } +void CallData::AsyncPickDone(grpc_call_element* elem, grpc_error* error) { + GRPC_CLOSURE_INIT(&pick_closure_, PickDone, elem, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_SCHED(&pick_closure_, error); +} + void CallData::PickDone(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); ChannelData* chand = static_cast(elem->channel_data); @@ -3682,10 +3647,9 @@ class CallData::QueuedPickCanceller { public: explicit QueuedPickCanceller(grpc_call_element* elem) : elem_(elem) { auto* calld = static_cast(elem->call_data); - auto* chand = static_cast(elem->channel_data); GRPC_CALL_STACK_REF(calld->owning_call_, "QueuedPickCanceller"); GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, - grpc_combiner_scheduler(chand->data_plane_combiner())); + grpc_schedule_on_exec_ctx); calld->call_combiner_->SetNotifyOnCancel(&closure_); } @@ -3694,6 +3658,7 @@ class CallData::QueuedPickCanceller { auto* self = static_cast(arg); auto* chand = static_cast(self->elem_->channel_data); auto* calld = static_cast(self->elem_->call_data); + MutexLock lock(chand->data_plane_mu()); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling queued pick: " @@ -3818,23 +3783,38 @@ const char* PickResultTypeName( GPR_UNREACHABLE_CODE(return "UNKNOWN"); } -void CallData::StartPickLocked(void* arg, grpc_error* error) { +void CallData::PickSubchannel(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); CallData* calld = static_cast(elem->call_data); ChannelData* chand = static_cast(elem->channel_data); - GPR_ASSERT(calld->connected_subchannel_ == nullptr); - GPR_ASSERT(calld->subchannel_call_ == nullptr); - // picker's being null means the channel is currently in IDLE state. The - // incoming call will make the channel exit IDLE and queue itself. + bool pick_complete; + { + MutexLock lock(chand->data_plane_mu()); + pick_complete = calld->PickSubchannelLocked(elem, &error); + } + if (pick_complete) { + PickDone(elem, error); + GRPC_ERROR_UNREF(error); + } +} + +bool CallData::PickSubchannelLocked(grpc_call_element* elem, + grpc_error** error) { + ChannelData* chand = static_cast(elem->channel_data); + GPR_ASSERT(connected_subchannel_ == nullptr); + GPR_ASSERT(subchannel_call_ == nullptr); + // The picker being null means that the channel is currently in IDLE state. + // The incoming call will make the channel exit IDLE. if (chand->picker() == nullptr) { - // We are currently in the data plane. - // Bounce into the control plane to exit IDLE. - chand->CheckConnectivityState(true); - calld->AddCallToQueuedPicksLocked(elem); - return; + // Bounce into the control plane combiner to exit IDLE. + chand->CheckConnectivityState(/*try_to_connect=*/true); + // Queue the pick, so that it will be attempted once the channel + // becomes connected. + AddCallToQueuedPicksLocked(elem); + return false; } // Apply service config to call if needed. - calld->MaybeApplyServiceConfigToCallLocked(elem); + MaybeApplyServiceConfigToCallLocked(elem); // If this is a retry, use the send_initial_metadata payload that // we've cached; otherwise, use the pending batch. The // send_initial_metadata batch will be the first pending batch in the @@ -3846,31 +3826,27 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { // subchannel's copy of the metadata batch (which is copied for each // attempt) to the LB policy instead the one from the parent channel. LoadBalancingPolicy::PickArgs pick_args; - pick_args.call_state = &calld->lb_call_state_; + pick_args.call_state = &lb_call_state_; Metadata initial_metadata( - calld, - calld->seen_send_initial_metadata_ - ? &calld->send_initial_metadata_ - : calld->pending_batches_[0] + this, + seen_send_initial_metadata_ + ? &send_initial_metadata_ + : pending_batches_[0] .batch->payload->send_initial_metadata.send_initial_metadata); pick_args.initial_metadata = &initial_metadata; // Grab initial metadata flags so that we can check later if the call has // wait_for_ready enabled. const uint32_t send_initial_metadata_flags = - calld->seen_send_initial_metadata_ - ? calld->send_initial_metadata_flags_ - : calld->pending_batches_[0] - .batch->payload->send_initial_metadata - .send_initial_metadata_flags; - // When done, we schedule this closure to leave the data plane combiner. - GRPC_CLOSURE_INIT(&calld->pick_closure_, PickDone, elem, - grpc_schedule_on_exec_ctx); + seen_send_initial_metadata_ ? send_initial_metadata_flags_ + : pending_batches_[0] + .batch->payload->send_initial_metadata + .send_initial_metadata_flags; // Attempt pick. auto result = chand->picker()->Pick(pick_args); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: LB pick returned %s (subchannel=%p, error=%s)", - chand, calld, PickResultTypeName(result.type), + chand, this, PickResultTypeName(result.type), result.subchannel.get(), grpc_error_string(result.error)); } switch (result.type) { @@ -3879,10 +3855,9 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { grpc_error* disconnect_error = chand->disconnect_error(); if (disconnect_error != GRPC_ERROR_NONE) { GRPC_ERROR_UNREF(result.error); - GRPC_CLOSURE_SCHED(&calld->pick_closure_, - GRPC_ERROR_REF(disconnect_error)); - if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); - break; + if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem); + *error = GRPC_ERROR_REF(disconnect_error); + return true; } // If wait_for_ready is false, then the error indicates the RPC // attempt's final status. @@ -3890,19 +3865,20 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { GRPC_INITIAL_METADATA_WAIT_FOR_READY) == 0) { // Retry if appropriate; otherwise, fail. grpc_status_code status = GRPC_STATUS_OK; - grpc_error_get_status(result.error, calld->deadline_, &status, nullptr, + grpc_error_get_status(result.error, deadline_, &status, nullptr, nullptr, nullptr); - if (!calld->enable_retries_ || - !calld->MaybeRetry(elem, nullptr /* batch_data */, status, - nullptr /* server_pushback_md */)) { + const bool retried = enable_retries_ && + MaybeRetry(elem, nullptr /* batch_data */, status, + nullptr /* server_pushback_md */); + if (!retried) { grpc_error* new_error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Failed to pick subchannel", &result.error, 1); GRPC_ERROR_UNREF(result.error); - GRPC_CLOSURE_SCHED(&calld->pick_closure_, new_error); + *error = new_error; } - if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); - break; + if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem); + return !retried; } // If wait_for_ready is true, then queue to retry when we get a new // picker. @@ -3910,26 +3886,26 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { } // Fallthrough case LoadBalancingPolicy::PickResult::PICK_QUEUE: - if (!calld->pick_queued_) calld->AddCallToQueuedPicksLocked(elem); - break; + if (!pick_queued_) AddCallToQueuedPicksLocked(elem); + return false; default: // PICK_COMPLETE + if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem); // Handle drops. if (GPR_UNLIKELY(result.subchannel == nullptr)) { result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Call dropped by load balancing policy"); } else { // Grab a ref to the connected subchannel while we're still - // holding the data plane combiner. - calld->connected_subchannel_ = + // holding the data plane mutex. + connected_subchannel_ = chand->GetConnectedSubchannelInDataPlane(result.subchannel.get()); - GPR_ASSERT(calld->connected_subchannel_ != nullptr); + GPR_ASSERT(connected_subchannel_ != nullptr); } - calld->lb_recv_trailing_metadata_ready_ = - result.recv_trailing_metadata_ready; - calld->lb_recv_trailing_metadata_ready_user_data_ = + lb_recv_trailing_metadata_ready_ = result.recv_trailing_metadata_ready; + lb_recv_trailing_metadata_ready_user_data_ = result.recv_trailing_metadata_ready_user_data; - GRPC_CLOSURE_SCHED(&calld->pick_closure_, result.error); - if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); + *error = result.error; + return true; } } diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h index 19f38d7f013..2e3f4671581 100644 --- a/src/core/lib/gprpp/ref_counted_ptr.h +++ b/src/core/lib/gprpp/ref_counted_ptr.h @@ -103,6 +103,8 @@ class RefCountedPtr { if (value_ != nullptr) value_->Unref(); } + void swap(RefCountedPtr& other) { std::swap(value_, other.value_); } + // If value is non-null, we take ownership of a ref to it. void reset(T* value = nullptr) { if (value_ != nullptr) value_->Unref(); diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index 96dbdf884b0..38bd4b61364 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -151,6 +151,20 @@ TEST(RefCountedPtr, EqualityOperators) { EXPECT_NE(foo, nullptr); } +TEST(RefCountedPtr, Swap) { + Foo* foo = New(); + Foo* bar = New(); + RefCountedPtr ptr1(foo); + RefCountedPtr ptr2(bar); + ptr1.swap(ptr2); + EXPECT_EQ(foo, ptr2.get()); + EXPECT_EQ(bar, ptr1.get()); + RefCountedPtr ptr3; + ptr3.swap(ptr2); + EXPECT_EQ(nullptr, ptr2.get()); + EXPECT_EQ(foo, ptr3.get()); +} + TEST(MakeRefCounted, NoArgs) { RefCountedPtr foo = MakeRefCounted(); EXPECT_EQ(0, foo->value()); From fd9bdd9922fffe88ae9f2752f790922d0ed8f369 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Sep 2019 08:17:16 -0700 Subject: [PATCH 102/176] Avoid duplicate initialization of SSL (from within grpc and from test) --- test/core/handshake/server_ssl_common.cc | 56 +++++++++++++++++++----- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/test/core/handshake/server_ssl_common.cc b/test/core/handshake/server_ssl_common.cc index 41b2829d8b7..1493094e3c3 100644 --- a/test/core/handshake/server_ssl_common.cc +++ b/test/core/handshake/server_ssl_common.cc @@ -32,6 +32,7 @@ #include #include +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/load_file.h" #include "test/core/util/port.h" @@ -41,10 +42,12 @@ #define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key" #define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem" +namespace { + // Handshake completed signal to server thread. -static gpr_event client_handshake_complete; +gpr_event client_handshake_complete; -static int create_socket(int port) { +int create_socket(int port) { int s; struct sockaddr_in addr; @@ -66,9 +69,34 @@ static int create_socket(int port) { return s; } +class ServerInfo { + public: + explicit ServerInfo(int p) : port_(p) {} + + int port() const { return port_; } + + void Activate() { + grpc_core::MutexLock lock(&mu_); + ready_ = true; + cv_.Signal(); + } + + void Await() { + grpc_core::MutexLock lock(&mu_); + cv_.WaitUntil(&mu_, [this] { return ready_; }); + } + + private: + const int port_; + grpc_core::Mutex mu_; + grpc_core::CondVar cv_; + bool ready_ = false; +}; + // Simple gRPC server. This listens until client_handshake_complete occurs. -static void server_thread(void* arg) { - const int port = *static_cast(arg); +void server_thread(void* arg) { + ServerInfo* s = static_cast(arg); + const int port = s->port(); // Load key pair and establish server SSL credentials. grpc_ssl_pem_key_cert_pair pem_key_cert_pair; @@ -100,6 +128,10 @@ static void server_thread(void* arg) { grpc_server_register_completion_queue(server, cq, nullptr); grpc_server_start(server); + // Notify the other side that it is now ok to start working since SSL is + // definitely already started. + s->Activate(); + // Wait a bounded number of time until client_handshake_complete is set, // sleeping between polls. int retries = 10; @@ -125,6 +157,8 @@ static void server_thread(void* arg) { grpc_slice_unref(ca_slice); } +} // namespace + // This test launches a gRPC server on a separate thread and then establishes a // TLS handshake via a minimal TLS client. The TLS client has configurable (via // alpn_list) ALPN settings and can probe at the supported ALPN preferences @@ -134,17 +168,19 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len, bool success = true; grpc_init(); - int port = grpc_pick_unused_port_or_die(); + ServerInfo s(grpc_pick_unused_port_or_die()); gpr_event_init(&client_handshake_complete); // Launch the gRPC server thread. bool ok; - grpc_core::Thread thd("grpc_ssl_test", server_thread, &port, &ok); + grpc_core::Thread thd("grpc_ssl_test", server_thread, &s, &ok); GPR_ASSERT(ok); thd.Start(); - SSL_load_error_strings(); - OpenSSL_add_ssl_algorithms(); + // The work in server_thread will cause the SSL initialization to take place + // so long as we wait for it to reach beyond the point of adding a secure + // server port. + s.Await(); const SSL_METHOD* method = TLSv1_2_client_method(); SSL_CTX* ctx = SSL_CTX_new(method); @@ -197,13 +233,13 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len, int retries = 10; int sock = -1; while (sock == -1 && retries-- > 0) { - sock = create_socket(port); + sock = create_socket(s.port()); if (sock < 0) { sleep(1); } } GPR_ASSERT(sock > 0); - gpr_log(GPR_INFO, "Connected to server on port %d", port); + gpr_log(GPR_INFO, "Connected to server on port %d", s.port()); // Establish a SSL* and connect at SSL layer. SSL* ssl = SSL_new(ctx); From ee603bf172d9905d172883106b8c64bf15beba34 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 4 Sep 2019 20:05:38 -0700 Subject: [PATCH 103/176] Better codegenfor validate_filtered_metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit validate_filtered_metadata() performs several checks to see if a call must be failed. Failure is the unlikely case; to that end, failing branches are marked unlikely, and the specific code handling failure cases is refactored into explicitly un-inlined helper methods. This will prevent us from unnecessarily clobbering registers and give us a straight-line codepath for the success case. Results: BM_UnaryPingPong/8/0 [polls/iter:3.00008 ] 22.5µs ± 0% 21.6µs ± 0% -4.02% (p=0.036 n=5+3) BM_UnaryPingPong/64/64 [polls/iter:3.00008 ] 23.4µs ± 1% 23.0µs ± 1% -1.63% (p=0.010 n=6+4) BM_UnaryPingPong/32768/0 [polls/iter:3.00007 ] 34.4µs ± 1% 34.1µs ± 0% -0.99% (p=0.024 n=6+3) BM_UnaryPingPong/0/0 [polls/iter:0 ] 6.36µs ± 5% 6.16µs ± 2% -3.26% (p=0.013 n=20+19) BM_UnaryPingPong/1/1 [polls/iter:0 ] 6.62µs ± 6% 6.50µs ± 4% -1.72% (p=0.049 n=20+20) BM_UnaryPingPong/512/0 [polls/iter:0 ] 6.67µs ± 6% 6.59µs ± 2% -1.29% (p=0.047 n=20+19) BM_UnaryPingPong/4096/0 [polls/iter:0 ] 7.68µs ± 1% 7.65µs ± 2% -0.46% (p=0.031 n=18+18) BM_UnaryPingPong/0/262144 [polls/iter:0 ] 86.0µs ± 2% 85.3µs ± 2% -0.77% (p=0.046 n=19+19) BM_UnaryPingPong/0/0 [polls/iter:0 ] 6.28µs ± 5% 6.00µs ± 2% -4.37% (p=0.000 n=20+20) BM_UnaryPingPong/1/0 [polls/iter:0 ] 6.39µs ± 6% 6.20µs ± 2% -3.03% (p=0.001 n=20+19) BM_UnaryPingPong/0/1 [polls/iter:0 ] 6.36µs ± 6% 6.17µs ± 1% -3.00% (p=0.006 n=20+17) BM_UnaryPingPong/1/1 [polls/iter:0 ] 6.59µs ± 5% 6.30µs ± 2% -4.37% (p=0.000 n=20+19) BM_UnaryPingPong/8/0 [polls/iter:0 ] 6.37µs ± 5% 6.20µs ± 2% -2.76% (p=0.001 n=20+20) BM_UnaryPingPong/0/8 [polls/iter:0 ] 6.36µs ± 5% 6.17µs ± 2% -2.95% (p=0.001 n=20+19) BM_UnaryPingPong/8/8 [polls/iter:0 ] 6.45µs ± 7% 6.27µs ± 1% -2.72% (p=0.002 n=20+18) BM_UnaryPingPong/64/0 [polls/iter:0 ] 6.46µs ± 6% 6.31µs ± 1% -2.39% (p=0.001 n=20+20) BM_UnaryPingPong/512/0 [polls/iter:0 ] 6.62µs ± 6% 6.43µs ± 2% -2.92% (p=0.000 n=20+18) BM_UnaryPingPong/0/512 [polls/iter:0 ] 6.58µs ± 7% 6.41µs ± 1% -2.57% (p=0.002 n=20+17) BM_UnaryPingPong/512/512 [polls/iter:0 ] 6.88µs ± 7% 6.76µs ± 2% -1.81% (p=0.047 n=20+19) BM_UnaryPingPong/4096/0 [polls/iter:0 ] 7.57µs ± 3% 7.49µs ± 2% -0.99% (p=0.007 n=20+20) BM_UnaryPingPong/0/4096 [polls/iter:0 ] 7.66µs ± 5% 7.50µs ± 2% -2.15% (p=0.003 n=20+20) BM_UnaryPingPong/32768/0 [polls/iter:0 ] 15.8µs ± 2% 15.7µs ± 1% -0.75% (p=0.001 n=20+19) BM_UnaryPingPong/0/32768 [polls/iter:0 ] 16.1µs ± 2% 16.0µs ± 2% -0.84% (p=0.002 n=20+20) BM_UnaryPingPong/32768/32768 [polls/iter:0 ] 25.5µs ± 1% 25.4µs ± 1% -0.42% (p=0.011 n=20+19) BM_UnaryPingPong, 2>, NoOpMutator>/0/0 [polls/iter:0 ] 7.99µs ± 5% 7.85µs ± 2% -1.81% (p=0.028 n=20+20) BM_UnaryPingPong, 1>>/0/0 [polls/iter:0 ] 7.07µs ± 6% 7.14µs ± 5% +0.95% (p=0.007 n=19+18) BM_UnaryPingPong, 1>, NoOpMutator>/0/0 [polls/iter:0 ] 6.95µs ± 5% 7.02µs ± 3% +0.94% (p=0.017 n=18+19) BM_UnaryPingPong, 1>, NoOpMutator>/0/0 [polls/iter:0 ] 7.10µs ± 2% 7.19µs ± 2% +1.31% (p=0.000 n=16+20) BM_UnaryPingPong, 1>>/0/0 [polls/iter:0 ] 6.89µs ± 2% 7.00µs ± 3% +1.61% (p=0.000 n=17+19) BM_UnaryPingPong/512/512 [polls/iter:3.00007 ] 24.1µs ± 1% 23.7µs ± 1% -1.77% (p=0.024 n=6+3) BM_UnaryPingPong/1/0 [polls/iter:3.00009 ] 21.5µs ± 1% 20.9µs ± 0% -2.78% (p=0.024 n=6+3) BM_UnaryPingPong/4096/0 [polls/iter:3.00005 ] 24.4µs ± 2% 23.9µs ± 2% -2.16% (p=0.020 n=9+4) BM_UnaryPingPong/32768/0 [polls/iter:3.0001 ] 35.3µs ± 1% 34.8µs ± 1% -1.45% (p=0.008 n=5+5) BM_UnaryPingPong/0/0 [polls/iter:3.00008 ] 19.5µs ± 1% 19.1µs ± 1% -2.30% (p=0.016 n=4+5) BM_UnaryPingPong/0/32768 [polls/iter:3.0001 ] 35.4µs ± 1% 34.7µs ± 1% -1.77% (p=0.016 n=4+5) --- src/core/lib/compression/compression.cc | 3 +- .../lib/compression/compression_internal.h | 8 ++ src/core/lib/surface/call.cc | 127 +++++++++++------- 3 files changed, 89 insertions(+), 49 deletions(-) diff --git a/src/core/lib/compression/compression.cc b/src/core/lib/compression/compression.cc index 2f35e5fa03f..8a0abca8dd7 100644 --- a/src/core/lib/compression/compression.cc +++ b/src/core/lib/compression/compression.cc @@ -127,7 +127,8 @@ void grpc_compression_options_disable_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); + return grpc_compression_options_is_algorithm_enabled_internal(opts, + algorithm); } grpc_slice grpc_compression_algorithm_slice( diff --git a/src/core/lib/compression/compression_internal.h b/src/core/lib/compression/compression_internal.h index 73947a2c34d..49afb941d73 100644 --- a/src/core/lib/compression/compression_internal.h +++ b/src/core/lib/compression/compression_internal.h @@ -23,6 +23,8 @@ #include +#include "src/core/lib/gpr/useful.h" + #ifdef __cplusplus extern "C" { #endif @@ -85,4 +87,10 @@ int grpc_stream_compression_algorithm_parse( } #endif +inline int grpc_compression_options_is_algorithm_enabled_internal( + const grpc_compression_options* opts, + grpc_compression_algorithm algorithm) { + return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm); +} + #endif /* GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1331e57ab0c..3c6a5d098ae 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1365,64 +1365,95 @@ static void receiving_stream_ready_in_call_combiner(void* bctlp, receiving_stream_ready(bctlp, error); } +static void GPR_ATTRIBUTE_NOINLINE +handle_both_stream_and_msg_compression_set(grpc_call* call) { + char* error_msg = nullptr; + gpr_asprintf(&error_msg, + "Incoming stream has both stream compression (%d) and message " + "compression (%d).", + call->incoming_stream_compression_algorithm, + call->incoming_message_compression_algorithm); + gpr_log(GPR_ERROR, "%s", error_msg); + cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE +handle_error_parsing_compression_algorithm(grpc_call* call) { + char* error_msg = nullptr; + gpr_asprintf(&error_msg, + "Error in incoming message compression (%d) or stream " + "compression (%d).", + call->incoming_stream_compression_algorithm, + call->incoming_message_compression_algorithm); + cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE handle_invalid_compression( + grpc_call* call, grpc_compression_algorithm compression_algorithm) { + char* error_msg = nullptr; + gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.", + compression_algorithm); + gpr_log(GPR_ERROR, "%s", error_msg); + cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_disabled( + grpc_call* call, grpc_compression_algorithm compression_algorithm) { + char* error_msg = nullptr; + const char* algo_name = nullptr; + grpc_compression_algorithm_name(compression_algorithm, &algo_name); + gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.", + algo_name); + gpr_log(GPR_ERROR, "%s", error_msg); + cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_not_accepted( + grpc_call* call, grpc_compression_algorithm compression_algorithm) { + const char* algo_name = nullptr; + grpc_compression_algorithm_name(compression_algorithm, &algo_name); + gpr_log(GPR_ERROR, + "Compression algorithm ('%s') not present in the bitset of " + "accepted encodings ('0x%x')", + algo_name, call->encodings_accepted_by_peer); +} + static void validate_filtered_metadata(batch_control* bctl) { grpc_compression_algorithm compression_algorithm; grpc_call* call = bctl->call; - if (call->incoming_stream_compression_algorithm != - GRPC_STREAM_COMPRESS_NONE && - call->incoming_message_compression_algorithm != - GRPC_MESSAGE_COMPRESS_NONE) { - char* error_msg = nullptr; - gpr_asprintf(&error_msg, - "Incoming stream has both stream compression (%d) and message " - "compression (%d).", - call->incoming_stream_compression_algorithm, - call->incoming_message_compression_algorithm); - gpr_log(GPR_ERROR, "%s", error_msg); - cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); - gpr_free(error_msg); + if (GPR_UNLIKELY(call->incoming_stream_compression_algorithm != + GRPC_STREAM_COMPRESS_NONE && + call->incoming_message_compression_algorithm != + GRPC_MESSAGE_COMPRESS_NONE)) { + handle_both_stream_and_msg_compression_set(call); } else if ( - grpc_compression_algorithm_from_message_stream_compression_algorithm( - &compression_algorithm, call->incoming_message_compression_algorithm, - call->incoming_stream_compression_algorithm) == 0) { - char* error_msg = nullptr; - gpr_asprintf(&error_msg, - "Error in incoming message compression (%d) or stream " - "compression (%d).", - call->incoming_stream_compression_algorithm, - call->incoming_message_compression_algorithm); - cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); - gpr_free(error_msg); + GPR_UNLIKELY( + grpc_compression_algorithm_from_message_stream_compression_algorithm( + &compression_algorithm, + call->incoming_message_compression_algorithm, + call->incoming_stream_compression_algorithm) == 0)) { + handle_error_parsing_compression_algorithm(call); } else { - char* error_msg = nullptr; const grpc_compression_options compression_options = grpc_channel_compression_options(call->channel); - if (compression_algorithm >= GRPC_COMPRESS_ALGORITHMS_COUNT) { - gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.", - compression_algorithm); - gpr_log(GPR_ERROR, "%s", error_msg); - cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); - } else if (grpc_compression_options_is_algorithm_enabled( - &compression_options, compression_algorithm) == 0) { + if (GPR_UNLIKELY(compression_algorithm >= GRPC_COMPRESS_ALGORITHMS_COUNT)) { + handle_invalid_compression(call, compression_algorithm); + } else if (GPR_UNLIKELY( + grpc_compression_options_is_algorithm_enabled_internal( + &compression_options, compression_algorithm) == 0)) { /* check if algorithm is supported by current channel config */ - const char* algo_name = nullptr; - grpc_compression_algorithm_name(compression_algorithm, &algo_name); - gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.", - algo_name); - gpr_log(GPR_ERROR, "%s", error_msg); - cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + handle_compression_algorithm_disabled(call, compression_algorithm); } - gpr_free(error_msg); - - GPR_ASSERT(call->encodings_accepted_by_peer != 0); - if (!GPR_BITGET(call->encodings_accepted_by_peer, compression_algorithm)) { + /* GRPC_COMPRESS_NONE is always set. */ + GPR_DEBUG_ASSERT(call->encodings_accepted_by_peer != 0); + if (GPR_UNLIKELY(!GPR_BITGET(call->encodings_accepted_by_peer, + compression_algorithm))) { if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) { - const char* algo_name = nullptr; - grpc_compression_algorithm_name(compression_algorithm, &algo_name); - gpr_log(GPR_ERROR, - "Compression algorithm ('%s') not present in the bitset of " - "accepted encodings ('0x%x')", - algo_name, call->encodings_accepted_by_peer); + handle_compression_algorithm_not_accepted(call, compression_algorithm); } } } From 7235091dc26918f1b112d706786ca62b6ca17b45 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Sep 2019 10:41:32 -0700 Subject: [PATCH 104/176] Don't start AuthMetadataProcessor threadpool for non-blocking processor --- src/cpp/server/secure_server_credentials.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpp/server/secure_server_credentials.h b/src/cpp/server/secure_server_credentials.h index 24b133cf7f0..cc5ed1e1f92 100644 --- a/src/cpp/server/secure_server_credentials.h +++ b/src/cpp/server/secure_server_credentials.h @@ -46,7 +46,11 @@ class AuthMetadataProcessorAyncWrapper final { AuthMetadataProcessorAyncWrapper( const std::shared_ptr& processor) - : thread_pool_(CreateDefaultThreadPool()), processor_(processor) {} + : processor_(processor) { + if (processor && processor->IsBlocking()) { + thread_pool_.reset(CreateDefaultThreadPool()); + } + } private: void InvokeProcessor(grpc_auth_context* context, const grpc_metadata* md, From 63cd77c835de2d0ea56d7a3535eb3dc2a975071d Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 5 Sep 2019 11:01:46 -0700 Subject: [PATCH 105/176] Fix transport manager shutdown queuing --- src/objective-c/GRPCClient/private/GRPCTransport+Private.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 5e9c2b52ab4..1ce9e8940ef 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -46,11 +46,10 @@ return self; } +// Must be called on _dispatchQueue or queues targeted by _dispatchQueue - (void)shutDown { - dispatch_async(_dispatchQueue, ^{ - self->_transport = nil; - self->_previousInterceptor = nil; - }); + _transport = nil; + _previousInterceptor = nil; } - (dispatch_queue_t)dispatchQueue { From ecf7274aaae21a2828b393c263520901a5fbad53 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 5 Sep 2019 11:41:36 -0700 Subject: [PATCH 106/176] Add docstring to py2and3_test --- bazel/python_rules.bzl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index e7e9e597b05..373895fc94d 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -183,6 +183,12 @@ def py_grpc_library( def py2and3_test(name, py_test = native.py_test, **kwargs): + """Runs a Python test under both Python 2 and Python 3. + + Args: + name: The name of the test. + py_test: The rule to use for each test. + """ if "python_version" in kwargs: fail("Cannot specify 'python_version' in py2and3_test.") From 04dd147b411dfbb203df73d8b2b39f82338691e9 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 12:24:26 -0700 Subject: [PATCH 107/176] Add Python 3.6 to default gRPC Python test environments --- tools/run_tests/run_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 1ff37ca85af..a90f6e3245e 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -846,6 +846,7 @@ class PythonLanguage(object): else: return ( python27_config, + python36_config, python37_config, ) elif args.compiler == 'python2.7': From c11539f79e75e6f6dd4fb17debe4e4f09755f07e Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 5 Sep 2019 12:32:58 -0700 Subject: [PATCH 108/176] Document kwargs --- bazel/python_rules.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 373895fc94d..356c62d673a 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -188,6 +188,8 @@ def py2and3_test(name, Args: name: The name of the test. py_test: The rule to use for each test. + **kwargs: Keyword arguments passed directly to the underlying py_test + rule. """ if "python_version" in kwargs: fail("Cannot specify 'python_version' in py2and3_test.") From 9f02fc7f91aa40e364835b4cf9fe9e78429d9ffb Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 21 Aug 2019 14:54:56 -0700 Subject: [PATCH 109/176] Enable end2end C++ tests on iOS. Some e2e tests were disabled on iOS because they hit the Apple CFStream bug. This commit enables e2e tests and works around the Apple bug by disabling CFStream. --- test/cpp/common/time_jump_test.cc | 2 +- test/cpp/end2end/BUILD | 8 +- test/cpp/end2end/channelz_service_test.cc | 8 +- .../end2end/client_callback_end2end_test.cc | 6 ++ test/cpp/end2end/client_lb_end2end_test.cc | 5 ++ test/cpp/end2end/end2end_test.cc | 14 +++- test/cpp/end2end/grpclb_end2end_test.cc | 5 ++ test/cpp/end2end/hybrid_end2end_test.cc | 8 ++ test/cpp/end2end/port_sharing_end2end_test.cc | 7 ++ test/cpp/end2end/thread_stress_test.cc | 8 +- test/cpp/end2end/xds_end2end_test.cc | 4 + .../UnitTesting/GTMGoogleTestRunner.mm | 83 +++++++++---------- 12 files changed, 100 insertions(+), 58 deletions(-) diff --git a/test/cpp/common/time_jump_test.cc b/test/cpp/common/time_jump_test.cc index ea6711dfce3..a997982d9fa 100644 --- a/test/cpp/common/time_jump_test.cc +++ b/test/cpp/common/time_jump_test.cc @@ -121,7 +121,7 @@ TEST_P(TimeJumpTest, TimedWait) { GPR_ASSERT(1 == gpr_time_similar(gpr_time_sub(after, before), gpr_time_from_millis(kWaitTimeMs, GPR_TIMESPAN), - gpr_time_from_millis(10, GPR_TIMESPAN))); + gpr_time_from_millis(50, GPR_TIMESPAN))); thd.join(); } diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 1b487602a7a..9153439341f 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -165,7 +165,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -224,6 +223,7 @@ grpc_cc_library( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + alwayslink = 1, ) grpc_cc_test( @@ -272,6 +272,7 @@ grpc_cc_test( # system uses it to specialize targets "//:grpc++", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -441,7 +442,6 @@ grpc_cc_test( "//test/core/util:test_lb_policies", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -482,7 +482,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -505,7 +504,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -698,7 +696,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -756,5 +753,4 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) diff --git a/test/cpp/end2end/channelz_service_test.cc b/test/cpp/end2end/channelz_service_test.cc index 1ed2d8c65f2..325a6ef7094 100644 --- a/test/cpp/end2end/channelz_service_test.cc +++ b/test/cpp/end2end/channelz_service_test.cc @@ -29,6 +29,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/proto/grpc/channelz/channelz.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -104,7 +105,12 @@ class Proxy : public ::grpc::testing::EchoTestService::Service { class ChannelzServerTest : public ::testing::Test { public: ChannelzServerTest() {} - + static void SetUpTestCase() { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + } void SetUp() override { // ensure channel server is brought up on all severs we build. ::grpc::channelz::experimental::InitChannelzService(); diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index a54158ac1d1..c4375b884ee 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -32,6 +32,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -1336,6 +1337,11 @@ TEST_P(ClientCallbackEnd2endTest, } std::vector CreateTestScenarios(bool test_insecure) { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + std::vector scenarios; std::vector credentials_types{ GetCredentialsProvider()->GetSecureCredentialsTypeList()}; diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 1a96aafd7a1..e0b4b074ff2 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -45,6 +45,7 @@ #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/tcp_client.h" @@ -220,6 +221,10 @@ class ClientLbEnd2endTest : public ::testing::Test { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif } void SetUp() override { grpc_init(); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a8592fd97c2..a5a9675d14d 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -36,6 +36,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -254,6 +255,8 @@ void TestScenario::Log() const { class End2endTest : public ::testing::TestWithParam { protected: + static void SetUpTestCase() { grpc_init(); } + static void TearDownTestCase() { grpc_shutdown(); } End2endTest() : is_server_started_(false), kMaxMessageSize_(8192), @@ -2106,6 +2109,13 @@ std::vector CreateTestScenarios(bool use_proxy, bool test_callback_server) { std::vector scenarios; std::vector credentials_types; + + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 200); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + if (test_secure) { credentials_types = GetCredentialsProvider()->GetSecureCredentialsTypeList(); @@ -2173,12 +2183,8 @@ INSTANTIATE_TEST_CASE_P( } // namespace grpc int main(int argc, char** argv) { - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 200); grpc::testing::TestEnvironment env(argc, argv); - // The grpc_init is to cover the MAYBE_SKIP_TEST. - grpc_init(); ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index d71dafc855f..8f0b4cef2ee 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -39,6 +39,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" @@ -378,6 +379,10 @@ class GrpclbEnd2endTest : public ::testing::Test { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif grpc_init(); } diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 75001f0ab27..58ee1e3abb3 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" @@ -229,6 +230,13 @@ class HybridEnd2endTest : public ::testing::TestWithParam { protected: HybridEnd2endTest() {} + static void SetUpTestCase() { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + } + void SetUp() override { inproc_ = (::testing::UnitTest::GetInstance() ->current_test_info() diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index 4f30290d815..2c094c523c0 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -33,6 +33,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset.h" @@ -310,6 +311,12 @@ static void SendRpc(EchoTestService::Stub* stub, int num_rpcs) { std::vector CreateTestScenarios() { std::vector scenarios; std::vector credentials_types; + +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + credentials_types = GetCredentialsProvider()->GetSecureCredentialsTypeList(); // Only allow insecure credentials type when it is registered with the // provider. User may create providers that do not have insecure. diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index eb8e7958b4b..fee20c82679 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -31,6 +31,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/surface/api_trace.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" @@ -66,7 +67,12 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { template class CommonStressTest { public: - CommonStressTest() : kMaxMessageSize_(8192) {} + CommonStressTest() : kMaxMessageSize_(8192) { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + } virtual ~CommonStressTest() {} virtual void SetUp() = 0; virtual void TearDown() = 0; diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 17436bbc13a..2d506c56c87 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -521,6 +521,10 @@ class XdsEnd2endTest : public ::testing::Test { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif grpc_init(); } diff --git a/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm b/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm index 3e8e9245fd4..20b2855cfb1 100644 --- a/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm +++ b/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm @@ -20,14 +20,14 @@ #error "This file requires ARC support." #endif -// This is a SenTest/XCTest based unit test that will run all of the GoogleTest +// This is a XCTest based unit test that will run all of the GoogleTest // https://code.google.com/p/googletest/ -// based tests in the project, and will report results correctly via SenTest so +// based tests in the project, and will report results correctly via XCTest so // that Xcode can pick them up in it's UI. -// SenTest dynamically creates one SenTest per GoogleTest. +// XCTest dynamically creates one XCTest per GoogleTest. // GoogleTest is set up using a custom event listener (GoogleTestPrinter) -// which knows how to log GoogleTest test results in a manner that SenTest (and +// which knows how to log GoogleTest test results in a manner that XCTest (and // the Xcode IDE) understand. // Note that this does not able you to control individual tests from the Xcode @@ -39,33 +39,30 @@ // project because of it's dependency on https://code.google.com/p/googletest/ // To use this: -// - If you are using XCTest (vs SenTest) make sure to define GTM_USING_XCTEST -// in the settings for your testing bundle. // - Add GTMGoogleTestRunner to your test bundle sources. // - Add gtest-all.cc from gtest to your test bundle sources. // - Write some C++ tests and add them to your test bundle sources. // - Build and run tests. Your C++ tests should just execute. -// If you are using this with XCTest (as opposed to SenTestingKit) -// make sure to define GTM_USING_XCTEST. -#ifndef GTM_USING_XCTEST -#define GTM_USING_XCTEST 0 -#endif +// NOTE: +// A key difference between how GTMGoogleTestRunner runs tests versus how a +// "standard" unit test package runs tests is that SetUpTestSuite/SetupTestCase +// and TeardownTestSuite/TeardownTestCase are going to be called before/after +// *every* individual test. Unfortunately this is due to restrictions in the +// design of GoogleTest in that the only way to run individual tests is to +// use a filter to focus on a specific test, and then "run" all the tests +// multiple times. +// If you have state that you need maintained across tests (not normally a +// great idea anyhow), using SetUp*, Teardown* is not going to work for you. -#if GTM_USING_XCTEST #import -#define SenTestCase XCTestCase -#define SenTestSuite XCTestSuite -#else // GTM_USING_XCTEST -#import -#endif // GTM_USING_XCTEST - #import #include using ::testing::EmptyTestEventListener; using ::testing::TestCase; +using ::testing::TestEventListener; using ::testing::TestEventListeners; using ::testing::TestInfo; using ::testing::TestPartResult; @@ -75,18 +72,19 @@ using ::testing::UnitTest; namespace { // A gtest printer that takes care of reporting gtest results via the -// SenTest interface. Note that a test suite in SenTest == a test case in gtest -// and a test case in SenTest == a test in gtest. +// XCTest interface. Note that a test suite in XCTest == a test case in gtest +// and a test case in XCTest == a test in gtest. // This will handle fatal and non-fatal gtests properly. class GoogleTestPrinter : public EmptyTestEventListener { public: - GoogleTestPrinter(SenTestCase *test_case) : test_case_(test_case) {} + GoogleTestPrinter(XCTestCase *test_case) : test_case_(test_case) {} virtual ~GoogleTestPrinter() {} virtual void OnTestPartResult(const TestPartResult &test_part_result) { if (!test_part_result.passed()) { - NSString *file = @(test_part_result.file_name()); + const char *file_name = test_part_result.file_name(); + NSString *file = @(file_name ? file_name : ""); int line = test_part_result.line_number(); NSString *summary = @(test_part_result.summary()); @@ -94,26 +92,16 @@ class GoogleTestPrinter : public EmptyTestEventListener { // the Xcode UI, so we clean them up. NSString *oneLineSummary = [summary stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; -#if GTM_USING_XCTEST BOOL expected = test_part_result.nonfatally_failed(); [test_case_ recordFailureWithDescription:oneLineSummary inFile:file atLine:line expected:expected]; -#else // GTM_USING_XCTEST - NSException *exception = - [NSException failureInFile:file - atLine:line - withDescription:@"%@", oneLineSummary]; - - // failWithException: will log appropriately. - [test_case_ failWithException:exception]; -#endif // GTM_USING_XCTEST } } private: - SenTestCase *test_case_; + XCTestCase *test_case_; }; NSString *SelectorNameFromGTestName(NSString *testName) { @@ -127,7 +115,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { // GTMGoogleTestRunner is a GTMTestCase that makes a sub test suite populated // with all of the GoogleTest unit tests. -@interface GTMGoogleTestRunner : SenTestCase { +@interface GTMGoogleTestRunner : XCTestCase { NSString *testName_; } @@ -154,8 +142,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { + (id)defaultTestSuite { [GTMGoogleTestRunner initGoogleTest]; - SenTestSuite *result = - [[SenTestSuite alloc] initWithName:NSStringFromClass(self)]; + XCTestSuite *result = [[XCTestSuite alloc] initWithName:NSStringFromClass(self)]; UnitTest *test = UnitTest::GetInstance(); // Walk the GoogleTest tests, adding sub tests and sub suites as appropriate. @@ -163,15 +150,14 @@ NSString *SelectorNameFromGTestName(NSString *testName) { for (int i = 0; i < total_test_case_count; ++i) { const TestCase *test_case = test->GetTestCase(i); int total_test_count = test_case->total_test_count(); - SenTestSuite *subSuite = - [[SenTestSuite alloc] initWithName:@(test_case->name())]; + XCTestSuite *subSuite = [[XCTestSuite alloc] initWithName:@(test_case->name())]; [result addTest:subSuite]; for (int j = 0; j < total_test_count; ++j) { const TestInfo *test_info = test_case->GetTestInfo(j); NSString *testName = [NSString stringWithFormat:@"%s.%s", test_case->name(), test_info->name()]; - SenTestCase *senTest = [[self alloc] initWithName:testName]; - [subSuite addTest:senTest]; + XCTestCase *xcTest = [[self alloc] initWithName:testName]; + [subSuite addTest:xcTest]; } } return result; @@ -201,7 +187,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { } - (NSString *)name { - // A SenTest name must be "-[foo bar]" or it won't be parsed properly. + // An XCTest name must be "-[foo bar]" or it won't be parsed properly. NSRange dot = [testName_ rangeOfString:@"."]; return [NSString stringWithFormat:@"-[%@ %@]", [testName_ substringToIndex:dot.location], @@ -214,11 +200,15 @@ NSString *SelectorNameFromGTestName(NSString *testName) { // Gets hold of the event listener list. TestEventListeners& listeners = UnitTest::GetInstance()->listeners(); - // Adds a listener to the end. Google Test takes the ownership. - listeners.Append(new GoogleTestPrinter(self)); + // Adds a listener to the end. + GoogleTestPrinter printer = GoogleTestPrinter(self); + listeners.Append(&printer); - // Remove the default printer. - delete listeners.Release(listeners.default_result_printer()); + // Remove the default printer if it exists. + TestEventListener *defaultListener = listeners.default_result_printer(); + if (defaultListener) { + delete listeners.Release(defaultListener); + } // Since there is no way of running a single GoogleTest directly, we use the // filter mechanism in GoogleTest to simulate it for us. @@ -228,6 +218,9 @@ NSString *SelectorNameFromGTestName(NSString *testName) { // the output appropriately, and there is no reason to mark this test as // "failed" if RUN_ALL_TESTS returns non-zero. (void)RUN_ALL_TESTS(); + + // Remove the listener that we added. + listeners.Release(&printer); } @end From e6e5d2d5318ddbc218e2a02896f6be4c931e7329 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 5 Sep 2019 14:18:35 -0700 Subject: [PATCH 110/176] Use libc++ for clang sanity test --- Makefile | 24 ++++++++++++------------ build.yaml | 35 ++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index d48b36a531f..1e8acd7e99e 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,8 @@ CC_asan-trace-cmp = clang CXX_asan-trace-cmp = clang++ LD_asan-trace-cmp = clang++ LDXX_asan-trace-cmp = clang++ -CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-trace-cmp = -fsanitize=address +CPPFLAGS_asan-trace-cmp = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-trace-cmp = -stdlib=libc++ -fsanitize=address VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -103,8 +103,8 @@ CC_asan = clang CXX_asan = clang++ LD_asan = clang++ LDXX_asan = clang++ -CPPFLAGS_asan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan = -fsanitize=address +CPPFLAGS_asan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan = -stdlib=libc++ -fsanitize=address VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -112,8 +112,8 @@ CC_msan = clang CXX_msan = clang++ LD_msan = clang++ LDXX_msan = clang++ -CPPFLAGS_msan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) +CPPFLAGS_msan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_msan = -stdlib=libc++ -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) DEFINES_msan = NDEBUG VALID_CONFIG_basicprof = 1 @@ -139,8 +139,8 @@ CC_asan-noleaks = clang CXX_asan-noleaks = clang++ LD_asan-noleaks = clang++ LDXX_asan-noleaks = clang++ -CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-noleaks = -fsanitize=address +CPPFLAGS_asan-noleaks = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-noleaks = -stdlib=libc++ -fsanitize=address VALID_CONFIG_noexcept = 1 CC_noexcept = $(DEFAULT_CC) @@ -157,8 +157,8 @@ CC_ubsan = clang CXX_ubsan = clang++ LD_ubsan = clang++ LDXX_ubsan = clang++ -CPPFLAGS_ubsan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs -LDFLAGS_ubsan = -fsanitize=undefined,unsigned-integer-overflow +CPPFLAGS_ubsan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs +LDFLAGS_ubsan = -stdlib=libc++ -fsanitize=undefined,unsigned-integer-overflow DEFINES_ubsan = NDEBUG GRPC_UBSAN VALID_CONFIG_tsan = 1 @@ -167,8 +167,8 @@ CC_tsan = clang CXX_tsan = clang++ LD_tsan = clang++ LDXX_tsan = clang++ -CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_tsan = -fsanitize=thread +CPPFLAGS_tsan = -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_tsan = -stdlib=libc++ -fsanitize=thread DEFINES_tsan = GRPC_TSAN VALID_CONFIG_stapprof = 1 diff --git a/build.yaml b/build.yaml index 9c546246ab0..ee51a72bb8d 100644 --- a/build.yaml +++ b/build.yaml @@ -6067,11 +6067,11 @@ vspackages: configs: asan: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer - -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address + -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -fsanitize=address + LDFLAGS: -stdlib=libc++ -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6079,23 +6079,23 @@ configs: LSAN_OPTIONS: suppressions=test/core/util/lsan_suppressions.txt:report_objects=1 asan-noleaks: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer - -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address + -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -fsanitize=address + LDFLAGS: -stdlib=libc++ -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: ASAN_OPTIONS: detect_leaks=0:color=always asan-trace-cmp: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -fsanitize=address + LDFLAGS: -stdlib=libc++ -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6137,13 +6137,14 @@ configs: valgrind: --tool=memcheck --leak-check=full msan: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory -fsanitize-memory-track-origins - -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 - -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory + -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer + -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument + -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: NDEBUG LD: clang++ - LDFLAGS: -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 + LDFLAGS: -stdlib=libc++ -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDXX: clang++ compile_the_world: true @@ -6165,24 +6166,24 @@ configs: DEFINES: NDEBUG tsan: CC: clang - CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: GRPC_TSAN LD: clang++ - LDFLAGS: -fsanitize=thread + LDFLAGS: -stdlib=libc++ -fsanitize=thread LDXX: clang++ compile_the_world: true test_environ: TSAN_OPTIONS: suppressions=test/core/util/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1 ubsan: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined -fno-omit-frame-pointer - -Wno-unused-command-line-argument -Wvarargs + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined + -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs CXX: clang++ DEFINES: NDEBUG GRPC_UBSAN LD: clang++ - LDFLAGS: -fsanitize=undefined,unsigned-integer-overflow + LDFLAGS: -stdlib=libc++ -fsanitize=undefined,unsigned-integer-overflow LDXX: clang++ compile_the_world: true test_environ: From 8b91cdbf6db580856dbe7f2da51055837f30ca94 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 15:53:34 -0700 Subject: [PATCH 111/176] Add a default Dockerfile for Python testing --- .../Dockerfile.template | 37 ++++++++ .../python_stretch_default_x64/Dockerfile | 88 +++++++++++++++++++ tools/run_tests/run_tests.py | 2 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template create mode 100644 tools/dockerfile/test/python_stretch_default_x64/Dockerfile diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template new file mode 100644 index 00000000000..c6799a38fb5 --- /dev/null +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -0,0 +1,37 @@ +%YAML 1.2 +--- | + # Copyright 2018 The 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 file="../../python_stretch.include"/> + + RUN apt-get install -y jq zlib1g-dev libssl-dev + RUN apt-get install -y jq build-essential libffi-dev + + RUN cd /tmp && ${'\\'} + wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} + tar xzvf v3.6.9.tar.gz && ${'\\'} + cd cpython-3.6.9 && ${'\\'} + ./configure && ${'\\'} + make install + + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev + RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 + + # for Python test coverage reporting + RUN python3.7 -m ensurepip && ${'\\'} + python3.7 -m pip install coverage + + RUN python3.6 -m ensurepip && ${'\\'} + python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile new file mode 100644 index 00000000000..8f1f7c820db --- /dev/null +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -0,0 +1,88 @@ +# Copyright 2018 The 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. + +FROM debian:stretch + +# Install Git and basic packages. +RUN apt-get update && apt-get install -y \ + autoconf \ + autotools-dev \ + build-essential \ + bzip2 \ + ccache \ + curl \ + dnsutils \ + 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 + +# Google Cloud platform API libraries +RUN apt-get update && apt-get install -y python-pip && apt-get clean +RUN pip install --upgrade google-api-python-client oauth2client + +# Install Python 2.7 +RUN apt-get update && apt-get install -y python2.7 python-all-dev +RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 + +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local + +RUN mkdir /var/local/jenkins + +# Define the default command. +CMD ["bash"] + + +RUN apt-get install -y jq zlib1g-dev libssl-dev +RUN apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && \ + wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ + tar xzvf v3.6.9.tar.gz && \ + cd cpython-3.6.9 && \ + ./configure && \ + make install + +RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev +RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 + +# for Python test coverage reporting +RUN python3.7 -m ensurepip && \ + python3.7 -m pip install coverage + +RUN python3.6 -m ensurepip && \ + python3.6 -m pip install coverage diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a90f6e3245e..8ee0710b484 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -761,7 +761,7 @@ class PythonLanguage(object): elif self.args.compiler == 'python3.4': return 'jessie' else: - return 'stretch_3.7' + return 'stretch_default' def _get_pythons(self, args): """Get python runtimes to test with, based on current platform, architecture, compiler etc.""" From 6620a74b7273bbc711fb0254baa3a228658f1f11 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 15:59:27 -0700 Subject: [PATCH 112/176] Run apt-get update before installing packages --- .../test/python_stretch_default_x64/Dockerfile.template | 4 ++-- tools/dockerfile/test/python_stretch_default_x64/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index c6799a38fb5..af86101b71b 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -16,8 +16,8 @@ <%include file="../../python_stretch.include"/> - RUN apt-get install -y jq zlib1g-dev libssl-dev - RUN apt-get install -y jq build-essential libffi-dev + RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev + RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && ${'\\'} wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 8f1f7c820db..484b5e0428a 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -67,8 +67,8 @@ RUN mkdir /var/local/jenkins CMD ["bash"] -RUN apt-get install -y jq zlib1g-dev libssl-dev -RUN apt-get install -y jq build-essential libffi-dev +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ From 113b2f2225bf4362367a51c15cff4a3b94227aa7 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 16:07:15 -0700 Subject: [PATCH 113/176] Remove the ensurepip for Python 3.7 --- .../test/python_stretch_default_x64/Dockerfile.template | 3 +-- tools/dockerfile/test/python_stretch_default_x64/Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index af86101b71b..57620b17aa4 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -30,8 +30,7 @@ RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting - RUN python3.7 -m ensurepip && ${'\\'} - python3.7 -m pip install coverage + RUN python3.7 -m pip install coverage RUN python3.6 -m ensurepip && ${'\\'} python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 484b5e0428a..a412c93fe73 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -81,8 +81,7 @@ RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting -RUN python3.7 -m ensurepip && \ - python3.7 -m pip install coverage +RUN python3.7 -m pip install coverage RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage From 04b3b8e9215994cba3243d0726163f22cec665f9 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 5 Sep 2019 16:39:55 -0700 Subject: [PATCH 114/176] Add default transport fallback --- src/objective-c/GRPCClient/GRPCTransport.m | 17 +++++-- .../CronetTests/TransportRegistryTests.m | 41 +++++++++++++++ .../tests/Tests.xcodeproj/project.pbxproj | 8 +++ .../tests/UnitTests/TransportRegistryTests.m | 51 +++++++++++++++++++ 4 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 src/objective-c/tests/CronetTests/TransportRegistryTests.m create mode 100644 src/objective-c/tests/UnitTests/TransportRegistryTests.m diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 966dc50d64d..353300c3bc4 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -86,8 +86,9 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { - (id)getTransportFactoryWithId:(GRPCTransportID)transportId { if (transportId == NULL) { if (_defaultFactory == nil) { + // fall back to default transport if no transport is provided [NSException raise:NSInvalidArgumentException - format:@"Unable to get default transport factory"]; + format:@"Did not specify transport and unable to find a default transport."]; return nil; } return _defaultFactory; @@ -95,10 +96,16 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; id transportFactory = _registry[nsTransportId]; if (transportFactory == nil) { - // User named a transport id that was not registered with the registry. - [NSException raise:NSInvalidArgumentException - format:@"Unable to get transport factory with id %s", transportId]; - return nil; + if (_defaultFactory != nil) { + // fall back to default transport if no transport is found + NSLog(@"Unable to find transport with id %s; falling back to default transport.", + transportId); + return _defaultFactory; + } else { + [NSException raise:NSInvalidArgumentException + format:@"Unable to find transport with id %s", transportId]; + return nil; + } } return transportFactory; } diff --git a/src/objective-c/tests/CronetTests/TransportRegistryTests.m b/src/objective-c/tests/CronetTests/TransportRegistryTests.m new file mode 100644 index 00000000000..75802e17c4f --- /dev/null +++ b/src/objective-c/tests/CronetTests/TransportRegistryTests.m @@ -0,0 +1,41 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import + +#import +#import +#import "src/objective-c/GRPCClient/private/GRPCTransport+Private.h" + +@interface TransportRegistryTests : XCTestCase + +@end + +@implementation TransportRegistryTests + +- (void)testCronetImplementationExist { + id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + id cronetTransportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + XCTAssertNotNil(secureTransportFactory); + XCTAssertNotNil(cronetTransportFactory); + XCTAssertNotEqual(secureTransportFactory, cronetTransportFactory); +} + +@end diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 6cb9f5560b9..2ce32d3916d 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 5E7F488E22778C87006656AD /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5E7F488F22778C8C006656AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488822778B04006656AD /* InteropTestsRemote.m */; }; 5E7F489022778C95006656AD /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; + 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */; }; + 5E9F1C352321C9B200837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */; }; 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; @@ -121,6 +123,8 @@ 5E7F488622778AEA006656AD /* GRPCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRPCClientTests.m; sourceTree = ""; }; 5E7F488822778B04006656AD /* InteropTestsRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemote.m; sourceTree = ""; }; 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; + 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; + 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; @@ -362,6 +366,7 @@ 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( + 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */, 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */, 5E7F488622778AEA006656AD /* GRPCClientTests.m */, 5E7F487F227782C1006656AD /* APIv2Tests.m */, @@ -375,6 +380,7 @@ 5E7F485A22775B15006656AD /* CronetTests */ = { isa = PBXGroup; children = ( + 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */, 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */, 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */, 5EAD6D261E27047400002378 /* CronetUnitTests.mm */, @@ -868,6 +874,7 @@ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */, 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */, 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */, + 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */, 5E7F488722778AEA006656AD /* GRPCClientTests.m in Sources */, 5E7F487E22778256006656AD /* ChannelTests.m in Sources */, 5E7F488B22778B5D006656AD /* RxLibraryUnitTests.m in Sources */, @@ -882,6 +889,7 @@ 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, + 5E9F1C352321C9B200837469 /* TransportRegistryTests.m in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */, diff --git a/src/objective-c/tests/UnitTests/TransportRegistryTests.m b/src/objective-c/tests/UnitTests/TransportRegistryTests.m new file mode 100644 index 00000000000..40035fefa90 --- /dev/null +++ b/src/objective-c/tests/UnitTests/TransportRegistryTests.m @@ -0,0 +1,51 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import + +#import +#import +#import "src/objective-c/GRPCClient/private/GRPCTransport+Private.h" + +@interface TransportRegistryTests : XCTestCase + +@end + +@implementation TransportRegistryTests + +- (void)testDefaultImplementationsExist { + id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + id insecureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_insecure]; + XCTAssertNotNil(secureTransportFactory); + XCTAssertNotNil(insecureTransportFactory); + XCTAssertNotEqual(secureTransportFactory, insecureTransportFactory); +} + +- (void)testCronetImplementationNotExistAndFallBack { + id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + id cronetTransportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + XCTAssertNotNil(secureTransportFactory); + XCTAssertNotNil(cronetTransportFactory); + XCTAssertEqual(secureTransportFactory, cronetTransportFactory); +} + +@end From 97f1f57dab1eda1c45601f19d104dcbdcc54ff46 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 5 Sep 2019 18:13:59 -0700 Subject: [PATCH 115/176] Allow call credentials to be set even after the call is created but before initial metadata is sent --- .../grpcpp/impl/codegen/client_context_impl.h | 6 +- src/cpp/client/client_context.cc | 16 ++++ test/cpp/end2end/end2end_test.cc | 81 +++++++++++++++++-- 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h index 7a543055b4b..bf5afa44b10 100644 --- a/include/grpcpp/impl/codegen/client_context_impl.h +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -310,11 +310,11 @@ class ClientContext { /// client’s identity, role, or whether it is authorized to make a particular /// call. /// + /// It is legal to call this only before initial metadata is sent. + /// /// \see https://grpc.io/docs/guides/auth.html void set_credentials( - const std::shared_ptr& creds) { - creds_ = creds; - } + const std::shared_ptr& creds); /// Return the compression algorithm the client call will request be used. /// Note that the gRPC runtime may decide to ignore this request, for example, diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index efb10a44006..fc44b654efe 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -72,6 +72,22 @@ ClientContext::~ClientContext() { g_client_callbacks->Destructor(this); } +void ClientContext::set_credentials( + const std::shared_ptr& creds) { + creds_ = creds; + // If call_ is set, we have already created the call, and set the call + // credentials. This should only be done before we have started the batch + // for sending initial metadata. + if (creds_ != nullptr && call_ != nullptr) { + if (!creds_->ApplyToCall(call_)) { + SendCancelToInterceptors(); + grpc_call_cancel_with_status(call_, GRPC_STATUS_CANCELLED, + "Failed to set credentials to rpc.", + nullptr); + } + } +} + std::unique_ptr ClientContext::FromServerContext( const grpc::ServerContext& context, PropagationOptions options) { std::unique_ptr ctx(new ClientContext); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a8592fd97c2..a4655329250 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -16,9 +16,6 @@ * */ -#include -#include - #include #include #include @@ -35,6 +32,9 @@ #include #include +#include +#include + #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" @@ -338,7 +338,11 @@ class End2endTest : public ::testing::TestWithParam { kMaxMessageSize_); // For testing max message size. } - void ResetChannel() { + void ResetChannel( + std::vector< + std::unique_ptr> + interceptor_creators = std::vector>()) { if (!is_server_started_) { StartServer(std::shared_ptr()); } @@ -358,20 +362,27 @@ class End2endTest : public ::testing::TestWithParam { } else { channel_ = CreateCustomChannelWithInterceptors( server_address_.str(), channel_creds, args, - CreateDummyClientInterceptors()); + interceptor_creators.empty() ? CreateDummyClientInterceptors() + : std::move(interceptor_creators)); } } else { if (!GetParam().use_interceptors) { channel_ = server_->InProcessChannel(args); } else { channel_ = server_->experimental().InProcessChannelWithInterceptors( - args, CreateDummyClientInterceptors()); + args, interceptor_creators.empty() + ? CreateDummyClientInterceptors() + : std::move(interceptor_creators)); } } } - void ResetStub() { - ResetChannel(); + void ResetStub( + std::vector< + std::unique_ptr> + interceptor_creators = std::vector>()) { + ResetChannel(std::move(interceptor_creators)); if (GetParam().use_proxy) { proxy_service_.reset(new Proxy(channel_)); int port = grpc_pick_unused_port_or_die(); @@ -1802,6 +1813,60 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { "fake_selector")); } +class CredentialsInterceptor : public experimental::Interceptor { + public: + CredentialsInterceptor(experimental::ClientRpcInfo* info) : info_(info) {} + + void Intercept(experimental::InterceptorBatchMethods* methods) { + if (methods->QueryInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { + std::shared_ptr creds = + GoogleIAMCredentials("fake_token", "fake_selector"); + info_->client_context()->set_credentials(creds); + } + methods->Proceed(); + } + + private: + experimental::ClientRpcInfo* info_ = nullptr; +}; + +class CredentialsInterceptorFactory + : public experimental::ClientInterceptorFactoryInterface { + CredentialsInterceptor* CreateClientInterceptor( + experimental::ClientRpcInfo* info) { + return new CredentialsInterceptor(info); + } +}; + +TEST_P(SecureEnd2endTest, CallCredentialsInterception) { + MAYBE_SKIP_TEST; + if (!GetParam().use_interceptors) { + return; + } + std::vector> + interceptor_creators; + interceptor_creators.push_back(std::unique_ptr( + new CredentialsInterceptorFactory())); + ResetStub(std::move(interceptor_creators)); + EchoRequest request; + EchoResponse response; + ClientContext context; + + request.set_message("Hello"); + request.mutable_param()->set_echo_metadata(true); + + Status s = stub_->Echo(&context, request, &response); + EXPECT_EQ(request.message(), response.message()); + EXPECT_TRUE(s.ok()); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + "fake_token")); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + "fake_selector")); +} + TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { MAYBE_SKIP_TEST; ResetStub(); From 4e8ecb9fe63c3d15363bb568c016636325ed3fb1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 6 Sep 2019 12:31:45 +0200 Subject: [PATCH 116/176] Revert "Upgrade to Bazel 0.29 (including Windows RBE)" --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- tools/internal_ci/windows/bazel_rbe.bat | 4 ++-- tools/remote_build/windows.bazelrc | 7 ++++--- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 9762bdcb85f..12a22785623 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index cfa875b0e63..4d1d57f60d9 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.29.0 +VERSION=0.28.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index fde54bae877..7141fb9c5f1 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4d3691f32bd..badff52de34 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 8d8ea118ebd..153b2d59687 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.29.0 --limit-output +choco install bazel -y --version 0.26.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% @@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE. -bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json +bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --incompatible_disallow_filetype=false --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json set BAZEL_EXITCODE=%errorlevel% @rem TODO(jtattermusch): upload results to bigquery diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 825d6765de9..9fd3071e79f 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -1,7 +1,8 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 -build --remote_cache=grpcs://remotebuildexecution.googleapis.com -build --remote_executor=grpcs://remotebuildexecution.googleapis.com +build --remote_cache=remotebuildexecution.googleapis.com +build --remote_executor=remotebuildexecution.googleapis.com +build --tls_enabled=true build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain @@ -37,7 +38,7 @@ test --test_env=GRPC_VERBOSITY=debug # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend=grpcs://buildeventservice.googleapis.com +build --bes_backend="buildeventservice.googleapis.com" build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing From 49d67b3531978b45ea091f0d06423ed315462668 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 6 Sep 2019 10:17:11 -0700 Subject: [PATCH 117/176] Revert using libc++ for asan & tsan --- Makefile | 16 ++++++++-------- build.yaml | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 1e8acd7e99e..e666a19eb79 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,8 @@ CC_asan-trace-cmp = clang CXX_asan-trace-cmp = clang++ LD_asan-trace-cmp = clang++ LDXX_asan-trace-cmp = clang++ -CPPFLAGS_asan-trace-cmp = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-trace-cmp = -stdlib=libc++ -fsanitize=address +CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-trace-cmp = -fsanitize=address VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -103,8 +103,8 @@ CC_asan = clang CXX_asan = clang++ LD_asan = clang++ LDXX_asan = clang++ -CPPFLAGS_asan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan = -stdlib=libc++ -fsanitize=address +CPPFLAGS_asan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan = -fsanitize=address VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -139,8 +139,8 @@ CC_asan-noleaks = clang CXX_asan-noleaks = clang++ LD_asan-noleaks = clang++ LDXX_asan-noleaks = clang++ -CPPFLAGS_asan-noleaks = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-noleaks = -stdlib=libc++ -fsanitize=address +CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-noleaks = fsanitize=address VALID_CONFIG_noexcept = 1 CC_noexcept = $(DEFAULT_CC) @@ -167,8 +167,8 @@ CC_tsan = clang CXX_tsan = clang++ LD_tsan = clang++ LDXX_tsan = clang++ -CPPFLAGS_tsan = -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_tsan = -stdlib=libc++ -fsanitize=thread +CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_tsan = -fsanitize=thread DEFINES_tsan = GRPC_TSAN VALID_CONFIG_stapprof = 1 diff --git a/build.yaml b/build.yaml index ee51a72bb8d..15203f242c9 100644 --- a/build.yaml +++ b/build.yaml @@ -6067,11 +6067,11 @@ vspackages: configs: asan: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address - -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer + -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=address + LDFLAGS: -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6079,23 +6079,23 @@ configs: LSAN_OPTIONS: suppressions=test/core/util/lsan_suppressions.txt:report_objects=1 asan-noleaks: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address - -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer + -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=address + LDFLAGS: fsanitize=address LDXX: clang++ compile_the_world: true test_environ: ASAN_OPTIONS: detect_leaks=0:color=always asan-trace-cmp: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp + CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=address + LDFLAGS: -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6166,12 +6166,12 @@ configs: DEFINES: NDEBUG tsan: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument + CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: GRPC_TSAN LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=thread + LDFLAGS: -fsanitize=thread LDXX: clang++ compile_the_world: true test_environ: From 3e2171ed6188b0941b47ed27785485cfd80a6341 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 11:15:00 -0700 Subject: [PATCH 118/176] Adopt reviewer's advice --- templates/tools/dockerfile/python_stretch.include | 2 -- .../test/python_stretch_default_x64/Dockerfile.template | 3 +++ tools/dockerfile/interoptest/grpc_interop_python/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_default_x64/Dockerfile | 5 +++-- tools/dockerfile/test/sanity/Dockerfile | 2 -- 10 files changed, 6 insertions(+), 18 deletions(-) diff --git a/templates/tools/dockerfile/python_stretch.include b/templates/tools/dockerfile/python_stretch.include index 43ba98ae64c..8591e753d01 100644 --- a/templates/tools/dockerfile/python_stretch.include +++ b/templates/tools/dockerfile/python_stretch.include @@ -7,5 +7,3 @@ FROM debian:stretch RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local <%include file="./run_tests_addons.include"/> -# Define the default command. -CMD ["bash"] diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 57620b17aa4..155e0068a99 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -25,6 +25,9 @@ cd cpython-3.6.9 && ${'\\'} ./configure && ${'\\'} make install + + RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 + RUN md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile index b11a1a1aa31..3583d783a81 100644 --- a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get -t stable install -y python3.7 python3-all-dev diff --git a/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile b/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile index 92b18e740da..0bbc11a21b2 100644 --- a/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile @@ -63,6 +63,4 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] diff --git a/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile index 7a256edffb2..bfedf432b78 100644 --- a/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get install -y python3.5 python3-all-dev diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index f18af660488..7a3a4a6dea5 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get install -y jq zlib1g-dev libssl-dev diff --git a/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile index 46b6526dc69..6745055c14f 100644 --- a/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile index 495d86fd099..b0e386ac57f 100644 --- a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get install -y jq zlib1g-dev libssl-dev diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index a412c93fe73..7a6e51fdf7a 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev @@ -77,6 +75,9 @@ RUN cd /tmp && \ ./configure && \ make install +RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 +RUN md5sum -c checksum.md5 + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4d3691f32bd..6ab449f14b1 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] #================= # C++ dependencies From 40d495a31b9ba29642561e33886eb2fa7b57650e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 11:25:12 -0700 Subject: [PATCH 119/176] Correct the checksum and download link --- .../python_stretch_default_x64/Dockerfile.template | 11 ++++++----- .../test/python_stretch_default_x64/Dockerfile | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 155e0068a99..80347d4b4d0 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -20,14 +20,15 @@ RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && ${'\\'} - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} - tar xzvf v3.6.9.tar.gz && ${'\\'} - cd cpython-3.6.9 && ${'\\'} + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} + tar xzvf Python-3.6.9.tgz && ${'\\'} + cd Python-3.6.9 && ${'\\'} ./configure && ${'\\'} make install - RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 - RUN md5sum -c checksum.md5 + RUN cd /tmp && ${'\\'} + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} + md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 7a6e51fdf7a..cf0eebe2ad6 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -69,14 +69,15 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ - tar xzvf v3.6.9.tar.gz && \ - cd cpython-3.6.9 && \ + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar xzvf Python-3.6.9.tgz && \ + cd Python-3.6.9 && \ ./configure && \ make install -RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 -RUN md5sum -c checksum.md5 +RUN cd /tmp && \ + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 From 9094826cf5e8da6718a531e44305eff5a6977113 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Sep 2019 11:25:18 -0700 Subject: [PATCH 120/176] Polish interceptor/transport manager logic --- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 ++ src/objective-c/GRPCClient/GRPCInterceptor.m | 13 +++++++------ .../GRPCClient/private/GRPCTransport+Private.h | 2 ++ .../GRPCClient/private/GRPCTransport+Private.m | 4 +++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 1794ef4b892..ed907a33054 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -182,6 +182,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the interceptor has shut down and the manager should release references * to other interceptors and stop forwarding requests/responses. + * + * The method can only be called by the manager's associated interceptor. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index abada5a80c1..1a64bccb89b 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -68,12 +68,11 @@ } - (void)shutDown { - dispatch_async(_dispatchQueue, ^{ - self->_nextInterceptor = nil; - self->_previousInterceptor = nil; - self->_thisInterceptor = nil; - self->_shutDown = YES; - }); + // immediately releases reference; should not queue to dispatch queue. + _nextInterceptor = nil; + _previousInterceptor = nil; + _thisInterceptor = nil; + _shutDown = YES; } - (void)createNextInterceptor { @@ -203,6 +202,8 @@ return; } id copiedPreviousInterceptor = _previousInterceptor; + // no more callbacks should be issued to the previous interceptor + _previousInterceptor = nil; dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; }); diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 075d185e5d7..eaf07950815 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -43,6 +43,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the transport has shut down and the manager should release references to * its response handler and stop forwarding requests/responses. + * + * The method can only be called by the manager's associated transport instance. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 1ce9e8940ef..aa9c7f2ce58 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -46,8 +46,8 @@ return self; } -// Must be called on _dispatchQueue or queues targeted by _dispatchQueue - (void)shutDown { + // immediately releases reference; should not queue to dispatch queue. _transport = nil; _previousInterceptor = nil; } @@ -111,6 +111,8 @@ return; } id copiedPreviousInterceptor = _previousInterceptor; + // no more callbacks should be issued to the previous interceptor + _previousInterceptor = nil; dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; }); From e592414fae42df3d4b4887480eda9a5c81c60fd3 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 6 Sep 2019 11:37:19 -0700 Subject: [PATCH 121/176] Add check for input parameter being null. --- src/core/ext/filters/client_channel/lb_policy_registry.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.cc b/src/core/ext/filters/client_channel/lb_policy_registry.cc index 20099b52d6c..c0788955419 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.cc +++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc @@ -117,8 +117,13 @@ namespace { grpc_json* ParseLoadBalancingConfigHelper(const grpc_json* lb_config_array, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); + if (lb_config_array == nullptr) { + *error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("LB config JSON tree is null"); + return nullptr; + } char* error_msg; - if (lb_config_array == nullptr || lb_config_array->type != GRPC_JSON_ARRAY) { + if (lb_config_array->type != GRPC_JSON_ARRAY) { gpr_asprintf(&error_msg, "field:%s error:type should be array", lb_config_array->key); *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg); From f6445add1f3966c6f1e13fb9751a9fc7b4f1f254 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 13:05:42 -0700 Subject: [PATCH 122/176] Move compile CPython 3.6 to a separate include file --- .../tools/dockerfile/compile_python_36.include | 15 +++++++++++++++ .../python_stretch_3.6_x64/Dockerfile.template | 16 +--------------- .../Dockerfile.template | 11 +---------- .../test/python_stretch_3.6_x64/Dockerfile | 17 +++++++++-------- .../test/python_stretch_default_x64/Dockerfile | 15 ++++++++++----- 5 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 templates/tools/dockerfile/compile_python_36.include diff --git a/templates/tools/dockerfile/compile_python_36.include b/templates/tools/dockerfile/compile_python_36.include new file mode 100644 index 00000000000..e8983db334f --- /dev/null +++ b/templates/tools/dockerfile/compile_python_36.include @@ -0,0 +1,15 @@ +#================= +# Compile CPython 3.6.9 from source + +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && ${'\\'} +wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} +tar xzvf Python-3.6.9.tgz && ${'\\'} +cd Python-3.6.9 && ${'\\'} +./configure && ${'\\'} +make install + +RUN python3.6 -m ensurepip && ${'\\'} + python3.6 -m pip install coverage \ No newline at end of file diff --git a/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template index 2c2cb6de08b..c7d5fe36faa 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template @@ -15,18 +15,4 @@ # limitations under the License. <%include file="../../python_stretch.include"/> - - RUN apt-get install -y jq zlib1g-dev libssl-dev - - RUN apt-get install -y jq build-essential libffi-dev - - RUN cd /tmp && ${'\\'} - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} - tar xzvf v3.6.9.tar.gz && ${'\\'} - cd cpython-3.6.9 && ${'\\'} - ./configure && ${'\\'} - make install - - RUN python3.6 -m ensurepip && ${'\\'} - python3.6 -m pip install coverage - + <%include file="../../compile_python_36.include"/> diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 80347d4b4d0..8f8bea1eb50 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -15,17 +15,8 @@ # limitations under the License. <%include file="../../python_stretch.include"/> + <%include file="../../compile_python_36.include"/> - RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev - RUN apt-get update && apt-get install -y jq build-essential libffi-dev - - RUN cd /tmp && ${'\\'} - wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} - tar xzvf Python-3.6.9.tgz && ${'\\'} - cd Python-3.6.9 && ${'\\'} - ./configure && ${'\\'} - make install - RUN cd /tmp && ${'\\'} echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} md5sum -c checksum.md5 diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index 7a3a4a6dea5..a7a5f53e549 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -64,17 +64,18 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins +#================= +# Compile CPython 3.6.9 from source -RUN apt-get install -y jq zlib1g-dev libssl-dev - -RUN apt-get install -y jq build-essential libffi-dev +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ - tar xzvf v3.6.9.tar.gz && \ - cd cpython-3.6.9 && \ - ./configure && \ - make install +wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ +tar xzvf Python-3.6.9.tgz && \ +cd Python-3.6.9 && \ +./configure && \ +make install RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index cf0eebe2ad6..7aba6c87593 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -64,16 +64,21 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins +#================= +# Compile CPython 3.6.9 from source RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ - tar xzvf Python-3.6.9.tgz && \ - cd Python-3.6.9 && \ - ./configure && \ - make install +wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ +tar xzvf Python-3.6.9.tgz && \ +cd Python-3.6.9 && \ +./configure && \ +make install + +RUN python3.6 -m ensurepip && \ + python3.6 -m pip install coverage RUN cd /tmp && \ echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ From 67b2eff113f5c256a50d99e17ee6a4f3bd5eda3c Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 13:17:30 -0700 Subject: [PATCH 123/176] Also fix the compilation of 3.8 --- .../dockerfile/compile_python_36.include | 16 ++++++++++------ .../dockerfile/compile_python_38.include | 19 +++++++++++++++++++ .../Dockerfile.template | 14 +------------- .../Dockerfile.template | 9 +-------- 4 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 templates/tools/dockerfile/compile_python_38.include diff --git a/templates/tools/dockerfile/compile_python_36.include b/templates/tools/dockerfile/compile_python_36.include index e8983db334f..af4d73e9f6b 100644 --- a/templates/tools/dockerfile/compile_python_36.include +++ b/templates/tools/dockerfile/compile_python_36.include @@ -5,11 +5,15 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && ${'\\'} -wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} -tar xzvf Python-3.6.9.tgz && ${'\\'} -cd Python-3.6.9 && ${'\\'} -./configure && ${'\\'} -make install + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} + tar xzvf Python-3.6.9.tgz && ${'\\'} + cd Python-3.6.9 && ${'\\'} + ./configure && ${'\\'} + make install + +RUN cd /tmp && ${'\\'} + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} + md5sum -c checksum.md5 RUN python3.6 -m ensurepip && ${'\\'} - python3.6 -m pip install coverage \ No newline at end of file + python3.6 -m pip install coverage diff --git a/templates/tools/dockerfile/compile_python_38.include b/templates/tools/dockerfile/compile_python_38.include new file mode 100644 index 00000000000..30337e0ecb7 --- /dev/null +++ b/templates/tools/dockerfile/compile_python_38.include @@ -0,0 +1,19 @@ +#================= +# Compile CPython 3.8.0b4 from source + +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && ${'\\'} + wget -q https://www.python.org/ftp/python/3.8.0/Python-3.8.0b4.tgz && ${'\\'} + tar xzvf Python-3.8.0b4.tgz && ${'\\'} + cd Python-3.8.0b4 && ${'\\'} + ./configure && ${'\\'} + make install + +RUN cd /tmp && ${'\\'} + echo "b8f4f897df967014ddb42033b90c3058 Python-3.8.0b4.tgz" > checksum.md5 && ${'\\'} + md5sum -c checksum.md5 + +RUN python3.8 -m ensurepip && ${'\\'} + python3.8 -m pip install coverage diff --git a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template index 841a7f51b51..b0098fda0cc 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template @@ -16,16 +16,4 @@ # limitations under the License. <%include file="../../python_stretch.include"/> - RUN apt-get install -y jq zlib1g-dev libssl-dev - - RUN apt-get install -y jq build-essential libffi-dev - - RUN cd /tmp && ${'\\'} - wget -q https://github.com/python/cpython/archive/v3.8.0b3.tar.gz && ${'\\'} - tar xzvf v3.8.0b3.tar.gz && ${'\\'} - cd cpython-3.8.0b3 && ${'\\'} - ./configure && ${'\\'} - make install - - RUN python3.8 -m ensurepip && ${'\\'} - python3.8 -m pip install coverage + <%include file="../../compile_python_38.include"/> diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 8f8bea1eb50..ccb88e75302 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -16,16 +16,9 @@ <%include file="../../python_stretch.include"/> <%include file="../../compile_python_36.include"/> - - RUN cd /tmp && ${'\\'} - echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} - md5sum -c checksum.md5 - + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting RUN python3.7 -m pip install coverage - - RUN python3.6 -m ensurepip && ${'\\'} - python3.6 -m pip install coverage From 7f49b9f1624ba9ea8922881691391cf3bf7e0957 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 13:20:31 -0700 Subject: [PATCH 124/176] Auto-generate the project --- .../test/python_stretch_3.6_x64/Dockerfile | 15 ++++++++----- .../test/python_stretch_3.8_x64/Dockerfile | 21 ++++++++++++------- .../python_stretch_default_x64/Dockerfile | 20 ++++++++---------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index a7a5f53e549..3d475849bb9 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -71,11 +71,16 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ -wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ -tar xzvf Python-3.6.9.tgz && \ -cd Python-3.6.9 && \ -./configure && \ -make install + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar xzvf Python-3.6.9.tgz && \ + cd Python-3.6.9 && \ + ./configure && \ + make install + +RUN cd /tmp && \ + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage + diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile index b0e386ac57f..8d780f0ad78 100644 --- a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile @@ -64,16 +64,23 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -RUN apt-get install -y jq zlib1g-dev libssl-dev +#================= +# Compile CPython 3.8.0b4 from source -RUN apt-get install -y jq build-essential libffi-dev +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://github.com/python/cpython/archive/v3.8.0b3.tar.gz && \ - tar xzvf v3.8.0b3.tar.gz && \ - cd cpython-3.8.0b3 && \ - ./configure && \ - make install + wget -q https://www.python.org/ftp/python/3.8.0/Python-3.8.0b4.tgz && \ + tar xzvf Python-3.8.0b4.tgz && \ + cd Python-3.8.0b4 && \ + ./configure && \ + make install + +RUN cd /tmp && \ + echo "b8f4f897df967014ddb42033b90c3058 Python-3.8.0b4.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN python3.8 -m ensurepip && \ python3.8 -m pip install coverage + diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 7aba6c87593..9a1d6c09deb 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -71,24 +71,22 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ -wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ -tar xzvf Python-3.6.9.tgz && \ -cd Python-3.6.9 && \ -./configure && \ -make install + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar xzvf Python-3.6.9.tgz && \ + cd Python-3.6.9 && \ + ./configure && \ + make install + +RUN cd /tmp && \ + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage -RUN cd /tmp && \ - echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ - md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting RUN python3.7 -m pip install coverage - -RUN python3.6 -m ensurepip && \ - python3.6 -m pip install coverage From 0b06676c9e9e1df592cd725a0f7ad874d1b5ce80 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 4 Sep 2019 14:50:26 -0700 Subject: [PATCH 125/176] hpack encoder optimizations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed some cycles and branches from hpack_enc for CH2. Specifically: 1. Pushed certain metadata key/value length checks to prepare_application_metadata() in src/core/lib/surface/call.cc. This means that rather than check all key/val lengths for all metadata, we only do so for custom added user metadata. Inside CH2, we change the length checks to debug checks so we can catch if core/filter metadata fails to pass the check. 2. Changed various asserts to debug asserts when able. 3. Refactored some of the header emission code to remove duplicated code. 4. Un-inlined some logging methods. This results in somewhat faster hpack_encoder performance: BM_HpackEncoderInitDestroy 222ns ± 0% 221ns ± 0% -0.29% (p=0.000 n=34+34) BM_HpackEncoderEncodeDeadline [framing_bytes/iter:9 header_bytes/iter:6 ] 135ns ± 1% 124ns ± 0% -8.05% (p=0.000 n=39+38) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:0 ] 34.2ns ± 0% 34.2ns ± 0% -0.01% (p=0.014 n=34+38) BM_HpackEncoderEncodeHeader/1/16384 [framing_bytes/iter:9 header_bytes/iter:0 ] 34.2ns ± 0% 34.2ns ± 0% -0.04% (p=0.004 n=34+37) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.5ns ± 0% 45.9ns ± 0% -3.28% (p=0.000 n=28+38) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:6 ] 77.0ns ± 1% 68.3ns ± 1% -11.33% (p=0.000 n=39+40) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 1% 45.5ns ± 0% -4.63% (p=0.000 n=39+33) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.2ns ± 0% 45.3ns ± 0% -3.96% (p=0.000 n=33+34) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.6ns ± 0% -4.54% (p=0.000 n=38+40) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.5ns ± 0% -4.63% (p=0.000 n=39+32) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 0% 45.6ns ± 1% -4.59% (p=0.000 n=38+39) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 0% 45.5ns ± 0% -4.64% (p=0.000 n=39+36) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.3ns ± 0% 45.3ns ± 0% -4.09% (p=0.000 n=38+36) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 1% 45.6ns ± 0% -4.71% (p=0.000 n=37+40) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.5ns ± 0% -4.66% (p=0.000 n=39+32) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 1% 45.6ns ± 1% -4.62% (p=0.000 n=37+39) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.5ns ± 0% -4.67% (p=0.000 n=38+32) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:9 ] 80.5ns ± 1% 74.7ns ± 0% -7.16% (p=0.000 n=38+35) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:12 ] 105ns ± 1% 99ns ± 0% -5.91% (p=0.000 n=38+34) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:14 ] 111ns ± 1% 106ns ± 1% -4.86% (p=0.020 n=39+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:23 ] 135ns ± 0% 130ns ± 0% -3.45% (p=0.020 n=35+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:46 ] 225ns ± 1% 223ns ± 0% -0.91% (p=0.003 n=37+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:120 ] 467ns ± 0% 472ns ± 0% +1.09% (p=0.003 n=38+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:12 ] 81.6ns ± 1% 74.8ns ± 0% -8.40% (p=0.000 n=37+33) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:14 ] 82.0ns ± 1% 74.8ns ± 0% -8.80% (p=0.000 n=37+32) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:21 ] 82.1ns ± 1% 74.9ns ± 0% -8.86% (p=0.000 n=35+34) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:42 ] 97.6ns ± 2% 91.8ns ± 0% -5.95% (p=0.000 n=35+27) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:111 ] 97.2ns ± 1% 91.2ns ± 2% -6.19% (p=0.000 n=37+38) BM_HpackEncoderEncodeHeader/0/1 [framing_bytes/iter:54 header_bytes/iter:9 ] 230ns ± 0% 221ns ± 0% -3.91% (p=0.000 n=38+37) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:16 ] 206ns ± 2% 170ns ± 1% -17.51% (p=0.000 n=39+39) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:3 ] 66.4ns ± 2% 62.5ns ± 1% -5.85% (p=0.000 n=34+39) BM_HpackEncoderEncodeHeader/1/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.5ns ± 0% 45.9ns ± 1% -3.29% (p=0.000 n=26+38) --- .../chttp2/transport/hpack_encoder.cc | 428 ++++++++++-------- src/core/lib/slice/slice_internal.h | 30 +- src/core/lib/surface/call.cc | 3 + src/core/lib/surface/validate_metadata.cc | 4 + test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 3 +- 5 files changed, 269 insertions(+), 199 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index e46504d9b30..f1291a10cc6 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -88,7 +88,19 @@ typedef struct { * with a data frame header */ static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len, uint8_t flags) { - GPR_ASSERT(len < 16777316); + /* len is the current frame size (i.e. for the frame we're finishing). + We finish a frame if: + 1) We called ensure_space(), (i.e. add_tiny_header_data()) and adding + 'need_bytes' to the frame would cause us to exceed st->max_frame_size. + 2) We called add_header_data, and adding the slice would cause us to exceed + st->max_frame_size. + 3) We're done encoding the header. + + Thus, len is always <= st->max_frame_size. + st->max_frame_size is derived from GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE, + which has a max allowable value of 16777215 (see chttp_transport.cc). + Thus, the following assert can be a debug assert. */ + GPR_DEBUG_ASSERT(len < 16777316); *p++ = static_cast(len >> 16); *p++ = static_cast(len >> 8); *p++ = static_cast(len); @@ -100,6 +112,13 @@ static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len, *p++ = static_cast(id); } +static size_t current_frame_size(framer_state* st) { + const size_t frame_size = + st->output->length - st->output_length_at_start_of_frame; + GPR_DEBUG_ASSERT(frame_size <= st->max_frame_size); + return frame_size; +} + /* finish a frame - fill in the previously reserved header */ static void finish_frame(framer_state* st, int is_header_boundary, int is_last_in_stream) { @@ -108,7 +127,7 @@ static void finish_frame(framer_state* st, int is_header_boundary, : GRPC_CHTTP2_FRAME_CONTINUATION; fill_header( GRPC_SLICE_START_PTR(st->output->slices[st->header_idx]), type, - st->stream_id, st->output->length - st->output_length_at_start_of_frame, + st->stream_id, current_frame_size(st), static_cast( (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) | (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0))); @@ -130,9 +149,7 @@ static void begin_frame(framer_state* st) { space to add at least about_to_add bytes -- finishes the current frame if needed */ static void ensure_space(framer_state* st, size_t need_bytes) { - if (GPR_LIKELY(st->output->length - st->output_length_at_start_of_frame + - need_bytes <= - st->max_frame_size)) { + if (GPR_LIKELY(current_frame_size(st) + need_bytes <= st->max_frame_size)) { return; } finish_frame(st, 0, 0); @@ -158,8 +175,7 @@ static void add_header_data(framer_state* st, grpc_slice slice) { size_t len = GRPC_SLICE_LENGTH(slice); size_t remaining; if (len == 0) return; - remaining = st->max_frame_size + st->output_length_at_start_of_frame - - st->output->length; + remaining = st->max_frame_size - current_frame_size(st); if (len <= remaining) { st->stats->header_bytes += len; grpc_slice_buffer_add(st->output, slice); @@ -325,132 +341,129 @@ static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index, len); } -typedef struct { - grpc_slice data; - uint8_t huffman_prefix; - bool insert_null_before_wire_value; -} wire_value; +struct wire_value { + wire_value(uint8_t huffman_prefix, bool insert_null_before_wire_value, + const grpc_slice& slice) + : data(slice), + huffman_prefix(huffman_prefix), + insert_null_before_wire_value(insert_null_before_wire_value), + length(GRPC_SLICE_LENGTH(slice) + + (insert_null_before_wire_value ? 1 : 0)) {} + // While wire_value is const from the POV of hpack encoder code, actually + // adding it to a slice buffer will possibly split the slice. + const grpc_slice data; + const uint8_t huffman_prefix; + const bool insert_null_before_wire_value; + const size_t length; +}; template static wire_value get_wire_value(grpc_mdelem elem, bool true_binary_enabled) { - wire_value wire_val; - bool is_bin_hdr = + const bool is_bin_hdr = mdkey_definitely_interned ? grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem)) : grpc_is_binary_header_internal(GRPC_MDKEY(elem)); + const grpc_slice& value = GRPC_MDVALUE(elem); if (is_bin_hdr) { if (true_binary_enabled) { GRPC_STATS_INC_HPACK_SEND_BINARY(); - wire_val.huffman_prefix = 0x00; - wire_val.insert_null_before_wire_value = true; - wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem)); - + return wire_value(0x00, true, grpc_slice_ref_internal(value)); } else { GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(); - wire_val.huffman_prefix = 0x80; - wire_val.insert_null_before_wire_value = false; - wire_val.data = - grpc_chttp2_base64_encode_and_huffman_compress(GRPC_MDVALUE(elem)); + return wire_value(0x80, false, + grpc_chttp2_base64_encode_and_huffman_compress(value)); } } else { /* TODO(ctiller): opportunistically compress non-binary headers */ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); - wire_val.huffman_prefix = 0x00; - wire_val.insert_null_before_wire_value = false; - wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem)); + return wire_value(0x00, false, grpc_slice_ref_internal(value)); } - return wire_val; -} - -static size_t wire_value_length(wire_value v) { - return GPR_SLICE_LENGTH(v.data) + v.insert_null_before_wire_value; } -static void add_wire_value(framer_state* st, wire_value v) { - if (v.insert_null_before_wire_value) *add_tiny_header_data(st, 1) = 0; - add_header_data(st, v.data); +static uint32_t wire_value_length(const wire_value& v) { + GPR_DEBUG_ASSERT(v.length <= UINT32_MAX); + return static_cast(v.length); } -static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor* c, - uint32_t key_index, grpc_mdelem elem, - framer_state* st) { - GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(); - uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - size_t len_val = wire_value_length(value); - uint32_t len_val_len; - GPR_ASSERT(len_val <= UINT32_MAX); - len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); - GPR_DEBUG_ASSERT(len_pfx + len_val_len < GRPC_SLICE_INLINED_SIZE); - uint8_t* data = add_tiny_header_data(st, len_pfx + len_val_len); - GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, data, len_pfx); - GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, value.huffman_prefix, - &data[len_pfx], len_val_len); - add_wire_value(st, value); -} - -static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor* c, - uint32_t key_index, grpc_mdelem elem, - framer_state* st) { - GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(); - uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - size_t len_val = wire_value_length(value); - uint32_t len_val_len; - GPR_ASSERT(len_val <= UINT32_MAX); - len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); +namespace { +enum class EmitLitHdrType { INC_IDX, NO_IDX }; + +enum class EmitLitHdrVType { INC_IDX_V, NO_IDX_V }; +} // namespace + +template +static void emit_lithdr(grpc_chttp2_hpack_compressor* c, uint32_t key_index, + grpc_mdelem elem, framer_state* st) { + switch (type) { + case EmitLitHdrType::INC_IDX: + GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(); + break; + case EmitLitHdrType::NO_IDX: + GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(); + break; + } + const uint32_t len_pfx = type == EmitLitHdrType::INC_IDX + ? GRPC_CHTTP2_VARINT_LENGTH(key_index, 2) + : GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); + const wire_value value = + get_wire_value(elem, st->use_true_binary_metadata); + const uint32_t len_val = wire_value_length(value); + const uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); GPR_DEBUG_ASSERT(len_pfx + len_val_len < GRPC_SLICE_INLINED_SIZE); - uint8_t* data = add_tiny_header_data(st, len_pfx + len_val_len); - GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, data, len_pfx); - GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, value.huffman_prefix, - &data[len_pfx], len_val_len); - add_wire_value(st, value); -} - -static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c, - uint32_t unused_index, grpc_mdelem elem, - framer_state* st) { - GPR_ASSERT(unused_index == 0); - GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(); - GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); - uint32_t len_key = static_cast GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - uint32_t len_val = static_cast(wire_value_length(value)); - uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); - uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); - GPR_ASSERT(len_key <= UINT32_MAX); - GPR_ASSERT(wire_value_length(value) <= UINT32_MAX); - GPR_DEBUG_ASSERT(1 + len_key_len < GRPC_SLICE_INLINED_SIZE); - uint8_t* data = add_tiny_header_data(st, 1 + len_key_len); - data[0] = 0x40; - GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &data[1], len_key_len); - add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem))); - GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, - add_tiny_header_data(st, len_val_len), len_val_len); - add_wire_value(st, value); + uint8_t* data = add_tiny_header_data( + st, + len_pfx + len_val_len + (value.insert_null_before_wire_value ? 1 : 0)); + switch (type) { + case EmitLitHdrType::INC_IDX: + GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, data, len_pfx); + break; + case EmitLitHdrType::NO_IDX: + GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, data, len_pfx); + break; + } + GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, &data[len_pfx], + len_val_len); + if (value.insert_null_before_wire_value) { + data[len_pfx + len_val_len] = 0; + } + add_header_data(st, value.data); } -static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c, - uint32_t unused_index, grpc_mdelem elem, - framer_state* st) { - GPR_ASSERT(unused_index == 0); - GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(); +template +static void emit_lithdr_v(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, + framer_state* st) { + switch (type) { + case EmitLitHdrVType::INC_IDX_V: + GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(); + break; + case EmitLitHdrVType::NO_IDX_V: + GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(); + break; + } GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); - uint32_t len_key = static_cast GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - uint32_t len_val = static_cast(wire_value_length(value)); - uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); - uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); - GPR_ASSERT(len_key <= UINT32_MAX); - GPR_ASSERT(wire_value_length(value) <= UINT32_MAX); - /* Preconditions passed; emit header. */ - uint8_t* data = add_tiny_header_data(st, 1 + len_key_len); - data[0] = 0x00; - GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &data[1], len_key_len); + const uint32_t len_key = + static_cast(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem))); + const wire_value value = + type == EmitLitHdrVType::INC_IDX_V + ? get_wire_value(elem, st->use_true_binary_metadata) + : get_wire_value(elem, st->use_true_binary_metadata); + const uint32_t len_val = wire_value_length(value); + const uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); + const uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); + GPR_DEBUG_ASSERT(len_key <= UINT32_MAX); + GPR_DEBUG_ASSERT(1 + len_key_len < GRPC_SLICE_INLINED_SIZE); + uint8_t* key_buf = add_tiny_header_data(st, 1 + len_key_len); + key_buf[0] = type == EmitLitHdrVType::INC_IDX_V ? 0x40 : 0x00; + GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &key_buf[1], len_key_len); add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem))); - GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, - add_tiny_header_data(st, len_val_len), len_val_len); - add_wire_value(st, value); + uint8_t* value_buf = add_tiny_header_data( + st, len_val_len + (value.insert_null_before_wire_value ? 1 : 0)); + GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, value_buf, + len_val_len); + if (value.insert_null_before_wire_value) { + value_buf[len_val_len] = 0; + } + add_header_data(st, value.data); } static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor* c, @@ -461,113 +474,142 @@ static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor* c, c->advertise_table_size_change = 0; } +static void GPR_ATTRIBUTE_NOINLINE hpack_enc_log(grpc_mdelem elem) { + char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem)); + char* v = nullptr; + if (grpc_is_binary_header_internal(GRPC_MDKEY(elem))) { + v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX); + } else { + v = grpc_slice_to_c_string(GRPC_MDVALUE(elem)); + } + gpr_log( + GPR_INFO, + "Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", + k, v, GRPC_MDELEM_IS_INTERNED(elem), GRPC_MDELEM_STORAGE(elem), + grpc_slice_is_interned(GRPC_MDKEY(elem)), + grpc_slice_is_interned(GRPC_MDVALUE(elem))); + gpr_free(k); + gpr_free(v); +} + static uint32_t dynidx(grpc_chttp2_hpack_compressor* c, uint32_t elem_index) { return 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY + c->tail_remote_index + c->table_elems - elem_index; } +struct EmitIndexedStatus { + EmitIndexedStatus() = default; + EmitIndexedStatus(uint32_t elem_hash, bool emitted, bool can_add) + : elem_hash(elem_hash), emitted(emitted), can_add(can_add) {} + const uint32_t elem_hash = 0; + const bool emitted = false; + const bool can_add = false; +}; + +static EmitIndexedStatus maybe_emit_indexed(grpc_chttp2_hpack_compressor* c, + grpc_mdelem elem, + framer_state* st) { + const uint32_t elem_hash = + GRPC_MDELEM_STORAGE(elem) == GRPC_MDELEM_STORAGE_INTERNED + ? reinterpret_cast( + GRPC_MDELEM_DATA(elem)) + ->hash() + : reinterpret_cast(GRPC_MDELEM_DATA(elem)) + ->hash(); + + inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems); + + /* is this elem currently in the decoders table? */ + if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], + elem) && + c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) { + /* HIT: complete element (first cuckoo hash) */ + emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), + st); + return EmitIndexedStatus(elem_hash, true, false); + } + if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], + elem) && + c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) { + /* HIT: complete element (second cuckoo hash) */ + emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), + st); + return EmitIndexedStatus(elem_hash, true, false); + } + + const bool can_add = c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >= + c->filter_elems_sum / ONE_ON_ADD_PROBABILITY; + return EmitIndexedStatus(elem_hash, false, can_add); +} + +static void emit_maybe_add(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, + framer_state* st, uint32_t indices_key, + bool should_add_elem, size_t decoder_space_usage, + uint32_t elem_hash, uint32_t key_hash) { + if (should_add_elem) { + emit_lithdr(c, dynidx(c, indices_key), elem, st); + add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); + } else { + emit_lithdr(c, dynidx(c, indices_key), elem, st); + } +} + /* encode an mdelem */ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, framer_state* st) { - GPR_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0); + /* User-provided key len validated in grpc_validate_header_key_is_legal(). */ + GPR_DEBUG_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0); + /* Header ordering: all reserved headers (prefixed with ':') must precede + * regular headers. This can be a debug assert, since: + * 1) User cannot give us ':' headers (grpc_validate_header_key_is_legal()). + * 2) grpc filters/core should be checked during debug builds. */ +#ifndef NDEBUG if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */ st->seen_regular_header = 1; } else { - GPR_ASSERT( + GPR_DEBUG_ASSERT( st->seen_regular_header == 0 && "Reserved header (colon-prefixed) happening after regular ones."); } - +#endif if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem)); - char* v = nullptr; - if (grpc_is_binary_header_internal(GRPC_MDKEY(elem))) { - v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX); - } else { - v = grpc_slice_to_c_string(GRPC_MDVALUE(elem)); - } - gpr_log( - GPR_INFO, - "Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", - k, v, GRPC_MDELEM_IS_INTERNED(elem), GRPC_MDELEM_STORAGE(elem), - grpc_slice_is_interned(GRPC_MDKEY(elem)), - grpc_slice_is_interned(GRPC_MDVALUE(elem))); - gpr_free(k); - gpr_free(v); + hpack_enc_log(elem); } - bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem); - bool key_interned = elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem)); + const bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem); + const bool key_interned = + elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem)); - // Key is not interned, emit literals. + /* Key is not interned, emit literals. */ if (!key_interned) { - emit_lithdr_noidx_v(c, 0, elem, st); + emit_lithdr_v(c, elem, st); return; } - - uint32_t elem_hash = 0; - - if (elem_interned) { - if (GRPC_MDELEM_STORAGE(elem) == GRPC_MDELEM_STORAGE_INTERNED) { - elem_hash = - reinterpret_cast(GRPC_MDELEM_DATA(elem)) - ->hash(); - } else { - elem_hash = - reinterpret_cast(GRPC_MDELEM_DATA(elem)) - ->hash(); - } - - inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, - c->filter_elems); - - /* is this elem currently in the decoders table? */ - if (grpc_mdelem_both_interned_eq( - c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) && - c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) { - /* HIT: complete element (first cuckoo hash) */ - emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), - st); - return; - } - if (grpc_mdelem_both_interned_eq( - c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) && - c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) { - /* HIT: complete element (second cuckoo hash) */ - emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), - st); - return; - } + /* Interned metadata => maybe already indexed. */ + const EmitIndexedStatus ret = + elem_interned ? maybe_emit_indexed(c, elem, st) : EmitIndexedStatus(); + if (ret.emitted) { + return; } - uint32_t indices_key; - /* should this elem be in the table? */ const size_t decoder_space_usage = grpc_chttp2_get_size_in_hpack_table(elem, st->use_true_binary_metadata); - const bool should_add_elem = elem_interned && - decoder_space_usage < MAX_DECODER_SPACE_USAGE && - c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >= - c->filter_elems_sum / ONE_ON_ADD_PROBABILITY; - - uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem)); - auto emit_maybe_add = [&should_add_elem, &elem, &st, &c, &indices_key, - &decoder_space_usage, &elem_hash, &key_hash] { - if (should_add_elem) { - emit_lithdr_incidx(c, dynidx(c, indices_key), elem, st); - add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); - } else { - emit_lithdr_noidx(c, dynidx(c, indices_key), elem, st); - } - }; + const bool decoder_space_available = + decoder_space_usage < MAX_DECODER_SPACE_USAGE; + const bool should_add_elem = + elem_interned && decoder_space_available && ret.can_add; + const uint32_t elem_hash = ret.elem_hash; /* no hits for the elem... maybe there's a key? */ - indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)]; + const uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem)); + uint32_t indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)]; if (grpc_slice_static_interned_equal( c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { /* HIT: key (first cuckoo hash) */ - emit_maybe_add(); + emit_maybe_add(c, elem, st, indices_key, should_add_elem, + decoder_space_usage, elem_hash, key_hash); return; } @@ -575,18 +617,18 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, if (grpc_slice_static_interned_equal( c->entries_keys[HASH_FRAGMENT_3(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { - /* HIT: key (first cuckoo hash) */ - emit_maybe_add(); + /* HIT: key (second cuckoo hash) */ + emit_maybe_add(c, elem, st, indices_key, should_add_elem, + decoder_space_usage, elem_hash, key_hash); return; } /* no elem, key in the table... fall back to literal emission */ - const bool should_add_key = - !elem_interned && decoder_space_usage < MAX_DECODER_SPACE_USAGE; + const bool should_add_key = !elem_interned && decoder_space_available; if (should_add_elem || should_add_key) { - emit_lithdr_incidx_v(c, 0, elem, st); + emit_lithdr_v(c, elem, st); } else { - emit_lithdr_noidx_v(c, 0, elem, st); + emit_lithdr_v(c, elem, st); } if (should_add_elem) { add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); @@ -695,8 +737,12 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, grpc_metadata_batch* metadata, const grpc_encode_header_options* options, grpc_slice_buffer* outbuf) { - GPR_ASSERT(options->stream_id != 0); - + /* grpc_chttp2_encode_header is called by FlushInitial/TrailingMetadata in + writing.cc. Specifically, on streams returned by NextStream(), which + returns streams from the list GRPC_CHTTP2_LIST_WRITABLE. The only way to be + added to the list is via grpc_chttp2_list_add_writable_stream(), which + validates that stream_id is not 0. So, this can be a debug assert. */ + GPR_DEBUG_ASSERT(options->stream_id != 0); framer_state st; st.seen_regular_header = 0; st.stream_id = options->stream_id; diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 49ad15d5a56..f1939b5ba7c 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -214,23 +214,39 @@ struct InternedSliceRefcount { } // namespace grpc_core +inline size_t grpc_refcounted_slice_length(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + return slice.data.refcounted.length; +} + +inline const uint8_t* grpc_refcounted_slice_data(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + return slice.data.refcounted.bytes; +} + inline int grpc_slice_refcount::Eq(const grpc_slice& a, const grpc_slice& b) { + GPR_DEBUG_ASSERT(a.refcount != nullptr); + GPR_DEBUG_ASSERT(a.refcount == this); switch (ref_type_) { case Type::STATIC: - return GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b); + GPR_DEBUG_ASSERT( + (GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b)) == + (a.refcount == b.refcount)); case Type::INTERNED: return a.refcount == b.refcount; case Type::NOP: case Type::REGULAR: break; } - if (GRPC_SLICE_LENGTH(a) != GRPC_SLICE_LENGTH(b)) return false; - if (GRPC_SLICE_LENGTH(a) == 0) return true; - return 0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b), - GRPC_SLICE_LENGTH(a)); + if (grpc_refcounted_slice_length(a) != GRPC_SLICE_LENGTH(b)) return false; + if (grpc_refcounted_slice_length(a) == 0) return true; + return 0 == memcmp(grpc_refcounted_slice_data(a), GRPC_SLICE_START_PTR(b), + grpc_refcounted_slice_length(a)); } inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + GPR_DEBUG_ASSERT(slice.refcount == this); switch (ref_type_) { case Type::STATIC: return ::grpc_static_metadata_hash_values[GRPC_STATIC_METADATA_INDEX( @@ -242,8 +258,8 @@ inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { case Type::REGULAR: break; } - return gpr_murmur_hash3(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice), - g_hash_seed); + return gpr_murmur_hash3(grpc_refcounted_slice_data(slice), + grpc_refcounted_slice_length(slice), g_hash_seed); } inline const grpc_slice& grpc_slice_ref_internal(const grpc_slice& slice) { diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1331e57ab0c..5388cbd75a9 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -910,6 +910,9 @@ static int prepare_application_metadata(grpc_call* call, int count, "validate_metadata", grpc_validate_header_nonbin_value_is_legal(md->value))) { break; + } else if (GRPC_SLICE_LENGTH(md->value) >= UINT32_MAX) { + // HTTP2 hpack encoding has a maximum limit. + break; } l->md = grpc_mdelem_from_grpc_metadata(const_cast(md)); } diff --git a/src/core/lib/surface/validate_metadata.cc b/src/core/lib/surface/validate_metadata.cc index 0f65091333d..138f5745e51 100644 --- a/src/core/lib/surface/validate_metadata.cc +++ b/src/core/lib/surface/validate_metadata.cc @@ -67,6 +67,10 @@ grpc_error* grpc_validate_header_key_is_legal(const grpc_slice& slice) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Metadata keys cannot be zero length"); } + if (GRPC_SLICE_LENGTH(slice) > UINT32_MAX) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Metadata keys cannot be larger than UINT32_MAX"); + } if (GRPC_SLICE_START_PTR(slice)[0] == ':') { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Metadata keys cannot start with :"); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 0c3c35edc56..18928531c83 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -131,11 +131,12 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { grpc_slice_buffer outbuf; grpc_slice_buffer_init(&outbuf); while (state.KeepRunning()) { + static constexpr int kEnsureMaxFrameAtLeast = 2; grpc_encode_header_options hopt = { static_cast(state.iterations()), state.range(0) != 0, Fixture::kEnableTrueBinary, - static_cast(state.range(1)), + static_cast(state.range(1) + kEnsureMaxFrameAtLeast), &stats, }; grpc_chttp2_encode_header(c.get(), nullptr, 0, &b, &hopt, &outbuf); From c63f419c4900399a45f5de0f45aedc95fa331f80 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 5 Sep 2019 12:52:44 -0700 Subject: [PATCH 126/176] Mark CH2 on_initial_header error path unlikely. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Yields slightly better unary and streaming performance for TCP: BM_UnaryPingPong/4096/4096 [polls/iter:3.00006 ] 27.1µs ± 2% 26.3µs ± 1% -2.77% (p=0.036 n=5+3) BM_UnaryPingPong/1/0 [polls/iter:3.00009 ] 21.7µs ± 2% 21.1µs ± 1% -2.88% (p=0.029 n=4+4) BM_UnaryPingPong/0/1 [polls/iter:3.00009 ] 21.8µs ± 2% 20.9µs ± 1% -4.32% (p=0.003 n=7+5) BM_UnaryPingPong/1/1 [polls/iter:3.00008 ] 22.0µs ± 1% 21.3µs ± 1% -3.15% (p=0.036 n=3+5) BM_UnaryPingPong/64/0 [polls/iter:3.00006 ] 22.0µs ± 1% 21.5µs ± 1% -2.19% (p=0.032 n=4+5) BM_UnaryPingPong/32768/0 [polls/iter:3.00007 ] 34.7µs ± 1% 34.1µs ± 0% -1.72% (p=0.017 n=7+3) BM_UnaryPingPong/0/262144 [polls/iter:3.00023 ] 160µs ± 1% 158µs ± 1% -1.29% (p=0.016 n=8+4) BM_UnaryPingPong/0/0 [polls/iter:3.00012 ] 20.8µs ± 1% 20.4µs ± 0% -1.89% (p=0.029 n=4+4) BM_UnaryPingPong/0/0 [polls/iter:3.00008 ] 22.1µs ± 4% 21.3µs ± 0% -3.88% (p=0.004 n=6+5) BM_UnaryPingPong/64/0 [polls/iter:3.00008 ] 23.2µs ± 2% 22.5µs ± 3% -3.07% (p=0.014 n=7+6) BM_UnaryPingPong/512/512 [polls/iter:3.0001 ] 23.5µs ± 2% 22.9µs ± 0% -2.85% (p=0.010 n=6+4) BM_UnaryPingPong/1/0 [polls/iter:3.00008 ] 22.5µs ± 1% 21.7µs ± 1% -3.35% (p=0.036 n=3+5) BM_UnaryPingPong/32768/32768 [polls/iter:3.0001 ] 48.6µs ± 1% 48.3µs ± 1% -0.58% (p=0.045 n=5+8) BM_UnaryPingPong/8/8 [polls/iter:3.00008 ] 22.0µs ± 1% 21.5µs ± 1% -2.35% (p=0.016 n=4+5) BM_UnaryPingPong/8/8 [polls/iter:3.00006 ] 22.4µs ± 3% 21.4µs ± 1% -4.05% (p=0.017 n=7+3) BM_UnaryPingPong/4096/0 [polls/iter:3.00007 ] 24.5µs ± 1% 23.9µs ± 1% -2.30% BM_UnaryPingPong/1/1 [polls/iter:3.0001 ] 22.9µs ± 2% 22.4µs ± 3% -2.04% (p=0.048 n=7+5) BM_UnaryPingPong/8/8 [polls/iter:3.0001 ] 23.0µs ± 2% 22.4µs ± 1% -2.75% (p=0.012 n=7+4) BM_UnaryPingPong/64/64 [polls/iter:3.00008 ] 23.5µs ± 2% 23.1µs ± 0% -2.10% (p=0.002 n=8+5) BM_UnaryPingPong/64/0 [polls/iter:3.00008 ] 22.1µs ± 2% 21.5µs ± 1% -2.93% (p=0.009 n=9+3) BM_UnaryPingPong/0/64 [polls/iter:3.00008 ] 22.2µs ± 1% 21.4µs ± 1% -3.51% (p=0.003 n=4+9) BM_UnaryPingPong/512/0 [polls/iter:3.00008 ] 22.4µs ± 2% 21.8µs ± 1% -2.75% (p=0.009 n=5+6) BM_UnaryPingPong/32768/0 [polls/iter:3.0001 ] 34.5µs ± 1% 34.0µs ± 1% -1.58% But, slightly worse performance for in-proc (about 2-3%). --- .../ext/transport/chttp2/transport/parsing.cc | 129 +++++++++++------- 1 file changed, 77 insertions(+), 52 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index a39f6e83db7..e789006ed31 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -422,6 +422,76 @@ static bool is_nonzero_status(grpc_mdelem md) { !md_cmp(md, GRPC_MDELEM_GRPC_STATUS_0, GRPC_MDSTR_GRPC_STATUS); } +static void GPR_ATTRIBUTE_NOINLINE on_initial_header_log( + grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_mdelem md) { + char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); + char* value = + grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_INFO, "HTTP:%d:HDR:%s: %s: %s", s->id, + t->is_client ? "CLI" : "SVR", key, value); + gpr_free(key); + gpr_free(value); +} + +static grpc_error* GPR_ATTRIBUTE_NOINLINE handle_timeout(grpc_chttp2_stream* s, + grpc_mdelem md) { + grpc_millis* cached_timeout = + static_cast(grpc_mdelem_get_user_data(md, free_timeout)); + grpc_millis timeout; + if (cached_timeout != nullptr) { + timeout = *cached_timeout; + } else { + if (GPR_UNLIKELY(!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) { + char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); + gpr_free(val); + timeout = GRPC_MILLIS_INF_FUTURE; + } + if (GRPC_MDELEM_IS_INTERNED(md)) { + /* store the result */ + cached_timeout = + static_cast(gpr_malloc(sizeof(grpc_millis))); + *cached_timeout = timeout; + grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); + } + } + if (timeout != GRPC_MILLIS_INF_FUTURE) { + grpc_chttp2_incoming_metadata_buffer_set_deadline( + &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); + } + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} + +static grpc_error* GPR_ATTRIBUTE_NOINLINE handle_metadata_size_limit_exceeded( + grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_mdelem md, + size_t new_size, size_t metadata_size_limit) { + gpr_log(GPR_DEBUG, + "received initial metadata size exceeds limit (%" PRIuPTR + " vs. %" PRIuPTR ")", + new_size, metadata_size_limit); + grpc_chttp2_cancel_stream( + t, s, + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "received initial metadata size exceeds limit"), + GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_RESOURCE_EXHAUSTED)); + grpc_chttp2_parsing_become_skip_parser(t); + s->seen_error = true; + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} + +static grpc_error* GPR_ATTRIBUTE_NOINLINE +handle_metadata_add_failure(grpc_chttp2_transport* t, grpc_chttp2_stream* s, + grpc_mdelem md, grpc_error* error) { + grpc_chttp2_cancel_stream(t, s, error); + grpc_chttp2_parsing_become_skip_parser(t); + s->seen_error = true; + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} + static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_initial_header", 0); @@ -430,45 +500,13 @@ static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { GPR_DEBUG_ASSERT(s != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); - char* value = - grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_INFO, "HTTP:%d:HDR:%s: %s: %s", s->id, - t->is_client ? "CLI" : "SVR", key, value); - gpr_free(key); - gpr_free(value); + on_initial_header_log(t, s, md); } if (is_nonzero_status(md)) { // not GRPC_MDELEM_GRPC_STATUS_0? s->seen_error = true; } else if (md_key_cmp(md, GRPC_MDSTR_GRPC_TIMEOUT)) { - grpc_millis* cached_timeout = - static_cast(grpc_mdelem_get_user_data(md, free_timeout)); - grpc_millis timeout; - if (cached_timeout != nullptr) { - timeout = *cached_timeout; - } else { - if (GPR_UNLIKELY( - !grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) { - char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); - gpr_free(val); - timeout = GRPC_MILLIS_INF_FUTURE; - } - if (GRPC_MDELEM_IS_INTERNED(md)) { - /* store the result */ - cached_timeout = - static_cast(gpr_malloc(sizeof(grpc_millis))); - *cached_timeout = timeout; - grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); - } - } - if (timeout != GRPC_MILLIS_INF_FUTURE) { - grpc_chttp2_incoming_metadata_buffer_set_deadline( - &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); - } - GRPC_MDELEM_UNREF(md); - return GRPC_ERROR_NONE; + return handle_timeout(s, md); } const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); @@ -476,29 +514,16 @@ static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { t->settings[GRPC_ACKED_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE]; if (GPR_UNLIKELY(new_size > metadata_size_limit)) { - gpr_log(GPR_DEBUG, - "received initial metadata size exceeds limit (%" PRIuPTR - " vs. %" PRIuPTR ")", - new_size, metadata_size_limit); - grpc_chttp2_cancel_stream( - t, s, - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "received initial metadata size exceeds limit"), - GRPC_ERROR_INT_GRPC_STATUS, - GRPC_STATUS_RESOURCE_EXHAUSTED)); - grpc_chttp2_parsing_become_skip_parser(t); - s->seen_error = true; - GRPC_MDELEM_UNREF(md); + return handle_metadata_size_limit_exceeded(t, s, md, new_size, + metadata_size_limit); } else { grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(&s->metadata_buffer[0], md); - if (error != GRPC_ERROR_NONE) { - grpc_chttp2_cancel_stream(t, s, error); - grpc_chttp2_parsing_become_skip_parser(t); - s->seen_error = true; - GRPC_MDELEM_UNREF(md); + if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { + return handle_metadata_add_failure(t, s, md, error); } } + // Not timeout-related metadata, and no error occurred. return GRPC_ERROR_NONE; } From f89e11d03735a3a0df4de96bc6c156904caff2ae Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Sep 2019 13:53:31 -0700 Subject: [PATCH 127/176] More Id -> ID --- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 4 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 2 +- src/objective-c/GRPCClient/GRPCCall.m | 4 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 4 +- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 10 ++-- src/objective-c/GRPCClient/GRPCTransport.h | 8 ++-- src/objective-c/GRPCClient/GRPCTransport.m | 46 +++++++++---------- .../GRPCClient/private/GRPCCore/GRPCChannel.m | 4 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 2 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 2 +- .../private/GRPCCore/GRPCCoreFactory.m | 4 +- .../GRPCClient/private/GRPCCore/GRPCHost.m | 2 +- .../private/GRPCTransport+Private.h | 4 +- .../private/GRPCTransport+Private.m | 14 +++--- .../InteropTestsRemoteWithCronet.m | 2 +- .../CronetTests/TransportRegistryTests.m | 4 +- .../tests/InteropTests/InteropTests.m | 2 +- .../tests/UnitTests/TransportRegistryTests.m | 8 ++-- 19 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index 10cea963631..f89b108c1bd 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -22,9 +22,9 @@ typedef struct stream_engine stream_engine; // Transport id for Cronet transport -extern const GRPCTransportID gGRPCCoreCronetId; +extern const GRPCTransportID gGRPCCoreCronetID; -// Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. +// Deprecated class. Please use the gGRPCCoreCronetID with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index 33b09136b33..15e79717bea 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,7 @@ #import "GRPCCall+Cronet.h" -const GRPCTransportID gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; +const GRPCTransportID gGRPCCoreCronetID = "io.grpc.transport.core.cronet"; static BOOL useCronet = NO; static stream_engine *globalCronetEngine; diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 73ee530ef2c..87c2768187e 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -186,14 +186,14 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { - _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport + _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportID:_callOptions.transport previousInterceptor:dispatcher]; break; } else { _firstInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories previousInterceptor:dispatcher - transportId:_callOptions.transport]; + transportID:_callOptions.transport]; if (_firstInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index f9044ddcd34..d147b2305a2 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -289,7 +289,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO; if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO; if (!(callOptions.transportType == _transportType)) return NO; - if (!(TransportIdIsEqual(callOptions.transport, _transport))) return NO; + if (!(TransportIDIsEqual(callOptions.transport, _transport))) return NO; if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO; if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO; if (!(callOptions.channelID == _channelID)) return NO; @@ -314,7 +314,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { result ^= _PEMCertificateChain.hash; result ^= _hostNameOverride.hash; result ^= _transportType; - result ^= TransportIdHash(_transport); + result ^= TransportIDHash(_transport); result ^= _logContext.hash; result ^= _channelPoolDomain.hash; result ^= _channelID; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index ed907a33054..5c203445fba 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithFactories:(nullable NSArray> *)factories previousInterceptor:(nullable id)previousInterceptor - transportId:(GRPCTransportID)transportId; + transportID:(GRPCTransportID)transportID; /** * Notify the manager that the interceptor has shut down and the manager should release references diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index 1a64bccb89b..ea723369737 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -31,13 +31,13 @@ GRPCInterceptor *_thisInterceptor; dispatch_queue_t _dispatchQueue; NSArray> *_factories; - GRPCTransportID _transportId; + GRPCTransportID _transportID; BOOL _shutDown; } - (instancetype)initWithFactories:(NSArray> *)factories previousInterceptor:(id)previousInterceptor - transportId:(nonnull GRPCTransportID)transportId { + transportID:(nonnull GRPCTransportID)transportID { if ((self = [super init])) { if (factories.count == 0) { [NSException raise:NSInternalInconsistencyException @@ -62,7 +62,7 @@ _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); } dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); - _transportId = transportId; + _transportID = transportID; } return self; } @@ -87,12 +87,12 @@ while (_nextInterceptor == nil) { if (interceptorFactories.count == 0) { _nextInterceptor = - [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; + [[GRPCTransportManager alloc] initWithTransportID:_transportID previousInterceptor:self]; break; } else { _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories previousInterceptor:self - transportId:_transportId]; + transportID:_transportID]; if (_nextInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index d9f341d08a3..a29dbd20e4d 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -34,10 +34,10 @@ extern const struct GRPCDefaultTransportImplList { } GRPCDefaultTransportImplList; /** Returns whether two transport id's are identical. */ -BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs); +BOOL TransportIDIsEqual(GRPCTransportID lhs, GRPCTransportID rhs); /** Returns the hash value of a transport id. */ -NSUInteger TransportIdHash(GRPCTransportID); +NSUInteger TransportIDHash(GRPCTransportID); #pragma mark Transport and factory @@ -63,10 +63,10 @@ NSUInteger TransportIdHash(GRPCTransportID); /** * Register a transport implementation with the registry. All transport implementations to be used * in a process must register with the registry on process start-up in its +load: class method. - * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory + * Parameter \a transportID is the identifier of the implementation, and \a factory is the factory * object to create the corresponding transport instance. */ -- (void)registerTransportWithId:(GRPCTransportID)transportId +- (void)registerTransportWithID:(GRPCTransportID)transportID factory:(id)factory; @end diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 353300c3bc4..c55beca0c4a 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -18,28 +18,28 @@ #import "GRPCTransport.h" -static const GRPCTransportID gGRPCCoreSecureId = "io.grpc.transport.core.secure"; -static const GRPCTransportID gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; +static const GRPCTransportID gGRPCCoreSecureID = "io.grpc.transport.core.secure"; +static const GRPCTransportID gGRPCCoreInsecureID = "io.grpc.transport.core.insecure"; const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { - .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; + .core_secure = gGRPCCoreSecureID, .core_insecure = gGRPCCoreInsecureID}; -static const GRPCTransportID gDefaultTransportId = gGRPCCoreSecureId; +static const GRPCTransportID gDefaultTransportID = gGRPCCoreSecureID; static GRPCTransportRegistry *gTransportRegistry = nil; static dispatch_once_t initTransportRegistry; -BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs) { +BOOL TransportIDIsEqual(GRPCTransportID lhs, GRPCTransportID rhs) { // Directly comparing pointers works because we require users to use the id provided by each // implementation, not coming up with their own string. return lhs == rhs; } -NSUInteger TransportIdHash(GRPCTransportID transportId) { - if (transportId == NULL) { - transportId = gDefaultTransportId; +NSUInteger TransportIDHash(GRPCTransportID transportID) { + if (transportID == NULL) { + transportID = gDefaultTransportID; } - return [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding].hash; + return [NSString stringWithCString:transportID encoding:NSUTF8StringEncoding].hash; } @implementation GRPCTransportRegistry { @@ -66,25 +66,25 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { return self; } -- (void)registerTransportWithId:(GRPCTransportID)transportId +- (void)registerTransportWithID:(GRPCTransportID)transportID factory:(id)factory { - NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; - NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", - nsTransportId); - if (_registry[nsTransportId] != nil) { - NSLog(@"The transport %@ has already been registered.", nsTransportId); + NSString *nsTransportID = [NSString stringWithCString:transportID encoding:NSUTF8StringEncoding]; + NSAssert(_registry[nsTransportID] == nil, @"The transport %@ has already been registered.", + nsTransportID); + if (_registry[nsTransportID] != nil) { + NSLog(@"The transport %@ has already been registered.", nsTransportID); return; } - _registry[nsTransportId] = factory; + _registry[nsTransportID] = factory; // if the default transport is registered, mark it. - if (0 == strcmp(transportId, gDefaultTransportId)) { + if (0 == strcmp(transportID, gDefaultTransportID)) { _defaultFactory = factory; } } -- (id)getTransportFactoryWithId:(GRPCTransportID)transportId { - if (transportId == NULL) { +- (id)getTransportFactoryWithID:(GRPCTransportID)transportID { + if (transportID == NULL) { if (_defaultFactory == nil) { // fall back to default transport if no transport is provided [NSException raise:NSInvalidArgumentException @@ -93,17 +93,17 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { } return _defaultFactory; } - NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; - id transportFactory = _registry[nsTransportId]; + NSString *nsTransportID = [NSString stringWithCString:transportID encoding:NSUTF8StringEncoding]; + id transportFactory = _registry[nsTransportID]; if (transportFactory == nil) { if (_defaultFactory != nil) { // fall back to default transport if no transport is found NSLog(@"Unable to find transport with id %s; falling back to default transport.", - transportId); + transportID); return _defaultFactory; } else { [NSException raise:NSInvalidArgumentException - format:@"Unable to find transport with id %s", transportId]; + format:@"Unable to find transport with id %s", transportID]; return nil; } } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index 89a12d96575..92670c89e52 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -53,7 +53,7 @@ - (id)channelFactory { if (_callOptions.transport != NULL) { id transportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:_callOptions.transport]; if (! [transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { // impossible because we are using GRPCCore now @@ -84,7 +84,7 @@ } case GRPCTransportTypeCronet: { id transportFactory = (id)[ - [GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + [GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID]; return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } case GRPCTransportTypeInsecure: diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h index 83d279d2c72..a36da1b502d 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -24,7 +24,7 @@ * testing purpose only on Github. * * To use this transport, a user must include the GRPCCoreCronet module as a - * dependency of the project and use gGRPCCoreCronetId in call options to + * dependency of the project and use gGRPCCoreCronetID in call options to * specify that this is the transport to be used for a call. */ @interface GRPCCoreCronetFactory : NSObject diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m index 5772694fc54..2205d167d82 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -39,7 +39,7 @@ static dispatch_once_t gInitGRPCCoreCronetFactory; + (void)load { [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:gGRPCCoreCronetId + registerTransportWithID:gGRPCCoreCronetID factory:[GRPCCoreCronetFactory sharedInstance]]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m index 19d7231a203..928625f1275 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -40,7 +40,7 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; + (void)load { [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:GRPCDefaultTransportImplList.core_secure + registerTransportWithID:GRPCDefaultTransportImplList.core_secure factory:[self sharedInstance]]; } @@ -75,7 +75,7 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; + (void)load { [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:GRPCDefaultTransportImplList.core_insecure + registerTransportWithID:GRPCDefaultTransportImplList.core_insecure factory:[self sharedInstance]]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 1f6a25ff78f..6a3853fc94e 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -115,7 +115,7 @@ static NSMutableDictionary *gHostCache; if (_transportType == GRPCTransportTypeInsecure) { options.transport = GRPCDefaultTransportImplList.core_insecure; } else if ([GRPCCall isUsingCronet]) { - options.transport = gGRPCCoreCronetId; + options.transport = gGRPCCoreCronetID; } else { options.transport = GRPCDefaultTransportImplList.core_secure; } diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index eaf07950815..4574e51b39f 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -31,13 +31,13 @@ NS_ASSUME_NONNULL_BEGIN * registered with the registry, the default transport factory (core + secure) is returned. If the * default transport does not exist, an exception is thrown. */ -- (id)getTransportFactoryWithId:(GRPCTransportID)transportId; +- (id)getTransportFactoryWithID:(GRPCTransportID)transportID; @end @interface GRPCTransportManager : NSObject -- (instancetype)initWithTransportId:(GRPCTransportID)transportId +- (instancetype)initWithTransportID:(GRPCTransportID)transportID previousInterceptor:(id)previousInterceptor; /** diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index aa9c7f2ce58..3084ed9ee4e 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -21,27 +21,27 @@ #import @implementation GRPCTransportManager { - GRPCTransportID _transportId; + GRPCTransportID _transportID; GRPCTransport *_transport; id _previousInterceptor; dispatch_queue_t _dispatchQueue; } -- (instancetype)initWithTransportId:(GRPCTransportID)transportId +- (instancetype)initWithTransportID:(GRPCTransportID)transportID previousInterceptor:(id)previousInterceptor { if ((self = [super init])) { id factory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:transportID]; _transport = [factory createTransportWithManager:self]; - NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); + NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportID); if (_transport == nil) { - NSLog(@"Failed to create transport with id: %s", transportId); + NSLog(@"Failed to create transport with id: %s", transportID); return nil; } _previousInterceptor = previousInterceptor; _dispatchQueue = _transport.dispatchQueue; - _transportId = transportId; + _transportID = transportID; } return self; } @@ -58,7 +58,7 @@ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - if (_transportId != callOptions.transport) { + if (_transportID != callOptions.transport) { [NSException raise:NSInvalidArgumentException format:@"Interceptors cannot change the call option 'transport'"]; return; diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index f4cd9e064d2..883734de26f 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -53,7 +53,7 @@ static int32_t kRemoteInteropServerOverhead = 12; } + (GRPCTransportID)transport { - return gGRPCCoreCronetId; + return gGRPCCoreCronetID; } - (int32_t)encodingOverhead { diff --git a/src/objective-c/tests/CronetTests/TransportRegistryTests.m b/src/objective-c/tests/CronetTests/TransportRegistryTests.m index 75802e17c4f..9e9be5ed733 100644 --- a/src/objective-c/tests/CronetTests/TransportRegistryTests.m +++ b/src/objective-c/tests/CronetTests/TransportRegistryTests.m @@ -30,9 +30,9 @@ - (void)testCronetImplementationExist { id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_secure]; id cronetTransportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID]; XCTAssertNotNil(secureTransportFactory); XCTAssertNotNil(cronetTransportFactory); XCTAssertNotEqual(secureTransportFactory, cronetTransportFactory); diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 0c7ef44e0fa..9a10cccecd4 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -1268,7 +1268,7 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testKeepaliveWithV2API { XCTAssertNotNil([[self class] host]); - if ([[self class] transport] == gGRPCCoreCronetId) { + if ([[self class] transport] == gGRPCCoreCronetID) { // Cronet does not support keepalive return; } diff --git a/src/objective-c/tests/UnitTests/TransportRegistryTests.m b/src/objective-c/tests/UnitTests/TransportRegistryTests.m index 40035fefa90..6fbf02d925d 100644 --- a/src/objective-c/tests/UnitTests/TransportRegistryTests.m +++ b/src/objective-c/tests/UnitTests/TransportRegistryTests.m @@ -30,9 +30,9 @@ - (void)testDefaultImplementationsExist { id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_secure]; id insecureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_insecure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_insecure]; XCTAssertNotNil(secureTransportFactory); XCTAssertNotNil(insecureTransportFactory); XCTAssertNotEqual(secureTransportFactory, insecureTransportFactory); @@ -40,9 +40,9 @@ - (void)testCronetImplementationNotExistAndFallBack { id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_secure]; id cronetTransportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID]; XCTAssertNotNil(secureTransportFactory); XCTAssertNotNil(cronetTransportFactory); XCTAssertEqual(secureTransportFactory, cronetTransportFactory); From 361a902262e72f3d647df933b3f4f84a51920996 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Sep 2019 14:20:39 -0700 Subject: [PATCH 128/176] Reviewer comments --- test/cpp/end2end/end2end_test.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a4655329250..5fb69c177b6 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -341,8 +341,7 @@ class End2endTest : public ::testing::TestWithParam { void ResetChannel( std::vector< std::unique_ptr> - interceptor_creators = std::vector>()) { + interceptor_creators = {}) { if (!is_server_started_) { StartServer(std::shared_ptr()); } @@ -380,8 +379,7 @@ class End2endTest : public ::testing::TestWithParam { void ResetStub( std::vector< std::unique_ptr> - interceptor_creators = std::vector>()) { + interceptor_creators = {}) { ResetChannel(std::move(interceptor_creators)); if (GetParam().use_proxy) { proxy_service_.reset(new Proxy(channel_)); From 56acfb9f26df67700824fe9b3f7c8c4e042f0c3c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Sep 2019 18:18:32 -0700 Subject: [PATCH 129/176] Thread safety fix --- src/objective-c/GRPCClient/GRPCInterceptor.h | 17 ++++--- src/objective-c/GRPCClient/GRPCInterceptor.m | 45 +++++++++++++++---- .../private/GRPCCore/GRPCCallInternal.m | 32 +++++++++---- .../private/GRPCTransport+Private.h | 14 +++++- .../private/GRPCTransport+Private.m | 25 ++++++++--- 5 files changed, 103 insertions(+), 30 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 5c203445fba..e3f49f444c4 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -164,10 +164,17 @@ NS_ASSUME_NONNULL_BEGIN @end /** - * The interceptor manager object retains reference to the next and previous interceptor object in - * the interceptor chain, and forward corresponding events to them. When a call terminates, it must - * invoke shutDown method of its corresponding manager so that references to other interceptors can - * be released. + * GRPCInterceptorManager is a helper class to forward messages between the interceptors. The + * interceptor manager object retains reference to the next and previous interceptor object in the + * interceptor chain, and forward corresponding events to them. + * + * All methods except the initializer of the class can only be called on the manager's dispatch + * queue. Since the manager's dispatch queue targets corresponding interceptor's dispatch queue, it + * is also safe to call the manager's methods in the corresponding interceptor instance's methods + * that implement GRPCInterceptorInterface. + * + * When an interceptor is shutting down, it must invoke -shutDown method of its corresponding + * manager so that references to other interceptors can be released and proper clean-up is made. */ @interface GRPCInterceptorManager : NSObject @@ -182,8 +189,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the interceptor has shut down and the manager should release references * to other interceptors and stop forwarding requests/responses. - * - * The method can only be called by the manager's associated interceptor. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index ea723369737..3aae52f7d4e 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -226,47 +226,74 @@ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; } - (void)writeData:(id)data { - [_thisInterceptor writeData:data]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor writeData:data]; } - (void)finish { - [_thisInterceptor finish]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor finish]; } - (void)cancel { - [_thisInterceptor cancel]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor cancel]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_thisInterceptor receiveNextMessages:numberOfMessages]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor receiveNextMessages:numberOfMessages]; } - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didReceiveInitialMetadata:initialMetadata]; } } - (void)didReceiveData:(id)data { if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { - [_thisInterceptor didReceiveData:data]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didReceiveData:data]; } } - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata error:(nullable NSError *)error { if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; } } - (void)didWriteData { if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { - [_thisInterceptor didWriteData]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didWriteData]; } } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m index ea01fcaf594..4c42ba80399 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m @@ -155,7 +155,7 @@ self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; } - [self issueClosedWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil]; + [self issueCloseWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil]; } // Clearing _call must happen *after* dispatching close in order to get trailing // metadata from _call. @@ -250,24 +250,40 @@ - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { if (initialMetadata != nil) { - [_transportManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + }); } } - (void)issueMessage:(id)message { if (message != nil) { - [_transportManager forwardPreviousInterceptorWithData:message]; + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorWithData:message]; + }); } } -- (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata - error:error]; - [_transportManager shutDown]; +- (void)issueCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata + error:error]; + [copiedManager shutDown]; + }); } - (void)issueDidWriteData { - [_transportManager forwardPreviousInterceptorDidWriteData]; + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorDidWriteData]; + }); } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 4574e51b39f..184aa287f0b 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -35,6 +35,18 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * GRPCTransportManager is a helper class to forward messages between the last interceptor and the + * transport instance. + * + * All methods except the initializer of the class can only be called on the manager's dispatch + * queue. Since the manager's dispatch queue is the same as the transport's dispatch queue, it is + * also safe to call the manager's methods in the corresponding transport instance's methods that + * implement GRPCInterceptorInterface. + * + * When a transport instance is shutting down, it must call -shutDown method of its associated + * transport manager for proper clean-up. + */ @interface GRPCTransportManager : NSObject - (instancetype)initWithTransportID:(GRPCTransportID)transportID @@ -43,8 +55,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the transport has shut down and the manager should release references to * its response handler and stop forwarding requests/responses. - * - * The method can only be called by the manager's associated transport instance. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 3084ed9ee4e..81c7dd1de1e 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -63,23 +63,38 @@ format:@"Interceptors cannot change the call option 'transport'"]; return; } - [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport startWithRequestOptions:requestOptions callOptions:callOptions]; } - (void)writeData:(id)data { - [_transport writeData:data]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport writeData:data]; } - (void)finish { - [_transport finish]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport finish]; } - (void)cancel { - [_transport cancel]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport cancel]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_transport receiveNextMessages:numberOfMessages]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport receiveNextMessages:numberOfMessages]; } /** Forward initial metadata to the previous interceptor in the chain */ From c9376b4e0bbd14808636ad0410e0b0387431d792 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 12 Aug 2019 11:07:22 -0400 Subject: [PATCH 130/176] Use cycle clock instead of clock monotonic to measure call latency. This removes two more getttime syscalls from the hot path, when cycle clock is enabled. --- .../ext/filters/client_channel/client_channel.cc | 5 +++-- .../client_channel/health/health_check_client.cc | 4 ++-- src/core/ext/filters/client_channel/subchannel.h | 3 ++- src/core/lib/channel/channel_stack.h | 3 ++- src/core/lib/gpr/time_precise.cc | 15 +++++++++++++++ src/core/lib/gpr/time_precise.h | 1 + src/core/lib/surface/call.cc | 6 +++--- test/core/channel/channel_stack_test.cc | 16 ++++++++-------- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- 9 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 40ac1f22059..51210107872 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -720,7 +720,7 @@ class CallData { grpc_deadline_state deadline_state_; grpc_slice path_; // Request path. - gpr_timespec call_start_time_; + gpr_cycle_counter call_start_time_; grpc_millis deadline_; Arena* arena_; grpc_call_stack* owning_call_; @@ -3730,7 +3730,8 @@ void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { // from the client API, reset the deadline timer. if (chand->deadline_checking_enabled() && method_params_->timeout() != 0) { const grpc_millis per_method_deadline = - grpc_timespec_to_millis_round_up(call_start_time_) + + grpc_timespec_to_millis_round_up( + gpr_cycle_counter_to_time(call_start_time_)) + method_params_->timeout(); if (per_method_deadline < deadline_) { deadline_ = per_method_deadline; diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index 026831645c0..2662d8466b6 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -304,8 +304,8 @@ void HealthCheckClient::CallState::StartCall() { health_check_client_->connected_subchannel_, &pollent_, GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH, - gpr_now(GPR_CLOCK_MONOTONIC), // start_time - GRPC_MILLIS_INF_FUTURE, // deadline + gpr_get_cycle_counter(), // start_time + GRPC_MILLIS_INF_FUTURE, // deadline arena_, context_, &call_combiner_, diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index d745bc8ddc2..c178401ca8a 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -26,6 +26,7 @@ #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/ref_counted.h" @@ -104,7 +105,7 @@ class SubchannelCall { RefCountedPtr connected_subchannel; grpc_polling_entity* pollent; grpc_slice path; - gpr_timespec start_time; + gpr_cycle_counter start_time; grpc_millis deadline; Arena* arena; grpc_call_context_element* context; diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index a7c28d059f3..f7be806b695 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -42,6 +42,7 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -67,7 +68,7 @@ typedef struct { const void* server_transport_data; grpc_call_context_element* context; const grpc_slice& path; - gpr_timespec start_time; + gpr_cycle_counter start_time; grpc_millis deadline; grpc_core::Arena* arena; grpc_core::CallCombiner* call_combiner; diff --git a/src/core/lib/gpr/time_precise.cc b/src/core/lib/gpr/time_precise.cc index 9d11c66831c..56b00d119ad 100644 --- a/src/core/lib/gpr/time_precise.cc +++ b/src/core/lib/gpr/time_precise.cc @@ -122,6 +122,16 @@ gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { return ts; } +gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) { + double secs = static_cast(a - b) / cycles_per_second; + gpr_timespec ts; + ts.tv_sec = static_cast(secs); + ts.tv_nsec = static_cast(GPR_NS_PER_SEC * + (secs - static_cast(ts.tv_sec))); + ts.clock_type = GPR_TIMESPAN; + return ts; +} + void gpr_precise_clock_now(gpr_timespec* clk) { int64_t counter = gpr_get_cycle_counter(); *clk = gpr_cycle_counter_to_time(counter); @@ -146,4 +156,9 @@ void gpr_precise_clock_now(gpr_timespec* clk) { *clk = gpr_now(GPR_CLOCK_REALTIME); clk->clock_type = GPR_CLOCK_PRECISE; } + +gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) { + return gpr_time_sub(gpr_cycle_counter_to_time(a), + gpr_cycle_counter_to_time(b)); +} #endif /* GPR_CYCLE_COUNTER_FALLBACK */ diff --git a/src/core/lib/gpr/time_precise.h b/src/core/lib/gpr/time_precise.h index ce16bafab2d..55eceb6c8ba 100644 --- a/src/core/lib/gpr/time_precise.h +++ b/src/core/lib/gpr/time_precise.h @@ -61,5 +61,6 @@ gpr_cycle_counter gpr_get_cycle_counter(); void gpr_precise_clock_init(void); void gpr_precise_clock_now(gpr_timespec* clk); gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles); +gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b); #endif /* GRPC_CORE_LIB_GPR_TIME_PRECISE_H */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 5388cbd75a9..435f536b3df 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -36,6 +36,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/alloc.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -154,7 +155,7 @@ struct grpc_call { grpc_completion_queue* cq; grpc_polling_entity pollent; grpc_channel* channel; - gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_cycle_counter start_time = gpr_get_cycle_counter(); /* parent_call* */ gpr_atm parent_call_atm = 0; child_call* child = nullptr; @@ -552,8 +553,7 @@ static void destroy_call(void* call, grpc_error* error) { &(c->final_info.error_string)); GRPC_ERROR_UNREF(status_error); c->final_info.stats.latency = - gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time); - + gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->start_time); grpc_call_stack_destroy(CALL_STACK_FROM_CALL(c), &c->final_info, GRPC_CLOSURE_INIT(&c->release_call, release_call, c, grpc_schedule_on_exec_ctx)); diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc index 14726336f92..3f15a0010bd 100644 --- a/test/core/channel/channel_stack_test.cc +++ b/test/core/channel/channel_stack_test.cc @@ -117,14 +117,14 @@ static void test_create_channel_stack(void) { call_stack = static_cast(gpr_malloc(channel_stack->call_stack_size)); const grpc_call_element_args args = { - call_stack, /* call_stack */ - nullptr, /* server_transport_data */ - nullptr, /* context */ - path, /* path */ - gpr_now(GPR_CLOCK_MONOTONIC), /* start_time */ - GRPC_MILLIS_INF_FUTURE, /* deadline */ - nullptr, /* arena */ - nullptr, /* call_combiner */ + call_stack, /* call_stack */ + nullptr, /* server_transport_data */ + nullptr, /* context */ + path, /* path */ + gpr_get_cycle_counter(), /* start_time */ + GRPC_MILLIS_INF_FUTURE, /* deadline */ + nullptr, /* arena */ + nullptr, /* call_combiner */ }; grpc_error* error = grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args); diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 99ea1e053e9..e3c853d4430 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -523,7 +523,7 @@ static void BM_IsolatedFilter(benchmark::State& state) { grpc_call_stack* call_stack = static_cast(gpr_zalloc(channel_stack->call_stack_size)); grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; - gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_cycle_counter start_time = gpr_get_cycle_counter(); grpc_slice method = grpc_slice_from_static_string("/foo/bar"); grpc_call_final_info final_info; TestOp test_op_data; From 81a29ae1a62bb8e7877ea100cc975ea27d431a7e Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 12 Aug 2019 17:32:47 -0400 Subject: [PATCH 131/176] Mark double-second local variables as const. --- src/core/lib/gpr/time_precise.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gpr/time_precise.cc b/src/core/lib/gpr/time_precise.cc index 56b00d119ad..3223a84c7ad 100644 --- a/src/core/lib/gpr/time_precise.cc +++ b/src/core/lib/gpr/time_precise.cc @@ -113,7 +113,8 @@ void gpr_precise_clock_init(void) { } gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { - double secs = static_cast(cycles - start_cycle) / cycles_per_second; + const double secs = + static_cast(cycles - start_cycle) / cycles_per_second; gpr_timespec ts; ts.tv_sec = static_cast(secs); ts.tv_nsec = static_cast(GPR_NS_PER_SEC * @@ -123,7 +124,7 @@ gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { } gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) { - double secs = static_cast(a - b) / cycles_per_second; + const double secs = static_cast(a - b) / cycles_per_second; gpr_timespec ts; ts.tv_sec = static_cast(secs); ts.tv_nsec = static_cast(GPR_NS_PER_SEC * From 7b84f81a8ca570c3d1e74bbb98d8d38de2bce3c7 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 13 Aug 2019 15:04:03 -0400 Subject: [PATCH 132/176] Add grpc_cycle_counter_to_millis(). --- .../filters/client_channel/client_channel.cc | 3 +-- src/core/lib/iomgr/exec_ctx.cc | 17 +++++++++++++++++ src/core/lib/iomgr/exec_ctx.h | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 51210107872..0a9b5ac43fb 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -3730,8 +3730,7 @@ void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { // from the client API, reset the deadline timer. if (chand->deadline_checking_enabled() && method_params_->timeout() != 0) { const grpc_millis per_method_deadline = - grpc_timespec_to_millis_round_up( - gpr_cycle_counter_to_time(call_start_time_)) + + grpc_cycle_counter_to_millis_round_up(call_start_time_) + method_params_->timeout(); if (per_method_deadline < deadline_) { deadline_ = per_method_deadline; diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index a847b4dcefc..5cb778de98e 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -52,6 +52,7 @@ static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) { } static gpr_timespec g_start_time; +static gpr_cycle_counter g_start_cycle; static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { ts = gpr_time_sub(ts, g_start_time); @@ -101,6 +102,16 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { gpr_convert_clock_type(ts, g_start_time.clock_type)); } +grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles) { + return timespec_to_millis_round_down( + gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); +} + +grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles) { + return timespec_to_millis_round_up( + gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); +} + static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { exec_ctx_run, exec_ctx_sched, "exec_ctx"}; static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable}; @@ -117,7 +128,13 @@ void ExecCtx::TestOnlyGlobalInit(gpr_timespec new_val) { } void ExecCtx::GlobalInit(void) { + // gpr_now(GPR_CLOCK_MONOTONIC) incurs a syscall. We don't actually know the + // exact cycle the time was captured, so we use the average of cycles before + // and after the syscall as the starting cycle. + const gpr_cycle_counter cycle_before = gpr_get_cycle_counter(); g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_cycle_counter cycle_after = gpr_get_cycle_counter(); + g_start_cycle = (cycle_before + cycle_after) / 2; gpr_tls_init(&exec_ctx_); } diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index daf019c41ee..0ccf2a878bf 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -26,6 +26,7 @@ #include #include +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/fork.h" #include "src/core/lib/iomgr/closure.h" @@ -58,6 +59,8 @@ extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx; gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock); grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec); grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec); +grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles); +grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles); namespace grpc_core { /** Execution context. From 4b2b00b35bb8be4752b4b986640ef76dd0eadc40 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 13 Aug 2019 15:25:34 -0400 Subject: [PATCH 133/176] Optimize cycle to millis conversion by bypassing sub+add. --- src/core/lib/iomgr/exec_ctx.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index 5cb778de98e..730237a250d 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -54,8 +54,7 @@ static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) { static gpr_timespec g_start_time; static gpr_cycle_counter g_start_cycle; -static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); +static grpc_millis timespan_to_millis_round_down(gpr_timespec ts) { double x = GPR_MS_PER_SEC * static_cast(ts.tv_sec) + static_cast(ts.tv_nsec) / GPR_NS_PER_MS; if (x < 0) return 0; @@ -63,8 +62,11 @@ static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { return static_cast(x); } -static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); +static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { + return timespan_to_millis_round_down(gpr_time_sub(ts, g_start_time)); +} + +static grpc_millis timespan_to_millis_round_up(gpr_timespec ts) { double x = GPR_MS_PER_SEC * static_cast(ts.tv_sec) + static_cast(ts.tv_nsec) / GPR_NS_PER_MS + static_cast(GPR_NS_PER_SEC - 1) / @@ -74,6 +76,10 @@ static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) { return static_cast(x); } +static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) { + return timespan_to_millis_round_up(gpr_time_sub(ts, g_start_time)); +} + gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock_type) { // special-case infinities as grpc_millis can be 32bit on some platforms @@ -103,13 +109,13 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { } grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles) { - return timespec_to_millis_round_down( - gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); + return timespan_to_millis_round_down( + gpr_cycle_counter_sub(cycles, g_start_cycle)); } grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles) { - return timespec_to_millis_round_up( - gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); + return timespan_to_millis_round_up( + gpr_cycle_counter_sub(cycles, g_start_cycle)); } static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { From c965ca14940dda1606109d959204d3eaeef9c1d6 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 9 Sep 2019 10:12:39 -0700 Subject: [PATCH 134/176] Pull out configuration from ssl_utils --- BUILD | 2 ++ BUILD.gn | 2 ++ CMakeLists.txt | 2 ++ Makefile | 3 ++ build.yaml | 2 ++ config.m4 | 1 + config.w32 | 1 + gRPC-Core.podspec | 3 ++ grpc.gemspec | 2 ++ grpc.gyp | 1 + package.xml | 2 ++ .../interop/app/src/main/cpp/grpc-interop.cc | 2 +- .../security/security_connector/ssl_utils.cc | 13 +------- .../security/security_connector/ssl_utils.h | 4 +-- .../security_connector/ssl_utils_config.cc | 32 +++++++++++++++++++ .../security_connector/ssl_utils_config.h | 30 +++++++++++++++++ .../CronetTests/CoreCronetEnd2EndTests.mm | 2 +- src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/bad_ssl/bad_ssl_test.cc | 2 +- test/core/end2end/fixtures/h2_spiffe.cc | 2 +- test/core/end2end/fixtures/h2_ssl.cc | 2 +- .../end2end/fixtures/h2_ssl_cred_reload.cc | 2 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 2 +- test/core/end2end/h2_ssl_cert_test.cc | 2 +- .../core/end2end/h2_ssl_session_reuse_test.cc | 2 +- test/core/http/httpscli_test.cc | 2 +- tools/doxygen/Doxyfile.core.internal | 2 ++ 27 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 src/core/lib/security/security_connector/ssl_utils_config.cc create mode 100644 src/core/lib/security/security_connector/ssl_utils_config.h diff --git a/BUILD b/BUILD index d911050b1be..576325c82f1 100644 --- a/BUILD +++ b/BUILD @@ -1580,6 +1580,7 @@ grpc_cc_library( "src/core/lib/security/security_connector/security_connector.cc", "src/core/lib/security/security_connector/ssl/ssl_security_connector.cc", "src/core/lib/security/security_connector/ssl_utils.cc", + "src/core/lib/security/security_connector/ssl_utils_config.cc", "src/core/lib/security/security_connector/tls/spiffe_security_connector.cc", "src/core/lib/security/transport/client_auth_filter.cc", "src/core/lib/security/transport/secure_endpoint.cc", @@ -1617,6 +1618,7 @@ grpc_cc_library( "src/core/lib/security/security_connector/security_connector.h", "src/core/lib/security/security_connector/ssl/ssl_security_connector.h", "src/core/lib/security/security_connector/ssl_utils.h", + "src/core/lib/security/security_connector/ssl_utils_config.h", "src/core/lib/security/security_connector/tls/spiffe_security_connector.h", "src/core/lib/security/transport/auth_filters.h", "src/core/lib/security/transport/secure_endpoint.h", diff --git a/BUILD.gn b/BUILD.gn index 771e968f366..3d0363cf175 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -749,6 +749,8 @@ config("grpc_config") { "src/core/lib/security/security_connector/ssl/ssl_security_connector.h", "src/core/lib/security/security_connector/ssl_utils.cc", "src/core/lib/security/security_connector/ssl_utils.h", + "src/core/lib/security/security_connector/ssl_utils_config.cc", + "src/core/lib/security/security_connector/ssl_utils_config.h", "src/core/lib/security/security_connector/tls/spiffe_security_connector.cc", "src/core/lib/security/security_connector/tls/spiffe_security_connector.h", "src/core/lib/security/transport/auth_filters.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 599f1441583..08a49697750 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1194,6 +1194,7 @@ add_library(grpc src/core/lib/security/security_connector/security_connector.cc src/core/lib/security/security_connector/ssl/ssl_security_connector.cc src/core/lib/security/security_connector/ssl_utils.cc + src/core/lib/security/security_connector/ssl_utils_config.cc src/core/lib/security/security_connector/tls/spiffe_security_connector.cc src/core/lib/security/transport/client_auth_filter.cc src/core/lib/security/transport/secure_endpoint.cc @@ -1717,6 +1718,7 @@ add_library(grpc_cronet src/core/lib/security/security_connector/security_connector.cc src/core/lib/security/security_connector/ssl/ssl_security_connector.cc src/core/lib/security/security_connector/ssl_utils.cc + src/core/lib/security/security_connector/ssl_utils_config.cc src/core/lib/security/security_connector/tls/spiffe_security_connector.cc src/core/lib/security/transport/client_auth_filter.cc src/core/lib/security/transport/secure_endpoint.cc diff --git a/Makefile b/Makefile index e666a19eb79..b24a27acfe6 100644 --- a/Makefile +++ b/Makefile @@ -3770,6 +3770,7 @@ LIBGRPC_SRC = \ src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ + src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ @@ -4288,6 +4289,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ + src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ @@ -22686,6 +22688,7 @@ src/core/lib/security/security_connector/local/local_security_connector.cc: $(OP src/core/lib/security/security_connector/security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/ssl/ssl_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/ssl_utils.cc: $(OPENSSL_DEP) +src/core/lib/security/security_connector/ssl_utils_config.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/tls/spiffe_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/transport/client_auth_filter.cc: $(OPENSSL_DEP) src/core/lib/security/transport/secure_endpoint.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 15203f242c9..dc5fd4236da 100644 --- a/build.yaml +++ b/build.yaml @@ -1274,6 +1274,7 @@ filegroups: - src/core/lib/security/security_connector/security_connector.h - src/core/lib/security/security_connector/ssl/ssl_security_connector.h - src/core/lib/security/security_connector/ssl_utils.h + - src/core/lib/security/security_connector/ssl_utils_config.h - src/core/lib/security/security_connector/tls/spiffe_security_connector.h - src/core/lib/security/transport/auth_filters.h - src/core/lib/security/transport/secure_endpoint.h @@ -1309,6 +1310,7 @@ filegroups: - src/core/lib/security/security_connector/security_connector.cc - src/core/lib/security/security_connector/ssl/ssl_security_connector.cc - src/core/lib/security/security_connector/ssl_utils.cc + - src/core/lib/security/security_connector/ssl_utils_config.cc - src/core/lib/security/security_connector/tls/spiffe_security_connector.cc - src/core/lib/security/transport/client_auth_filter.cc - src/core/lib/security/transport/secure_endpoint.cc diff --git a/config.m4 b/config.m4 index efa86576f84..15455a8e114 100644 --- a/config.m4 +++ b/config.m4 @@ -304,6 +304,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ + src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ diff --git a/config.w32 b/config.w32 index 13b5f1350f0..f5adca6fb53 100644 --- a/config.w32 +++ b/config.w32 @@ -274,6 +274,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\security\\security_connector\\security_connector.cc " + "src\\core\\lib\\security\\security_connector\\ssl\\ssl_security_connector.cc " + "src\\core\\lib\\security\\security_connector\\ssl_utils.cc " + + "src\\core\\lib\\security\\security_connector\\ssl_utils_config.cc " + "src\\core\\lib\\security\\security_connector\\tls\\spiffe_security_connector.cc " + "src\\core\\lib\\security\\transport\\client_auth_filter.cc " + "src\\core\\lib\\security\\transport\\secure_endpoint.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 658a3ad6158..3770425e5e3 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -310,6 +310,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', + 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', @@ -802,6 +803,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', + 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', @@ -1044,6 +1046,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', + 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', diff --git a/grpc.gemspec b/grpc.gemspec index 1b705016cee..431dd9f8f7e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -240,6 +240,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/security_connector/security_connector.h ) s.files += %w( src/core/lib/security/security_connector/ssl/ssl_security_connector.h ) s.files += %w( src/core/lib/security/security_connector/ssl_utils.h ) + s.files += %w( src/core/lib/security/security_connector/ssl_utils_config.h ) s.files += %w( src/core/lib/security/security_connector/tls/spiffe_security_connector.h ) s.files += %w( src/core/lib/security/transport/auth_filters.h ) s.files += %w( src/core/lib/security/transport/secure_endpoint.h ) @@ -732,6 +733,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/security_connector/security_connector.cc ) s.files += %w( src/core/lib/security/security_connector/ssl/ssl_security_connector.cc ) s.files += %w( src/core/lib/security/security_connector/ssl_utils.cc ) + s.files += %w( src/core/lib/security/security_connector/ssl_utils_config.cc ) s.files += %w( src/core/lib/security/security_connector/tls/spiffe_security_connector.cc ) s.files += %w( src/core/lib/security/transport/client_auth_filter.cc ) s.files += %w( src/core/lib/security/transport/secure_endpoint.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5468675e768..b0168dc15df 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -504,6 +504,7 @@ 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', + 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', diff --git a/package.xml b/package.xml index 385a57c77ea..fb43cf9c4d7 100644 --- a/package.xml +++ b/package.xml @@ -245,6 +245,7 @@ + @@ -737,6 +738,7 @@ + diff --git a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc index b5075529be2..15cf44fb88d 100644 --- a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc +++ b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc @@ -19,7 +19,7 @@ #include #include -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/cpp/interop/interop_client.h" extern "C" JNIEXPORT void JNICALL diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index ebb4a3f9ee8..bacd31a1f30 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -28,12 +28,12 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/security_connector/load_system_roots.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/tsi/ssl_transport_security.h" /* -- Constants. -- */ @@ -45,17 +45,6 @@ static const char* installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem"; #endif -/** Config variable that points to the default SSL roots file. This file - must be a PEM encoded file with all the roots such as the one that can be - downloaded from https://pki.google.com/roots.pem. */ -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", - "Path to the default SSL roots file."); - -/** Config variable used as a flag to enable/disable loading system root - certificates from the OS trust store. */ -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, - "Disable loading system root certificates."); - #ifndef TSI_OPENSSL_ALPN_SUPPORT #define TSI_OPENSSL_ALPN_SUPPORT 1 #endif diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 29366b309e8..c13dd90a932 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -31,13 +31,11 @@ #include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security_interface.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); -GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); - /* --- Util --- */ /* --- URL schemes. --- */ diff --git a/src/core/lib/security/security_connector/ssl_utils_config.cc b/src/core/lib/security/security_connector/ssl_utils_config.cc new file mode 100644 index 00000000000..2d056a781fd --- /dev/null +++ b/src/core/lib/security/security_connector/ssl_utils_config.cc @@ -0,0 +1,32 @@ +/* + * + * Copyright 2019 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 "src/core/lib/security/security_connector/ssl_utils_config.h" + +/** Config variable that points to the default SSL roots file. This file + must be a PEM encoded file with all the roots such as the one that can be + downloaded from https://pki.google.com/roots.pem. */ +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", + "Path to the default SSL roots file."); + +/** Config variable used as a flag to enable/disable loading system root + certificates from the OS trust store. */ +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, + "Disable loading system root certificates."); diff --git a/src/core/lib/security/security_connector/ssl_utils_config.h b/src/core/lib/security/security_connector/ssl_utils_config.h new file mode 100644 index 00000000000..efaf497ab1e --- /dev/null +++ b/src/core/lib/security/security_connector/ssl_utils_config.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H +#define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H + +#include + +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); +GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); + +#endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H \ + */ diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index ad426014a5b..c3963874f77 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -41,7 +41,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 6eb8bc8c9c1..9ef13c117ee 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -273,6 +273,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', + 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index deae9072613..0480815443a 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -28,7 +28,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 37fb44b5ad6..c56a13b17a0 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -35,7 +35,7 @@ #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index cb55bb72061..4e09bccd0a3 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 2a9591845b9..e5a05570809 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index b16ffa1b8b8..77420e38b3a 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -28,7 +28,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/proxy.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 34a9ef760b5..2b97ab3d3f7 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index 6ffc138820e..ed450aebf1b 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index eb63367d750..79f0c1ea365 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index ed6f88dde3c..10e11825f8d 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1502,6 +1502,8 @@ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.h \ src/core/lib/security/security_connector/ssl_utils.cc \ src/core/lib/security/security_connector/ssl_utils.h \ +src/core/lib/security/security_connector/ssl_utils_config.cc \ +src/core/lib/security/security_connector/ssl_utils_config.h \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.h \ src/core/lib/security/transport/auth_filters.h \ From 0a3b333c045800e3be4e8fce8d1b28ee0123b6aa Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 9 Sep 2019 11:32:04 -0700 Subject: [PATCH 135/176] Fix internal warning --- bazel/python_rules.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index e65bae3f5b5..c2a16d6cce1 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -164,6 +164,8 @@ def py_grpc_library( stripped from the beginning of foo_pb2 modules imported by the generated stubs. This is useful in combination with the `imports` attribute of the `py_library` rule. + **kwargs: Additional arguments to be supplied to the invocation of + py_library. """ codegen_grpc_target = "_{}_grpc_codegen".format(name) if len(srcs) != 1: From 05901eaaa36fc85e357f0e717bce56bf796a6c09 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 9 Sep 2019 14:14:26 -0400 Subject: [PATCH 136/176] Fix filter_latency.cc On Windows tests, clock monotonic doesn't progress. Switch to CLOCK_PRECISE to fix this. --- test/core/end2end/tests/filter_latency.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc index a89db7b094b..85de58a3d20 100644 --- a/test/core/end2end/tests/filter_latency.cc +++ b/test/core/end2end/tests/filter_latency.cc @@ -122,7 +122,7 @@ static void test_request(grpc_end2end_test_config config) { g_client_latency = gpr_time_0(GPR_TIMESPAN); g_server_latency = gpr_time_0(GPR_TIMESPAN); gpr_mu_unlock(&g_mu); - const gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_timespec start_time = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, @@ -224,7 +224,7 @@ static void test_request(grpc_end2end_test_config config) { end_test(&f); config.tear_down_data(&f); - const gpr_timespec end_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_timespec end_time = gpr_now(GPR_CLOCK_REALTIME); const gpr_timespec max_latency = gpr_time_sub(end_time, start_time); // Perform checks after test tear-down From aa84ceb38ea48058de2ce940842e8aefdc0ae69d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 9 Sep 2019 15:58:33 -0700 Subject: [PATCH 137/176] Add another test for when the credentials were previously set --- test/cpp/end2end/end2end_test.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 5fb69c177b6..778a3dc6507 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1865,6 +1865,36 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterception) { "fake_selector")); } +TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) { + MAYBE_SKIP_TEST; + if (!GetParam().use_interceptors) { + return; + } + std::vector> + interceptor_creators; + interceptor_creators.push_back(std::unique_ptr( + new CredentialsInterceptorFactory())); + ResetStub(std::move(interceptor_creators)); + EchoRequest request; + EchoResponse response; + ClientContext context; + std::shared_ptr creds1 = + GoogleIAMCredentials("wrong_token", "wrong_selector"); + context.set_credentials(creds1); + request.set_message("Hello"); + request.mutable_param()->set_echo_metadata(true); + + Status s = stub_->Echo(&context, request, &response); + EXPECT_EQ(request.message(), response.message()); + EXPECT_TRUE(s.ok()); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + "fake_token")); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + "fake_selector")); +} + TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { MAYBE_SKIP_TEST; ResetStub(); From e7c9b46a1e4e01e0c0424dc774b2e1a970d7d164 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 9 Sep 2019 16:08:23 -0700 Subject: [PATCH 138/176] Move ErrorForBadProto --- src/objective-c/ProtoRPC/ProtoRPC.m | 18 ++++++++++++++++++ src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index dbfa3c0f23d..9c0eb13d9d6 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -273,3 +273,21 @@ } @end + +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + NSUnderlyingErrorKey : parsingError, + @"Expected class" : expectedClass, + @"Received value" : proto, + }; + // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. + return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; +} diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index 4ba93674063..eaa02e9170b 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -101,21 +101,3 @@ @implementation GRPCProtoCall @end - -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - NSUnderlyingErrorKey : parsingError, - @"Expected class" : expectedClass, - @"Received value" : proto, - }; - // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. - return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; -} From deb8d569bae85789c31c41b1d949a52d01915402 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Mon, 9 Sep 2019 19:35:11 -0700 Subject: [PATCH 139/176] Assign Karthik to next github rotation --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/cleanup_request.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/pull_request_template.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4709997666e..66d87f4f508 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Report a bug about: Create a report to help us improve labels: kind/bug, priority/P2 -assignees: nanahpang +assignees: karthikravis --- diff --git a/.github/ISSUE_TEMPLATE/cleanup_request.md b/.github/ISSUE_TEMPLATE/cleanup_request.md index 4ec33fafb58..ee564f00630 100644 --- a/.github/ISSUE_TEMPLATE/cleanup_request.md +++ b/.github/ISSUE_TEMPLATE/cleanup_request.md @@ -2,7 +2,7 @@ name: Request a cleanup about: Suggest a cleanup in our repository labels: kind/internal cleanup -assignees: nanahpang +assignees: karthikravis --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index efa5b1611bb..b6ef503c7c2 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Request a feature about: Suggest an idea for this project labels: kind/enhancement -assignees: nanahpang +assignees: karthikravis --- diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 55d8d600541..681d2f819ce 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,4 +8,4 @@ If you know who should review your pull request, please remove the mentioning be --> -@nanahpang +@karthikravis From 107db8dab43120ed4f2815eef5e3d52d5f5d480f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 09:53:41 -0400 Subject: [PATCH 140/176] upgrade bazel to 0.29 --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 12a22785623..9762bdcb85f 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index 4d1d57f60d9..cfa875b0e63 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.28.1 +VERSION=0.29.0 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7141fb9c5f1..fde54bae877 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index badff52de34..4d3691f32bd 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 From e88553ed17dd0c59f75c11869ce3b7fa6a6540d7 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 03:48:40 -0400 Subject: [PATCH 141/176] upgrade windows RBE to bazel 0.29 --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 153b2d59687..e55534e2e84 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.26.0 --limit-output +choco install bazel -y --version 0.29.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 5cd37064cb0533844d9150f3e90503fd55d68008 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 04:09:21 -0400 Subject: [PATCH 142/176] try fix win RBE build --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- tools/remote_build/windows.bazelrc | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index e55534e2e84..8d8ea118ebd 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE. -bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --incompatible_disallow_filetype=false --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json +bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json set BAZEL_EXITCODE=%errorlevel% @rem TODO(jtattermusch): upload results to bigquery diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 9fd3071e79f..825d6765de9 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -1,8 +1,7 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain @@ -38,7 +37,7 @@ test --test_env=GRPC_VERBOSITY=debug # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing From 98d2d32b9edf9ff740d867e12ff529c0b637d980 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 12:11:19 -0400 Subject: [PATCH 143/176] upgrade to bazel 0.29.1 --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 9762bdcb85f..f2124a62db8 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.29.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index cfa875b0e63..0ff7fa09487 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.29.0 +VERSION=0.29.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index fde54bae877..25fcf3e6f28 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.29.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4d3691f32bd..b455a9171da 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.29.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 8d8ea118ebd..86dcc74c429 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.29.0 --limit-output +choco install bazel -y --version 0.29.1 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 37491ccd32d879fce1daff06bf162f0a230a18bc Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 10 Sep 2019 14:07:37 -0700 Subject: [PATCH 144/176] Bump version to 1.25 --- BUILD | 4 ++-- build.yaml | 4 ++-- doc/g_stands_for.md | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 576325c82f1..b2be0a29b90 100644 --- a/BUILD +++ b/BUILD @@ -77,11 +77,11 @@ config_setting( python_config_settings() # This should be updated along with build.yaml -g_stands_for = "ganges" +g_stands_for = "game" core_version = "7.0.0" -version = "1.24.0-dev" +version = "1.25.0-dev" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index dc5fd4236da..1164b9023ce 100644 --- a/build.yaml +++ b/build.yaml @@ -14,8 +14,8 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 8.0.0 csharp_major_version: 2 - g_stands_for: ganges - version: 1.24.0-dev + g_stands_for: game + version: 1.25.0-dev filegroups: - name: alts_tsi headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index 413ddcb341d..ccc79b24916 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -23,4 +23,5 @@ - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) - 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) - 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/v1.23.x) -- 1.24 'g' stands for ['ganges'](https://github.com/grpc/grpc/tree/master) +- 1.24 'g' stands for ['ganges'](https://github.com/grpc/grpc/tree/v1.24.x) +- 1.25 'g' stands for ['game'](https://github.com/grpc/grpc/tree/master) From cf444b9cab9e41ff4c7bf04271c127eb0eb98688 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 10 Sep 2019 14:08:50 -0700 Subject: [PATCH 145/176] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 32 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a49697750..ebcabe99cb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.24.0-dev") +set(PACKAGE_VERSION "1.25.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index b24a27acfe6..f73924257f8 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 8.0.0 -CPP_VERSION = 1.24.0-dev -CSHARP_VERSION = 2.24.0-dev +CPP_VERSION = 1.25.0-dev +CSHARP_VERSION = 2.25.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 881e8959651..30cb9ce1de9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.24.0-dev' + # version = '1.25.0-dev' version = '0.0.9-dev' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.24.0-dev' + grpc_version = '1.25.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 3770425e5e3..7c2877f6edc 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 4c5ebb36562..551999bbea8 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 2e412cf67d6..dfa9363cd2c 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index e18adcd276e..1b36c5ed2ea 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index fb43cf9c4d7..375f2e0e436 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.24.0dev - 1.24.0dev + 1.25.0dev + 1.25.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 71eb89a1b42..d05b6ab9563 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "8.0.0"; } -const char* grpc_g_stands_for(void) { return "ganges"; } +const char* grpc_g_stands_for(void) { return "game"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 71ddc6e5d71..041956ecf5c 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.24.0-dev"; } +grpc::string Version() { return "1.25.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index f732af32ec3..6d540155d9a 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "2.24.0.0"; + public const string CurrentAssemblyFileVersion = "2.25.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.24.0-dev"; + public const string CurrentVersion = "2.25.0-dev"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index d45d3b1b0eb..df109183253 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.24.0-dev + 2.25.0-dev 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 9fade5c1dd0..4e689754aca 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.24.0-dev +set VERSION=2.25.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index 67faaeb2567..9103c785f85 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.24.0-dev' + v = '1.25.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index f65086b6df5..30a07f1647d 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.24.0-dev' + v = '1.25.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/version.h b/src/objective-c/GRPCClient/version.h index fc6982c55d6..01ba728003d 100644 --- a/src/objective-c/GRPCClient/version.h +++ b/src/objective-c/GRPCClient/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.25.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 9182189f4c8..54d05af8226 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.25.0-dev" #define GRPC_C_VERSION_STRING @"8.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index 6da1fd77d65..f4af57682ab 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.24.0", + "version": "1.25.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 000508dd3f8..82863121990 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.24.0dev" +#define PHP_GRPC_VERSION "1.25.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index ff1b1a17d25..cf9055adb49 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.24.0.dev0""" +__version__ = """1.25.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index e0280abaa7c..3902f3fecac 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 93a448ecb64..61a651d45d3 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 2a1aa0c9359..7e9703c3c93 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 93c28ba9fac..0c82a4c7768 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index a2b5a814b52..307d9ba7245 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 937e57da02f..b6a2dc2ba21 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index a1e43215b09..4656e5af94a 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 43f08a0c87b..40744531d72 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.24.0.dev' + VERSION = '1.25.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index b08edb08478..4d67f9c6302 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.24.0.dev' + VERSION = '1.25.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 184a0a9dda6..716add95195 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 168e6c8d770..12435d0edb9 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.24.0-dev +PROJECT_NUMBER = 1.25.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 diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3b7af742baa..14e5599bc17 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.24.0-dev +PROJECT_NUMBER = 1.25.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 From db861a254623228468c736a17b13af1d4afdc112 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 9 Sep 2019 12:07:00 -0700 Subject: [PATCH 146/176] Coalesced arena allocs in callback unary C++ code. --- .../grpcpp/impl/codegen/client_callback_impl.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h index 37746ef5ce4..34c738ac1e6 100644 --- a/include/grpcpp/impl/codegen/client_callback_impl.h +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -72,11 +72,16 @@ class CallbackUnaryCallImpl { grpc::internal::CallOpClientSendClose, grpc::internal::CallOpClientRecvStatus>; - auto* ops = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(FullCallOpSet))) FullCallOpSet; - - auto* tag = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(grpc::internal::CallbackWithStatusTag))) + struct OpSetAndTag { + FullCallOpSet opset; + grpc::internal::CallbackWithStatusTag tag; + }; + const size_t alloc_sz = sizeof(OpSetAndTag); + auto* const alloced = static_cast( + ::grpc::g_core_codegen_interface->grpc_call_arena_alloc(call.call(), + alloc_sz)); + auto* ops = new (&alloced->opset) FullCallOpSet; + auto* tag = new (&alloced->tag) grpc::internal::CallbackWithStatusTag(call.call(), on_completion, ops); // TODO(vjpai): Unify code with sync API as much as possible From 300077aac1f12dfa8365494f0a82194ccd8cb0b4 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 10 Sep 2019 15:26:33 -0700 Subject: [PATCH 147/176] Update upb to HEAD --- bazel/grpc_deps.bzl | 6 +++--- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index f904f42f8c9..01b9ffc9a0e 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -201,9 +201,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "95150db57b51b65f3422c38953956e0f786945d842d76f8ab685fbcd93ab5caa", - strip_prefix = "upb-931bbecbd3230ae7f22efa5d203639facc47f719", - url = "https://github.com/protocolbuffers/upb/archive/931bbecbd3230ae7f22efa5d203639facc47f719.tar.gz", + sha256 = "61d0417abd60e65ed589c9deee7c124fe76a4106831f6ad39464e1525cef1454", + strip_prefix = "upb-9effcbcb27f0a665f9f345030188c0b291e32482", + url = "https://github.com/protocolbuffers/upb/archive/9effcbcb27f0a665f9f345030188c0b291e32482.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/third_party/upb b/third_party/upb index 931bbecbd32..9effcbcb27f 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit 931bbecbd3230ae7f22efa5d203639facc47f719 +Subproject commit 9effcbcb27f0a665f9f345030188c0b291e32482 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index bd98e5c479a..e49ddc8950e 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -41,7 +41,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) 94324803a497c8f76dbc78df393ef629d3a9f3c3 third_party/udpa (heads/master) - 931bbecbd3230ae7f22efa5d203639facc47f719 third_party/upb (heads/master) + 9effcbcb27f0a665f9f345030188c0b291e32482 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 711a4147ae1cdc0568ef4179dfc3958a59e241dc Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 11 Sep 2019 01:21:47 +0200 Subject: [PATCH 148/176] Removing all warning flags and Werror for now. --- Makefile | 18 +++++++++--------- build.yaml | 17 +++++------------ grpc.gyp | 36 ------------------------------------ 3 files changed, 14 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index 5189f704297..e1f7480a54c 100644 --- a/Makefile +++ b/Makefile @@ -353,8 +353,8 @@ ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif -CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated +CFLAGS += -g +CPPFLAGS += -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g @@ -553,7 +553,7 @@ OPENSSL_LIBS = ssl crypto endif OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) -BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS) +BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(CFLAGS) -g -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS) ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) CARES_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/c-ares.c -lcares $(LDFLAGS) @@ -7901,7 +7901,7 @@ LIBBORINGSSL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(LIBBORINGSSL_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(LIBBORINGSSL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(LIBBORINGSSL_OBJS): CFLAGS += -g $(LIBDIR)/$(CONFIG)/libboringssl.a: $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBBORINGSSL_OBJS) $(E) "[AR] Creating $@" @@ -7931,7 +7931,7 @@ LIBBORINGSSL_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(LIBBORINGSSL_TEST_UTIL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(LIBBORINGSSL_TEST_UTIL_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(LIBBORINGSSL_TEST_UTIL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(LIBBORINGSSL_TEST_UTIL_OBJS): CFLAGS += -g ifeq ($(NO_PROTOBUF),true) @@ -8034,7 +8034,7 @@ PUBLIC_HEADERS_C += \ LIBZ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBZ_SRC)))) -$(LIBZ_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden +$(LIBZ_OBJS): CFLAGS += -fvisibility=hidden $(LIBDIR)/$(CONFIG)/libz.a: $(LIBZ_OBJS) $(E) "[AR] Creating $@" @@ -8110,7 +8110,7 @@ PUBLIC_HEADERS_C += \ LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC)))) $(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares -fvisibility=hidden -D_GNU_SOURCE $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) $(if $(subst FreeBSD,,$(SYSTEM)),,-Ithird_party/cares/config_freebsd) $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst OpenBSD,,$(SYSTEM)),,-Ithird_party/cares/config_openbsd) -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,) -$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32) $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,) +$(LIBARES_OBJS): CFLAGS += -g $(LIBDIR)/$(CONFIG)/libares.a: $(LIBARES_OBJS) $(E) "[AR] Creating $@" @@ -20108,7 +20108,7 @@ endif $(BORINGSSL_SSL_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(BORINGSSL_SSL_TEST_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(BORINGSSL_SSL_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(BORINGSSL_SSL_TEST_OBJS): CFLAGS += -g $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/gtest_main.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a $(OBJDIR)/$(CONFIG)/third_party/boringssl/ssl/span_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a @@ -20200,7 +20200,7 @@ endif $(BORINGSSL_CRYPTO_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(BORINGSSL_CRYPTO_TEST_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(BORINGSSL_CRYPTO_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(BORINGSSL_CRYPTO_TEST_OBJS): CFLAGS += -g $(OBJDIR)/$(CONFIG)/src/boringssl/crypto_test_data.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/asn1/asn1_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a diff --git a/build.yaml b/build.yaml index cbdbf8a60bc..d231dc41f16 100644 --- a/build.yaml +++ b/build.yaml @@ -6174,8 +6174,7 @@ configs: UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=test/core/util/ubsan_suppressions.txt defaults: ares: - CFLAGS: -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32) - $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,) + CFLAGS: -g CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares -fvisibility=hidden -D_GNU_SOURCE $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) $(if $(subst FreeBSD,,$(SYSTEM)),,-Ithird_party/cares/config_freebsd) $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) @@ -6184,9 +6183,7 @@ defaults: benchmark: CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX boringssl: - CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas - -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough - $(NO_W_EXTRA_SEMI) + CFLAGS: -g CPPFLAGS: -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX CXXFLAGS: -fno-rtti -fno-exceptions @@ -6196,16 +6193,12 @@ defaults: $(W_NO_MAYBE_UNINITIALIZED) -fvisibility=hidden CXXFLAGS: $(W_NO_CXX14_COMPAT) global: + CFLAGS: -g COREFLAGS: -fno-rtti -fno-exceptions - CPPFLAGS: -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long - -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow - -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers - -Wno-maybe-uninitialized -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated - CXXFLAGS: -Wnon-virtual-dtor + CPPFLAGS: -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated LDFLAGS: -g zlib: - CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration - -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden + CFLAGS: -fvisibility=hidden openssl_fallback: base_uri: https://openssl.org/source/old/1.0.2/ extraction_dir: openssl-1.0.2f diff --git a/grpc.gyp b/grpc.gyp index 3b86e613131..9ef4488689a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -54,18 +54,6 @@ '-g', '-Wall', '-Wextra', - '-Werror', - '$(W_NO_UNKNOWN_WARNING_OPTION)', - '-Wno-long-long', - '-Wno-unused-parameter', - '-Wno-deprecated-declarations', - '-Wno-sign-conversion', - '-Wno-shadow', - '-Wno-conversion', - '-Wno-implicit-fallthrough', - '-Wno-sign-compare', - '-Wno-missing-field-initializers', - '-Wno-maybe-uninitialized', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', @@ -142,18 +130,6 @@ '-g', '-Wall', '-Wextra', - '-Werror', - '$(W_NO_UNKNOWN_WARNING_OPTION)', - '-Wno-long-long', - '-Wno-unused-parameter', - '-Wno-deprecated-declarations', - '-Wno-sign-conversion', - '-Wno-shadow', - '-Wno-conversion', - '-Wno-implicit-fallthrough', - '-Wno-sign-compare', - '-Wno-missing-field-initializers', - '-Wno-maybe-uninitialized', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', @@ -162,18 +138,6 @@ '-g', '-Wall', '-Wextra', - '-Werror', - '$(W_NO_UNKNOWN_WARNING_OPTION)', - '-Wno-long-long', - '-Wno-unused-parameter', - '-Wno-deprecated-declarations', - '-Wno-sign-conversion', - '-Wno-shadow', - '-Wno-conversion', - '-Wno-implicit-fallthrough', - '-Wno-sign-compare', - '-Wno-missing-field-initializers', - '-Wno-maybe-uninitialized', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', From 6f5e358da7f3ba2de1dbfeafa7116adf093c073b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 10 Sep 2019 16:46:06 -0700 Subject: [PATCH 149/176] Rename filter functions to be able to uniquely identify them --- .../grpclb/client_load_reporting_filter.cc | 28 ++++++------- .../ext/filters/deadline/deadline_filter.cc | 40 +++++++++---------- .../filters/http/client/http_client_filter.cc | 24 +++++------ .../filters/http/client_authority_filter.cc | 28 ++++++------- .../message_compress_filter.cc | 24 +++++------ .../ext/filters/max_age/max_age_filter.cc | 24 +++++------ .../message_size/message_size_filter.cc | 28 ++++++------- .../workaround_cronet_compression_filter.cc | 29 +++++++------- .../security/transport/client_auth_filter.cc | 34 ++++++++-------- .../security/transport/server_auth_filter.cc | 28 ++++++------- src/core/lib/surface/lame_client.cc | 24 +++++------ 11 files changed, 156 insertions(+), 155 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc index 3057b26d315..09dd75b041f 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc @@ -30,12 +30,12 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/profiling/timers.h" -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* clr_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void clr_destroy_channel_elem(grpc_channel_element* elem) {} namespace { @@ -71,16 +71,16 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { GRPC_ERROR_REF(error)); } -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* clr_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { GPR_ASSERT(args->context != nullptr); new (elem->call_data) call_data(); return GRPC_ERROR_NONE; } -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void clr_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); if (calld->client_stats != nullptr) { // Record call finished, optionally setting client_failed_to_send and @@ -92,7 +92,7 @@ static void destroy_call_elem(grpc_call_element* elem, calld->~call_data(); } -static void start_transport_stream_op_batch( +static void clr_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); GPR_TIMER_SCOPE("clr_start_transport_stream_op_batch", 0); @@ -142,14 +142,14 @@ static void start_transport_stream_op_batch( } const grpc_channel_filter grpc_client_load_reporting_filter = { - start_transport_stream_op_batch, + clr_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + clr_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + clr_destroy_call_elem, 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, + clr_init_channel_elem, + clr_destroy_channel_elem, grpc_channel_next_get_info, "client_load_reporting"}; diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index 20a2953e5ff..d6c2b8e2588 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -233,14 +233,14 @@ void grpc_deadline_state_client_start_transport_stream_op_batch( // // Constructor for channel_data. Used for both client and server filters. -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* deadline_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); return GRPC_ERROR_NONE; } // Destructor for channel_data. Used for both client and server filters. -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void deadline_destroy_channel_elem(grpc_channel_element* elem) {} // Call data used for both client and server filter. typedef struct base_call_data { @@ -260,24 +260,24 @@ typedef struct server_call_data { } server_call_data; // Constructor for call_data. Used for both client and server filters. -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* deadline_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { new (elem->call_data) grpc_deadline_state( elem, args->call_stack, args->call_combiner, args->deadline); return GRPC_ERROR_NONE; } // Destructor for call_data. Used for both client and server filters. -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void deadline_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { grpc_deadline_state* deadline_state = static_cast(elem->call_data); deadline_state->~grpc_deadline_state(); } // Method for starting a call op for client filter. -static void client_start_transport_stream_op_batch( +static void deadline_client_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { grpc_deadline_state_client_start_transport_stream_op_batch(elem, op); // Chain to next filter. @@ -295,7 +295,7 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { } // Method for starting a call op for server filter. -static void server_start_transport_stream_op_batch( +static void deadline_server_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { server_call_data* calld = static_cast(elem->call_data); if (op->cancel_stream) { @@ -329,29 +329,29 @@ static void server_start_transport_stream_op_batch( } const grpc_channel_filter grpc_client_deadline_filter = { - client_start_transport_stream_op_batch, + deadline_client_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(base_call_data), - init_call_elem, + deadline_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + deadline_destroy_call_elem, 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, + deadline_init_channel_elem, + deadline_destroy_channel_elem, grpc_channel_next_get_info, "deadline", }; const grpc_channel_filter grpc_server_deadline_filter = { - server_start_transport_stream_op_batch, + deadline_server_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(server_call_data), - init_call_elem, + deadline_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + deadline_destroy_call_elem, 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, + deadline_init_channel_elem, + deadline_destroy_channel_elem, grpc_channel_next_get_info, "deadline", }; diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index b16d26b1f24..1793e8106e4 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -465,16 +465,16 @@ done: } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* hc_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void hc_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } @@ -566,8 +566,8 @@ static grpc_core::ManagedMemorySlice user_agent_from_args( } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* hc_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); GPR_ASSERT(!args->is_last); GPR_ASSERT(args->optional_transport != nullptr); @@ -582,7 +582,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void hc_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); GRPC_MDELEM_UNREF(chand->user_agent); } @@ -591,11 +591,11 @@ const grpc_channel_filter grpc_http_client_filter = { hc_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + hc_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + hc_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + hc_init_channel_elem, + hc_destroy_channel_elem, grpc_channel_next_get_info, "http-client"}; diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index dc8beb986fc..4d5d6233f8c 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -48,7 +48,7 @@ struct channel_data { grpc_mdelem default_authority_mdelem; }; -void authority_start_transport_stream_op_batch( +void client_authority_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); @@ -72,21 +72,21 @@ void authority_start_transport_stream_op_batch( } /* Constructor for call_data */ -grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +grpc_error* client_authority_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { call_data* calld = static_cast(elem->call_data); calld->call_combiner = args->call_combiner; return GRPC_ERROR_NONE; } /* Destructor for call_data */ -void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) {} +void client_authority_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} /* Constructor for channel_data */ -grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +grpc_error* client_authority_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); const grpc_arg* default_authority_arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_DEFAULT_AUTHORITY); @@ -110,7 +110,7 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -void destroy_channel_elem(grpc_channel_element* elem) { +void client_authority_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); grpc_slice_unref_internal(chand->default_authority); GRPC_MDELEM_UNREF(chand->default_authority_mdelem); @@ -118,15 +118,15 @@ void destroy_channel_elem(grpc_channel_element* elem) { } // namespace const grpc_channel_filter grpc_client_authority_filter = { - authority_start_transport_stream_op_batch, + client_authority_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + client_authority_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + client_authority_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + client_authority_init_channel_elem, + client_authority_destroy_channel_elem, grpc_channel_next_get_info, "authority"}; diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index 9ef8e6a1990..2f4854e43ec 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -441,23 +441,23 @@ static void compress_start_transport_stream_op_batch( } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* compress_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void compress_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* compress_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* channeld = static_cast(elem->channel_data); // Get the enabled and the default algorithms from channel args. channeld->enabled_compression_algorithms_bitset = @@ -487,17 +487,17 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void compress_destroy_channel_elem(grpc_channel_element* elem) {} const grpc_channel_filter grpc_message_compress_filter = { compress_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + compress_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + compress_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + compress_init_channel_elem, + compress_destroy_channel_elem, grpc_channel_next_get_info, "message_compress"}; diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index 96f2f02056f..770343d9b1f 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -395,24 +395,24 @@ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) { } /* Constructor for call_data. */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* max_age_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { channel_data* chand = static_cast(elem->channel_data); increase_call_count(chand); return GRPC_ERROR_NONE; } /* Destructor for call_data. */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void max_age_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { channel_data* chand = static_cast(elem->channel_data); decrease_call_count(chand); } /* Constructor for channel_data. */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* max_age_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); gpr_mu_init(&chand->max_age_timer_mu); chand->max_age_timer_pending = false; @@ -499,7 +499,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel_data. */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void max_age_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); gpr_mu_destroy(&chand->max_age_timer_mu); } @@ -508,12 +508,12 @@ const grpc_channel_filter grpc_max_age_filter = { grpc_call_next_op, grpc_channel_next_op, 0, /* sizeof_call_data */ - init_call_elem, + max_age_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + max_age_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + max_age_init_channel_elem, + max_age_destroy_channel_elem, grpc_channel_next_get_info, "max_age"}; diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index 8e93d11c9c0..df447c226b1 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -238,7 +238,7 @@ static void recv_trailing_metadata_ready(void* user_data, grpc_error* error) { } // Start transport stream op. -static void start_transport_stream_op_batch( +static void message_size_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { call_data* calld = static_cast(elem->call_data); // Check max send message size. @@ -277,17 +277,17 @@ static void start_transport_stream_op_batch( } // Constructor for call_data. -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* message_size_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { channel_data* chand = static_cast(elem->channel_data); new (elem->call_data) call_data(elem, *chand, *args); return GRPC_ERROR_NONE; } // Destructor for call_data. -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void message_size_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = (call_data*)elem->call_data; calld->~call_data(); } @@ -325,8 +325,8 @@ grpc_core::MessageSizeParsedConfig::message_size_limits get_message_size_limits( } // Constructor for channel_data. -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* message_size_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); channel_data* chand = static_cast(elem->channel_data); new (chand) channel_data(); @@ -355,21 +355,21 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } // Destructor for channel_data. -static void destroy_channel_elem(grpc_channel_element* elem) { +static void message_size_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); chand->~channel_data(); } const grpc_channel_filter grpc_message_size_filter = { - start_transport_stream_op_batch, + message_size_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + message_size_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + message_size_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + message_size_init_channel_elem, + message_size_destroy_channel_elem, grpc_channel_next_get_info, "message_size"}; diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc index c7070d4d9ba..0426e008e40 100644 --- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc @@ -75,7 +75,7 @@ static void recv_initial_metadata_ready(void* user_data, grpc_error* error) { } // Start transport stream op. -static void start_transport_stream_op_batch( +static void cronet_compression_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { call_data* calld = static_cast(elem->call_data); @@ -104,8 +104,8 @@ static void start_transport_stream_op_batch( } // Constructor for call_data. -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* cronet_compression_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { call_data* calld = static_cast(elem->call_data); calld->next_recv_initial_metadata_ready = nullptr; calld->workaround_active = false; @@ -116,18 +116,19 @@ static grpc_error* init_call_elem(grpc_call_element* elem, } // Destructor for call_data. -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) {} +static void cronet_compression_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) {} // Constructor for channel_data. -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* cronet_compression_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } // Destructor for channel_data. -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void cronet_compression_destroy_channel_elem( + grpc_channel_element* elem) {} // Parse the user agent static bool parse_user_agent(grpc_mdelem md) { @@ -169,15 +170,15 @@ static bool parse_user_agent(grpc_mdelem md) { } const grpc_channel_filter grpc_workaround_cronet_compression_filter = { - start_transport_stream_op_batch, + cronet_compression_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + cronet_compression_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + cronet_compression_destroy_call_elem, 0, - init_channel_elem, - destroy_channel_elem, + cronet_compression_init_channel_elem, + cronet_compression_destroy_channel_elem, grpc_channel_next_get_info, "workaround_cronet_compression"}; diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 33343d276eb..282ec5c97a9 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -324,7 +324,7 @@ static void cancel_check_call_host(void* arg, grpc_error* error) { } } -static void auth_start_transport_stream_op_batch( +static void client_auth_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { GPR_TIMER_SCOPE("auth_start_transport_stream_op_batch", 0); @@ -369,29 +369,29 @@ static void auth_start_transport_stream_op_batch( } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* client_auth_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } -static void set_pollset_or_pollset_set(grpc_call_element* elem, - grpc_polling_entity* pollent) { +static void client_auth_set_pollset_or_pollset_set( + grpc_call_element* elem, grpc_polling_entity* pollent) { call_data* calld = static_cast(elem->call_data); calld->pollent = pollent; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void client_auth_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->destroy(); } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* client_auth_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { /* The first and the last filters tend to be implemented differently to handle the case that there's no 'next' filter to call on the up or down path */ @@ -414,20 +414,20 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void client_auth_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); chand->~channel_data(); } const grpc_channel_filter grpc_client_auth_filter = { - auth_start_transport_stream_op_batch, + client_auth_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, - set_pollset_or_pollset_set, - destroy_call_elem, + client_auth_init_call_elem, + client_auth_set_pollset_or_pollset_set, + client_auth_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + client_auth_init_channel_elem, + client_auth_destroy_channel_elem, grpc_channel_next_get_info, "client-auth"}; diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index 43509e6c61b..341e0e4a86a 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -257,7 +257,7 @@ static void recv_trailing_metadata_ready(void* user_data, grpc_error* err) { GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready, err); } -static void auth_start_transport_stream_op_batch( +static void server_auth_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); if (batch->recv_initial_metadata) { @@ -278,23 +278,23 @@ static void auth_start_transport_stream_op_batch( } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* server_auth_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void server_auth_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* server_auth_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); grpc_auth_context* auth_context = grpc_find_auth_context_in_args(args->channel_args); @@ -306,20 +306,20 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void server_auth_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); chand->~channel_data(); } const grpc_channel_filter grpc_server_auth_filter = { - auth_start_transport_stream_op_batch, + server_auth_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + server_auth_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + server_auth_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + server_auth_init_channel_elem, + server_auth_destroy_channel_elem, grpc_channel_next_get_info, "server-auth"}; diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index 10a27924073..9208160938e 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -115,27 +115,27 @@ static void lame_start_transport_op(grpc_channel_element* elem, } } -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* lame_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { CallData* calld = static_cast(elem->call_data); calld->call_combiner = args->call_combiner; return GRPC_ERROR_NONE; } -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* then_schedule_closure) { +static void lame_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* then_schedule_closure) { GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE); } -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* lame_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { GPR_ASSERT(args->is_first); GPR_ASSERT(args->is_last); return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void lame_destroy_channel_elem(grpc_channel_element* elem) {} } // namespace @@ -145,12 +145,12 @@ const grpc_channel_filter grpc_lame_filter = { grpc_core::lame_start_transport_stream_op_batch, grpc_core::lame_start_transport_op, sizeof(grpc_core::CallData), - grpc_core::init_call_elem, + grpc_core::lame_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - grpc_core::destroy_call_elem, + grpc_core::lame_destroy_call_elem, sizeof(grpc_core::ChannelData), - grpc_core::init_channel_elem, - grpc_core::destroy_channel_elem, + grpc_core::lame_init_channel_elem, + grpc_core::lame_destroy_channel_elem, grpc_core::lame_get_channel_info, "lame-client", }; From 5abf2e5095c9fe28ae1d562970326664249bd743 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 11 Sep 2019 09:53:14 +0800 Subject: [PATCH 150/176] Fix: add a blank line before the subtitle --- examples/python/data_transmission/README.en.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md index fb834ab80c9..659ee1b93fb 100644 --- a/examples/python/data_transmission/README.en.md +++ b/examples/python/data_transmission/README.en.md @@ -9,6 +9,7 @@ Four ways of data transmission when gRPC is used in Python. [Offical Guide]( Date: Wed, 11 Sep 2019 10:20:23 +0800 Subject: [PATCH 151/176] Fix: add copyright headers in `client.py` --- examples/python/data_transmission/client.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index 0a9559ed79a..dee25b3a2ab 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -1,3 +1,18 @@ +# Copyright 2019 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. +"""The example of four ways of data transmission using gRPC in Python.""" + import time import grpc From 5c0fd4b4e6b535d3f5fc93b88dde8a38461d85bb Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 11 Sep 2019 10:23:31 +0800 Subject: [PATCH 152/176] Fix: add copyright headers in `demo.proto` --- examples/python/data_transmission/demo.proto | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/python/data_transmission/demo.proto b/examples/python/data_transmission/demo.proto index d3d96b523d1..b2d956c89d5 100644 --- a/examples/python/data_transmission/demo.proto +++ b/examples/python/data_transmission/demo.proto @@ -1,3 +1,17 @@ +// Copyright 2019 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. + // 语法版本声明,必须放在非注释的第一行 // Syntax version declaration. Must be placed on the first line of non-commentary. From c5d55ee64f48db1334e973a7f9290324c2c83175 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 11 Sep 2019 10:27:15 +0800 Subject: [PATCH 153/176] Fix: add copyright headers in `server.py` --- examples/python/data_transmission/server.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 288c561382b..f550b9b7bd2 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,3 +1,18 @@ +# Copyright 2019 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. +"""The example of four ways of data transmission using gRPC in Python.""" + from threading import Thread from concurrent import futures From 9e0eb19ca4cef2aaa61236dcb9a042092166da86 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 9 Sep 2019 14:54:36 +0200 Subject: [PATCH 154/176] generate separate sponge target for each test suite --- tools/run_tests/python_utils/report_utils.py | 20 +++++++++++++++----- tools/run_tests/run_tests.py | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index 8d8dedb929b..707f9ef656c 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -49,12 +49,22 @@ def render_junit_xml_report(resultset, report_file, suite_package='grpc', suite_name='tests', - replace_dots=True): + replace_dots=True, + split_by_target=False): """Generate JUnit-like XML report.""" - tree = new_junit_xml_tree() - append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', - replace_dots) - create_xml_report_file(tree, report_file) + if not split_by_target: + tree = new_junit_xml_tree() + append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', + replace_dots) + create_xml_report_file(tree, report_file) + else: + for shortname, results in six.iteritems(resultset): + one_result = { shortname: results } + tree = new_junit_xml_tree() + append_junit_xml_results(tree, one_result, '%s_%s' % (suite_package, shortname), '%s_%s' % (suite_name, shortname), '1', + replace_dots) + per_suite_report_file = os.path.join(os.path.dirname(report_file), shortname, os.path.basename(report_file)) + create_xml_report_file(tree, per_suite_report_file) def create_xml_report_file(tree, report_file): diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 1ff37ca85af..cb26d0ab772 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1880,7 +1880,7 @@ def _build_and_run(check_cancelled, upload_extra_fields) if xml_report and resultset: report_utils.render_junit_xml_report( - resultset, xml_report, suite_name=args.report_suite_name) + resultset, xml_report, suite_name=args.report_suite_name, split_by_target=True) number_failures, _ = jobset.run( post_tests_steps, From 42da89171442ce6eadcd6d1cd00844f484bd0b4f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 10:01:02 +0200 Subject: [PATCH 155/176] include run_tests in target name --- tools/run_tests/run_tests_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 80c0a7d6455..5d38cb4c711 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -52,14 +52,14 @@ def _safe_report_name(name): def _report_filename(name): """Generates report file name with directory structure that leads to better presentation by internal CI""" # 'sponge_log.xml' suffix must be there for results to get recognized by kokoro. - return '%s/%s' % (_safe_report_name(name), 'sponge_log.xml') + return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.xml') def _report_logfilename(name): """Generates log file name that corresponds to name generated by _report_filename""" # 'sponge_log.log' suffix must be there for log to get recognized as "target log" # for the corresponding 'sponge_log.xml' report. - return '%s/%s' % (_safe_report_name(name), 'sponge_log.log') + return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.log') def _docker_jobspec(name, From 6b44344161d51c1018a5f1acf6eb39122f4251ef Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 10:04:34 +0200 Subject: [PATCH 156/176] use run_tests_invocations instead of aggregate tests --- tools/run_tests/run_tests_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 5d38cb4c711..a517e261056 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -604,8 +604,8 @@ if __name__ == "__main__": resultset.update(skipped_results) report_utils.render_junit_xml_report( resultset, - _report_filename('aggregate_tests'), - suite_name='aggregate_tests') + _report_filename('run_tests_invocations'), + suite_name='run_tests_invocations') if num_failures == 0: jobset.message( From 243b43d6cc596f09b72af19026e791dec4406a0c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 18:36:21 +0200 Subject: [PATCH 157/176] better run_tests prefix --- tools/run_tests/run_tests_matrix.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index a517e261056..e0f070ffed8 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -52,14 +52,14 @@ def _safe_report_name(name): def _report_filename(name): """Generates report file name with directory structure that leads to better presentation by internal CI""" # 'sponge_log.xml' suffix must be there for results to get recognized by kokoro. - return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.xml') + return '%s/%s' % (_safe_report_name(name), 'sponge_log.xml') def _report_logfilename(name): """Generates log file name that corresponds to name generated by _report_filename""" # 'sponge_log.log' suffix must be there for log to get recognized as "target log" # for the corresponding 'sponge_log.xml' report. - return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.log') + return '%s/%s' % (_safe_report_name(name), 'sponge_log.log') def _docker_jobspec(name, @@ -75,7 +75,7 @@ def _docker_jobspec(name, 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t', '-j', str(inner_jobs), '-x', - _report_filename(name), '--report_suite_name', + 'run_tests/%s' % _report_filename(name), '--report_suite_name', '%s' % _safe_report_name(name) ] + runtests_args, environ=runtests_envs, @@ -103,7 +103,7 @@ def _workspace_jobspec(name, 'bash', 'tools/run_tests/helper_scripts/run_tests_in_workspace.sh', '-t', '-j', str(inner_jobs), '-x', - '../%s' % _report_filename(name), '--report_suite_name', + '../run_tests/%s' % _report_filename(name), '--report_suite_name', '%s' % _safe_report_name(name) ] + runtests_args, environ=env, From 218e7b0c54ea121c2c90f105c14d538525b243ae Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 18:44:56 +0200 Subject: [PATCH 158/176] split run_tests_invocations to separate targets --- tools/run_tests/run_tests_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index e0f070ffed8..0321ea2c455 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -605,7 +605,7 @@ if __name__ == "__main__": report_utils.render_junit_xml_report( resultset, _report_filename('run_tests_invocations'), - suite_name='run_tests_invocations') + suite_name='run_tests_invocations', split_by_target=True) if num_failures == 0: jobset.message( From 902094f9f2a4e91ba06cc40b6a45e5cb55d54663 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 20:28:07 +0200 Subject: [PATCH 159/176] rename to run_tests_matrix_jobs --- tools/run_tests/run_tests_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 0321ea2c455..36df41b4abd 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -604,8 +604,8 @@ if __name__ == "__main__": resultset.update(skipped_results) report_utils.render_junit_xml_report( resultset, - _report_filename('run_tests_invocations'), - suite_name='run_tests_invocations', split_by_target=True) + _report_filename('run_tests_matrix_jobs'), + suite_name='run_tests_matrix_jobs', split_by_target=True) if num_failures == 0: jobset.message( From 11222b78c24ba73e32032d5fe068479a0173c6ea Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 09:27:59 +0200 Subject: [PATCH 160/176] only use multi_target report for selected languages --- tools/run_tests/python_utils/report_utils.py | 6 +++-- tools/run_tests/run_tests.py | 10 +++++++- tools/run_tests/run_tests_matrix.py | 26 ++++++++++---------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index 707f9ef656c..714d9cf0605 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -50,14 +50,16 @@ def render_junit_xml_report(resultset, suite_package='grpc', suite_name='tests', replace_dots=True, - split_by_target=False): + multi_target=False): """Generate JUnit-like XML report.""" - if not split_by_target: + if not multi_targets: tree = new_junit_xml_tree() append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', replace_dots) create_xml_report_file(tree, report_file) else: + # To have each test result displayed as a separate target by the Resultstore/Sponge UI, + # we generate a separate XML report file for each test result for shortname, results in six.iteritems(resultset): one_result = { shortname: results } tree = new_junit_xml_tree() diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index cb26d0ab772..8b2dfad2ef0 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1472,6 +1472,14 @@ argp.add_argument( default='tests', type=str, help='Test suite name to use in generated JUnit XML report') +argp.add_argument( + '--report_multi_target', + default=False, + const=True, + action='store_const', + help= + 'Generate separate XML report for each test job (Looks better in UIs).' +) argp.add_argument( '--quiet_success', default=False, @@ -1880,7 +1888,7 @@ def _build_and_run(check_cancelled, upload_extra_fields) if xml_report and resultset: report_utils.render_junit_xml_report( - resultset, xml_report, suite_name=args.report_suite_name, split_by_target=True) + resultset, xml_report, suite_name=args.report_suite_name, multi_target=args.report_multi_target) number_failures, _ = jobset.run( post_tests_steps, diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 36df41b4abd..2948f415559 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -175,7 +175,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux'], labels=['basictests'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on linux only @@ -184,7 +184,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on all platforms. @@ -193,7 +193,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests', 'corelang'], - extra_args=extra_args, + extra_args=extra_args, # don't use multi_target report because C has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -203,7 +203,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # C# tests on .NET core test_jobs += _generate_jobs( @@ -213,7 +213,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): arch='default', compiler='coreclr', labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) test_jobs += _generate_jobs( @@ -222,7 +222,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): platforms=['linux', 'macos', 'windows'], iomgr_platforms=['native', 'gevent'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on linux and mac. @@ -231,7 +231,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests', 'corelang'], - extra_args=extra_args, + extra_args=extra_args, # don't use multi_target report because C++ has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -240,7 +240,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on mac only. @@ -249,7 +249,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['opt'], platforms=['macos'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs, timeout_seconds=_OBJC_RUNTESTS_TIMEOUT) @@ -400,7 +400,7 @@ def _create_portability_test_jobs(extra_args=[], arch='default', compiler='python_alpine', labels=['portability', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # TODO(jtattermusch): a large portion of the libuv tests is failing, @@ -605,16 +605,16 @@ if __name__ == "__main__": report_utils.render_junit_xml_report( resultset, _report_filename('run_tests_matrix_jobs'), - suite_name='run_tests_matrix_jobs', split_by_target=True) + suite_name='run_tests_matrix_jobs', multi_target=True) if num_failures == 0: jobset.message( 'SUCCESS', - 'All run_tests.py instance finished successfully.', + 'All run_tests.py instances finished successfully.', do_newline=True) else: jobset.message( 'FAILED', - 'Some run_tests.py instance have failed.', + 'Some run_tests.py instances have failed.', do_newline=True) sys.exit(1) From 2381d693b82e0a6c9d350fe959fddbfcea9c6333 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 10:03:36 +0200 Subject: [PATCH 161/176] preserve the run_tests.py logs in sponge --- tools/run_tests/run_tests_matrix.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 2948f415559..f7ce0ae9664 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -43,6 +43,8 @@ _OBJC_RUNTESTS_TIMEOUT = 90 * 60 # Number of jobs assigned to each run_tests.py instance _DEFAULT_INNER_JOBS = 2 +# Name of the top-level umbrella report that includes all the run_tests.py invocations +_MATRIX_REPORT_NAME = 'run_tests_matrix_jobs' def _safe_report_name(name): """Reports with '+' in target name won't show correctly in ResultStore""" @@ -55,11 +57,15 @@ def _report_filename(name): return '%s/%s' % (_safe_report_name(name), 'sponge_log.xml') -def _report_logfilename(name): - """Generates log file name that corresponds to name generated by _report_filename""" +def _matrix_job_logfilename(shortname_for_multi_target): + """Generate location for log file that will match the sponge_log.xml from the top-level matrix report.""" # 'sponge_log.log' suffix must be there for log to get recognized as "target log" # for the corresponding 'sponge_log.xml' report. - return '%s/%s' % (_safe_report_name(name), 'sponge_log.log') + # the shortname_for_multi_target component must be set to match the sponge_log.xml location + # because the top-level render_junit_xml_report is called with multi_target=True + s = '%s/%s/%s' % (_MATRIX_REPORT_NAME, shortname_for_multi_target, 'sponge_log.log') + print(s) + return s def _docker_jobspec(name, @@ -70,6 +76,7 @@ def _docker_jobspec(name, """Run a single instance of run_tests.py in a docker container""" if not timeout_seconds: timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT + shortname = 'run_tests_%s' % name test_job = jobset.JobSpec( cmdline=[ 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t', @@ -79,9 +86,9 @@ def _docker_jobspec(name, '%s' % _safe_report_name(name) ] + runtests_args, environ=runtests_envs, - shortname='run_tests_%s' % name, + shortname=shortname, timeout_seconds=timeout_seconds, - logfilename=_report_logfilename(name)) + logfilename=_matrix_job_logfilename(shortname)) return test_job @@ -96,6 +103,7 @@ def _workspace_jobspec(name, workspace_name = 'workspace_%s' % name if not timeout_seconds: timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT + shortname = 'run_tests_%s' % name env = {'WORKSPACE_NAME': workspace_name} env.update(runtests_envs) test_job = jobset.JobSpec( @@ -107,9 +115,9 @@ def _workspace_jobspec(name, '%s' % _safe_report_name(name) ] + runtests_args, environ=env, - shortname='run_tests_%s' % name, + shortname=shortname, timeout_seconds=timeout_seconds, - logfilename=_report_logfilename(name)) + logfilename=_matrix_job_logfilename(shortname)) return test_job @@ -604,8 +612,8 @@ if __name__ == "__main__": resultset.update(skipped_results) report_utils.render_junit_xml_report( resultset, - _report_filename('run_tests_matrix_jobs'), - suite_name='run_tests_matrix_jobs', multi_target=True) + _report_filename(_MATRIX_REPORT_NAME), + suite_name=_MATRIX_REPORT_NAME, multi_target=True) if num_failures == 0: jobset.message( From babb70705d76b7730808b13ccfaef1c1d6e75113 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 10:05:54 +0200 Subject: [PATCH 162/176] fixup in report_utils.py --- tools/run_tests/python_utils/report_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index 714d9cf0605..d9f6c5595d0 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -52,7 +52,7 @@ def render_junit_xml_report(resultset, replace_dots=True, multi_target=False): """Generate JUnit-like XML report.""" - if not multi_targets: + if not multi_target: tree = new_junit_xml_tree() append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', replace_dots) From 5207c148ff2dac593e8bfa3b671df4ba8509e1a6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 10:35:01 +0200 Subject: [PATCH 163/176] more readable test target ordering --- tools/run_tests/run_tests_matrix.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index f7ce0ae9664..f4e8f3cdc5f 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -44,7 +44,9 @@ _OBJC_RUNTESTS_TIMEOUT = 90 * 60 _DEFAULT_INNER_JOBS = 2 # Name of the top-level umbrella report that includes all the run_tests.py invocations -_MATRIX_REPORT_NAME = 'run_tests_matrix_jobs' +# Note that the starting letter 't' matters so that the targets are listed AFTER +# the per-test breakdown items that start with 'run_tests/' (it is more readable that way) +_MATRIX_REPORT_NAME = 'toplevel_run_tests_invocations' def _safe_report_name(name): """Reports with '+' in target name won't show correctly in ResultStore""" From f268db6f33cbde498aa5f8e37c01318a7e5eec8b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 04:56:10 -0400 Subject: [PATCH 164/176] yapf format code --- tools/run_tests/python_utils/report_utils.py | 16 ++++++++++------ tools/run_tests/run_tests.py | 8 +++++--- tools/run_tests/run_tests_matrix.py | 13 +++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index d9f6c5595d0..0ab346b6139 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -54,18 +54,22 @@ def render_junit_xml_report(resultset, """Generate JUnit-like XML report.""" if not multi_target: tree = new_junit_xml_tree() - append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', - replace_dots) + append_junit_xml_results(tree, resultset, suite_package, suite_name, + '1', replace_dots) create_xml_report_file(tree, report_file) else: # To have each test result displayed as a separate target by the Resultstore/Sponge UI, # we generate a separate XML report file for each test result for shortname, results in six.iteritems(resultset): - one_result = { shortname: results } + one_result = {shortname: results} tree = new_junit_xml_tree() - append_junit_xml_results(tree, one_result, '%s_%s' % (suite_package, shortname), '%s_%s' % (suite_name, shortname), '1', - replace_dots) - per_suite_report_file = os.path.join(os.path.dirname(report_file), shortname, os.path.basename(report_file)) + append_junit_xml_results(tree, one_result, '%s_%s' % (suite_package, + shortname), + '%s_%s' % (suite_name, + shortname), '1', replace_dots) + per_suite_report_file = os.path.join( + os.path.dirname(report_file), shortname, + os.path.basename(report_file)) create_xml_report_file(tree, per_suite_report_file) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 8b2dfad2ef0..a3708dc2b80 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1477,8 +1477,7 @@ argp.add_argument( default=False, const=True, action='store_const', - help= - 'Generate separate XML report for each test job (Looks better in UIs).' + help='Generate separate XML report for each test job (Looks better in UIs).' ) argp.add_argument( '--quiet_success', @@ -1888,7 +1887,10 @@ def _build_and_run(check_cancelled, upload_extra_fields) if xml_report and resultset: report_utils.render_junit_xml_report( - resultset, xml_report, suite_name=args.report_suite_name, multi_target=args.report_multi_target) + resultset, + xml_report, + suite_name=args.report_suite_name, + multi_target=args.report_multi_target) number_failures, _ = jobset.run( post_tests_steps, diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index f4e8f3cdc5f..105e5dcd906 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -48,6 +48,7 @@ _DEFAULT_INNER_JOBS = 2 # the per-test breakdown items that start with 'run_tests/' (it is more readable that way) _MATRIX_REPORT_NAME = 'toplevel_run_tests_invocations' + def _safe_report_name(name): """Reports with '+' in target name won't show correctly in ResultStore""" return name.replace('+', 'p') @@ -65,7 +66,8 @@ def _matrix_job_logfilename(shortname_for_multi_target): # for the corresponding 'sponge_log.xml' report. # the shortname_for_multi_target component must be set to match the sponge_log.xml location # because the top-level render_junit_xml_report is called with multi_target=True - s = '%s/%s/%s' % (_MATRIX_REPORT_NAME, shortname_for_multi_target, 'sponge_log.log') + s = '%s/%s/%s' % (_MATRIX_REPORT_NAME, shortname_for_multi_target, + 'sponge_log.log') print(s) return s @@ -203,7 +205,8 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests', 'corelang'], - extra_args=extra_args, # don't use multi_target report because C has too many test cases + extra_args= + extra_args, # don't use multi_target report because C has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -241,7 +244,8 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests', 'corelang'], - extra_args=extra_args, # don't use multi_target report because C++ has too many test cases + extra_args= + extra_args, # don't use multi_target report because C++ has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -615,7 +619,8 @@ if __name__ == "__main__": report_utils.render_junit_xml_report( resultset, _report_filename(_MATRIX_REPORT_NAME), - suite_name=_MATRIX_REPORT_NAME, multi_target=True) + suite_name=_MATRIX_REPORT_NAME, + multi_target=True) if num_failures == 0: jobset.message( From 38d6c74fb3e8ad7dc41555fcfd319fffacf6f48a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 14:47:33 +0200 Subject: [PATCH 165/176] remove node from singlevm e2e benchmarks --- tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh b/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh index 21f9d48ac41..710ca25a982 100755 --- a/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh +++ b/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh @@ -20,8 +20,10 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc # "smoketest" scenarios on a single VM (=no remote VM for running qps_workers) +# TODO(jtattermusch): add back "node" language once the scenarios are passing again +# See https://github.com/grpc/grpc/issues/20234 tools/run_tests/run_performance_tests.py \ - -l c++ csharp ruby java python go php7 php7_protobuf_c node \ + -l c++ csharp ruby java python go php7 php7_protobuf_c \ --netperf \ --category smoketest \ -u kbuilder \ From a44e6d76b74d977ad121f942202a087db853607f Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Wed, 11 Sep 2019 20:37:45 +0200 Subject: [PATCH 166/176] [Aio] Unary unary client call barebones implementation Implement the minimal stuff for making a unary call with the new experimental gRPC Python implementation for Asyncio, called Aio. What has been added: - Minimal iomgr code for performing the required network and timer calls. - Minimal Cython code implementing the channel, call and the callback context. - Minimal Python code that mimics the synchronous implementation but designed to be asynchronous. Testing considerations: Tests have to be executed using the `GRPC_ENABLE_FORK_SUPPORT=0` environment variable for skipping the fork handles installed by the core library. This is due to the usage of a syncrhonous server used as a fixture executed in another process. Co-authored-by: Manuel Miranda Co-authored-by: Mariano Anaya Co-authored-by: Zhanghui Mao Co-authored-by: Lidi Zheng --- AUTHORS | 1 + setup.py | 3 + src/python/grpcio/grpc/_cython/BUILD.bazel | 16 ++ .../grpc/_cython/_cygrpc/aio/call.pxd.pxi | 27 +++ .../grpc/_cython/_cygrpc/aio/call.pyx.pxi | 149 ++++++++++++++ .../_cygrpc/aio/callbackcontext.pxd.pxi | 20 ++ .../grpc/_cython/_cygrpc/aio/channel.pxd.pxi | 18 ++ .../grpc/_cython/_cygrpc/aio/channel.pyx.pxi | 30 +++ .../grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi | 25 +++ .../grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi | 37 ++++ .../_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi | 185 ++++++++++++++++++ .../_cygrpc/aio/iomgr/resolver.pxd.pxi | 23 +++ .../_cygrpc/aio/iomgr/resolver.pyx.pxi | 61 ++++++ .../_cython/_cygrpc/aio/iomgr/socket.pxd.pxi | 34 ++++ .../_cython/_cygrpc/aio/iomgr/socket.pyx.pxi | 134 +++++++++++++ .../_cython/_cygrpc/aio/iomgr/timer.pxd.pxi | 25 +++ .../_cython/_cygrpc/aio/iomgr/timer.pyx.pxi | 45 +++++ .../grpcio/grpc/_cython/_cygrpc/grpc.pxi | 10 + .../grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi | 109 ----------- .../grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi | 46 ----- .../grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi | 124 ++++++++++++ .../grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi | 62 ++++++ src/python/grpcio/grpc/_cython/cygrpc.pxd | 11 ++ src/python/grpcio/grpc/_cython/cygrpc.pyx | 19 ++ .../grpcio/grpc/experimental/BUILD.bazel | 12 ++ .../grpcio/grpc/experimental/aio/__init__.py | 123 ++++++++++++ .../grpcio/grpc/experimental/aio/_channel.py | 105 ++++++++++ src/python/grpcio_tests/commands.py | 29 +++ src/python/grpcio_tests/setup.py | 1 + .../tests/_sanity/_sanity_test.py | 7 +- src/python/grpcio_tests/tests_aio/__init__.py | 21 ++ .../tests_aio/_sanity/__init__.py | 13 ++ .../tests_aio/_sanity/_sanity_test.py | 27 +++ src/python/grpcio_tests/tests_aio/tests.json | 5 + .../grpcio_tests/tests_aio/unit/__init__.py | 13 ++ .../tests_aio/unit/channel_test.py | 58 ++++++ .../grpcio_tests/tests_aio/unit/init_test.py | 35 ++++ .../tests_aio/unit/sync_server.py | 50 +++++ .../grpcio_tests/tests_aio/unit/test_base.py | 101 ++++++++++ tools/run_tests/run_tests.py | 38 +++- 40 files changed, 1691 insertions(+), 161 deletions(-) create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi create mode 100644 src/python/grpcio/grpc/experimental/aio/__init__.py create mode 100644 src/python/grpcio/grpc/experimental/aio/_channel.py create mode 100644 src/python/grpcio_tests/tests_aio/__init__.py create mode 100644 src/python/grpcio_tests/tests_aio/_sanity/__init__.py create mode 100644 src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py create mode 100644 src/python/grpcio_tests/tests_aio/tests.json create mode 100644 src/python/grpcio_tests/tests_aio/unit/__init__.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/channel_test.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/init_test.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/sync_server.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/test_base.py diff --git a/AUTHORS b/AUTHORS index 0e8797391f2..0c5fee8c739 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ Dropbox, Inc. Google Inc. +Skyscanner Ltd. WeWork Companies Inc. diff --git a/setup.py b/setup.py index 609b18e01b5..eed516a1f11 100644 --- a/setup.py +++ b/setup.py @@ -265,6 +265,7 @@ if 'darwin' in sys.platform and PY3: r'macosx-10.7-\1', util.get_platform()) + def cython_extensions_and_necessity(): cython_module_files = [os.path.join(PYTHON_STEM, name.replace('.', '/') + '.pyx') @@ -295,6 +296,8 @@ def cython_extensions_and_necessity(): need_cython = BUILD_WITH_CYTHON if not BUILD_WITH_CYTHON: need_cython = need_cython or not commands.check_and_update_cythonization(extensions) + # TODO: the strategy for conditional compiling and exposing the aio Cython + # dependencies will be revisited by https://github.com/grpc/grpc/issues/19728 return commands.try_cythonize(extensions, linetracing=ENABLE_CYTHON_TRACING, mandatory=BUILD_WITH_CYTHON), need_cython CYTHON_EXTENSION_MODULES, need_cython = cython_extensions_and_necessity() diff --git a/src/python/grpcio/grpc/_cython/BUILD.bazel b/src/python/grpcio/grpc/_cython/BUILD.bazel index 18b1c92b9a7..e3cb89a81d3 100644 --- a/src/python/grpcio/grpc/_cython/BUILD.bazel +++ b/src/python/grpcio/grpc/_cython/BUILD.bazel @@ -8,6 +8,20 @@ pyx_library( "__init__.py", "_cygrpc/_hooks.pxd.pxi", "_cygrpc/_hooks.pyx.pxi", + "_cygrpc/aio/call.pxd.pxi", + "_cygrpc/aio/call.pyx.pxi", + "_cygrpc/aio/callbackcontext.pxd.pxi", + "_cygrpc/aio/channel.pxd.pxi", + "_cygrpc/aio/channel.pyx.pxi", + "_cygrpc/aio/grpc_aio.pxd.pxi", + "_cygrpc/aio/grpc_aio.pyx.pxi", + "_cygrpc/aio/iomgr/iomgr.pyx.pxi", + "_cygrpc/aio/iomgr/resolver.pxd.pxi", + "_cygrpc/aio/iomgr/resolver.pyx.pxi", + "_cygrpc/aio/iomgr/socket.pxd.pxi", + "_cygrpc/aio/iomgr/socket.pyx.pxi", + "_cygrpc/aio/iomgr/timer.pxd.pxi", + "_cygrpc/aio/iomgr/timer.pyx.pxi", "_cygrpc/arguments.pxd.pxi", "_cygrpc/arguments.pyx.pxi", "_cygrpc/call.pxd.pxi", @@ -27,6 +41,8 @@ pyx_library( "_cygrpc/grpc_gevent.pxd.pxi", "_cygrpc/grpc_gevent.pyx.pxi", "_cygrpc/grpc_string.pyx.pxi", + "_cygrpc/iomgr.pxd.pxi", + "_cygrpc/iomgr.pyx.pxi", "_cygrpc/metadata.pxd.pxi", "_cygrpc/metadata.pyx.pxi", "_cygrpc/operation.pxd.pxi", diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi new file mode 100644 index 00000000000..1166551fd5c --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi @@ -0,0 +1,27 @@ +# Copyright 2019 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. + + +cdef class _AioCall: + cdef: + AioChannel _channel + CallbackContext _watcher_call + grpc_completion_queue * _cq + grpc_experimental_completion_queue_functor _functor + object _waiter_call + + @staticmethod + cdef void functor_run(grpc_experimental_completion_queue_functor* functor, int succeed) + @staticmethod + cdef void watcher_call_functor_run(grpc_experimental_completion_queue_functor* functor, int succeed) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi new file mode 100644 index 00000000000..9530a47f389 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi @@ -0,0 +1,149 @@ +# Copyright 2019 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. + +cimport cpython + +_EMPTY_FLAGS = 0 +_EMPTY_METADATA = () +_OP_ARRAY_LENGTH = 6 + + +cdef class _AioCall: + + + def __cinit__(self, AioChannel channel): + self._channel = channel + self._functor.functor_run = _AioCall.functor_run + + self._cq = grpc_completion_queue_create_for_callback( + &self._functor, + NULL + ) + + self._watcher_call.functor.functor_run = _AioCall.watcher_call_functor_run + self._watcher_call.waiter = self + self._waiter_call = None + + def __dealloc__(self): + grpc_completion_queue_shutdown(self._cq) + grpc_completion_queue_destroy(self._cq) + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_}>" + + @staticmethod + cdef void functor_run(grpc_experimental_completion_queue_functor* functor, int succeed): + pass + + @staticmethod + cdef void watcher_call_functor_run(grpc_experimental_completion_queue_functor* functor, int succeed): + call = <_AioCall>(functor).waiter + + assert call._waiter_call + + if succeed == 0: + call._waiter_call.set_exception(Exception("Some error ocurred")) + else: + call._waiter_call.set_result(None) + + async def unary_unary(self, method, request): + cdef grpc_call * call + cdef grpc_slice method_slice + cdef grpc_op * ops + + cdef Operation initial_metadata_operation + cdef Operation send_message_operation + cdef Operation send_close_from_client_operation + cdef Operation receive_initial_metadata_operation + cdef Operation receive_message_operation + cdef Operation receive_status_on_client_operation + + cdef grpc_call_error call_status + + + method_slice = grpc_slice_from_copied_buffer( + method, + len(method) + ) + + call = grpc_channel_create_call( + self._channel.channel, + NULL, + 0, + self._cq, + method_slice, + NULL, + _timespec_from_time(None), + NULL + ) + + grpc_slice_unref(method_slice) + + ops = gpr_malloc(sizeof(grpc_op) * _OP_ARRAY_LENGTH) + + initial_metadata_operation = SendInitialMetadataOperation(_EMPTY_METADATA, GRPC_INITIAL_METADATA_USED_MASK) + initial_metadata_operation.c() + ops[0] = initial_metadata_operation.c_op + + send_message_operation = SendMessageOperation(request, _EMPTY_FLAGS) + send_message_operation.c() + ops[1] = send_message_operation.c_op + + send_close_from_client_operation = SendCloseFromClientOperation(_EMPTY_FLAGS) + send_close_from_client_operation.c() + ops[2] = send_close_from_client_operation.c_op + + receive_initial_metadata_operation = ReceiveInitialMetadataOperation(_EMPTY_FLAGS) + receive_initial_metadata_operation.c() + ops[3] = receive_initial_metadata_operation.c_op + + receive_message_operation = ReceiveMessageOperation(_EMPTY_FLAGS) + receive_message_operation.c() + ops[4] = receive_message_operation.c_op + + receive_status_on_client_operation = ReceiveStatusOnClientOperation(_EMPTY_FLAGS) + receive_status_on_client_operation.c() + ops[5] = receive_status_on_client_operation.c_op + + self._waiter_call = asyncio.get_event_loop().create_future() + + call_status = grpc_call_start_batch( + call, + ops, + _OP_ARRAY_LENGTH, + &self._watcher_call.functor, + NULL + ) + + try: + if call_status != GRPC_CALL_OK: + self._waiter_call = None + raise Exception("Error with grpc_call_start_batch {}".format(call_status)) + + await self._waiter_call + + finally: + initial_metadata_operation.un_c() + send_message_operation.un_c() + send_close_from_client_operation.un_c() + receive_initial_metadata_operation.un_c() + receive_message_operation.un_c() + receive_status_on_client_operation.un_c() + + grpc_call_unref(call) + gpr_free(ops) + + return receive_message_operation.message() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi new file mode 100644 index 00000000000..8e52c856dd2 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi @@ -0,0 +1,20 @@ +# Copyright 2019 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. + +cimport cpython + +cdef struct CallbackContext: + grpc_experimental_completion_queue_functor functor + cpython.PyObject *waiter + diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi new file mode 100644 index 00000000000..f5e1a5d3095 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi @@ -0,0 +1,18 @@ +# Copyright 2019 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. + +cdef class AioChannel: + cdef: + grpc_channel * channel + bytes _target diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi new file mode 100644 index 00000000000..b52c070553d --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi @@ -0,0 +1,30 @@ +# Copyright 2019 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. + +cdef class AioChannel: + def __cinit__(self, bytes target): + self.channel = grpc_insecure_channel_create(target, NULL, NULL) + self._target = target + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_}>" + + def close(self): + grpc_channel_destroy(self.channel) + + async def unary_unary(self, method, request): + call = _AioCall(self) + return await call.unary_unary(method, request) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi new file mode 100644 index 00000000000..6cefb63d208 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi @@ -0,0 +1,25 @@ +# Copyright 2019 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. +# distutils: language=c++ + +cdef extern from "src/core/lib/iomgr/timer_manager.h": + void grpc_timer_manager_set_threading(bint enabled); + +cdef extern from "src/core/lib/iomgr/iomgr_internal.h": + void grpc_set_default_iomgr_platform(); + +cdef extern from "src/core/lib/iomgr/executor.h" namespace "grpc_core": + cdef cppclass Executor: + @staticmethod + void SetThreadingAll(bint enable); diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi new file mode 100644 index 00000000000..64645a6c3b4 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi @@ -0,0 +1,37 @@ +# Copyright 2019 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. + + +cdef bint _grpc_aio_initialized = 0 + + +def init_grpc_aio(): + global _grpc_aio_initialized + + if _grpc_aio_initialized: + return + + install_asyncio_iomgr() + grpc_init() + + # Timers are triggered by the Asyncio loop. We disable + # the background thread that is being used by the native + # gRPC iomgr. + grpc_timer_manager_set_threading(0) + + # gRPC callbaks are executed within the same thread used by the Asyncio + # event loop, as it is being done by the other Asyncio callbacks. + Executor.SetThreadingAll(0) + + _grpc_aio_initialized = 1 diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi new file mode 100644 index 00000000000..13e95ee1206 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi @@ -0,0 +1,185 @@ +# Copyright 2019 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. + + +from cpython cimport Py_INCREF, Py_DECREF + +from libc cimport string + +cdef grpc_socket_vtable asyncio_socket_vtable +cdef grpc_custom_resolver_vtable asyncio_resolver_vtable +cdef grpc_custom_timer_vtable asyncio_timer_vtable +cdef grpc_custom_poller_vtable asyncio_pollset_vtable + + +cdef grpc_error* asyncio_socket_init( + grpc_custom_socket* grpc_socket, + int domain) with gil: + socket = _AsyncioSocket.create(grpc_socket) + Py_INCREF(socket) + grpc_socket.impl = socket + return 0 + + +cdef void asyncio_socket_destroy(grpc_custom_socket* grpc_socket) with gil: + Py_DECREF(<_AsyncioSocket>grpc_socket.impl) + + +cdef void asyncio_socket_connect( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + size_t addr_len, + grpc_custom_connect_callback connect_cb) with gil: + + host, port = sockaddr_to_tuple(addr, addr_len) + socket = <_AsyncioSocket>grpc_socket.impl + socket.connect(host, port, connect_cb) + + +cdef void asyncio_socket_close( + grpc_custom_socket* grpc_socket, + grpc_custom_close_callback close_cb) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.close() + close_cb(grpc_socket) + + +cdef void asyncio_socket_shutdown(grpc_custom_socket* grpc_socket) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.close() + + +cdef void asyncio_socket_write( + grpc_custom_socket* grpc_socket, + grpc_slice_buffer* slice_buffer, + grpc_custom_write_callback write_cb) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.write(slice_buffer, write_cb) + + +cdef void asyncio_socket_read( + grpc_custom_socket* grpc_socket, + char* buffer_, + size_t length, + grpc_custom_read_callback read_cb) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.read(buffer_, length, read_cb) + + +cdef grpc_error* asyncio_socket_getpeername( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + int* length) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_socket_getsockname( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + int* length) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_socket_listen(grpc_custom_socket* grpc_socket) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_socket_bind( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + size_t len, int flags) with gil: + raise NotImplemented() + + +cdef void asyncio_socket_accept( + grpc_custom_socket* grpc_socket, + grpc_custom_socket* grpc_socket_client, + grpc_custom_accept_callback accept_cb) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_resolve( + char* host, + char* port, + grpc_resolved_addresses** res) with gil: + raise NotImplemented() + + +cdef void asyncio_resolve_async( + grpc_custom_resolver* grpc_resolver, + char* host, + char* port) with gil: + resolver = _AsyncioResolver.create(grpc_resolver) + resolver.resolve(host, port) + + +cdef void asyncio_timer_start(grpc_custom_timer* grpc_timer) with gil: + timer = _AsyncioTimer.create(grpc_timer, grpc_timer.timeout_ms / 1000.0) + Py_INCREF(timer) + grpc_timer.timer = timer + + +cdef void asyncio_timer_stop(grpc_custom_timer* grpc_timer) with gil: + timer = <_AsyncioTimer>grpc_timer.timer + timer.stop() + Py_DECREF(timer) + + +cdef void asyncio_init_loop() with gil: + pass + + +cdef void asyncio_destroy_loop() with gil: + pass + + +cdef void asyncio_kick_loop() with gil: + pass + + +cdef void asyncio_run_loop(size_t timeout_ms) with gil: + pass + + +def install_asyncio_iomgr(): + asyncio_resolver_vtable.resolve = asyncio_resolve + asyncio_resolver_vtable.resolve_async = asyncio_resolve_async + + asyncio_socket_vtable.init = asyncio_socket_init + asyncio_socket_vtable.connect = asyncio_socket_connect + asyncio_socket_vtable.destroy = asyncio_socket_destroy + asyncio_socket_vtable.shutdown = asyncio_socket_shutdown + asyncio_socket_vtable.close = asyncio_socket_close + asyncio_socket_vtable.write = asyncio_socket_write + asyncio_socket_vtable.read = asyncio_socket_read + asyncio_socket_vtable.getpeername = asyncio_socket_getpeername + asyncio_socket_vtable.getsockname = asyncio_socket_getsockname + asyncio_socket_vtable.bind = asyncio_socket_bind + asyncio_socket_vtable.listen = asyncio_socket_listen + asyncio_socket_vtable.accept = asyncio_socket_accept + + asyncio_timer_vtable.start = asyncio_timer_start + asyncio_timer_vtable.stop = asyncio_timer_stop + + asyncio_pollset_vtable.init = asyncio_init_loop + asyncio_pollset_vtable.poll = asyncio_run_loop + asyncio_pollset_vtable.kick = asyncio_kick_loop + asyncio_pollset_vtable.shutdown = asyncio_destroy_loop + + grpc_custom_iomgr_init( + &asyncio_socket_vtable, + &asyncio_resolver_vtable, + &asyncio_timer_vtable, + &asyncio_pollset_vtable + ) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi new file mode 100644 index 00000000000..26089c95337 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi @@ -0,0 +1,23 @@ +# Copyright 2019 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. + +cdef class _AsyncioResolver: + cdef: + grpc_custom_resolver* _grpc_resolver + object _task_resolve + + @staticmethod + cdef _AsyncioResolver create(grpc_custom_resolver* grpc_resolver) + + cdef void resolve(self, char* host, char* port) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi new file mode 100644 index 00000000000..4c102392e5c --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi @@ -0,0 +1,61 @@ +# Copyright 2019 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. + + +cdef class _AsyncioResolver: + def __cinit__(self): + self._grpc_resolver = NULL + self._task_resolve = None + + @staticmethod + cdef _AsyncioResolver create(grpc_custom_resolver* grpc_resolver): + resolver = _AsyncioResolver() + resolver._grpc_resolver = grpc_resolver + return resolver + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_}>" + + def _resolve_cb(self, future): + error = False + try: + res = future.result() + except Exception as e: + error = True + finally: + self._task_resolve = None + + if not error: + grpc_custom_resolve_callback( + self._grpc_resolver, + tuples_to_resolvaddr(res), + 0 + ) + else: + grpc_custom_resolve_callback( + self._grpc_resolver, + NULL, + grpc_socket_error("getaddrinfo {}".format(str(e)).encode()) + ) + + cdef void resolve(self, char* host, char* port): + assert not self._task_resolve + + loop = asyncio.get_event_loop() + self._task_resolve = asyncio.ensure_future( + loop.getaddrinfo(host, port) + ) + self._task_resolve.add_done_callback(self._resolve_cb) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi new file mode 100644 index 00000000000..aab5db2149a --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi @@ -0,0 +1,34 @@ +# Copyright 2019 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. + + +cdef class _AsyncioSocket: + cdef: + grpc_custom_socket * _grpc_socket + grpc_custom_connect_callback _grpc_connect_cb + grpc_custom_read_callback _grpc_read_cb + object _reader + object _writer + object _task_read + object _task_connect + char * _read_buffer + + @staticmethod + cdef _AsyncioSocket create(grpc_custom_socket * grpc_socket) + + cdef void connect(self, object host, object port, grpc_custom_connect_callback grpc_connect_cb) + cdef void write(self, grpc_slice_buffer * g_slice_buffer, grpc_custom_write_callback grpc_write_cb) + cdef void read(self, char * buffer_, size_t length, grpc_custom_read_callback grpc_read_cb) + cdef bint is_connected(self) + cdef void close(self) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi new file mode 100644 index 00000000000..690c34c2da9 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi @@ -0,0 +1,134 @@ +# Copyright 2019 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. + +import socket + +from libc cimport string + +cdef class _AsyncioSocket: + def __cinit__(self): + self._grpc_socket = NULL + self._grpc_connect_cb = NULL + self._grpc_read_cb = NULL + self._reader = None + self._writer = None + self._task_connect = None + self._task_read = None + self._read_buffer = NULL + + @staticmethod + cdef _AsyncioSocket create(grpc_custom_socket * grpc_socket): + socket = _AsyncioSocket() + socket._grpc_socket = grpc_socket + return socket + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + connected = self.is_connected() + return f"<{class_name} {id_} connected={connected}>" + + def _connect_cb(self, future): + error = False + try: + self._reader, self._writer = future.result() + except Exception as e: + error = True + finally: + self._task_connect = None + + if not error: + # gRPC default posix implementation disables nagle + # algorithm. + sock = self._writer.transport.get_extra_info('socket') + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) + + self._grpc_connect_cb( + self._grpc_socket, + 0 + ) + else: + self._grpc_connect_cb( + self._grpc_socket, + grpc_socket_error("connect {}".format(str(e)).encode()) + ) + + def _read_cb(self, future): + error = False + try: + buffer_ = future.result() + except Exception as e: + error = True + error_msg = str(e) + finally: + self._task_read = None + + if not error: + string.memcpy( + self._read_buffer, + buffer_, + len(buffer_) + ) + self._grpc_read_cb( + self._grpc_socket, + len(buffer_), + 0 + ) + else: + self._grpc_read_cb( + self._grpc_socket, + -1, + grpc_socket_error("read {}".format(error_msg).encode()) + ) + + cdef void connect(self, object host, object port, grpc_custom_connect_callback grpc_connect_cb): + assert not self._task_connect + + self._task_connect = asyncio.ensure_future( + asyncio.open_connection(host, port) + ) + self._grpc_connect_cb = grpc_connect_cb + self._task_connect.add_done_callback(self._connect_cb) + + cdef void read(self, char * buffer_, size_t length, grpc_custom_read_callback grpc_read_cb): + assert not self._task_read + + self._task_read = asyncio.ensure_future( + self._reader.read(n=length) + ) + self._grpc_read_cb = grpc_read_cb + self._task_read.add_done_callback(self._read_cb) + self._read_buffer = buffer_ + + cdef void write(self, grpc_slice_buffer * g_slice_buffer, grpc_custom_write_callback grpc_write_cb): + cdef char* start + buffer_ = bytearray() + for i in range(g_slice_buffer.count): + start = grpc_slice_buffer_start(g_slice_buffer, i) + length = grpc_slice_buffer_length(g_slice_buffer, i) + buffer_.extend(start[:length]) + + self._writer.write(buffer_) + + grpc_write_cb( + self._grpc_socket, + 0 + ) + + cdef bint is_connected(self): + return self._reader and not self._reader._transport.is_closing() + + cdef void close(self): + if self.is_connected(): + self._writer.close() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi new file mode 100644 index 00000000000..5af5dcd9282 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi @@ -0,0 +1,25 @@ +# Copyright 2019 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. + +cdef class _AsyncioTimer: + cdef: + grpc_custom_timer * _grpc_timer + object _deadline + object _timer_handler + int _active + + @staticmethod + cdef _AsyncioTimer create(grpc_custom_timer * grpc_timer, deadline) + + cdef stop(self) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi new file mode 100644 index 00000000000..e8edb4a5cf8 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi @@ -0,0 +1,45 @@ +# Copyright 2019 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. + + +cdef class _AsyncioTimer: + def __cinit__(self): + self._grpc_timer = NULL + self._timer_handler = None + self._active = 0 + + @staticmethod + cdef _AsyncioTimer create(grpc_custom_timer * grpc_timer, deadline): + timer = _AsyncioTimer() + timer._grpc_timer = grpc_timer + timer._deadline = deadline + timer._timer_handler = asyncio.get_event_loop().call_later(deadline, timer._on_deadline) + timer._active = 1 + return timer + + def _on_deadline(self): + self._active = 0 + grpc_custom_timer_callback(self._grpc_timer, 0) + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_} deadline={self._deadline} active={self._active}>" + + cdef stop(self): + if self._active == 0: + return + + self._timer_handler.cancel() + self._active = 0 diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 4bfb42026aa..e2117905421 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -41,6 +41,11 @@ cdef extern from "grpc/byte_buffer_reader.h": pass +cdef extern from "grpc/impl/codegen/grpc_types.h": + ctypedef struct grpc_experimental_completion_queue_functor: + void (*functor_run)(grpc_experimental_completion_queue_functor*, int); + + cdef extern from "grpc/grpc.h": ctypedef struct grpc_slice: @@ -325,6 +330,7 @@ cdef extern from "grpc/grpc.h": ctypedef struct grpc_op: grpc_op_type type "op" uint32_t flags + void * reserved grpc_op_data data void grpc_init() nogil @@ -350,6 +356,10 @@ cdef extern from "grpc/grpc.h": void grpc_completion_queue_shutdown(grpc_completion_queue *cq) nogil void grpc_completion_queue_destroy(grpc_completion_queue *cq) nogil + grpc_completion_queue *grpc_completion_queue_create_for_callback( + grpc_experimental_completion_queue_functor* shutdown_callback, + void *reserved) nogil + grpc_call_error grpc_call_start_batch( grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved) nogil diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi index 30fdf6a7600..4f5033b8e44 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi @@ -13,115 +13,6 @@ # limitations under the License. # distutils: language=c++ -cdef extern from "grpc/impl/codegen/slice.h": - struct grpc_slice_buffer: - int count - -cdef extern from "src/core/lib/iomgr/error.h": - struct grpc_error: - pass - -cdef extern from "src/core/lib/iomgr/gevent_util.h": - grpc_error* grpc_socket_error(char* error) - char* grpc_slice_buffer_start(grpc_slice_buffer* buffer, int i) - int grpc_slice_buffer_length(grpc_slice_buffer* buffer, int i) - -cdef extern from "src/core/lib/iomgr/sockaddr.h": - ctypedef struct grpc_sockaddr: - pass - -cdef extern from "src/core/lib/iomgr/resolve_address.h": - ctypedef struct grpc_resolved_addresses: - size_t naddrs - grpc_resolved_address* addrs - - ctypedef struct grpc_resolved_address: - char[128] addr - size_t len - -cdef extern from "src/core/lib/iomgr/resolve_address_custom.h": - struct grpc_custom_resolver: - pass - - struct grpc_custom_resolver_vtable: - grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res); - void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port); - - void grpc_custom_resolve_callback(grpc_custom_resolver* resolver, - grpc_resolved_addresses* result, - grpc_error* error); - -cdef extern from "src/core/lib/iomgr/tcp_custom.h": - struct grpc_custom_socket: - void* impl - # We don't care about the rest of the fields - ctypedef void (*grpc_custom_connect_callback)(grpc_custom_socket* socket, - grpc_error* error) - ctypedef void (*grpc_custom_write_callback)(grpc_custom_socket* socket, - grpc_error* error) - ctypedef void (*grpc_custom_read_callback)(grpc_custom_socket* socket, - size_t nread, grpc_error* error) - ctypedef void (*grpc_custom_accept_callback)(grpc_custom_socket* socket, - grpc_custom_socket* client, - grpc_error* error) - ctypedef void (*grpc_custom_close_callback)(grpc_custom_socket* socket) - - struct grpc_socket_vtable: - grpc_error* (*init)(grpc_custom_socket* socket, int domain); - void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, grpc_custom_connect_callback cb); - void (*destroy)(grpc_custom_socket* socket); - void (*shutdown)(grpc_custom_socket* socket); - void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb); - void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices, - grpc_custom_write_callback cb); - void (*read)(grpc_custom_socket* socket, char* buffer, size_t length, - grpc_custom_read_callback cb); - grpc_error* (*getpeername)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len); - grpc_error* (*getsockname)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len); - grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, int flags); - grpc_error* (*listen)(grpc_custom_socket* socket); - void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client, - grpc_custom_accept_callback cb); - -cdef extern from "src/core/lib/iomgr/timer_custom.h": - struct grpc_custom_timer: - void* timer - int timeout_ms - # We don't care about the rest of the fields - - struct grpc_custom_timer_vtable: - void (*start)(grpc_custom_timer* t); - void (*stop)(grpc_custom_timer* t); - - void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error); - -cdef extern from "src/core/lib/iomgr/pollset_custom.h": - struct grpc_custom_poller_vtable: - void (*init)() - void (*poll)(size_t timeout_ms) - void (*kick)() - void (*shutdown)() - -cdef extern from "src/core/lib/iomgr/iomgr_custom.h": - void grpc_custom_iomgr_init(grpc_socket_vtable* socket, - grpc_custom_resolver_vtable* resolver, - grpc_custom_timer_vtable* timer, - grpc_custom_poller_vtable* poller); - -cdef extern from "src/core/lib/iomgr/sockaddr_utils.h": - int grpc_sockaddr_get_port(const grpc_resolved_address *addr); - int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr, - int normalize); - void grpc_string_to_sockaddr(grpc_resolved_address *out, char* addr, int port); - int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr, - int port) - const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* resolved_addr) - - cdef class TimerWrapper: cdef grpc_custom_timer *c_timer diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index a1618d04d0e..13256ed49b8 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi @@ -15,7 +15,6 @@ cimport cpython from libc cimport string -from libc.stdlib cimport malloc, free import errno gevent_g = None gevent_socket = None @@ -24,51 +23,6 @@ gevent_event = None g_event = None g_pool = None -cdef grpc_error* grpc_error_none(): - return 0 - -cdef grpc_error* socket_error(str syscall, str err): - error_str = "{} failed: {}".format(syscall, err) - error_bytes = str_to_bytes(error_str) - return grpc_socket_error(error_bytes) - -cdef resolved_addr_to_tuple(grpc_resolved_address* address): - cdef char* res_str - port = grpc_sockaddr_get_port(address) - str_len = grpc_sockaddr_to_string(&res_str, address, 0) - byte_str = _decode(res_str[:str_len]) - if byte_str.endswith(':' + str(port)): - byte_str = byte_str[:(0 - len(str(port)) - 1)] - byte_str = byte_str.lstrip('[') - byte_str = byte_str.rstrip(']') - byte_str = '{}'.format(byte_str) - return byte_str, port - -cdef sockaddr_to_tuple(const grpc_sockaddr* address, size_t length): - cdef grpc_resolved_address c_addr - string.memcpy(c_addr.addr, address, length) - c_addr.len = length - return resolved_addr_to_tuple(&c_addr) - -cdef sockaddr_is_ipv4(const grpc_sockaddr* address, size_t length): - cdef grpc_resolved_address c_addr - string.memcpy(c_addr.addr, address, length) - c_addr.len = length - return grpc_sockaddr_get_uri_scheme(&c_addr) == b'ipv4' - -cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups): - cdef grpc_resolved_addresses* addresses - tups_set = set((tup[4][0], tup[4][1]) for tup in tups) - addresses = malloc(sizeof(grpc_resolved_addresses)) - addresses.naddrs = len(tups_set) - addresses.addrs = malloc(sizeof(grpc_resolved_address) * len(tups_set)) - i = 0 - for tup in set(tups_set): - hostname = str_to_bytes(tup[0]) - grpc_string_to_sockaddr(&addresses.addrs[i], hostname, tup[1]) - i += 1 - return addresses - def _spawn_greenlet(*args): greenlet = g_pool.spawn(*args) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi new file mode 100644 index 00000000000..2f00bab3c0a --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi @@ -0,0 +1,124 @@ +# Copyright 2019 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. +# distutils: language=c++ + +cdef extern from "grpc/impl/codegen/slice.h": + struct grpc_slice_buffer: + int count + +cdef extern from "src/core/lib/iomgr/error.h": + struct grpc_error: + pass + +# TODO(https://github.com/grpc/grpc/issues/20135) Change the filename +# for something more meaningful. +cdef extern from "src/core/lib/iomgr/gevent_util.h": + grpc_error* grpc_socket_error(char* error) + char* grpc_slice_buffer_start(grpc_slice_buffer* buffer, int i) + int grpc_slice_buffer_length(grpc_slice_buffer* buffer, int i) + +cdef extern from "src/core/lib/iomgr/sockaddr.h": + ctypedef struct grpc_sockaddr: + pass + +cdef extern from "src/core/lib/iomgr/resolve_address.h": + ctypedef struct grpc_resolved_addresses: + size_t naddrs + grpc_resolved_address* addrs + + ctypedef struct grpc_resolved_address: + char[128] addr + size_t len + +cdef extern from "src/core/lib/iomgr/resolve_address_custom.h": + struct grpc_custom_resolver: + pass + + struct grpc_custom_resolver_vtable: + grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res); + void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port); + + void grpc_custom_resolve_callback(grpc_custom_resolver* resolver, + grpc_resolved_addresses* result, + grpc_error* error); + +cdef extern from "src/core/lib/iomgr/tcp_custom.h": + struct grpc_custom_socket: + void* impl + # We don't care about the rest of the fields + ctypedef void (*grpc_custom_connect_callback)(grpc_custom_socket* socket, + grpc_error* error) + ctypedef void (*grpc_custom_write_callback)(grpc_custom_socket* socket, + grpc_error* error) + ctypedef void (*grpc_custom_read_callback)(grpc_custom_socket* socket, + size_t nread, grpc_error* error) + ctypedef void (*grpc_custom_accept_callback)(grpc_custom_socket* socket, + grpc_custom_socket* client, + grpc_error* error) + ctypedef void (*grpc_custom_close_callback)(grpc_custom_socket* socket) + + struct grpc_socket_vtable: + grpc_error* (*init)(grpc_custom_socket* socket, int domain); + void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr, + size_t len, grpc_custom_connect_callback cb); + void (*destroy)(grpc_custom_socket* socket); + void (*shutdown)(grpc_custom_socket* socket); + void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb); + void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices, + grpc_custom_write_callback cb); + void (*read)(grpc_custom_socket* socket, char* buffer, size_t length, + grpc_custom_read_callback cb); + grpc_error* (*getpeername)(grpc_custom_socket* socket, + const grpc_sockaddr* addr, int* len); + grpc_error* (*getsockname)(grpc_custom_socket* socket, + const grpc_sockaddr* addr, int* len); + grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, + size_t len, int flags); + grpc_error* (*listen)(grpc_custom_socket* socket); + void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client, + grpc_custom_accept_callback cb); + +cdef extern from "src/core/lib/iomgr/timer_custom.h": + struct grpc_custom_timer: + void* timer + int timeout_ms + # We don't care about the rest of the fields + + struct grpc_custom_timer_vtable: + void (*start)(grpc_custom_timer* t); + void (*stop)(grpc_custom_timer* t); + + void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error); + +cdef extern from "src/core/lib/iomgr/pollset_custom.h": + struct grpc_custom_poller_vtable: + void (*init)() + void (*poll)(size_t timeout_ms) + void (*kick)() + void (*shutdown)() + +cdef extern from "src/core/lib/iomgr/iomgr_custom.h": + void grpc_custom_iomgr_init(grpc_socket_vtable* socket, + grpc_custom_resolver_vtable* resolver, + grpc_custom_timer_vtable* timer, + grpc_custom_poller_vtable* poller); + +cdef extern from "src/core/lib/iomgr/sockaddr_utils.h": + int grpc_sockaddr_get_port(const grpc_resolved_address *addr); + int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr, + int normalize); + void grpc_string_to_sockaddr(grpc_resolved_address *out, char* addr, int port); + int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr, + int port) + const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* resolved_addr) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi new file mode 100644 index 00000000000..9274f1c5fdb --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi @@ -0,0 +1,62 @@ +# Copyright 2019 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. +# distutils: language=c++ + +from libc cimport string +from libc.stdlib cimport malloc + +cdef grpc_error* grpc_error_none(): + return 0 + +cdef grpc_error* socket_error(str syscall, str err): + error_str = "{} failed: {}".format(syscall, err) + error_bytes = str_to_bytes(error_str) + return grpc_socket_error(error_bytes) + +cdef resolved_addr_to_tuple(grpc_resolved_address* address): + cdef char* res_str + port = grpc_sockaddr_get_port(address) + str_len = grpc_sockaddr_to_string(&res_str, address, 0) + byte_str = _decode(res_str[:str_len]) + if byte_str.endswith(':' + str(port)): + byte_str = byte_str[:(0 - len(str(port)) - 1)] + byte_str = byte_str.lstrip('[') + byte_str = byte_str.rstrip(']') + byte_str = '{}'.format(byte_str) + return byte_str, port + +cdef sockaddr_to_tuple(const grpc_sockaddr* address, size_t length): + cdef grpc_resolved_address c_addr + string.memcpy(c_addr.addr, address, length) + c_addr.len = length + return resolved_addr_to_tuple(&c_addr) + +cdef sockaddr_is_ipv4(const grpc_sockaddr* address, size_t length): + cdef grpc_resolved_address c_addr + string.memcpy(c_addr.addr, address, length) + c_addr.len = length + return grpc_sockaddr_get_uri_scheme(&c_addr) == b'ipv4' + +cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups): + cdef grpc_resolved_addresses* addresses + tups_set = set((tup[4][0], tup[4][1]) for tup in tups) + addresses = malloc(sizeof(grpc_resolved_addresses)) + addresses.naddrs = len(tups_set) + addresses.addrs = malloc(sizeof(grpc_resolved_address) * len(tups_set)) + i = 0 + for tup in set(tups_set): + hostname = str_to_bytes(tup[0]) + grpc_string_to_sockaddr(&addresses.addrs[i], hostname, tup[1]) + i += 1 + return addresses diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pxd b/src/python/grpcio/grpc/_cython/cygrpc.pxd index e29f7aee97a..4d081fb83e2 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pxd +++ b/src/python/grpcio/grpc/_cython/cygrpc.pxd @@ -32,7 +32,18 @@ include "_cygrpc/time.pxd.pxi" include "_cygrpc/vtable.pxd.pxi" include "_cygrpc/_hooks.pxd.pxi" +include "_cygrpc/iomgr.pxd.pxi" + include "_cygrpc/grpc_gevent.pxd.pxi" IF UNAME_SYSNAME != "Windows": include "_cygrpc/fork_posix.pxd.pxi" + +# Following pxi files are part of the Aio module +include "_cygrpc/aio/iomgr/socket.pxd.pxi" +include "_cygrpc/aio/iomgr/timer.pxd.pxi" +include "_cygrpc/aio/iomgr/resolver.pxd.pxi" +include "_cygrpc/aio/grpc_aio.pxd.pxi" +include "_cygrpc/aio/callbackcontext.pxd.pxi" +include "_cygrpc/aio/call.pxd.pxi" +include "_cygrpc/aio/channel.pxd.pxi" diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index f2dd0df89d4..316fb993095 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -17,6 +17,13 @@ cimport cpython import os.path import sys +try: + import asyncio +except ImportError: + # TODO(https://github.com/grpc/grpc/issues/19728) Improve how Aio Cython is + # distributed without breaking none compatible Python versions. For now, if + # Asyncio package is not available we just skip it. + pass # 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. @@ -39,6 +46,8 @@ include "_cygrpc/time.pyx.pxi" include "_cygrpc/vtable.pyx.pxi" include "_cygrpc/_hooks.pyx.pxi" +include "_cygrpc/iomgr.pyx.pxi" + include "_cygrpc/grpc_gevent.pyx.pxi" IF UNAME_SYSNAME == "Windows": @@ -46,6 +55,16 @@ IF UNAME_SYSNAME == "Windows": ELSE: include "_cygrpc/fork_posix.pyx.pxi" +# Following pxi files are part of the Aio module +include "_cygrpc/aio/iomgr/iomgr.pyx.pxi" +include "_cygrpc/aio/iomgr/socket.pyx.pxi" +include "_cygrpc/aio/iomgr/timer.pyx.pxi" +include "_cygrpc/aio/iomgr/resolver.pyx.pxi" +include "_cygrpc/aio/grpc_aio.pyx.pxi" +include "_cygrpc/aio/call.pyx.pxi" +include "_cygrpc/aio/channel.pyx.pxi" + + # # initialize gRPC # diff --git a/src/python/grpcio/grpc/experimental/BUILD.bazel b/src/python/grpcio/grpc/experimental/BUILD.bazel index cd8afe533b6..00815c4e72e 100644 --- a/src/python/grpcio/grpc/experimental/BUILD.bazel +++ b/src/python/grpcio/grpc/experimental/BUILD.bazel @@ -1,9 +1,21 @@ package(default_visibility = ["//visibility:public"]) +py_library( + name = "aio", + srcs = [ + "aio/__init__.py", + "aio/_channel.py", + ], + deps = [ + "//src/python/grpcio/grpc/_cython:cygrpc", + ], +) + py_library( name = "experimental", srcs = ["__init__.py",], deps = [ + ":aio", ":gevent", ":session_cache", ], diff --git a/src/python/grpcio/grpc/experimental/aio/__init__.py b/src/python/grpcio/grpc/experimental/aio/__init__.py new file mode 100644 index 00000000000..6004126549b --- /dev/null +++ b/src/python/grpcio/grpc/experimental/aio/__init__.py @@ -0,0 +1,123 @@ +# Copyright 2019 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. +"""gRPC's Asynchronous Python API.""" + +import abc +import six + +from grpc._cython.cygrpc import init_grpc_aio + + +class Channel(six.with_metaclass(abc.ABCMeta)): + """Asynchronous Channel implementation.""" + + @abc.abstractmethod + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + """Creates a UnaryUnaryMultiCallable for a unary-unary method. + + Args: + method: The name of the RPC method. + request_serializer: Optional behaviour for serializing the request + message. Request goes unserialized in case None is passed. + response_deserializer: Optional behaviour for deserializing the + response message. Response goes undeserialized in case None + is passed. + + Returns: + A UnaryUnaryMultiCallable value for the named unary-unary method. + """ + raise NotImplementedError() + + @abc.abstractmethod + async def close(self): + """Closes this Channel and releases all resources held by it. + + Closing the Channel will proactively terminate all RPCs active with the + Channel and it is not valid to invoke new RPCs with the Channel. + + This method is idempotent. + """ + raise NotImplementedError() + + @abc.abstractmethod + async def __aenter__(self): + """Starts an asynchronous context manager. + + Returns: + Channel the channel that was instantiated. + """ + raise NotImplementedError() + + @abc.abstractmethod + async def __aexit__(self, exc_type, exc_val, exc_tb): + """Finishes the asynchronous context manager by closing gracefully the channel.""" + raise NotImplementedError() + + +class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): + """Affords invoking a unary-unary RPC from client-side in an asynchronous way.""" + + @abc.abstractmethod + async def __call__(self, + request, + timeout=None, + metadata=None, + credentials=None, + wait_for_ready=None, + compression=None): + """Asynchronously invokes the underlying RPC. + + Args: + request: The request value for the RPC. + timeout: An optional duration of time in seconds to allow + for the RPC. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. + wait_for_ready: This is an EXPERIMENTAL argument. An optional + flag to enable wait for ready mechanism + compression: An element of grpc.compression, e.g. + grpc.compression.Gzip. This is an EXPERIMENTAL option. + + Returns: + The response value for the RPC. + + Raises: + RpcError: Indicating that the RPC terminated with non-OK status. The + raised RpcError will also be a Call for the RPC affording the RPC's + metadata, status code, and details. + """ + raise NotImplementedError() + + +def insecure_channel(target, options=None, compression=None): + """Creates an insecure asynchronous Channel to a server. + + Args: + target: The server address + options: An optional list of key-value pairs (channel args + in gRPC Core runtime) to configure the channel. + compression: An optional value indicating the compression method to be + used over the lifetime of the channel. This is an EXPERIMENTAL option. + + Returns: + A Channel. + """ + from grpc.experimental.aio import _channel # pylint: disable=cyclic-import + return _channel.Channel(target, () + if options is None else options, None, compression) diff --git a/src/python/grpcio/grpc/experimental/aio/_channel.py b/src/python/grpcio/grpc/experimental/aio/_channel.py new file mode 100644 index 00000000000..e3c8fcdbf2f --- /dev/null +++ b/src/python/grpcio/grpc/experimental/aio/_channel.py @@ -0,0 +1,105 @@ +# Copyright 2019 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. +"""Invocation-side implementation of gRPC Asyncio Python.""" + +from grpc import _common +from grpc._cython import cygrpc +from grpc.experimental import aio + + +class UnaryUnaryMultiCallable(aio.UnaryUnaryMultiCallable): + + def __init__(self, channel, method, request_serializer, + response_deserializer): + self._channel = channel + self._method = method + self._request_serializer = request_serializer + self._response_deserializer = response_deserializer + + async def __call__(self, + request, + timeout=None, + metadata=None, + credentials=None, + wait_for_ready=None, + compression=None): + + if timeout: + raise NotImplementedError("TODO: timeout not implemented yet") + + if metadata: + raise NotImplementedError("TODO: metadata not implemented yet") + + if credentials: + raise NotImplementedError("TODO: credentials not implemented yet") + + if wait_for_ready: + raise NotImplementedError( + "TODO: wait_for_ready not implemented yet") + + if compression: + raise NotImplementedError("TODO: compression not implemented yet") + + response = await self._channel.unary_unary( + self._method, _common.serialize(request, self._request_serializer)) + + return _common.deserialize(response, self._response_deserializer) + + +class Channel(aio.Channel): + """A cygrpc.AioChannel-backed implementation of grpc.experimental.aio.Channel.""" + + def __init__(self, target, options, credentials, compression): + """Constructor. + + Args: + target: The target to which to connect. + options: Configuration options for the channel. + credentials: A cygrpc.ChannelCredentials or None. + compression: An optional value indicating the compression method to be + used over the lifetime of the channel. + """ + + if options: + raise NotImplementedError("TODO: options not implemented yet") + + if credentials: + raise NotImplementedError("TODO: credentials not implemented yet") + + if compression: + raise NotImplementedError("TODO: compression not implemented yet") + + self._channel = cygrpc.AioChannel(_common.encode(target)) + + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + + return UnaryUnaryMultiCallable(self._channel, _common.encode(method), + request_serializer, + response_deserializer) + + async def _close(self): + # TODO: Send cancellation status + self._channel.close() + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + await self._close() + + async def close(self): + await self._close() diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 61d8bdc1f7b..2912ba113c9 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -107,6 +107,35 @@ class TestLite(setuptools.Command): self.distribution.fetch_build_eggs(self.distribution.tests_require) +class TestAio(setuptools.Command): + """Command to run aio tests without fetching or building anything.""" + + description = 'run aio tests without fetching or building anything.' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + self._add_eggs_to_path() + + import tests + loader = tests.Loader() + loader.loadTestsFromNames(['tests_aio']) + runner = tests.Runner() + result = runner.run(loader.suite) + if not result.wasSuccessful(): + sys.exit('Test failure') + + def _add_eggs_to_path(self): + """Fetch install and test requirements""" + self.distribution.fetch_build_eggs(self.distribution.install_requires) + self.distribution.fetch_build_eggs(self.distribution.tests_require) + + class TestGevent(setuptools.Command): """Command to run tests w/gevent.""" diff --git a/src/python/grpcio_tests/setup.py b/src/python/grpcio_tests/setup.py index f9cb9d0cec9..50ba1bb5942 100644 --- a/src/python/grpcio_tests/setup.py +++ b/src/python/grpcio_tests/setup.py @@ -58,6 +58,7 @@ COMMAND_CLASS = { 'run_interop': commands.RunInterop, 'test_lite': commands.TestLite, 'test_gevent': commands.TestGevent, + 'test_aio': commands.TestAio, } PACKAGE_DATA = { diff --git a/src/python/grpcio_tests/tests/_sanity/_sanity_test.py b/src/python/grpcio_tests/tests/_sanity/_sanity_test.py index 7da6e7b34c3..6b4efdaca9f 100644 --- a/src/python/grpcio_tests/tests/_sanity/_sanity_test.py +++ b/src/python/grpcio_tests/tests/_sanity/_sanity_test.py @@ -25,17 +25,20 @@ class SanityTest(unittest.TestCase): maxDiff = 32768 + TEST_PKG_MODULE_NAME = 'tests' + TEST_PKG_PATH = 'tests' + def testTestsJsonUpToDate(self): """Autodiscovers all test suites and checks that tests.json is up to date""" loader = tests.Loader() - loader.loadTestsFromNames(['tests']) + loader.loadTestsFromNames([self.TEST_PKG_MODULE_NAME]) test_suite_names = sorted({ test_case_class.id().rsplit('.', 1)[0] for test_case_class in tests._loader.iterate_suite_cases( loader.suite) }) - tests_json_string = pkgutil.get_data('tests', 'tests.json') + tests_json_string = pkgutil.get_data(self.TEST_PKG_PATH, 'tests.json') tests_json = json.loads(tests_json_string.decode() if six.PY3 else tests_json_string) diff --git a/src/python/grpcio_tests/tests_aio/__init__.py b/src/python/grpcio_tests/tests_aio/__init__.py new file mode 100644 index 00000000000..8ddd3106965 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2019 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. + +from __future__ import absolute_import + +from tests import _loader +from tests import _runner + +Loader = _loader.Loader +Runner = _runner.Runner diff --git a/src/python/grpcio_tests/tests_aio/_sanity/__init__.py b/src/python/grpcio_tests/tests_aio/_sanity/__init__.py new file mode 100644 index 00000000000..f4b321fc5b2 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/_sanity/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 The 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. diff --git a/src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py b/src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py new file mode 100644 index 00000000000..e74dec0739b --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py @@ -0,0 +1,27 @@ +# Copyright 2019 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. + +import unittest + +from tests._sanity import _sanity_test + + +class AioSanityTest(_sanity_test.SanityTest): + + TEST_PKG_MODULE_NAME = 'tests_aio' + TEST_PKG_PATH = 'tests_aio' + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests_aio/tests.json b/src/python/grpcio_tests/tests_aio/tests.json new file mode 100644 index 00000000000..49d025a5abe --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/tests.json @@ -0,0 +1,5 @@ +[ + "_sanity._sanity_test.AioSanityTest", + "unit.channel_test.TestChannel", + "unit.init_test.TestInsecureChannel" +] diff --git a/src/python/grpcio_tests/tests_aio/unit/__init__.py b/src/python/grpcio_tests/tests_aio/unit/__init__.py new file mode 100644 index 00000000000..f4b321fc5b2 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 The 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. diff --git a/src/python/grpcio_tests/tests_aio/unit/channel_test.py b/src/python/grpcio_tests/tests_aio/unit/channel_test.py new file mode 100644 index 00000000000..6bc53ec625e --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/channel_test.py @@ -0,0 +1,58 @@ +# Copyright 2019 The 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. + +import logging +import unittest + +from grpc.experimental import aio +from tests_aio.unit import test_base +from src.proto.grpc.testing import messages_pb2 + + +class TestChannel(test_base.AioTestBase): + + def test_async_context(self): + + async def coro(): + async with aio.insecure_channel(self.server_target) as channel: + hi = channel.unary_unary( + '/grpc.testing.TestService/UnaryCall', + request_serializer=messages_pb2.SimpleRequest. + SerializeToString, + response_deserializer=messages_pb2.SimpleResponse.FromString + ) + await hi(messages_pb2.SimpleRequest()) + + self.loop.run_until_complete(coro()) + + def test_unary_unary(self): + + async def coro(): + channel = aio.insecure_channel(self.server_target) + hi = channel.unary_unary( + '/grpc.testing.TestService/UnaryCall', + request_serializer=messages_pb2.SimpleRequest.SerializeToString, + response_deserializer=messages_pb2.SimpleResponse.FromString) + response = await hi(messages_pb2.SimpleRequest()) + + self.assertEqual(type(response), messages_pb2.SimpleResponse) + + await channel.close() + + self.loop.run_until_complete(coro()) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests_aio/unit/init_test.py b/src/python/grpcio_tests/tests_aio/unit/init_test.py new file mode 100644 index 00000000000..ab580f18e11 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/init_test.py @@ -0,0 +1,35 @@ +# Copyright 2019 The 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. + +import logging +import unittest + +from grpc.experimental import aio +from tests_aio.unit import test_base + + +class TestInsecureChannel(test_base.AioTestBase): + + def test_insecure_channel(self): + + async def coro(): + channel = aio.insecure_channel(self.server_target) + self.assertIsInstance(channel, aio.Channel) + + self.loop.run_until_complete(coro()) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests_aio/unit/sync_server.py b/src/python/grpcio_tests/tests_aio/unit/sync_server.py new file mode 100644 index 00000000000..105ded8e76c --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/sync_server.py @@ -0,0 +1,50 @@ +# Copyright 2019 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. + +import argparse + +from concurrent import futures +from time import sleep + +import grpc +from src.proto.grpc.testing import messages_pb2 +from src.proto.grpc.testing import test_pb2_grpc + + +# TODO (https://github.com/grpc/grpc/issues/19762) +# Change for an asynchronous server version once it's implemented. +class TestServiceServicer(test_pb2_grpc.TestServiceServicer): + + def UnaryCall(self, request, context): + return messages_pb2.SimpleResponse() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Synchronous gRPC server.') + parser.add_argument( + '--host_and_port', + required=True, + type=str, + nargs=1, + help='the host and port to listen.') + args = parser.parse_args() + + server = grpc.server( + futures.ThreadPoolExecutor(max_workers=1), + options=(('grpc.so_reuseport', 1),)) + test_pb2_grpc.add_TestServiceServicer_to_server(TestServiceServicer(), + server) + server.add_insecure_port(args.host_and_port[0]) + server.start() + server.wait_for_termination() diff --git a/src/python/grpcio_tests/tests_aio/unit/test_base.py b/src/python/grpcio_tests/tests_aio/unit/test_base.py new file mode 100644 index 00000000000..0b325523e0f --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/test_base.py @@ -0,0 +1,101 @@ +# Copyright 2019 The 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. + +import os +import sys +import subprocess + +import asyncio +import unittest +import socket + +from grpc.experimental import aio +from tests_aio.unit import sync_server + + +def _get_free_loopback_tcp_port(): + if socket.has_ipv6: + tcp_socket = socket.socket(socket.AF_INET6) + host = "::1" + host_target = "[::1]" + else: + tcp_socket = socket.socket(socket.AF_INET) + host = "127.0.0.1" + host_target = host + tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) + tcp_socket.bind((host, 0)) + address_tuple = tcp_socket.getsockname() + return tcp_socket, "%s:%s" % (host_target, address_tuple[1]) + + +class _Server: + """_Server is an wrapper for a sync-server subprocess. + + The synchronous server is executed in another process which initializes + implicitly the grpc using the synchronous configuration. Both worlds + can not coexist within the same process. + """ + + def __init__(self, host_and_port): # pylint: disable=W0621 + self._host_and_port = host_and_port + self._handle = None + + def start(self): + assert self._handle is None + + try: + from google3.pyglib import resources + executable = resources.GetResourceFilename( + "google3/third_party/py/grpc/sync_server") + args = [executable, '--host_and_port', self._host_and_port] + except ImportError: + executable = sys.executable + directory, _ = os.path.split(os.path.abspath(__file__)) + filename = directory + '/sync_server.py' + args = [ + executable, filename, '--host_and_port', self._host_and_port + ] + + self._handle = subprocess.Popen(args) + + def terminate(self): + if not self._handle: + return + + self._handle.terminate() + self._handle.wait() + self._handle = None + + +class AioTestBase(unittest.TestCase): + + def setUp(self): + self._socket, self._target = _get_free_loopback_tcp_port() + self._server = _Server(self._target) + self._server.start() + self._loop = asyncio.new_event_loop() + asyncio.set_event_loop(self._loop) + aio.init_grpc_aio() + + def tearDown(self): + self._server.terminate() + self._socket.close() + + @property + def loop(self): + return self._loop + + @property + def server_target(self): + return self._target diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a3708dc2b80..3476f9ce4c8 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -703,6 +703,10 @@ class PythonConfig( class PythonLanguage(object): + _DEFAULT_COMMAND = 'test_lite' + _TEST_SPECS_FILE = 'src/python/grpcio_tests/tests/tests.json' + _TEST_FOLDER = 'test' + def configure(self, config, args): self.config = config self.args = args @@ -710,8 +714,7 @@ class PythonLanguage(object): def test_specs(self): # load list of known test suites - with open( - 'src/python/grpcio_tests/tests/tests.json') as tests_json_file: + with open(self._TEST_SPECS_FILE) as tests_json_file: tests_json = json.load(tests_json_file) environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS) return [ @@ -721,7 +724,8 @@ class PythonLanguage(object): environ=dict( list(environment.items()) + [( 'GRPC_PYTHON_TESTRUNNER_FILTER', str(suite_name))]), - shortname='%s.test.%s' % (config.name, suite_name), + shortname='%s.%s.%s' % (config.name, self._TEST_FOLDER, + suite_name), ) for suite_name in tests_json for config in self.pythons ] @@ -789,7 +793,7 @@ class PythonLanguage(object): venv_relative_python = ['bin/python'] toolchain = ['unix'] - test_command = 'test_lite' + test_command = self._DEFAULT_COMMAND if args.iomgr_platform == 'gevent': test_command = 'test_gevent' runner = [ @@ -882,6 +886,31 @@ class PythonLanguage(object): return 'python' +class PythonAioLanguage(PythonLanguage): + + _DEFAULT_COMMAND = 'test_aio' + _TEST_SPECS_FILE = 'src/python/grpcio_tests/tests_aio/tests.json' + _TEST_FOLDER = 'test_aio' + + def configure(self, config, args): + self.config = config + self.args = args + self.pythons = self._get_pythons(self.args) + + def _get_pythons(self, args): + """Get python runtimes to test with, based on current platform, architecture, compiler etc.""" + + if args.compiler not in ('python3.6', 'python3.7', 'python3.8'): + raise Exception('Compiler %s not supported.' % args.compiler) + if args.iomgr_platform not in ('native'): + raise Exception( + 'Iomgr platform %s not supported.' % args.iomgr_platform) + return super()._get_pythons(args) + + def __str__(self): + return 'python_aio' + + class RubyLanguage(object): def configure(self, config, args): @@ -1269,6 +1298,7 @@ _LANGUAGES = { 'php': PhpLanguage(), 'php7': Php7Language(), 'python': PythonLanguage(), + 'python-aio': PythonAioLanguage(), 'ruby': RubyLanguage(), 'csharp': CSharpLanguage(), 'objc': ObjCLanguage(), From e9802ca190550dbe38f89c4b79914b008f56a26f Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Wed, 11 Sep 2019 19:06:34 +0000 Subject: [PATCH 167/176] Add v1.22.3 and v1.23.1 release of grpc-go to interop matrix. v1.23.0 seems to have missed out since the [PR](https://github.com/grpc/grpc/pull/19928) to add that had a merge conflict and was never merged. --- tools/interop_matrix/client_matrix.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 5011e2ae700..ec219655543 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -145,7 +145,8 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), ('v1.21.3', ReleaseInfo(runtimes=['go1.11'])), - ('v1.22.2', ReleaseInfo(runtimes=['go1.11'])), + ('v1.22.3', ReleaseInfo(runtimes=['go1.11'])), + ('v1.23.1', ReleaseInfo(runtimes=['go1.11'])), ]), 'java': OrderedDict([ From 35a1f0a9634baea573b343edf77e63f09dbff039 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 2 Sep 2019 21:10:11 -0700 Subject: [PATCH 168/176] Add transport interceptor --- src/objective-c/GRPCClient/GRPCCall.m | 11 + src/objective-c/GRPCClient/GRPCTransport.h | 6 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 4 + .../private/GRPCCore/GRPCCoreFactory.m | 8 + .../tests/Tests.xcodeproj/project.pbxproj | 4 + .../tests/UnitTests/TransportTests.m | 232 ++++++++++++++++++ 6 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 src/objective-c/tests/UnitTests/TransportTests.m diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 87c2768187e..0cfa38aa3e5 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -22,6 +22,7 @@ #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" +#import "GRPCTransport.h" #import "private/GRPCTransport+Private.h" NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; @@ -183,6 +184,16 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; if (globalInterceptorFactory != nil) { [interceptorFactories addObject:globalInterceptorFactory]; } + if (_actualCallOptions.transport != NULL) { + id transportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithID:_actualCallOptions.transport]; + + NSArray> *transportInterceptorFactories = + transportFactory.transportInterceptorFactories; + if (transportInterceptorFactories != nil) { + [interceptorFactories addObjectsFromArray:transportInterceptorFactories]; + } + } // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index a29dbd20e4d..400cf46e705 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -48,11 +48,15 @@ NSUInteger TransportIDHash(GRPCTransportID); @class GRPCCallOptions; @class GRPCTransport; -/** The factory method to create a transport. */ +/** The factory to create a transport. */ @protocol GRPCTransportFactory +/** Create a transport implementation. */ - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; +/** Get a list of factories for transport inteceptors. */ +@property(nonatomic, readonly) NSArray> *transportInterceptorFactories; + @end /** The registry of transport implementations. */ diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m index 2205d167d82..a595f4b7e63 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -47,6 +47,10 @@ static dispatch_once_t gInitGRPCCoreCronetFactory; return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; } +- (NSArray> *)transportInterceptorFactories { + return nil; +} + - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { return [GRPCCronetChannelFactory sharedInstance]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m index 928625f1275..c3cefb7b649 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -48,6 +48,10 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; } +- (NSArray> *)transportInterceptorFactories { + return nil; +} + - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { NSError *error; id factory = @@ -83,6 +87,10 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; } +- (NSArray> *)transportInterceptorFactories { + return nil; +} + - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { return [GRPCInsecureChannelFactory sharedInstance]; } diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 2ce32d3916d..927a7b64c3e 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 5E7F489022778C95006656AD /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */; }; 5E9F1C352321C9B200837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */; }; + 5E9F1C59232302E200837469 /* TransportTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C58232302E200837469 /* TransportTests.m */; }; 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; @@ -125,6 +126,7 @@ 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; + 5E9F1C58232302E200837469 /* TransportTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TransportTests.m; sourceTree = ""; }; 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; @@ -366,6 +368,7 @@ 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( + 5E9F1C58232302E200837469 /* TransportTests.m */, 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */, 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */, 5E7F488622778AEA006656AD /* GRPCClientTests.m */, @@ -874,6 +877,7 @@ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */, 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */, 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */, + 5E9F1C59232302E200837469 /* TransportTests.m in Sources */, 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */, 5E7F488722778AEA006656AD /* GRPCClientTests.m in Sources */, 5E7F487E22778256006656AD /* ChannelTests.m in Sources */, diff --git a/src/objective-c/tests/UnitTests/TransportTests.m b/src/objective-c/tests/UnitTests/TransportTests.m new file mode 100644 index 00000000000..5f4db26258e --- /dev/null +++ b/src/objective-c/tests/UnitTests/TransportTests.m @@ -0,0 +1,232 @@ +/* + * + * Copyright 2019 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. + * + */ + +#import +#import +#import +#import + +#define TEST_TIMEOUT (8.0) + +static NSString *const kRemoteHost = @"grpc-test.sandbox.googleapis.com:443"; + +static const GRPCTransportID kFakeTransportID = "io.grpc.transport.unittest.fake"; + +@class GRPCFakeTransportFactory; +dispatch_once_t initFakeTransportFactory; +static GRPCFakeTransportFactory *fakeTransportFactory; + +@interface GRPCFakeTransportFactory : NSObject + +@property(atomic) GRPCTransport *nextTransportInstance; +- (void)setTransportInterceptorFactories:(NSArray> *)factories; + +@end + +@implementation GRPCFakeTransportFactory { + NSArray> *_interceptorFactories; +} + ++ (instancetype)sharedInstance { + dispatch_once(&initFakeTransportFactory, ^{ + fakeTransportFactory = [[GRPCFakeTransportFactory alloc] init]; + }); + return fakeTransportFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] registerTransportWithID:kFakeTransportID + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return _nextTransportInstance; +} + +- (void)setTransportInterceptorFactories:(NSArray> *)factories { + _interceptorFactories = [NSArray arrayWithArray:factories]; +} + +- (NSArray> *)transportInterceptorFactories { + return _interceptorFactories; +} + +@end + +@interface DummyInterceptor : GRPCInterceptor + +@property(atomic) BOOL hit; + +@end + +@implementation DummyInterceptor { + GRPCInterceptorManager *_manager; +} + +- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager + dispatchQueue:(dispatch_queue_t)dispatchQueue { + if (dispatchQueue == nil) { + dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { + _manager = interceptorManager; + } + return self; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + self.hit = YES; + [_manager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled." + }]]; + [_manager shutDown]; +} + +@end + +@interface DummyInterceptorFactory : NSObject + ++ (instancetype)sharedInstance; + +@end + +static DummyInterceptorFactory *dummyInterceptorFactory; +static dispatch_once_t initDummyInterceptorFactory; + +@implementation DummyInterceptorFactory + ++ (instancetype)sharedInstance { + dispatch_once(&initDummyInterceptorFactory, ^{ + dummyInterceptorFactory = [[DummyInterceptorFactory alloc] init]; + }); + return dummyInterceptorFactory; +} + +- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { + return [[DummyInterceptor alloc] + initWithInterceptorManager:interceptorManager + dispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL)]; +} + +@end + +@interface TestsBlockCallbacks : NSObject + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + dataCallback:(void (^)(id))dataCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback + writeMessageCallback:(void (^)(void))writeMessageCallback; + +@end + +@implementation TestsBlockCallbacks { + void (^_initialMetadataCallback)(NSDictionary *); + void (^_dataCallback)(id); + void (^_closeCallback)(NSDictionary *, NSError *); + void (^_writeMessageCallback)(void); + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + dataCallback:(void (^)(id))dataCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback + writeMessageCallback:(void (^)(void))writeMessageCallback { + if ((self = [super init])) { + _initialMetadataCallback = initialMetadataCallback; + _dataCallback = dataCallback; + _closeCallback = closeCallback; + _writeMessageCallback = writeMessageCallback; + _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL); + } + return self; +} + +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { + if (_initialMetadataCallback) { + _initialMetadataCallback(initialMetadata); + } +} + +- (void)didReceiveProtoMessage:(id)message { + if (_dataCallback) { + _dataCallback(message); + } +} + +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + if (_closeCallback) { + _closeCallback(trailingMetadata, error); + } +} + +- (void)didWriteMessage { + if (_writeMessageCallback) { + _writeMessageCallback(); + } +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} +@end + +@interface TransportTests : XCTestCase + +@end + +@implementation TransportTests + +- (void)testTransportInterceptors { + __weak XCTestExpectation *expectComplete = + [self expectationWithDescription:@"Expect call complete"]; + [GRPCFakeTransportFactory sharedInstance].nextTransportInstance = nil; + + [[GRPCFakeTransportFactory sharedInstance] + setTransportInterceptorFactories:@[ [DummyInterceptorFactory sharedInstance] ]]; + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:kRemoteHost + path:@"/UnaryCall" + safety:GRPCCallSafetyDefault]; + GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; + callOptions.transport = kFakeTransportID; + GRPCCall2 *call = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[TestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + dataCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual(error.code, + GRPCErrorCodeCancelled); + [expectComplete fulfill]; + } + writeMessageCallback:nil] + callOptions:callOptions]; + [call start]; + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +@end From 1b1364eb6b6b17875d1dce77377ec1a8b343d0a2 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 11 Sep 2019 14:17:27 -0700 Subject: [PATCH 169/176] Reviewer comments --- .../filters/http/client/http_client_filter.cc | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 1793e8106e4..1687f7ead09 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -340,11 +340,11 @@ static void remove_if_present(grpc_metadata_batch* batch, } } -static void hc_start_transport_stream_op_batch( +static void http_client_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); channel_data* channeld = static_cast(elem->channel_data); - GPR_TIMER_SCOPE("hc_start_transport_stream_op_batch", 0); + GPR_TIMER_SCOPE("http_client_start_transport_stream_op_batch", 0); if (batch->recv_initial_metadata) { /* substitute our callback for the higher callback */ @@ -465,16 +465,16 @@ done: } /* Constructor for call_data */ -static grpc_error* hc_init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* http_client_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void hc_destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void http_client_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } @@ -566,8 +566,8 @@ static grpc_core::ManagedMemorySlice user_agent_from_args( } /* Constructor for channel_data */ -static grpc_error* hc_init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* http_client_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); GPR_ASSERT(!args->is_last); GPR_ASSERT(args->optional_transport != nullptr); @@ -582,20 +582,20 @@ static grpc_error* hc_init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void hc_destroy_channel_elem(grpc_channel_element* elem) { +static void http_client_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); GRPC_MDELEM_UNREF(chand->user_agent); } const grpc_channel_filter grpc_http_client_filter = { - hc_start_transport_stream_op_batch, + http_client_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - hc_init_call_elem, + http_client_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - hc_destroy_call_elem, + http_client_destroy_call_elem, sizeof(channel_data), - hc_init_channel_elem, - hc_destroy_channel_elem, + http_client_init_channel_elem, + http_client_destroy_channel_elem, grpc_channel_next_get_info, "http-client"}; From 9f6f04d91a89fb71ab7a46932aa43df7ca8d2a5f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 11 Sep 2019 14:12:29 -0700 Subject: [PATCH 170/176] Address comments --- src/objective-c/GRPCClient/GRPCCall.m | 8 +-- .../tests/UnitTests/TransportTests.m | 51 ++++++++++++------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 0cfa38aa3e5..047e6774c74 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -197,14 +197,15 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { - _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportID:_callOptions.transport - previousInterceptor:dispatcher]; + _firstInterceptor = + [[GRPCTransportManager alloc] initWithTransportID:_actualCallOptions.transport + previousInterceptor:dispatcher]; break; } else { _firstInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories previousInterceptor:dispatcher - transportID:_callOptions.transport]; + transportID:_actualCallOptions.transport]; if (_firstInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } @@ -215,7 +216,6 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; NSLog(@"Failed to create interceptor or transport."); } } - return self; } diff --git a/src/objective-c/tests/UnitTests/TransportTests.m b/src/objective-c/tests/UnitTests/TransportTests.m index 5f4db26258e..37564cdb972 100644 --- a/src/objective-c/tests/UnitTests/TransportTests.m +++ b/src/objective-c/tests/UnitTests/TransportTests.m @@ -76,15 +76,18 @@ static GRPCFakeTransportFactory *fakeTransportFactory; @implementation DummyInterceptor { GRPCInterceptorManager *_manager; + BOOL _passthrough; } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue { + dispatchQueue:(dispatch_queue_t)dispatchQueue + passthrough:(BOOL)passthrough { if (dispatchQueue == nil) { dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); } if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { _manager = interceptorManager; + _passthrough = passthrough; } return self; } @@ -92,42 +95,50 @@ static GRPCFakeTransportFactory *fakeTransportFactory; - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { self.hit = YES; - [_manager - forwardPreviousInterceptorCloseWithTrailingMetadata:nil - error:[NSError + if (_passthrough) { + [super startWithRequestOptions:requestOptions callOptions:callOptions]; + } else { + [_manager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error: + [NSError errorWithDomain:kGRPCErrorDomain code:GRPCErrorCodeCancelled userInfo:@{ NSLocalizedDescriptionKey : @"Canceled." }]]; - [_manager shutDown]; + [_manager shutDown]; + } } @end @interface DummyInterceptorFactory : NSObject -+ (instancetype)sharedInstance; +- (instancetype)initWithPassthrough:(BOOL)passthrough; -@end +@property(nonatomic, readonly) DummyInterceptor *lastInterceptor; -static DummyInterceptorFactory *dummyInterceptorFactory; -static dispatch_once_t initDummyInterceptorFactory; +@end -@implementation DummyInterceptorFactory +@implementation DummyInterceptorFactory { + BOOL _passthrough; +} -+ (instancetype)sharedInstance { - dispatch_once(&initDummyInterceptorFactory, ^{ - dummyInterceptorFactory = [[DummyInterceptorFactory alloc] init]; - }); - return dummyInterceptorFactory; +- (instancetype)initWithPassthrough:(BOOL)passthrough { + if ((self = [super init])) { + _passthrough = passthrough; + } + return self; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { - return [[DummyInterceptor alloc] + _lastInterceptor = [[DummyInterceptor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL)]; + dispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + passthrough:_passthrough]; + return _lastInterceptor; } @end @@ -203,8 +214,10 @@ static dispatch_once_t initDummyInterceptorFactory; [self expectationWithDescription:@"Expect call complete"]; [GRPCFakeTransportFactory sharedInstance].nextTransportInstance = nil; + DummyInterceptorFactory *factory = [[DummyInterceptorFactory alloc] initWithPassthrough:YES]; + DummyInterceptorFactory *factory2 = [[DummyInterceptorFactory alloc] initWithPassthrough:NO]; [[GRPCFakeTransportFactory sharedInstance] - setTransportInterceptorFactories:@[ [DummyInterceptorFactory sharedInstance] ]]; + setTransportInterceptorFactories:@[ factory, factory2 ]]; GRPCRequestOptions *requestOptions = [[GRPCRequestOptions alloc] initWithHost:kRemoteHost path:@"/UnaryCall" @@ -227,6 +240,8 @@ static dispatch_once_t initDummyInterceptorFactory; callOptions:callOptions]; [call start]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + XCTAssertTrue(factory.lastInterceptor.hit); + XCTAssertTrue(factory2.lastInterceptor.hit); } @end From 5630b97a6ccb1495707119027996bddf8ccb47c9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 12 Sep 2019 10:18:59 +0200 Subject: [PATCH 171/176] update docs with grpc-dotnet info --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3a4c1f17d1..9f91412bc2c 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Libraries in different languages may be in various states of development. We are | Ruby | [src/ruby](src/ruby) | | Python | [src/python](src/python) | | PHP | [src/php](src/php) | -| C# | [src/csharp](src/csharp) | +| C# (core library based) | [src/csharp](src/csharp) | | Objective-C | [src/objective-c](src/objective-c) | | Language | Source repo | @@ -82,4 +82,4 @@ Libraries in different languages may be in various states of development. We are | NodeJS | [grpc-node](https://github.com/grpc/grpc-node) | | WebJS | [grpc-web](https://github.com/grpc/grpc-web) | | Dart | [grpc-dart](https://github.com/grpc/grpc-dart) | - +| .NET (pure C# impl.) | [grpc-dotnet](https://github.com/grpc/grpc-dotnet) | From 275b613681b62e7b14a84d263118c5ef363740bc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 12 Sep 2019 14:52:06 +0200 Subject: [PATCH 172/176] note on two C# implementations --- src/csharp/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/csharp/README.md b/src/csharp/README.md index 13c8502af61..26da8d560cc 100644 --- a/src/csharp/README.md +++ b/src/csharp/README.md @@ -2,7 +2,18 @@ gRPC C# ======= -A C# implementation of gRPC. +A C# implementation of gRPC based on the native gRPC Core library. + +There are currently two official implementations of gRPC for C# + +- The original gRPC C# implementation based on the native gRPC Core library (the source code lives in this directory) +- The new "gRPC for .NET" implementation written in pure C# and based on the newly released .NET Core 3 (source code available at https://github.com/grpc/grpc-dotnet) + +The implementations are meant to coexist side-by-side and each has its own advantages in terms of available features, integrations, supported platforms, maturity level and performance. +They share the same API for invoking and handling RPCs, thus limiting the lock-in and enabling users to choose the implementation that satisfies their needs the best +(and perhaps adjust their choice over time without needing to do too much refactoring). + +The following documentation is for the original gRPC C# implementation only (the `Grpc.Core` nuget package). SUPPORTED PLATFORMS ------------------ From a879ff73c29c932a3e864b865341bf75901618c7 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 12 Sep 2019 16:27:45 -0700 Subject: [PATCH 173/176] Move mock test to use ::grpc_impl Some mock tests are using ::grpc which was causing build issues. Move them over to use ::grpc_impl. --- include/grpcpp/test/mock_stream.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/test/mock_stream.h b/include/grpcpp/test/mock_stream.h index 93963f7dbb7..b4e16159061 100644 --- a/include/grpcpp/test/mock_stream.h +++ b/include/grpcpp/test/mock_stream.h @@ -31,7 +31,7 @@ namespace grpc { namespace testing { template -class MockClientReader : public ClientReaderInterface { +class MockClientReader : public ::grpc_impl::ClientReaderInterface { public: MockClientReader() = default; @@ -47,7 +47,7 @@ class MockClientReader : public ClientReaderInterface { }; template -class MockClientWriter : public ClientWriterInterface { +class MockClientWriter : public ::grpc_impl::ClientWriterInterface { public: MockClientWriter() = default; @@ -62,7 +62,7 @@ class MockClientWriter : public ClientWriterInterface { }; template -class MockClientReaderWriter : public ClientReaderWriterInterface { +class MockClientReaderWriter : public ::grpc_impl::ClientReaderWriterInterface { public: MockClientReaderWriter() = default; @@ -85,7 +85,7 @@ class MockClientReaderWriter : public ClientReaderWriterInterface { template class MockClientAsyncResponseReader - : public ClientAsyncResponseReaderInterface { + : public ::grpc_impl::ClientAsyncResponseReaderInterface { public: MockClientAsyncResponseReader() = default; @@ -107,7 +107,7 @@ class MockClientAsyncReader : public ClientAsyncReaderInterface { }; template -class MockClientAsyncWriter : public ClientAsyncWriterInterface { +class MockClientAsyncWriter : public ::grpc_impl::ClientAsyncWriterInterface { public: MockClientAsyncWriter() = default; From 3e4fd7967c3d07e7cec501c583efc19e246cd312 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Fri, 13 Sep 2019 09:10:59 -0700 Subject: [PATCH 174/176] Formatting fixes --- include/grpcpp/test/mock_stream.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/grpcpp/test/mock_stream.h b/include/grpcpp/test/mock_stream.h index b4e16159061..55e76f6f0a2 100644 --- a/include/grpcpp/test/mock_stream.h +++ b/include/grpcpp/test/mock_stream.h @@ -62,7 +62,8 @@ class MockClientWriter : public ::grpc_impl::ClientWriterInterface { }; template -class MockClientReaderWriter : public ::grpc_impl::ClientReaderWriterInterface { +class MockClientReaderWriter + : public ::grpc_impl::ClientReaderWriterInterface { public: MockClientReaderWriter() = default; @@ -107,7 +108,8 @@ class MockClientAsyncReader : public ClientAsyncReaderInterface { }; template -class MockClientAsyncWriter : public ::grpc_impl::ClientAsyncWriterInterface { +class MockClientAsyncWriter + : public ::grpc_impl::ClientAsyncWriterInterface { public: MockClientAsyncWriter() = default; From ad8d728b0015eba4075aa3abf118920eaa751ad4 Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Fri, 13 Sep 2019 10:31:22 -0700 Subject: [PATCH 175/176] Root pem certificates update on Sept 2019 --- etc/roots.pem | 100 -------------------------------------------------- 1 file changed, 100 deletions(-) diff --git a/etc/roots.pem b/etc/roots.pem index 22bd2ab88dd..85850b9a78f 100644 --- a/etc/roots.pem +++ b/etc/roots.pem @@ -774,36 +774,6 @@ vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep +OkuE6N36B9K -----END CERTIFICATE----- -# Issuer: CN=Class 2 Primary CA O=Certplus -# Subject: CN=Class 2 Primary CA O=Certplus -# Label: "Certplus Class 2 Primary CA" -# Serial: 177770208045934040241468760488327595043 -# MD5 Fingerprint: 88:2c:8c:52:b8:a2:3c:f3:f7:bb:03:ea:ae:ac:42:0b -# SHA1 Fingerprint: 74:20:74:41:72:9c:dd:92:ec:79:31:d8:23:10:8d:c2:81:92:e2:bb -# SHA256 Fingerprint: 0f:99:3c:8a:ef:97:ba:af:56:87:14:0e:d5:9a:d1:82:1b:b4:af:ac:f0:aa:9a:58:b5:d5:7a:33:8a:3a:fb:cb ------BEGIN CERTIFICATE----- -MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAw -PTELMAkGA1UEBhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFz -cyAyIFByaW1hcnkgQ0EwHhcNOTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9 -MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2VydHBsdXMxGzAZBgNVBAMTEkNsYXNz -IDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANxQ -ltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR5aiR -VhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyL -kcAbmXuZVg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCd -EgETjdyAYveVqUSISnFOYFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yas -H7WLO7dDWWuwJKZtkIvEcupdM5i3y95ee++U8Rs+yskhwcWYAqqi9lt3m/V+llU0 -HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRMECDAGAQH/AgEKMAsGA1Ud -DwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJYIZIAYb4 -QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMu -Y29tL0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/ -AN9WM2K191EBkOvDP9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8 -yfFC82x/xXp8HVGIutIKPidd3i1RTtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMR -FcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+7UCmnYR0ObncHoUW2ikbhiMA -ybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW//1IMwrh3KWB -kJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7 -l7+ijrRU ------END CERTIFICATE----- - # Issuer: CN=DST Root CA X3 O=Digital Signature Trust Co. # Subject: CN=DST Root CA X3 O=Digital Signature Trust Co. # Label: "DST Root CA X3" @@ -1222,36 +1192,6 @@ t0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg== -----END CERTIFICATE----- -# Issuer: CN=Deutsche Telekom Root CA 2 O=Deutsche Telekom AG OU=T-TeleSec Trust Center -# Subject: CN=Deutsche Telekom Root CA 2 O=Deutsche Telekom AG OU=T-TeleSec Trust Center -# Label: "Deutsche Telekom Root CA 2" -# Serial: 38 -# MD5 Fingerprint: 74:01:4a:91:b1:08:c4:58:ce:47:cd:f0:dd:11:53:08 -# SHA1 Fingerprint: 85:a4:08:c0:9c:19:3e:5d:51:58:7d:cd:d6:13:30:fd:8c:de:37:bf -# SHA256 Fingerprint: b6:19:1a:50:d0:c3:97:7f:7d:a9:9b:cd:aa:c8:6a:22:7d:ae:b9:67:9e:c7:0b:a3:b0:c9:d9:22:71:c1:70:d3 ------BEGIN CERTIFICATE----- -MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEc -MBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2Vj -IFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENB -IDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5MjM1OTAwWjBxMQswCQYDVQQGEwJE -RTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxl -U2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290 -IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEU -ha88EOQ5bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhC -QN/Po7qCWWqSG6wcmtoIKyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1Mjwr -rFDa1sPeg5TKqAyZMg4ISFZbavva4VhYAUlfckE8FQYBjl2tqriTtM2e66foai1S -NNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aKSe5TBY8ZTNXeWHmb0moc -QqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTVjlsB9WoH -txa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAP -BgNVHRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOC -AQEAlGRZrTlk5ynrE/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756Abrsp -tJh6sTtU6zkXR34ajgv8HzFZMQSyzhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpa -IzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8rZ7/gFnkm0W09juwzTkZmDLl -6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4Gdyd1Lx+4ivn+ -xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU -Cm26OWMohpLzGITY+9HPBVZkVw== ------END CERTIFICATE----- - # Issuer: CN=Cybertrust Global Root O=Cybertrust, Inc # Subject: CN=Cybertrust Global Root O=Cybertrust, Inc # Label: "Cybertrust Global Root" @@ -3495,46 +3435,6 @@ AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ 5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su -----END CERTIFICATE----- -# Issuer: CN=Certinomis - Root CA O=Certinomis OU=0002 433998903 -# Subject: CN=Certinomis - Root CA O=Certinomis OU=0002 433998903 -# Label: "Certinomis - Root CA" -# Serial: 1 -# MD5 Fingerprint: 14:0a:fd:8d:a8:28:b5:38:69:db:56:7e:61:22:03:3f -# SHA1 Fingerprint: 9d:70:bb:01:a5:a4:a0:18:11:2e:f7:1c:01:b9:32:c5:34:e7:88:a8 -# SHA256 Fingerprint: 2a:99:f5:bc:11:74:b7:3c:bb:1d:62:08:84:e0:1c:34:e5:1c:cb:39:78:da:12:5f:0e:33:26:88:83:bf:41:58 ------BEGIN CERTIFICATE----- -MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjET -MBEGA1UEChMKQ2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAb -BgNVBAMTFENlcnRpbm9taXMgLSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMz -MTAyMTA5MTcxOFowWjELMAkGA1UEBhMCRlIxEzARBgNVBAoTCkNlcnRpbm9taXMx -FzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMR0wGwYDVQQDExRDZXJ0aW5vbWlzIC0g -Um9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANTMCQosP5L2 -fxSeC5yaah1AMGT9qt8OHgZbn1CF6s2Nq0Nn3rD6foCWnoR4kkjW4znuzuRZWJfl -LieY6pOod5tK8O90gC3rMB+12ceAnGInkYjwSond3IjmFPnVAy//ldu9n+ws+hQV -WZUKxkd8aRi5pwP5ynapz8dvtF4F/u7BUrJ1Mofs7SlmO/NKFoL21prbcpjp3vDF -TKWrteoB4owuZH9kb/2jJZOLyKIOSY008B/sWEUuNKqEUL3nskoTuLAPrjhdsKkb -5nPJWqHZZkCqqU2mNAKthH6yI8H7KsZn9DS2sJVqM09xRLWtwHkziOC/7aOgFLSc -CbAK42C++PhmiM1b8XcF4LVzbsF9Ri6OSyemzTUK/eVNfaoqoynHWmgE6OXWk6Ri -wsXm9E/G+Z8ajYJJGYrKWUM66A0ywfRMEwNvbqY/kXPLynNvEiCL7sCCeN5LLsJJ -wx3tFvYk9CcbXFcx3FXuqB5vbKziRcxXV4p1VxngtViZSTYxPDMBbRZKzbgqg4SG -m/lg0h9tkQPTYKbVPZrdd5A9NaSfD171UkRpucC63M9933zZxKyGIjK8e2uR73r4 -F2iw4lNVYC2vPsKD2NkJK/DAZNuHi5HMkesE/Xa0lZrmFAYb1TQdvtj/dBxThZng -WVJKYe2InmtJiUZ+IFrZ50rlau7SZRFDAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIB -BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTvkUz1pcMw6C8I6tNxIqSSaHh0 -2TAfBgNVHSMEGDAWgBTvkUz1pcMw6C8I6tNxIqSSaHh02TANBgkqhkiG9w0BAQsF -AAOCAgEAfj1U2iJdGlg+O1QnurrMyOMaauo++RLrVl89UM7g6kgmJs95Vn6RHJk/ -0KGRHCwPT5iVWVO90CLYiF2cN/z7ZMF4jIuaYAnq1fohX9B0ZedQxb8uuQsLrbWw -F6YSjNRieOpWauwK0kDDPAUwPk2Ut59KA9N9J0u2/kTO+hkzGm2kQtHdzMjI1xZS -g081lLMSVX3l4kLr5JyTCcBMWwerx20RoFAXlCOotQqSD7J6wWAsOMwaplv/8gzj -qh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5nU7aJ+BIJy29SWwNyhlCVCNSN -h4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrjcOa4pvi2WsS9Iff/ -ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu6AdBBR8V -btaw5BngDwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwj -Y/M50n92Uaf0yKHxDHYiI0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ -8ow7bkrHxuaAKzyBvBGAFhAn1/DNP3nMcyrDflOR1m749fPH0FFNjkulW+YZFzvW -gQncItzujrnEj1PhZ7szuIgVRs/taTX/dQ1G885x4cVrhkIGuUE= ------END CERTIFICATE----- - # Issuer: CN=OISTE WISeKey Global Root GB CA O=WISeKey OU=OISTE Foundation Endorsed # Subject: CN=OISTE WISeKey Global Root GB CA O=WISeKey OU=OISTE Foundation Endorsed # Label: "OISTE WISeKey Global Root GB CA" From c5662bba808569eba9a2b47312a357cb35887b5c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 16 Sep 2019 13:16:33 +0200 Subject: [PATCH 176/176] use bazel 0.29.0 on windows --- tools/internal_ci/windows/bazel_rbe.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 86dcc74c429..827952791c9 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,8 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.29.1 --limit-output +@rem TODO(jtattermusch): https://github.com/bazelbuild/bazel/issues/9369 prevents upgrade to 0.29.1 +choco install bazel -y --version 0.29.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH%