From 40edfc12b7dfa59d6fc0c3ac2803fadf2f6eec70 Mon Sep 17 00:00:00 2001 From: Robbie Shade Date: Wed, 29 Jun 2016 15:40:54 -0400 Subject: [PATCH 01/25] Delete unused TIMEOUT enum in end2end tests --- test/core/end2end/tests/bad_hostname.c | 1 - test/core/end2end/tests/binary_metadata.c | 1 - test/core/end2end/tests/call_creds.c | 1 - test/core/end2end/tests/cancel_after_accept.c | 1 - test/core/end2end/tests/cancel_after_client_done.c | 1 - test/core/end2end/tests/cancel_after_invoke.c | 1 - test/core/end2end/tests/cancel_before_invoke.c | 1 - test/core/end2end/tests/cancel_in_a_vacuum.c | 1 - test/core/end2end/tests/cancel_with_status.c | 1 - test/core/end2end/tests/compressed_payload.c | 1 - test/core/end2end/tests/default_host.c | 1 - test/core/end2end/tests/disappearing_server.c | 1 - test/core/end2end/tests/empty_batch.c | 1 - test/core/end2end/tests/filter_causes_close.c | 1 - test/core/end2end/tests/graceful_server_shutdown.c | 1 - test/core/end2end/tests/high_initial_seqno.c | 1 - test/core/end2end/tests/idempotent_request.c | 1 - test/core/end2end/tests/invoke_large_request.c | 1 - test/core/end2end/tests/large_metadata.c | 1 - test/core/end2end/tests/max_concurrent_streams.c | 1 - test/core/end2end/tests/max_message_length.c | 1 - test/core/end2end/tests/negative_deadline.c | 1 - test/core/end2end/tests/network_status_change.c | 1 - test/core/end2end/tests/no_op.c | 1 - test/core/end2end/tests/payload.c | 1 - test/core/end2end/tests/ping_pong_streaming.c | 1 - test/core/end2end/tests/registered_call.c | 1 - test/core/end2end/tests/request_with_flags.c | 1 - test/core/end2end/tests/request_with_payload.c | 1 - test/core/end2end/tests/server_finishes_request.c | 1 - test/core/end2end/tests/shutdown_finishes_calls.c | 1 - test/core/end2end/tests/shutdown_finishes_tags.c | 1 - test/core/end2end/tests/simple_delayed_request.c | 1 - test/core/end2end/tests/simple_metadata.c | 1 - test/core/end2end/tests/simple_request.c | 1 - test/core/end2end/tests/streaming_error_response.c | 1 - test/core/end2end/tests/trailing_metadata.c | 1 - 37 files changed, 37 deletions(-) diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index c9663c2155e..4418e6af86a 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 3dd26120777..b59ef73c695 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 694a0aa9ef4..78accf5ede6 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -53,7 +53,6 @@ static const char overridden_iam_selector[] = "overridden_selector"; typedef enum { NONE, OVERRIDE, DESTROY } override_mode; -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 51c13da3b1e..9c1a150f7d0 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 2b5a409deef..c8bab54915b 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 85fbe9de7bb..24d211a3ac6 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index d99062c6082..540196f189e 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 0c893b5f9ef..89560cb38e6 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index 673c7051ad1..1cc87ca4381 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index ec5c012238e..41200278a10 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -50,7 +50,6 @@ #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 728ee597b50..5eb448dfe1c 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 536fbd0d8a8..c06cd83ce69 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index c05b9199146..4617e4e4c48 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 526c05ca3e8..595dc46f685 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -46,7 +46,6 @@ #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static bool g_enable_filter = false; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index f527b8617d9..676a7850ebf 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 50e3c9cb898..1ff4196f173 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -47,7 +47,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index dfedcfebee8..73e5cfc3f0d 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 9c9ca951293..2bc98833d67 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 1f278960196..144b2e1363a 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 41de74ff874..60297420b8a 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 08d326ab4d6..9865300821b 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index dff7992f63b..cd48a93afc4 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index 7e7628391de..a31e0199aec 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -46,7 +46,6 @@ /* this is a private API but exposed here for testing*/ extern void grpc_network_status_shutdown_all_endpoints(); -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 284be7af2ae..142fc04f2b8 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 443d85eecc4..439dfd63266 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 1d2f7943c1d..f1ef05a29d5 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index ece6250ea13..dbeb33aaace 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index b5d398bba9f..41f9eeac7c9 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -44,7 +44,6 @@ #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index d94267e09cf..5f9ba231107 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index a723c6fd2ca..def6a08472e 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index abb6b26a875..6ec766abb55 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c index b1f3c94562a..1df86ce1e47 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.c +++ b/test/core/end2end/tests/shutdown_finishes_tags.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index e1fcc035bbd..5585b493aef 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index c9b1a03da52..f46b3026478 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index a8014e6894c..585e0be7e64 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index e15c132d633..e659f446307 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 41e0f009113..6f6efec8a26 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } From a0399f2a6055ca68e3849da06f8fe2e9c08d6cc7 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Thu, 4 Aug 2016 17:52:53 -0700 Subject: [PATCH 02/25] Fix the error ref issue --- src/core/lib/iomgr/ev_epoll_linux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/ev_epoll_linux.c b/src/core/lib/iomgr/ev_epoll_linux.c index 6a63c4d1d18..70a8ce9d1d2 100644 --- a/src/core/lib/iomgr/ev_epoll_linux.c +++ b/src/core/lib/iomgr/ev_epoll_linux.c @@ -927,7 +927,8 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, fd->polling_island = NULL; } - grpc_exec_ctx_sched(exec_ctx, fd->on_done_closure, error, NULL); + grpc_exec_ctx_sched(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error), + NULL); gpr_mu_unlock(&fd->mu); UNREF_BY(fd, 2, reason); /* Drop the reference */ @@ -939,6 +940,7 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, PI_UNREF(exec_ctx, unref_pi, "fd_orphan"); } GRPC_LOG_IF_ERROR("fd_orphan", GRPC_ERROR_REF(error)); + GRPC_ERROR_UNREF(error); } static grpc_error *fd_shutdown_error(bool shutdown) { From 39d3100f44b3fec6a76c3ee99f9a3c9292dfa27d Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Mon, 4 Jul 2016 13:12:59 +0900 Subject: [PATCH 03/25] Fix a typo --- include/grpc++/impl/codegen/client_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index 012bcc2bbe5..fb10a3be1ab 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -271,7 +271,7 @@ class ClientContext { /// Set \a algorithm to be the compression algorithm used for the client call. /// - /// \param algorith The compression algorithm used for the client call. + /// \param algorithm The compression algorithm used for the client call. void set_compression_algorithm(grpc_compression_algorithm algorithm); /// Return the peer uri in a string. From 4bf00c9f51214e63c3151b8eecbbd48e41088de0 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 19 Aug 2016 12:39:10 -0700 Subject: [PATCH 04/25] slight rewording of grpc_error ownership rules --- src/core/lib/iomgr/error.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index bc7781250e8..6c769accdb6 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -47,7 +47,8 @@ /// if a grpc_error is passed to a grpc_closure callback function (functions /// with the signature: /// void (*f)(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error)) -/// then those functions do not automatically own a ref to error +/// then those functions do not own a ref to error (but are free to manually +/// take a reference). /// if a grpc_error is passed to *ANY OTHER FUNCTION* then that function takes /// ownership of the error /// Errors have: From e0705e2dc258e0679e249f488f3ac7a59d34e762 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 19 Aug 2016 15:13:43 -0700 Subject: [PATCH 05/25] Add ServerReaderWriterInterface --- include/grpc++/impl/codegen/sync_stream.h | 36 ++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index b2b972760db..36518abb785 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -64,6 +64,14 @@ class ClientStreamingInterface { virtual Status Finish() = 0; }; +/// Common interface for all synchronous server side streaming. +class ServerStreamingInterface { + public: + virtual ~ServerStreamingInterface() {} + + virtual void SendInitialMetadata() = 0; +}; + /// An interface that yields a sequence of messages of type \a R. template class ReaderInterface { @@ -336,12 +344,17 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { Call call_; }; +/// Server-side interface for streaming reads of message of type \a R. +template +class ServerReaderInterface : public ServerStreamingInterface, + public ReaderInterface {}; + template -class ServerReader GRPC_FINAL : public ReaderInterface { +class ServerReader GRPC_FINAL : public ServerReaderInterface { public: ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - void SendInitialMetadata() { + void SendInitialMetadata() GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet ops; @@ -367,12 +380,17 @@ class ServerReader GRPC_FINAL : public ReaderInterface { ServerContext* const ctx_; }; +/// Server-side interface for streaming writes of message of type \a W. template -class ServerWriter GRPC_FINAL : public WriterInterface { +class ServerWriterInterface : public ServerStreamingInterface, + public WriterInterface {}; + +template +class ServerWriter GRPC_FINAL : public ServerWriterInterface { public: ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - void SendInitialMetadata() { + void SendInitialMetadata() GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet ops; @@ -411,12 +429,16 @@ class ServerWriter GRPC_FINAL : public WriterInterface { /// Server-side interface for bi-directional streaming. template -class ServerReaderWriter GRPC_FINAL : public WriterInterface, - public ReaderInterface { +class ServerReaderWriterInterface : public ServerStreamingInterface, + public WriterInterface, + public ReaderInterface {}; + +template +class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface { public: ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - void SendInitialMetadata() { + void SendInitialMetadata() GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet ops; From 59e835d43189722e9e84db12ea067001c521c98d Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 19 Aug 2016 15:23:23 -0700 Subject: [PATCH 06/25] Add comments --- include/grpc++/impl/codegen/sync_stream.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 36518abb785..7601ceae92d 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -69,6 +69,7 @@ class ServerStreamingInterface { public: virtual ~ServerStreamingInterface() {} + /// Blocking send initial metadata to client. virtual void SendInitialMetadata() = 0; }; From ff4df06a663e1ed7c9e22392c61dcf982ab0f9ff Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 22 Aug 2016 15:02:49 -0700 Subject: [PATCH 07/25] Rename grpc_client_config to grpc_resolver_result. --- BUILD | 16 ++-- CMakeLists.txt | 6 +- Makefile | 6 +- binding.gyp | 2 +- build.yaml | 4 +- config.m4 | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- package.xml | 4 +- src/core/ext/client_config/README.md | 4 +- src/core/ext/client_config/client_channel.c | 81 ++++++++++--------- .../ext/client_config/lb_policy_factory.h | 2 - src/core/ext/client_config/resolver.c | 4 +- src/core/ext/client_config/resolver.h | 12 +-- src/core/ext/client_config/resolver_factory.h | 2 +- .../{client_config.c => resolver_result.c} | 23 +++--- .../{client_config.h => resolver_result.h} | 27 +++---- .../ext/resolver/dns/native/dns_resolver.c | 42 +++++----- .../ext/resolver/sockaddr/sockaddr_resolver.c | 18 ++--- src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/sources_and_headers.json | 6 +- vsprojects/vcxproj/grpc/grpc.vcxproj | 6 +- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 12 +-- .../grpc_unsecure/grpc_unsecure.vcxproj | 6 +- .../grpc_unsecure.vcxproj.filters | 12 +-- 26 files changed, 156 insertions(+), 157 deletions(-) rename src/core/ext/client_config/{client_config.c => resolver_result.c} (73%) rename src/core/ext/client_config/{client_config.h => resolver_result.h} (68%) diff --git a/BUILD b/BUILD index b7044c5e685..12f0fd316ea 100644 --- a/BUILD +++ b/BUILD @@ -286,7 +286,6 @@ cc_library( "src/core/lib/tsi/transport_security_interface.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -296,6 +295,7 @@ cc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -459,7 +459,6 @@ cc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -471,6 +470,7 @@ cc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -658,7 +658,6 @@ cc_library( "src/core/ext/transport/chttp2/alpn/alpn.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -668,6 +667,7 @@ cc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -815,7 +815,6 @@ cc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -827,6 +826,7 @@ cc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -1011,7 +1011,6 @@ cc_library( "src/core/ext/transport/chttp2/alpn/alpn.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -1021,6 +1020,7 @@ cc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -1159,7 +1159,6 @@ cc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -1171,6 +1170,7 @@ cc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -1952,7 +1952,6 @@ objc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -1964,6 +1963,7 @@ objc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -2153,7 +2153,6 @@ objc_library( "src/core/lib/tsi/transport_security_interface.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -2163,6 +2162,7 @@ objc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5754e6fc1f6..f847c9b0e68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -435,7 +435,6 @@ add_library(grpc src/core/ext/client_config/channel_connectivity.c src/core/ext/client_config/client_channel.c src/core/ext/client_config/client_channel_factory.c - src/core/ext/client_config/client_config.c src/core/ext/client_config/client_config_plugin.c src/core/ext/client_config/connector.c src/core/ext/client_config/default_initial_connect_string.c @@ -447,6 +446,7 @@ add_library(grpc src/core/ext/client_config/resolver.c src/core/ext/client_config/resolver_factory.c src/core/ext/client_config/resolver_registry.c + src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c @@ -667,7 +667,6 @@ add_library(grpc_cronet src/core/ext/client_config/channel_connectivity.c src/core/ext/client_config/client_channel.c src/core/ext/client_config/client_channel_factory.c - src/core/ext/client_config/client_config.c src/core/ext/client_config/client_config_plugin.c src/core/ext/client_config/connector.c src/core/ext/client_config/default_initial_connect_string.c @@ -679,6 +678,7 @@ add_library(grpc_cronet src/core/ext/client_config/resolver.c src/core/ext/client_config/resolver_factory.c src/core/ext/client_config/resolver_registry.c + src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c @@ -899,7 +899,6 @@ add_library(grpc_unsecure src/core/ext/client_config/channel_connectivity.c src/core/ext/client_config/client_channel.c src/core/ext/client_config/client_channel_factory.c - src/core/ext/client_config/client_config.c src/core/ext/client_config/client_config_plugin.c src/core/ext/client_config/connector.c src/core/ext/client_config/default_initial_connect_string.c @@ -911,6 +910,7 @@ add_library(grpc_unsecure src/core/ext/client_config/resolver.c src/core/ext/client_config/resolver_factory.c src/core/ext/client_config/resolver_registry.c + src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c diff --git a/Makefile b/Makefile index 2db87e83ae4..6b619e310b9 100644 --- a/Makefile +++ b/Makefile @@ -2651,7 +2651,6 @@ LIBGRPC_SRC = \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -2663,6 +2662,7 @@ LIBGRPC_SRC = \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ @@ -2901,7 +2901,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -2913,6 +2912,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ @@ -3359,7 +3359,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -3371,6 +3370,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ diff --git a/binding.gyp b/binding.gyp index 17dbfc0d381..a29cfda6fc5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -707,7 +707,6 @@ 'src/core/ext/client_config/channel_connectivity.c', 'src/core/ext/client_config/client_channel.c', 'src/core/ext/client_config/client_channel_factory.c', - 'src/core/ext/client_config/client_config.c', 'src/core/ext/client_config/client_config_plugin.c', 'src/core/ext/client_config/connector.c', 'src/core/ext/client_config/default_initial_connect_string.c', @@ -719,6 +718,7 @@ 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', + 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', diff --git a/build.yaml b/build.yaml index 2f57859fc16..73c626351da 100644 --- a/build.yaml +++ b/build.yaml @@ -332,7 +332,6 @@ filegroups: headers: - src/core/ext/client_config/client_channel.h - src/core/ext/client_config/client_channel_factory.h - - src/core/ext/client_config/client_config.h - src/core/ext/client_config/connector.h - src/core/ext/client_config/initial_connect_string.h - src/core/ext/client_config/lb_policy.h @@ -342,6 +341,7 @@ filegroups: - src/core/ext/client_config/resolver.h - src/core/ext/client_config/resolver_factory.h - src/core/ext/client_config/resolver_registry.h + - src/core/ext/client_config/resolver_result.h - src/core/ext/client_config/subchannel.h - src/core/ext/client_config/subchannel_call_holder.h - src/core/ext/client_config/subchannel_index.h @@ -350,7 +350,6 @@ filegroups: - src/core/ext/client_config/channel_connectivity.c - src/core/ext/client_config/client_channel.c - src/core/ext/client_config/client_channel_factory.c - - src/core/ext/client_config/client_config.c - src/core/ext/client_config/client_config_plugin.c - src/core/ext/client_config/connector.c - src/core/ext/client_config/default_initial_connect_string.c @@ -362,6 +361,7 @@ filegroups: - src/core/ext/client_config/resolver.c - src/core/ext/client_config/resolver_factory.c - src/core/ext/client_config/resolver_registry.c + - src/core/ext/client_config/resolver_result.c - src/core/ext/client_config/subchannel.c - src/core/ext/client_config/subchannel_call_holder.c - src/core/ext/client_config/subchannel_index.c diff --git a/config.m4 b/config.m4 index b37658dc617..5b47074bcd7 100644 --- a/config.m4 +++ b/config.m4 @@ -226,7 +226,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -238,6 +237,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 200f9c21252..02a500f626e 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -379,7 +379,6 @@ Pod::Spec.new do |s| 'src/core/lib/tsi/transport_security_interface.h', 'src/core/ext/client_config/client_channel.h', 'src/core/ext/client_config/client_channel_factory.h', - 'src/core/ext/client_config/client_config.h', 'src/core/ext/client_config/connector.h', 'src/core/ext/client_config/initial_connect_string.h', 'src/core/ext/client_config/lb_policy.h', @@ -389,6 +388,7 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver.h', 'src/core/ext/client_config/resolver_factory.h', 'src/core/ext/client_config/resolver_registry.h', + 'src/core/ext/client_config/resolver_result.h', 'src/core/ext/client_config/subchannel.h', 'src/core/ext/client_config/subchannel_call_holder.h', 'src/core/ext/client_config/subchannel_index.h', @@ -556,7 +556,6 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/channel_connectivity.c', 'src/core/ext/client_config/client_channel.c', 'src/core/ext/client_config/client_channel_factory.c', - 'src/core/ext/client_config/client_config.c', 'src/core/ext/client_config/client_config_plugin.c', 'src/core/ext/client_config/connector.c', 'src/core/ext/client_config/default_initial_connect_string.c', @@ -568,6 +567,7 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', + 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', @@ -740,7 +740,6 @@ Pod::Spec.new do |s| 'src/core/lib/tsi/transport_security_interface.h', 'src/core/ext/client_config/client_channel.h', 'src/core/ext/client_config/client_channel_factory.h', - 'src/core/ext/client_config/client_config.h', 'src/core/ext/client_config/connector.h', 'src/core/ext/client_config/initial_connect_string.h', 'src/core/ext/client_config/lb_policy.h', @@ -750,6 +749,7 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver.h', 'src/core/ext/client_config/resolver_factory.h', 'src/core/ext/client_config/resolver_registry.h', + 'src/core/ext/client_config/resolver_result.h', 'src/core/ext/client_config/subchannel.h', 'src/core/ext/client_config/subchannel_call_holder.h', 'src/core/ext/client_config/subchannel_index.h', diff --git a/grpc.gemspec b/grpc.gemspec index a7516a369f8..9c82db8ee30 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -298,7 +298,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/tsi/transport_security_interface.h ) s.files += %w( src/core/ext/client_config/client_channel.h ) s.files += %w( src/core/ext/client_config/client_channel_factory.h ) - s.files += %w( src/core/ext/client_config/client_config.h ) s.files += %w( src/core/ext/client_config/connector.h ) s.files += %w( src/core/ext/client_config/initial_connect_string.h ) s.files += %w( src/core/ext/client_config/lb_policy.h ) @@ -308,6 +307,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/resolver.h ) s.files += %w( src/core/ext/client_config/resolver_factory.h ) s.files += %w( src/core/ext/client_config/resolver_registry.h ) + s.files += %w( src/core/ext/client_config/resolver_result.h ) s.files += %w( src/core/ext/client_config/subchannel.h ) s.files += %w( src/core/ext/client_config/subchannel_call_holder.h ) s.files += %w( src/core/ext/client_config/subchannel_index.h ) @@ -475,7 +475,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/channel_connectivity.c ) s.files += %w( src/core/ext/client_config/client_channel.c ) s.files += %w( src/core/ext/client_config/client_channel_factory.c ) - s.files += %w( src/core/ext/client_config/client_config.c ) s.files += %w( src/core/ext/client_config/client_config_plugin.c ) s.files += %w( src/core/ext/client_config/connector.c ) s.files += %w( src/core/ext/client_config/default_initial_connect_string.c ) @@ -487,6 +486,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/resolver.c ) s.files += %w( src/core/ext/client_config/resolver_factory.c ) s.files += %w( src/core/ext/client_config/resolver_registry.c ) + s.files += %w( src/core/ext/client_config/resolver_result.c ) s.files += %w( src/core/ext/client_config/subchannel.c ) s.files += %w( src/core/ext/client_config/subchannel_call_holder.c ) s.files += %w( src/core/ext/client_config/subchannel_index.c ) diff --git a/package.xml b/package.xml index 890cf323372..be8c08d766c 100644 --- a/package.xml +++ b/package.xml @@ -306,7 +306,6 @@ - @@ -316,6 +315,7 @@ + @@ -483,7 +483,6 @@ - @@ -495,6 +494,7 @@ + diff --git a/src/core/ext/client_config/README.md b/src/core/ext/client_config/README.md index 7024fd540d8..eda01e3e715 100644 --- a/src/core/ext/client_config/README.md +++ b/src/core/ext/client_config/README.md @@ -12,7 +12,7 @@ data might include: - a load balancing policy to decide which server to send a request to - a set of filters to mutate outgoing requests (say, by adding metadata) -The resolver provides this data as a stream of grpc_client_config objects to +The resolver provides this data as a stream of grpc_resolver_result objects to the channel. We represent configuration as a stream so that it can be changed by the resolver during execution, by reacting to external events (such as a new configuration file being pushed to some store). @@ -22,7 +22,7 @@ Load Balancing -------------- Load balancing configuration is provided by a grpc_lb_policy object, stored as -part of grpc_client_config. +part of grpc_resolver_result. The primary job of the load balancing policies is to pick a target server given only the initial metadata for a request. It does this by providing a grpc_subchannel diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 2c0c4abffc7..852e45e35f7 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -62,16 +62,15 @@ typedef struct client_channel_channel_data { /** mutex protecting client configuration, including all variables below in this data structure */ - gpr_mu mu_config; - /** currently active load balancer - guarded by mu_config */ + gpr_mu mu; + /** currently active load balancer - guarded by mu */ grpc_lb_policy *lb_policy; - /** incoming configuration - set by resolver.next - guarded by mu_config */ - grpc_client_config *incoming_configuration; + /** incoming resolver result - set by resolver.next(), guarded by mu */ + grpc_resolver_result *resolver_result; /** a list of closures that are all waiting for config to come in */ grpc_closure_list waiting_for_config_closures; /** resolver callback */ - grpc_closure on_config_changed; + grpc_closure on_resolver_result_changed; /** connectivity state being tracked */ grpc_connectivity_state_tracker state_tracker; /** when an lb_policy arrives, should we try to exit idle */ @@ -156,9 +155,9 @@ static void on_lb_policy_state_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { lb_policy_connectivity_watcher *w = arg; - gpr_mu_lock(&w->chand->mu_config); + gpr_mu_lock(&w->chand->mu); on_lb_policy_state_changed_locked(exec_ctx, w, error); - gpr_mu_unlock(&w->chand->mu_config); + gpr_mu_unlock(&w->chand->mu); GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack, "watch_lb_policy"); gpr_free(w); @@ -178,8 +177,8 @@ static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand, &w->on_changed); } -static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { channel_data *chand = arg; grpc_lb_policy *lb_policy = NULL; grpc_lb_policy *old_lb_policy; @@ -187,8 +186,9 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, int exit_idle = 0; grpc_error *state_error = GRPC_ERROR_CREATE("No load balancing policy"); - if (chand->incoming_configuration != NULL) { - lb_policy = grpc_client_config_get_lb_policy(chand->incoming_configuration); + if (chand->resolver_result != NULL) { + lb_policy = + grpc_resolver_result_get_lb_policy(chand->resolver_result); if (lb_policy != NULL) { GRPC_LB_POLICY_REF(lb_policy, "channel"); GRPC_LB_POLICY_REF(lb_policy, "config_change"); @@ -197,17 +197,17 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_lb_policy_check_connectivity(exec_ctx, lb_policy, &state_error); } - grpc_client_config_unref(exec_ctx, chand->incoming_configuration); + grpc_resolver_result_unref(exec_ctx, chand->resolver_result); } - chand->incoming_configuration = NULL; + chand->resolver_result = NULL; if (lb_policy != NULL) { grpc_pollset_set_add_pollset_set(exec_ctx, lb_policy->interested_parties, chand->interested_parties); } - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); old_lb_policy = chand->lb_policy; chand->lb_policy = lb_policy; if (lb_policy != NULL) { @@ -234,9 +234,9 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, } GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); grpc_resolver_next(exec_ctx, chand->resolver, - &chand->incoming_configuration, - &chand->on_config_changed); - gpr_mu_unlock(&chand->mu_config); + &chand->resolver_result, + &chand->on_resolver_result_changed); + gpr_mu_unlock(&chand->mu); } else { if (chand->resolver != NULL) { grpc_resolver_shutdown(exec_ctx, chand->resolver); @@ -249,7 +249,7 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, GRPC_ERROR_CREATE_REFERENCING("Got config after disconnection", refs, GPR_ARRAY_SIZE(refs)), "resolver_gone"); - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } if (exit_idle) { @@ -284,7 +284,7 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, op->bind_pollset); } - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); if (op->on_connectivity_state_change != NULL) { grpc_connectivity_state_notify_on_state_change( exec_ctx, &chand->state_tracker, op->connectivity_state, @@ -329,7 +329,7 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, } GRPC_ERROR_UNREF(op->disconnect_with_error); } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } typedef struct { @@ -377,7 +377,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, GPR_ASSERT(connected_subchannel); - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); if (initial_metadata == NULL) { if (chand->lb_policy != NULL) { grpc_lb_policy_cancel_pick(exec_ctx, chand->lb_policy, @@ -392,7 +392,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, GRPC_ERROR_CREATE("Pick cancelled"), NULL); } } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); GPR_TIMER_END("cc_pick_subchannel", 0); return 1; } @@ -400,7 +400,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, grpc_lb_policy *lb_policy = chand->lb_policy; int r; GRPC_LB_POLICY_REF(lb_policy, "cc_pick_subchannel"); - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); r = grpc_lb_policy_pick(exec_ctx, lb_policy, calld->pollent, initial_metadata, initial_metadata_flags, connected_subchannel, on_ready); @@ -412,8 +412,8 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); grpc_resolver_next(exec_ctx, chand->resolver, - &chand->incoming_configuration, - &chand->on_config_changed); + &chand->resolver_result, + &chand->on_resolver_result_changed); } if (chand->resolver != NULL) { cpa = gpr_malloc(sizeof(*cpa)); @@ -429,7 +429,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, grpc_exec_ctx_sched(exec_ctx, on_ready, GRPC_ERROR_CREATE("Disconnected"), NULL); } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); GPR_TIMER_END("cc_pick_subchannel", 0); return 0; @@ -463,8 +463,9 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, GPR_ASSERT(args->is_last); GPR_ASSERT(elem->filter == &grpc_client_channel_filter); - gpr_mu_init(&chand->mu_config); - grpc_closure_init(&chand->on_config_changed, cc_on_config_changed, chand); + gpr_mu_init(&chand->mu); + grpc_closure_init(&chand->on_resolver_result_changed, + cc_on_resolver_result_changed, chand); chand->owning_stack = args->channel_stack; grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE, @@ -489,7 +490,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, } grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker); grpc_pollset_set_destroy(chand->interested_parties); - gpr_mu_destroy(&chand->mu_config); + gpr_mu_destroy(&chand->mu); } static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx, @@ -519,7 +520,7 @@ void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, /* post construction initialization: set the transport setup pointer */ grpc_channel_element *elem = grpc_channel_stack_last_element(channel_stack); channel_data *chand = elem->channel_data; - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); GPR_ASSERT(!chand->resolver); chand->resolver = resolver; GRPC_RESOLVER_REF(resolver, "channel"); @@ -527,17 +528,17 @@ void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, chand->exit_idle_when_lb_policy_arrives) { chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, resolver, &chand->incoming_configuration, - &chand->on_config_changed); + grpc_resolver_next(exec_ctx, resolver, &chand->resolver_result, + &chand->on_resolver_result_changed); } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } grpc_connectivity_state grpc_client_channel_check_connectivity_state( grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect) { channel_data *chand = elem->channel_data; grpc_connectivity_state out; - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); out = grpc_connectivity_state_check(&chand->state_tracker, NULL); if (out == GRPC_CHANNEL_IDLE && try_to_connect) { if (chand->lb_policy != NULL) { @@ -548,12 +549,12 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state( GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); chand->started_resolving = 1; grpc_resolver_next(exec_ctx, chand->resolver, - &chand->incoming_configuration, - &chand->on_config_changed); + &chand->resolver_result, + &chand->on_resolver_result_changed); } } } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); return out; } @@ -588,8 +589,8 @@ void grpc_client_channel_watch_connectivity_state( grpc_closure_init(&w->my_closure, on_external_watch_complete, w); GRPC_CHANNEL_STACK_REF(w->chand->owning_stack, "external_connectivity_watcher"); - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); grpc_connectivity_state_notify_on_state_change( exec_ctx, &chand->state_tracker, state, &w->my_closure); - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } diff --git a/src/core/ext/client_config/lb_policy_factory.h b/src/core/ext/client_config/lb_policy_factory.h index 1c89b28b59a..da1de3579a0 100644 --- a/src/core/ext/client_config/lb_policy_factory.h +++ b/src/core/ext/client_config/lb_policy_factory.h @@ -43,8 +43,6 @@ typedef struct grpc_lb_policy_factory grpc_lb_policy_factory; typedef struct grpc_lb_policy_factory_vtable grpc_lb_policy_factory_vtable; -/** grpc_lb_policy provides grpc_client_config objects to grpc_channel - objects */ struct grpc_lb_policy_factory { const grpc_lb_policy_factory_vtable *vtable; }; diff --git a/src/core/ext/client_config/resolver.c b/src/core/ext/client_config/resolver.c index eb004455bd0..7534ea62af5 100644 --- a/src/core/ext/client_config/resolver.c +++ b/src/core/ext/client_config/resolver.c @@ -76,7 +76,7 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, } void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **result, grpc_closure *on_complete) { - resolver->vtable->next(exec_ctx, resolver, target_config, on_complete); + resolver->vtable->next(exec_ctx, resolver, result, on_complete); } diff --git a/src/core/ext/client_config/resolver.h b/src/core/ext/client_config/resolver.h index 6ecb5d2774f..88ac262d513 100644 --- a/src/core/ext/client_config/resolver.h +++ b/src/core/ext/client_config/resolver.h @@ -34,14 +34,14 @@ #ifndef GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H #define GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H -#include "src/core/ext/client_config/client_config.h" +#include "src/core/ext/client_config/resolver_result.h" #include "src/core/ext/client_config/subchannel.h" #include "src/core/lib/iomgr/iomgr.h" typedef struct grpc_resolver grpc_resolver; typedef struct grpc_resolver_vtable grpc_resolver_vtable; -/** grpc_resolver provides grpc_client_config objects to grpc_channel +/** grpc_resolver provides grpc_resolver_result objects to grpc_channel objects */ struct grpc_resolver { const grpc_resolver_vtable *vtable; @@ -53,7 +53,7 @@ struct grpc_resolver_vtable { void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*channel_saw_error)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, grpc_closure *on_complete); + grpc_resolver_result **result, grpc_closure *on_complete); }; #ifdef GRPC_RESOLVER_REFCOUNT_DEBUG @@ -82,13 +82,13 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); /** Get the next client config. Called by the channel to fetch a new - configuration. Expected to set *target_config with a new configuration, + configuration. Expected to set *result with a new configuration, and then schedule on_complete for execution. - If resolution is fatally broken, set *target_config to NULL and + If resolution is fatally broken, set *result to NULL and schedule on_complete. */ void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **result, grpc_closure *on_complete); #endif /* GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H */ diff --git a/src/core/ext/client_config/resolver_factory.h b/src/core/ext/client_config/resolver_factory.h index 4eb6979aad8..f69bf795649 100644 --- a/src/core/ext/client_config/resolver_factory.h +++ b/src/core/ext/client_config/resolver_factory.h @@ -41,7 +41,7 @@ typedef struct grpc_resolver_factory grpc_resolver_factory; typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable; -/** grpc_resolver provides grpc_client_config objects to grpc_channel +/** grpc_resolver provides grpc_resolver_result objects to grpc_channel objects */ struct grpc_resolver_factory { const grpc_resolver_factory_vtable *vtable; diff --git a/src/core/ext/client_config/client_config.c b/src/core/ext/client_config/resolver_result.c similarity index 73% rename from src/core/ext/client_config/client_config.c rename to src/core/ext/client_config/resolver_result.c index f9b8e686988..c6c4166e834 100644 --- a/src/core/ext/client_config/client_config.c +++ b/src/core/ext/client_config/resolver_result.c @@ -31,44 +31,45 @@ * */ -#include "src/core/ext/client_config/client_config.h" +#include "src/core/ext/client_config/resolver_result.h" #include #include -struct grpc_client_config { +struct grpc_resolver_result { gpr_refcount refs; grpc_lb_policy *lb_policy; }; -grpc_client_config *grpc_client_config_create() { - grpc_client_config *c = gpr_malloc(sizeof(*c)); +grpc_resolver_result *grpc_resolver_result_create() { + grpc_resolver_result *c = gpr_malloc(sizeof(*c)); memset(c, 0, sizeof(*c)); gpr_ref_init(&c->refs, 1); return c; } -void grpc_client_config_ref(grpc_client_config *c) { gpr_ref(&c->refs); } +void grpc_resolver_result_ref(grpc_resolver_result *c) { gpr_ref(&c->refs); } -void grpc_client_config_unref(grpc_exec_ctx *exec_ctx, grpc_client_config *c) { +void grpc_resolver_result_unref(grpc_exec_ctx *exec_ctx, + grpc_resolver_result *c) { if (gpr_unref(&c->refs)) { if (c->lb_policy != NULL) { - GRPC_LB_POLICY_UNREF(exec_ctx, c->lb_policy, "client_config"); + GRPC_LB_POLICY_UNREF(exec_ctx, c->lb_policy, "resolver_result"); } gpr_free(c); } } -void grpc_client_config_set_lb_policy(grpc_client_config *c, - grpc_lb_policy *lb_policy) { +void grpc_resolver_result_set_lb_policy(grpc_resolver_result *c, + grpc_lb_policy *lb_policy) { GPR_ASSERT(c->lb_policy == NULL); if (lb_policy) { - GRPC_LB_POLICY_REF(lb_policy, "client_config"); + GRPC_LB_POLICY_REF(lb_policy, "resolver_result"); } c->lb_policy = lb_policy; } -grpc_lb_policy *grpc_client_config_get_lb_policy(grpc_client_config *c) { +grpc_lb_policy *grpc_resolver_result_get_lb_policy(grpc_resolver_result *c) { return c->lb_policy; } diff --git a/src/core/ext/client_config/client_config.h b/src/core/ext/client_config/resolver_result.h similarity index 68% rename from src/core/ext/client_config/client_config.h rename to src/core/ext/client_config/resolver_result.h index a6290cbcf00..402f7dbd7e6 100644 --- a/src/core/ext/client_config/client_config.h +++ b/src/core/ext/client_config/resolver_result.h @@ -31,23 +31,22 @@ * */ -#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H -#define GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H +#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H +#define GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H #include "src/core/ext/client_config/lb_policy.h" -/** Total configuration for a client. Provided, and updated, by - grpc_resolver */ -typedef struct grpc_client_config grpc_client_config; +/** Results reported from a grpc_resolver. */ +typedef struct grpc_resolver_result grpc_resolver_result; -grpc_client_config *grpc_client_config_create(); -void grpc_client_config_ref(grpc_client_config *client_config); -void grpc_client_config_unref(grpc_exec_ctx *exec_ctx, - grpc_client_config *client_config); +grpc_resolver_result *grpc_resolver_result_create(); +void grpc_resolver_result_ref(grpc_resolver_result *client_config); +void grpc_resolver_result_unref(grpc_exec_ctx *exec_ctx, + grpc_resolver_result *client_config); -void grpc_client_config_set_lb_policy(grpc_client_config *client_config, - grpc_lb_policy *lb_policy); -grpc_lb_policy *grpc_client_config_get_lb_policy( - grpc_client_config *client_config); +void grpc_resolver_result_set_lb_policy(grpc_resolver_result *client_config, + grpc_lb_policy *lb_policy); +grpc_lb_policy *grpc_resolver_result_get_lb_policy( + grpc_resolver_result *client_config); -#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H */ +#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H */ diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c index 31ac968670f..79682e78b5d 100644 --- a/src/core/ext/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/resolver/dns/native/dns_resolver.c @@ -67,16 +67,16 @@ typedef struct { gpr_mu mu; /** are we currently resolving? */ int resolving; - /** which version of resolved_config have we published? */ + /** which version of the result have we published? */ int published_version; - /** which version of resolved_config is current? */ + /** which version of the result is current? */ int resolved_version; /** pending next completion, or NULL */ grpc_closure *next_completion; - /** target config address for next completion */ - grpc_client_config **target_config; - /** current (fully resolved) config */ - grpc_client_config *resolved_config; + /** target result address for next completion */ + grpc_resolver_result **target_result; + /** current (fully resolved) result */ + grpc_resolver_result *resolved_result; /** retry timer */ bool have_retry_timer; grpc_timer retry_timer; @@ -97,7 +97,7 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete); static const grpc_resolver_vtable dns_resolver_vtable = { @@ -110,7 +110,7 @@ static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) { grpc_timer_cancel(exec_ctx, &r->retry_timer); } if (r->next_completion != NULL) { - *r->target_config = NULL; + *r->target_result = NULL; grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_CREATE("Resolver Shutdown"), NULL); r->next_completion = NULL; @@ -130,13 +130,13 @@ static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, } static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete) { dns_resolver *r = (dns_resolver *)resolver; gpr_mu_lock(&r->mu); GPR_ASSERT(!r->next_completion); r->next_completion = on_complete; - r->target_config = target_config; + r->target_result = target_result; if (r->resolved_version == 0 && !r->resolving) { gpr_backoff_reset(&r->backoff_state); dns_start_resolving_locked(exec_ctx, r); @@ -165,7 +165,7 @@ static void dns_on_retry_timer(grpc_exec_ctx *exec_ctx, void *arg, static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { dns_resolver *r = arg; - grpc_client_config *config = NULL; + grpc_resolver_result *result = NULL; grpc_lb_policy *lb_policy; gpr_mu_lock(&r->mu); GPR_ASSERT(r->resolving); @@ -173,14 +173,14 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_resolved_addresses *addresses = r->addresses; if (addresses != NULL) { grpc_lb_policy_args lb_policy_args; - config = grpc_client_config_create(); + result = grpc_resolver_result_create(); memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.addresses = addresses; lb_policy_args.client_channel_factory = r->client_channel_factory; lb_policy = grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); if (lb_policy != NULL) { - grpc_client_config_set_lb_policy(config, lb_policy); + grpc_resolver_result_set_lb_policy(result, lb_policy); GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction"); } grpc_resolved_addresses_destroy(addresses); @@ -203,10 +203,10 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_timer_init(exec_ctx, &r->retry_timer, next_try, dns_on_retry_timer, r, now); } - if (r->resolved_config) { - grpc_client_config_unref(exec_ctx, r->resolved_config); + if (r->resolved_result) { + grpc_resolver_result_unref(exec_ctx, r->resolved_result); } - r->resolved_config = config; + r->resolved_result = result; r->resolved_version++; dns_maybe_finish_next_locked(exec_ctx, r); gpr_mu_unlock(&r->mu); @@ -228,9 +228,9 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, dns_resolver *r) { if (r->next_completion != NULL && r->resolved_version != r->published_version) { - *r->target_config = r->resolved_config; - if (r->resolved_config) { - grpc_client_config_ref(r->resolved_config); + *r->target_result = r->resolved_result; + if (r->resolved_result) { + grpc_resolver_result_ref(r->resolved_result); } grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; @@ -241,8 +241,8 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { dns_resolver *r = (dns_resolver *)gr; gpr_mu_destroy(&r->mu); - if (r->resolved_config) { - grpc_client_config_unref(exec_ctx, r->resolved_config); + if (r->resolved_result) { + grpc_resolver_result_unref(exec_ctx, r->resolved_result); } grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory); gpr_free(r->name); diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 1f7cce2f43a..3807522d2bd 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -66,8 +66,8 @@ typedef struct { int published; /** pending next completion, or NULL */ grpc_closure *next_completion; - /** target config address for next completion */ - grpc_client_config **target_config; + /** target result address for next completion */ + grpc_resolver_result **target_result; } sockaddr_resolver; static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r); @@ -79,7 +79,7 @@ static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete); static const grpc_resolver_vtable sockaddr_resolver_vtable = { @@ -91,7 +91,7 @@ static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, sockaddr_resolver *r = (sockaddr_resolver *)resolver; gpr_mu_lock(&r->mu); if (r->next_completion != NULL) { - *r->target_config = NULL; + *r->target_result = NULL; grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; } @@ -108,13 +108,13 @@ static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, } static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete) { sockaddr_resolver *r = (sockaddr_resolver *)resolver; gpr_mu_lock(&r->mu); GPR_ASSERT(!r->next_completion); r->next_completion = on_complete; - r->target_config = target_config; + r->target_result = target_result; sockaddr_maybe_finish_next_locked(exec_ctx, r); gpr_mu_unlock(&r->mu); } @@ -122,17 +122,17 @@ static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, sockaddr_resolver *r) { if (r->next_completion != NULL && !r->published) { - grpc_client_config *cfg = grpc_client_config_create(); + grpc_resolver_result *result = grpc_resolver_result_create(); grpc_lb_policy_args lb_policy_args; memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.addresses = r->addresses; lb_policy_args.client_channel_factory = r->client_channel_factory; grpc_lb_policy *lb_policy = grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); - grpc_client_config_set_lb_policy(cfg, lb_policy); + grpc_resolver_result_set_lb_policy(result, lb_policy); GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "sockaddr"); r->published = 1; - *r->target_config = cfg; + *r->target_result = result; grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; } diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 7ae76f52c1f..660e34d7420 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -220,7 +220,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/channel_connectivity.c', 'src/core/ext/client_config/client_channel.c', 'src/core/ext/client_config/client_channel_factory.c', - 'src/core/ext/client_config/client_config.c', 'src/core/ext/client_config/client_config_plugin.c', 'src/core/ext/client_config/connector.c', 'src/core/ext/client_config/default_initial_connect_string.c', @@ -232,6 +231,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', + 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index dcb11bd9330..50cebfa84e4 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -917,7 +917,6 @@ src/core/lib/tsi/transport_security.h \ src/core/lib/tsi/transport_security_interface.h \ src/core/ext/client_config/client_channel.h \ src/core/ext/client_config/client_channel_factory.h \ -src/core/ext/client_config/client_config.h \ src/core/ext/client_config/connector.h \ src/core/ext/client_config/initial_connect_string.h \ src/core/ext/client_config/lb_policy.h \ @@ -927,6 +926,7 @@ src/core/ext/client_config/parse_address.h \ src/core/ext/client_config/resolver.h \ src/core/ext/client_config/resolver_factory.h \ src/core/ext/client_config/resolver_registry.h \ +src/core/ext/client_config/resolver_result.h \ src/core/ext/client_config/subchannel.h \ src/core/ext/client_config/subchannel_call_holder.h \ src/core/ext/client_config/subchannel_index.h \ @@ -1094,7 +1094,6 @@ src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ -src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -1106,6 +1105,7 @@ src/core/ext/client_config/parse_address.c \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ +src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index e5946cc14ab..84f7da8cb9a 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6087,7 +6087,6 @@ "headers": [ "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -6097,6 +6096,7 @@ "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -6110,8 +6110,6 @@ "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.c", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.c", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/connector.h", @@ -6132,6 +6130,8 @@ "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.c", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.c", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.c", diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index ed010c55b51..298887e9157 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -426,7 +426,6 @@ - @@ -436,6 +435,7 @@ + @@ -750,8 +750,6 @@ - - @@ -774,6 +772,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index b3101728ab1..539dbad3604 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -436,9 +436,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -472,6 +469,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config @@ -1046,9 +1046,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -1076,6 +1073,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 7a5f8589ca9..6a890656548 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -391,7 +391,6 @@ - @@ -401,6 +400,7 @@ + @@ -665,8 +665,6 @@ - - @@ -689,6 +687,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 99db98eb7ce..8325d910ec2 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -361,9 +361,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -397,6 +394,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config @@ -881,9 +881,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -911,6 +908,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config From 82c01e5a9509adfa4fc4f81edd2cc6f16906e862 Mon Sep 17 00:00:00 2001 From: siddharthshukla Date: Tue, 23 Aug 2016 00:03:21 +0200 Subject: [PATCH 08/25] remove skipIf from TypeSmokeTest (issue 7672) remove skipIfStatement from TypeSmokeTest.testCallCredentialsFromPluginUpDown since the test passes on PyPy variants 5.3.0 and newer since these variants have improved compatibility support for the C-Extensions --- src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py index 2f50263730f..142387d810a 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py +++ b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py @@ -114,9 +114,6 @@ class TypeSmokeTest(unittest.TestCase): lambda ignored_a, ignored_b: None, b'') del plugin - @unittest.skipIf( - platform.python_implementation() == "PyPy", - 'TODO(issue 7672): figure out why this fails on PyPy') def testCallCredentialsFromPluginUpDown(self): plugin = cygrpc.CredentialsMetadataPlugin(_metadata_plugin_callback, b'') call_credentials = cygrpc.call_credentials_metadata_plugin(plugin) From 6b93d46bb841200f100cb0dd7f8c6b62af445078 Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Tue, 23 Aug 2016 10:04:03 -0700 Subject: [PATCH 09/25] Adding extension points for security context. --- include/grpc++/impl/codegen/client_context.h | 6 ++++++ include/grpc++/impl/codegen/server_context.h | 6 ++++++ src/core/lib/security/context/security_context.c | 6 ++++++ src/core/lib/security/context/security_context.h | 7 +++++++ 4 files changed, 25 insertions(+) diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index 012bcc2bbe5..156bdb82f70 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -307,6 +307,12 @@ class ClientContext { }; static void SetGlobalCallbacks(GlobalCallbacks* callbacks); + // Should be used for framework-level extensions only. + // Applications never need to call this method. + grpc_call* c_call() const { + return call_; + } + private: // Disallow copy and assign. ClientContext(const ClientContext&); diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index 08212af861b..82cb5a32ea1 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -166,6 +166,12 @@ class ServerContext { async_notify_when_done_tag_ = tag; } + // Should be used for framework-level extensions only. + // Applications never need to call this method. + grpc_call* c_call() const { + return call_; + } + private: friend class ::grpc::testing::InteropServerContextInspector; friend class ::grpc::ServerInterface; diff --git a/src/core/lib/security/context/security_context.c b/src/core/lib/security/context/security_context.c index 127b13ee503..2204fadf54c 100644 --- a/src/core/lib/security/context/security_context.c +++ b/src/core/lib/security/context/security_context.c @@ -99,6 +99,9 @@ void grpc_client_security_context_destroy(void *ctx) { grpc_client_security_context *c = (grpc_client_security_context *)ctx; grpc_call_credentials_unref(c->creds); GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "client_security_context"); + if (c->extension.instance != NULL && c->extension.destroy != NULL) { + c->extension.destroy(c->extension.instance); + } gpr_free(ctx); } @@ -114,6 +117,9 @@ grpc_server_security_context *grpc_server_security_context_create(void) { void grpc_server_security_context_destroy(void *ctx) { grpc_server_security_context *c = (grpc_server_security_context *)ctx; GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "server_security_context"); + if (c->extension.instance != NULL && c->extension.destroy != NULL) { + c->extension.destroy(c->extension.instance); + } gpr_free(ctx); } diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index 4e7666dfe31..b2ffd4efc2e 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -84,6 +84,11 @@ void grpc_auth_context_unref(grpc_auth_context *policy); void grpc_auth_property_reset(grpc_auth_property *property); +typedef struct { + void *instance; + void (*destroy)(void *); +} grpc_security_context_extension; + /* --- grpc_client_security_context --- Internal client-side security context. */ @@ -91,6 +96,7 @@ void grpc_auth_property_reset(grpc_auth_property *property); typedef struct { grpc_call_credentials *creds; grpc_auth_context *auth_context; + grpc_security_context_extension extension; } grpc_client_security_context; grpc_client_security_context *grpc_client_security_context_create(void); @@ -102,6 +108,7 @@ void grpc_client_security_context_destroy(void *ctx); typedef struct { grpc_auth_context *auth_context; + grpc_security_context_extension extension; } grpc_server_security_context; grpc_server_security_context *grpc_server_security_context_create(void); From 1bbfe0fb439beed32f3ce72980c1aab1301dc0f2 Mon Sep 17 00:00:00 2001 From: Robbie Shade Date: Tue, 23 Aug 2016 14:39:32 -0400 Subject: [PATCH 10/25] clang-format remove blank lines --- test/core/end2end/tests/bad_hostname.c | 1 - test/core/end2end/tests/binary_metadata.c | 1 - test/core/end2end/tests/call_creds.c | 1 - test/core/end2end/tests/cancel_after_accept.c | 1 - test/core/end2end/tests/cancel_after_client_done.c | 1 - test/core/end2end/tests/cancel_after_invoke.c | 1 - test/core/end2end/tests/cancel_before_invoke.c | 1 - test/core/end2end/tests/cancel_in_a_vacuum.c | 1 - test/core/end2end/tests/cancel_with_status.c | 1 - test/core/end2end/tests/compressed_payload.c | 1 - test/core/end2end/tests/default_host.c | 1 - test/core/end2end/tests/disappearing_server.c | 1 - test/core/end2end/tests/empty_batch.c | 1 - test/core/end2end/tests/filter_causes_close.c | 1 - test/core/end2end/tests/graceful_server_shutdown.c | 1 - test/core/end2end/tests/high_initial_seqno.c | 1 - test/core/end2end/tests/idempotent_request.c | 1 - test/core/end2end/tests/invoke_large_request.c | 1 - test/core/end2end/tests/large_metadata.c | 1 - test/core/end2end/tests/max_concurrent_streams.c | 1 - test/core/end2end/tests/max_message_length.c | 1 - test/core/end2end/tests/negative_deadline.c | 1 - test/core/end2end/tests/network_status_change.c | 1 - test/core/end2end/tests/no_op.c | 1 - test/core/end2end/tests/payload.c | 1 - test/core/end2end/tests/ping_pong_streaming.c | 1 - test/core/end2end/tests/registered_call.c | 1 - test/core/end2end/tests/request_with_flags.c | 1 - test/core/end2end/tests/request_with_payload.c | 1 - test/core/end2end/tests/server_finishes_request.c | 1 - test/core/end2end/tests/shutdown_finishes_calls.c | 1 - test/core/end2end/tests/shutdown_finishes_tags.c | 1 - test/core/end2end/tests/simple_delayed_request.c | 1 - test/core/end2end/tests/simple_metadata.c | 1 - test/core/end2end/tests/simple_request.c | 1 - test/core/end2end/tests/streaming_error_response.c | 1 - test/core/end2end/tests/trailing_metadata.c | 1 - 37 files changed, 37 deletions(-) diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index 4418e6af86a..d48b3b4e5f5 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index b59ef73c695..a007571dc9f 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 78accf5ede6..2ebc19d524c 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -53,7 +53,6 @@ static const char overridden_iam_selector[] = "overridden_selector"; typedef enum { NONE, OVERRIDE, DESTROY } override_mode; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 9c1a150f7d0..55b2cd2538c 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index c8bab54915b..2d354c6cb76 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 24d211a3ac6..af1ab2d1f90 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 540196f189e..27c83d0aed2 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 89560cb38e6..3b03616b3bb 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -44,7 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index 1cc87ca4381..1818193dbe6 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 41200278a10..3cd07535ed6 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -50,7 +50,6 @@ #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 5eb448dfe1c..bdfec89d568 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index c06cd83ce69..dda0bcea331 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index 4617e4e4c48..c09ce39e469 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 8df19cce987..91b5a391151 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -46,7 +46,6 @@ #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" - static bool g_enable_filter = false; static void *tag(intptr_t t) { return (void *)t; } diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 676a7850ebf..9fd5e82db7c 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 7f8f4c2967e..f96f3a22e5a 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -47,7 +47,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 73e5cfc3f0d..5be42931d99 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 2bc98833d67..acc65725f7d 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 144b2e1363a..c64ce63fadf 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 60297420b8a..3d3e314c407 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 9865300821b..b17ce904dae 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index cd48a93afc4..76bb7ed3f70 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index f910a683a18..b09c251b6d8 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -46,7 +46,6 @@ /* this is a private API but exposed here for testing*/ extern void grpc_network_status_shutdown_all_endpoints(); - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 142fc04f2b8..8b29c219dcf 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 439dfd63266..a92a85c63e8 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index f1ef05a29d5..d071cb897e9 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index dbeb33aaace..671656d33b7 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 41f9eeac7c9..29dddc5b9a9 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -44,7 +44,6 @@ #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 5f9ba231107..2ffcd2e798f 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index def6a08472e..b5a27fc767b 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 6ec766abb55..382c83f705c 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c index 1df86ce1e47..fe3f28ba4da 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.c +++ b/test/core/end2end/tests/shutdown_finishes_tags.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 5585b493aef..c719a5e593a 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index f46b3026478..90d1946b079 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 585e0be7e64..f0b1e697863 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -45,7 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index e659f446307..de4ca8daeab 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 6f6efec8a26..70559f5334b 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -43,7 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, From a275aea5300a72ea0d00ae1184bc38431854a8fa Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Aug 2016 12:30:45 -0700 Subject: [PATCH 11/25] clang-format --- src/core/ext/client_config/client_channel.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 852e45e35f7..566d3d5ce49 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -187,8 +187,7 @@ static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *state_error = GRPC_ERROR_CREATE("No load balancing policy"); if (chand->resolver_result != NULL) { - lb_policy = - grpc_resolver_result_get_lb_policy(chand->resolver_result); + lb_policy = grpc_resolver_result_get_lb_policy(chand->resolver_result); if (lb_policy != NULL) { GRPC_LB_POLICY_REF(lb_policy, "channel"); GRPC_LB_POLICY_REF(lb_policy, "config_change"); @@ -233,8 +232,7 @@ static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, watch_lb_policy(exec_ctx, chand, lb_policy, state); } GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, chand->resolver, - &chand->resolver_result, + grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); gpr_mu_unlock(&chand->mu); } else { @@ -411,8 +409,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, if (chand->resolver != NULL && !chand->started_resolving) { chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, chand->resolver, - &chand->resolver_result, + grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); } if (chand->resolver != NULL) { @@ -548,8 +545,7 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state( if (!chand->started_resolving && chand->resolver != NULL) { GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); chand->started_resolving = 1; - grpc_resolver_next(exec_ctx, chand->resolver, - &chand->resolver_result, + grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); } } From 1edf65219eb47181ee9495deb4077c1d992d06c2 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Aug 2016 12:35:40 -0700 Subject: [PATCH 12/25] Fix broken test. --- .../resolvers/dns_resolver_connectivity_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/core/client_config/resolvers/dns_resolver_connectivity_test.c b/test/core/client_config/resolvers/dns_resolver_connectivity_test.c index 69c07d83f43..6a33525f629 100644 --- a/test/core/client_config/resolvers/dns_resolver_connectivity_test.c +++ b/test/core/client_config/resolvers/dns_resolver_connectivity_test.c @@ -127,26 +127,26 @@ int main(int argc, char **argv) { grpc_resolver *resolver = create_resolver("dns:test"); - grpc_client_config *config = (grpc_client_config *)1; + grpc_resolver_result *result = (grpc_resolver_result *)1; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_event ev1; gpr_event_init(&ev1); - grpc_resolver_next(&exec_ctx, resolver, &config, + grpc_resolver_next(&exec_ctx, resolver, &result, grpc_closure_create(on_done, &ev1)); grpc_exec_ctx_flush(&exec_ctx); GPR_ASSERT(wait_loop(5, &ev1)); - GPR_ASSERT(config == NULL); + GPR_ASSERT(result == NULL); gpr_event ev2; gpr_event_init(&ev2); - grpc_resolver_next(&exec_ctx, resolver, &config, + grpc_resolver_next(&exec_ctx, resolver, &result, grpc_closure_create(on_done, &ev2)); grpc_exec_ctx_flush(&exec_ctx); GPR_ASSERT(wait_loop(30, &ev2)); - GPR_ASSERT(config != NULL); + GPR_ASSERT(result != NULL); - grpc_client_config_unref(&exec_ctx, config); + grpc_resolver_result_unref(&exec_ctx, result); GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test"); grpc_exec_ctx_finish(&exec_ctx); From 15b3a165e964795fa113b53cf3bb481ccc6fdcee Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Wed, 24 Aug 2016 16:53:23 +0900 Subject: [PATCH 13/25] remove docstring for not existing argument --- include/grpc++/create_channel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index e9ccb515039..0537695ed2b 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -48,7 +48,6 @@ namespace grpc { /// \param target The URI of the endpoint to connect to. /// \param creds Credentials to use for the created channel. If it does not hold /// an object or is invalid, a lame channel is returned. -/// \param args Options for channel creation. std::shared_ptr CreateChannel( const grpc::string& target, const std::shared_ptr& creds); From ea5325c484571cb114946b6e1d06e4a26284e198 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 24 Aug 2016 18:47:51 -0700 Subject: [PATCH 14/25] Avoid static initialization of the kIdentity block Unlike other Objective-C objects, there's no hard reason why the compiler wouldn't be able to initialize a block statically (as it does with NSString literals). And it certainly doesn't complain about it (like it does with other object initializers). But as I haven't been able to find confirmation of this, and we're seeing a weird crash occur near this code, let's play it safe. --- .../RxLibrary/transformations/GRXMappingWriter.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m b/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m index f3242e4fa95..6ee1545d251 100644 --- a/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m +++ b/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m @@ -33,10 +33,6 @@ #import "GRXMappingWriter.h" -static id (^kIdentity)(id value) = ^id(id value) { - return value; -}; - @interface GRXForwardingWriter () @end @@ -51,7 +47,9 @@ static id (^kIdentity)(id value) = ^id(id value) { // Designated initializer - (instancetype)initWithWriter:(GRXWriter *)writer map:(id (^)(id value))map { if ((self = [super initWithWriter:writer])) { - _map = map ?: kIdentity; + _map = map ?: ^id(id value) { + return value; + }; } return self; } From bb04734eecc84eb7a2acde8e8ba77e5ae2cbe4fd Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Mon, 4 Jul 2016 13:12:59 +0900 Subject: [PATCH 15/25] Fix a typo --- include/grpc++/impl/codegen/client_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index 012bcc2bbe5..fb10a3be1ab 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -271,7 +271,7 @@ class ClientContext { /// Set \a algorithm to be the compression algorithm used for the client call. /// - /// \param algorith The compression algorithm used for the client call. + /// \param algorithm The compression algorithm used for the client call. void set_compression_algorithm(grpc_compression_algorithm algorithm); /// Return the peer uri in a string. From c0080b7c92c1692ffa4acf101b9815ef3a05a810 Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Wed, 24 Aug 2016 16:53:23 +0900 Subject: [PATCH 16/25] remove docstring for not existing argument --- include/grpc++/create_channel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index e9ccb515039..0537695ed2b 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -48,7 +48,6 @@ namespace grpc { /// \param target The URI of the endpoint to connect to. /// \param creds Credentials to use for the created channel. If it does not hold /// an object or is invalid, a lame channel is returned. -/// \param args Options for channel creation. std::shared_ptr CreateChannel( const grpc::string& target, const std::shared_ptr& creds); From 2b2b345841be2f2d1fd220264c034bdf440eb0ca Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Thu, 25 Aug 2016 21:22:55 -0700 Subject: [PATCH 17/25] Addressing feedback. --- include/grpc++/impl/codegen/client_context.h | 4 +--- include/grpc++/impl/codegen/server_context.h | 4 +--- src/core/lib/security/context/security_context.h | 5 +++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index 156bdb82f70..72ed639b03c 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -309,9 +309,7 @@ class ClientContext { // Should be used for framework-level extensions only. // Applications never need to call this method. - grpc_call* c_call() const { - return call_; - } + grpc_call* c_call() { return call_; } private: // Disallow copy and assign. diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index 82cb5a32ea1..c9d1f4d69e9 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -168,9 +168,7 @@ class ServerContext { // Should be used for framework-level extensions only. // Applications never need to call this method. - grpc_call* c_call() const { - return call_; - } + grpc_call* c_call() { return call_; } private: friend class ::grpc::testing::InteropServerContextInspector; diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index b2ffd4efc2e..1e131a0c230 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -84,6 +84,11 @@ void grpc_auth_context_unref(grpc_auth_context *policy); void grpc_auth_property_reset(grpc_auth_property *property); +/* --- grpc_security_context_extension --- + + Extension to the security context that may be set in a filter and accessed + later by a higher level method on a grpc_call object. */ + typedef struct { void *instance; void (*destroy)(void *); From 6f7e55fe26fb31c4ce32004ead58cbc89415f68a Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 26 Aug 2016 15:23:28 -0700 Subject: [PATCH 18/25] php: fix per_rpc_creds capital auth header key --- src/php/tests/interop/interop_client.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index bf40549a04f..7f8354e236b 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -197,7 +197,12 @@ function updateAuthMetadataCallback($context) $methodName = $context->method_name; $auth_credentials = ApplicationDefaultCredentials::getCredentials(); - return $auth_credentials->updateMetadata($metadata = [], $authUri); + $metadata = []; + $result = $auth_credentials->updateMetadata([], $authUri); + foreach ($result as $key => $value) { + $metadata[strtolower($key)] = $value; + } + return $metadata; } /** From 129bca6c5b34683b675c78ee3c2846d74f701f25 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 26 Aug 2016 19:54:57 -0700 Subject: [PATCH 19/25] php: error out if metadata key is not legal --- package.xml | 4 +- src/php/ext/grpc/call.c | 3 + src/php/ext/grpc/call_credentials.c | 20 +-- src/php/tests/interop/interop_client.php | 30 ++-- .../tests/unit_tests/CallCredentials2Test.php | 65 +++++++++ .../tests/unit_tests/CallCredentials3Test.php | 135 ------------------ src/php/tests/unit_tests/CallTest.php | 24 +++- templates/package.xml.template | 4 +- 8 files changed, 118 insertions(+), 167 deletions(-) delete mode 100644 src/php/tests/unit_tests/CallCredentials3Test.php diff --git a/package.xml b/package.xml index 387afc34982..ca5ba244ad1 100644 --- a/package.xml +++ b/package.xml @@ -22,7 +22,7 @@ BSD -- TBD +- Reject metadata keys which are not legal #7881 @@ -1181,7 +1181,7 @@ Update to wrap gRPC C Core version 0.10.0 2016-08-22 BSD -- TBD +- Reject metadata keys which are not legal #7881 diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index 66ca1513ed7..31c59fe5adc 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -164,6 +164,9 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) { if (key_type1 != HASH_KEY_IS_STRING) { return false; } + if (!grpc_header_key_is_legal(key1, strlen(key1))) { + return false; + } inner_array_hash = Z_ARRVAL_P(inner_array); PHP_GRPC_HASH_FOREACH_VAL_START(inner_array_hash, value) if (Z_TYPE_P(value) != IS_STRING) { diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c index 6921a5df17b..25c92c91fec 100644 --- a/src/php/ext/grpc/call_credentials.c +++ b/src/php/ext/grpc/call_credentials.c @@ -192,24 +192,16 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context, /* call the user callback function */ zend_call_function(state->fci, state->fci_cache TSRMLS_CC); - if (Z_TYPE_P(retval) != IS_ARRAY) { - zend_throw_exception(spl_ce_InvalidArgumentException, - "plugin callback must return metadata array", - 1 TSRMLS_CC); - return; - } - + grpc_status_code code = GRPC_STATUS_OK; grpc_metadata_array metadata; - if (!create_metadata_array(retval, &metadata)) { - zend_throw_exception(spl_ce_InvalidArgumentException, - "invalid metadata", 1 TSRMLS_CC); + + if (Z_TYPE_P(retval) != IS_ARRAY) { + code = GRPC_STATUS_INVALID_ARGUMENT; + } else if (!create_metadata_array(retval, &metadata)) { grpc_metadata_array_destroy(&metadata); - return; + code = GRPC_STATUS_INVALID_ARGUMENT; } - /* TODO: handle error */ - grpc_status_code code = GRPC_STATUS_OK; - /* Pass control back to core */ cb(user_data, metadata.metadata, metadata.count, code, NULL); } diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 7f8354e236b..c94ba61296f 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -54,6 +54,15 @@ function hardAssert($value, $error_message) } } +function hardAssertIfStatusOk($status) +{ + if ($status->code !== Grpc\STATUS_OK) { + echo "Call did not complete successfully. Status object:\n"; + var_dump($status); + exit(1); + } +} + /** * Run the empty_unary test. * @@ -62,7 +71,7 @@ function hardAssert($value, $error_message) function emptyUnary($stub) { list($result, $status) = $stub->EmptyCall(new grpc\testing\EmptyMessage())->wait(); - hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssertIfStatusOk($status); hardAssert($result !== null, 'Call completed with a null response'); } @@ -105,7 +114,7 @@ function performLargeUnary($stub, $fillUsername = false, $fillOauthScope = false } list($result, $status) = $stub->UnaryCall($request, [], $options)->wait(); - hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssertIfStatusOk($status); hardAssert($result !== null, 'Call returned a null response'); $payload = $result->getPayload(); hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, @@ -247,7 +256,7 @@ function clientStreaming($stub) $call->write($request); } list($result, $status) = $call->wait(); - hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssertIfStatusOk($status); hardAssert($result->getAggregatedPayloadSize() === 74922, 'aggregated_payload_size was incorrect'); } @@ -280,8 +289,7 @@ function serverStreaming($stub) 'Response '.$i.' had the wrong length'); $i += 1; } - hardAssert($call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($call->getStatus()); } /** @@ -317,8 +325,7 @@ function pingPong($stub) } $call->writesDone(); hardAssert($call->read() === null, 'Server returned too many responses'); - hardAssert($call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($call->getStatus()); } /** @@ -331,8 +338,7 @@ function emptyStream($stub) $call = $stub->FullDuplexCall(); $call->writesDone(); hardAssert($call->read() === null, 'Server returned too many responses'); - hardAssert($call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($call->getStatus()); } /** @@ -424,8 +430,7 @@ function customMetadata($stub) 'Incorrect initial metadata value'); list($result, $status) = $call->wait(); - hardAssert($status->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($status); $trailing_metadata = $call->getTrailingMetadata(); hardAssert(array_key_exists($ECHO_TRAILING_KEY, $trailing_metadata), @@ -440,8 +445,7 @@ function customMetadata($stub) $streaming_call->write($streaming_request); $streaming_call->writesDone(); - hardAssert($streaming_call->getStatus()->code === Grpc\STATUS_OK, - 'Call did not complete successfully'); + hardAssertIfStatusOk($streaming_call->getStatus()); $streaming_trailing_metadata = $streaming_call->getTrailingMetadata(); hardAssert(array_key_exists($ECHO_TRAILING_KEY, diff --git a/src/php/tests/unit_tests/CallCredentials2Test.php b/src/php/tests/unit_tests/CallCredentials2Test.php index a57e2b9b4ee..b3b98a22cae 100644 --- a/src/php/tests/unit_tests/CallCredentials2Test.php +++ b/src/php/tests/unit_tests/CallCredentials2Test.php @@ -132,4 +132,69 @@ class CallCredentials2Test extends PHPUnit_Framework_TestCase unset($call); unset($server_call); } + + public function invalidKeyCallbackFunc($context) + { + $this->assertTrue(is_string($context->service_url)); + $this->assertTrue(is_string($context->method_name)); + + return ['K1' => ['v1']]; + } + + public function testCallbackWithInvalidKey() + { + $deadline = Grpc\Timeval::infFuture(); + $status_text = 'xyz'; + $call = new Grpc\Call($this->channel, + '/abc/dummy_method', + $deadline, + $this->host_override); + + $call_credentials = Grpc\CallCredentials::createFromPlugin( + array($this, 'invalidKeyCallbackFunc')); + $call->setCredentials($call_credentials); + + $event = $call->startBatch([ + Grpc\OP_SEND_INITIAL_METADATA => [], + Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, + Grpc\OP_RECV_STATUS_ON_CLIENT => true, + ]); + + $this->assertTrue($event->send_metadata); + $this->assertTrue($event->send_close); + $this->assertTrue($event->status->code == Grpc\STATUS_UNAUTHENTICATED); + } + + public function invalidReturnCallbackFunc($context) + { + $this->assertTrue(is_string($context->service_url)); + $this->assertTrue(is_string($context->method_name)); + + return "a string"; + } + + public function testCallbackWithInvalidReturnValue() + { + $deadline = Grpc\Timeval::infFuture(); + $status_text = 'xyz'; + $call = new Grpc\Call($this->channel, + '/abc/dummy_method', + $deadline, + $this->host_override); + + $call_credentials = Grpc\CallCredentials::createFromPlugin( + array($this, 'invalidReturnCallbackFunc')); + $call->setCredentials($call_credentials); + + $event = $call->startBatch([ + Grpc\OP_SEND_INITIAL_METADATA => [], + Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, + Grpc\OP_RECV_STATUS_ON_CLIENT => true, + ]); + + $this->assertTrue($event->send_metadata); + $this->assertTrue($event->send_close); + $this->assertTrue($event->status->code == Grpc\STATUS_UNAUTHENTICATED); + } + } diff --git a/src/php/tests/unit_tests/CallCredentials3Test.php b/src/php/tests/unit_tests/CallCredentials3Test.php deleted file mode 100644 index 8f5e109bf5c..00000000000 --- a/src/php/tests/unit_tests/CallCredentials3Test.php +++ /dev/null @@ -1,135 +0,0 @@ -credentials = Grpc\ChannelCredentials::createSsl( - file_get_contents(dirname(__FILE__).'/../data/ca.pem')); - $server_credentials = Grpc\ServerCredentials::createSsl( - null, - file_get_contents(dirname(__FILE__).'/../data/server1.key'), - file_get_contents(dirname(__FILE__).'/../data/server1.pem')); - $this->server = new Grpc\Server(); - $this->port = $this->server->addSecureHttp2Port('0.0.0.0:0', - $server_credentials); - $this->server->start(); - $this->host_override = 'foo.test.google.fr'; - $this->channel = new Grpc\Channel( - 'localhost:'.$this->port, - [ - 'grpc.ssl_target_name_override' => $this->host_override, - 'grpc.default_authority' => $this->host_override, - 'credentials' => $this->credentials, - ] - ); - } - - public function tearDown() - { - unset($this->channel); - unset($this->server); - } - - public function callbackFunc($context) - { - $this->assertTrue(is_string($context->service_url)); - $this->assertTrue(is_string($context->method_name)); - - return ['k1' => ['v1'], 'k2' => ['v2']]; - } - - public function testCreateFromPlugin() - { - $deadline = Grpc\Timeval::infFuture(); - $status_text = 'xyz'; - $call = new Grpc\Call($this->channel, - '/abc/dummy_method', - $deadline, - $this->host_override); - - $call_credentials = Grpc\CallCredentials::createFromPlugin( - [$this, 'callbackFunc']); - $call->setCredentials($call_credentials); - - $event = $call->startBatch([ - Grpc\OP_SEND_INITIAL_METADATA => [], - Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, - ]); - - $this->assertTrue($event->send_metadata); - $this->assertTrue($event->send_close); - - $event = $this->server->requestCall(); - - $this->assertTrue(is_array($event->metadata)); - $metadata = $event->metadata; - $this->assertTrue(array_key_exists('k1', $metadata)); - $this->assertTrue(array_key_exists('k2', $metadata)); - $this->assertSame($metadata['k1'], ['v1']); - $this->assertSame($metadata['k2'], ['v2']); - - $this->assertSame('/abc/dummy_method', $event->method); - $server_call = $event->call; - - $event = $server_call->startBatch([ - Grpc\OP_SEND_INITIAL_METADATA => [], - Grpc\OP_SEND_STATUS_FROM_SERVER => [ - 'metadata' => [], - 'code' => Grpc\STATUS_OK, - 'details' => $status_text, - ], - Grpc\OP_RECV_CLOSE_ON_SERVER => true, - ]); - - $this->assertTrue($event->send_metadata); - $this->assertTrue($event->send_status); - $this->assertFalse($event->cancelled); - - $event = $call->startBatch([ - Grpc\OP_RECV_INITIAL_METADATA => true, - Grpc\OP_RECV_STATUS_ON_CLIENT => true, - ]); - - $this->assertSame([], $event->metadata); - $status = $event->status; - $this->assertSame([], $status->metadata); - $this->assertSame(Grpc\STATUS_OK, $status->code); - $this->assertSame($status_text, $status->details); - - unset($call); - unset($server_call); - } -} diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php index d736f515460..1205f0cd8eb 100644 --- a/src/php/tests/unit_tests/CallTest.php +++ b/src/php/tests/unit_tests/CallTest.php @@ -113,7 +113,7 @@ class CallTest extends PHPUnit_Framework_TestCase /** * @expectedException InvalidArgumentException */ - public function testInvalidMetadataKey() + public function testInvalidStartBatchKey() { $batch = [ 'invalid' => ['key1' => 'value1'], @@ -121,6 +121,28 @@ class CallTest extends PHPUnit_Framework_TestCase $result = $this->call->startBatch($batch); } + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidMetadataStrKey() + { + $batch = [ + Grpc\OP_SEND_INITIAL_METADATA => ['Key' => ['value1', 'value2']], + ]; + $result = $this->call->startBatch($batch); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidMetadataIntKey() + { + $batch = [ + Grpc\OP_SEND_INITIAL_METADATA => [1 => ['value1', 'value2']], + ]; + $result = $this->call->startBatch($batch); + } + /** * @expectedException InvalidArgumentException */ diff --git a/templates/package.xml.template b/templates/package.xml.template index 65fef1892fb..32ed3b633e8 100644 --- a/templates/package.xml.template +++ b/templates/package.xml.template @@ -24,7 +24,7 @@ BSD - - TBD + - Reject metadata keys which are not legal #7881 @@ -291,7 +291,7 @@ 2016-08-22 BSD - - TBD + - Reject metadata keys which are not legal #7881 From cef5401b2e01c0d0b5e86e825b2ec28363b9b63d Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Sun, 28 Aug 2016 23:05:31 -0700 Subject: [PATCH 20/25] Mark an epoll that has a timeout as a blocking region --- src/core/lib/iomgr/ev_epoll_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/iomgr/ev_epoll_linux.c b/src/core/lib/iomgr/ev_epoll_linux.c index 02bcbaa10f5..27264694d14 100644 --- a/src/core/lib/iomgr/ev_epoll_linux.c +++ b/src/core/lib/iomgr/ev_epoll_linux.c @@ -1353,8 +1353,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, gpr_mu_unlock(&pollset->mu); do { + GRPC_SCHEDULING_START_BLOCKING_REGION; ep_rv = epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask); + GRPC_SCHEDULING_END_BLOCKING_REGION; if (ep_rv < 0) { if (errno != EINTR) { gpr_asprintf(&err_msg, From 8dfdb7e29912d239542c40e581660331059179a3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Aug 2016 11:25:56 -0700 Subject: [PATCH 21/25] Specify the "g" in gRPC --- build.yaml | 1 + include/grpc/grpc.h | 3 +++ src/core/lib/channel/http_client_filter.c | 5 +++-- src/core/lib/surface/version.c | 2 ++ templates/src/core/lib/surface/version.c.template | 8 +++++--- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.yaml b/build.yaml index 506a02920c1..7017f5c99b7 100644 --- a/build.yaml +++ b/build.yaml @@ -7,6 +7,7 @@ settings: '#3': Use "-preN" suffixes to identify pre-release versions '#4': Per-language overrides are possible with (eg) ruby_version tag here '#5': See the expand_version.py for all the quirks here + g_stands_for: good version: 1.1.0-dev filegroups: - name: census diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 4ca018edb39..587d86c98fd 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -90,6 +90,9 @@ GRPCAPI void grpc_shutdown(void); /** Return a string representing the current version of grpc */ GRPCAPI const char *grpc_version_string(void); +/** Return a string specifying what the 'g' in gRPC stands for */ +GRPCAPI const char *grpc_g_stands_for(void); + /** Create a completion queue */ GRPCAPI grpc_completion_queue *grpc_completion_queue_create(void *reserved); diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index a7a775cc533..9e67df8a9cf 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -233,8 +233,9 @@ static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args, } } - gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s)", is_first ? "" : " ", - grpc_version_string(), GPR_PLATFORM_STRING, transport_name); + gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s; %s)", is_first ? "" : " ", + grpc_version_string(), GPR_PLATFORM_STRING, transport_name, + grpc_g_stands_for()); is_first = 0; gpr_strvec_add(&v, tmp); diff --git a/src/core/lib/surface/version.c b/src/core/lib/surface/version.c index 19420750545..41242684da5 100644 --- a/src/core/lib/surface/version.c +++ b/src/core/lib/surface/version.c @@ -37,3 +37,5 @@ #include const char *grpc_version_string(void) { return "1.1.0-dev"; } + +const char *grpc_g_stands_for(void) { return "good"; } diff --git a/templates/src/core/lib/surface/version.c.template b/templates/src/core/lib/surface/version.c.template index 5f0273e49df..12c490e6a9d 100644 --- a/templates/src/core/lib/surface/version.c.template +++ b/templates/src/core/lib/surface/version.c.template @@ -32,10 +32,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + /* This file is autogenerated from: templates/src/core/surface/version.c.template */ - + #include - + const char *grpc_version_string(void) { return "${settings.core_version}"; } + + const char *grpc_g_stands_for(void) { return "${settings.g_stands_for}"; } From d9f907671d9ea702252615d98547f91d885840aa Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Aug 2016 16:47:22 -0700 Subject: [PATCH 22/25] Update documentation --- build.yaml | 15 ++++++++++----- doc/g_stands_for.md | 8 ++++++++ grpc.def | 1 + src/ruby/ext/grpc/rb_grpc_imports.generated.c | 2 ++ src/ruby/ext/grpc/rb_grpc_imports.generated.h | 3 +++ 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 doc/g_stands_for.md diff --git a/build.yaml b/build.yaml index 7017f5c99b7..7ac7f2065f6 100644 --- a/build.yaml +++ b/build.yaml @@ -2,11 +2,16 @@ '#2': It is used among other things to generate all of our project files. '#3': Please refer to the templates directory for more information. settings: - '#1': The public version number of the library. - '#2': Master always has a "-dev" suffix - '#3': Use "-preN" suffixes to identify pre-release versions - '#4': Per-language overrides are possible with (eg) ruby_version tag here - '#5': See the expand_version.py for all the quirks here + '#01': The public version number of the library. + '#02': === + '#03': Please update the 'g_stands_for' field periodically with a new g word + '#04': not listed in doc/g_stands_for.md - and update that document to list the + '#05': new word. + '#06': === + '#07': Master always has a "-dev" suffix + '#08': Use "-preN" suffixes to identify pre-release versions + '#09': Per-language overrides are possible with (eg) ruby_version tag here + '#10': See the expand_version.py for all the quirks here g_stands_for: good version: 1.1.0-dev filegroups: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md new file mode 100644 index 00000000000..52f8eae05aa --- /dev/null +++ b/doc/g_stands_for.md @@ -0,0 +1,8 @@ +Each version of gRPC gets a new description of what the 'g' stands for, since +we've never really been able to figure it out. + +Below is a list of already-used definitions (that should not be repeated in the +future), and the corresponding version numbers that used them: + +- 1.0 'g' stands for 'gRPC' +- 1.1 'g' stands for 'good' diff --git a/grpc.def b/grpc.def index e2255df7388..d6ddd33a926 100644 --- a/grpc.def +++ b/grpc.def @@ -42,6 +42,7 @@ EXPORTS grpc_init grpc_shutdown grpc_version_string + grpc_g_stands_for grpc_completion_queue_create grpc_completion_queue_next grpc_completion_queue_pluck diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index aee57b11aa1..9caaf7b7835 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -80,6 +80,7 @@ grpc_register_plugin_type grpc_register_plugin_import; grpc_init_type grpc_init_import; grpc_shutdown_type grpc_shutdown_import; grpc_version_string_type grpc_version_string_import; +grpc_g_stands_for_type grpc_g_stands_for_import; grpc_completion_queue_create_type grpc_completion_queue_create_import; grpc_completion_queue_next_type grpc_completion_queue_next_import; grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import; @@ -348,6 +349,7 @@ void grpc_rb_load_imports(HMODULE library) { grpc_init_import = (grpc_init_type) GetProcAddress(library, "grpc_init"); grpc_shutdown_import = (grpc_shutdown_type) GetProcAddress(library, "grpc_shutdown"); grpc_version_string_import = (grpc_version_string_type) GetProcAddress(library, "grpc_version_string"); + grpc_g_stands_for_import = (grpc_g_stands_for_type) GetProcAddress(library, "grpc_g_stands_for"); grpc_completion_queue_create_import = (grpc_completion_queue_create_type) GetProcAddress(library, "grpc_completion_queue_create"); grpc_completion_queue_next_import = (grpc_completion_queue_next_type) GetProcAddress(library, "grpc_completion_queue_next"); grpc_completion_queue_pluck_import = (grpc_completion_queue_pluck_type) GetProcAddress(library, "grpc_completion_queue_pluck"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 3bb76fbb97e..a2f5b86497b 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -191,6 +191,9 @@ extern grpc_shutdown_type grpc_shutdown_import; typedef const char *(*grpc_version_string_type)(void); extern grpc_version_string_type grpc_version_string_import; #define grpc_version_string grpc_version_string_import +typedef const char *(*grpc_g_stands_for_type)(void); +extern grpc_g_stands_for_type grpc_g_stands_for_import; +#define grpc_g_stands_for grpc_g_stands_for_import typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(void *reserved); extern grpc_completion_queue_create_type grpc_completion_queue_create_import; #define grpc_completion_queue_create grpc_completion_queue_create_import From 505d171c4cc16b6c03fab1bd9bd150a34d8d6a83 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 30 Aug 2016 04:41:21 -0700 Subject: [PATCH 23/25] Updated protobuf to bba446bbf2ac7b0b9923d4eb07d5acd0665a8cf0 --- third_party/protobuf | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/protobuf b/third_party/protobuf index e8ae137c964..bba446bbf2a 160000 --- a/third_party/protobuf +++ b/third_party/protobuf @@ -1 +1 @@ -Subproject commit e8ae137c96444ea313485ed1118c5e43b2099cf1 +Subproject commit bba446bbf2ac7b0b9923d4eb07d5acd0665a8cf0 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index d2ab5b01cc1..5562d330fd5 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -45,7 +45,7 @@ cat << EOF | awk '{ print $1 }' | sort > $want_submodules 05b155ff59114735ec8cd089f669c4c3d8f59029 third_party/gflags (v2.1.0-45-g05b155f) c99458533a9b4c743ed51537e25989ea55944908 third_party/googletest (release-1.7.0) f8ac463766281625ad710900479130c7fcb4d63b third_party/nanopb (nanopb-0.3.4-29-gf8ac463) - e8ae137c96444ea313485ed1118c5e43b2099cf1 third_party/protobuf (v3.0.0-beta-4-74-ge8ae137) + bba446bbf2ac7b0b9923d4eb07d5acd0665a8cf0 third_party/protobuf (v3.0.0-beta-4-160-gbba446b) 50893291621658f355bc5b4d450a8d06a563053d third_party/zlib (v1.2.8) bcad91771b7f0bff28a1cac1981d7ef2b9bcef3c third_party/thrift EOF From 4c0fe49f76e0e3d7e7ceed5722cc43010af61ab3 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 31 Aug 2016 13:51:55 -0700 Subject: [PATCH 24/25] Move subchannel_call_holder code into client_channel module. --- BUILD | 8 - CMakeLists.txt | 3 - Makefile | 3 - binding.gyp | 1 - build.yaml | 2 - config.m4 | 1 - gRPC-Core.podspec | 3 - grpc.gemspec | 2 - package.xml | 2 - src/core/ext/client_config/client_channel.c | 322 ++++++++++++++++-- .../client_config/subchannel_call_holder.c | 292 ---------------- .../client_config/subchannel_call_holder.h | 99 ------ src/python/grpcio/grpc_core_dependencies.py | 1 - tools/doxygen/Doxyfile.core.internal | 2 - tools/run_tests/sources_and_headers.json | 3 - vsprojects/vcxproj/grpc/grpc.vcxproj | 3 - vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 6 - .../grpc_unsecure/grpc_unsecure.vcxproj | 3 - .../grpc_unsecure.vcxproj.filters | 6 - 19 files changed, 290 insertions(+), 472 deletions(-) delete mode 100644 src/core/ext/client_config/subchannel_call_holder.c delete mode 100644 src/core/ext/client_config/subchannel_call_holder.h diff --git a/BUILD b/BUILD index 7dc5b6ca398..927b6e532a5 100644 --- a/BUILD +++ b/BUILD @@ -299,7 +299,6 @@ cc_library( "src/core/ext/client_config/resolver_registry.h", "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", - "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", "src/core/ext/client_config/uri_parser.h", "src/core/ext/lb_policy/grpclb/grpclb.h", @@ -474,7 +473,6 @@ cc_library( "src/core/ext/client_config/resolver_registry.c", "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", - "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c", @@ -671,7 +669,6 @@ cc_library( "src/core/ext/client_config/resolver_registry.h", "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", - "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", "src/core/ext/client_config/uri_parser.h", "src/core/lib/security/context/security_context.h", @@ -830,7 +827,6 @@ cc_library( "src/core/ext/client_config/resolver_registry.c", "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", - "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", "src/core/lib/http/httpcli_security_connector.c", @@ -1024,7 +1020,6 @@ cc_library( "src/core/ext/client_config/resolver_registry.h", "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", - "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", "src/core/ext/client_config/uri_parser.h", "src/core/ext/load_reporting/load_reporting.h", @@ -1174,7 +1169,6 @@ cc_library( "src/core/ext/client_config/resolver_registry.c", "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", - "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", "src/core/ext/resolver/dns/native/dns_resolver.c", @@ -2320,7 +2314,6 @@ objc_library( "src/core/ext/client_config/resolver_registry.c", "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", - "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c", @@ -2519,7 +2512,6 @@ objc_library( "src/core/ext/client_config/resolver_registry.h", "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", - "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", "src/core/ext/client_config/uri_parser.h", "src/core/ext/lb_policy/grpclb/grpclb.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index b8194652519..7b4ec92c40d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -448,7 +448,6 @@ add_library(grpc src/core/ext/client_config/resolver_registry.c src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c - src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c src/core/ext/client_config/uri_parser.c src/core/ext/transport/chttp2/server/insecure/server_chttp2.c @@ -680,7 +679,6 @@ add_library(grpc_cronet src/core/ext/client_config/resolver_registry.c src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c - src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c src/core/ext/client_config/uri_parser.c src/core/lib/http/httpcli_security_connector.c @@ -912,7 +910,6 @@ add_library(grpc_unsecure src/core/ext/client_config/resolver_registry.c src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c - src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c src/core/ext/client_config/uri_parser.c src/core/ext/resolver/dns/native/dns_resolver.c diff --git a/Makefile b/Makefile index 4bd4c306c17..0f8cfdf294d 100644 --- a/Makefile +++ b/Makefile @@ -2664,7 +2664,6 @@ LIBGRPC_SRC = \ src/core/ext/client_config/resolver_registry.c \ src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ - src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ @@ -2914,7 +2913,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/client_config/resolver_registry.c \ src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ - src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/lib/http/httpcli_security_connector.c \ @@ -3373,7 +3371,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/client_config/resolver_registry.c \ src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ - src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/ext/resolver/dns/native/dns_resolver.c \ diff --git a/binding.gyp b/binding.gyp index a29cfda6fc5..76276475df8 100644 --- a/binding.gyp +++ b/binding.gyp @@ -720,7 +720,6 @@ 'src/core/ext/client_config/resolver_registry.c', 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', - 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', 'src/core/ext/client_config/uri_parser.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', diff --git a/build.yaml b/build.yaml index 9b182d2ffcf..1f47a41858a 100644 --- a/build.yaml +++ b/build.yaml @@ -350,7 +350,6 @@ filegroups: - src/core/ext/client_config/resolver_registry.h - src/core/ext/client_config/resolver_result.h - src/core/ext/client_config/subchannel.h - - src/core/ext/client_config/subchannel_call_holder.h - src/core/ext/client_config/subchannel_index.h - src/core/ext/client_config/uri_parser.h src: @@ -370,7 +369,6 @@ filegroups: - src/core/ext/client_config/resolver_registry.c - src/core/ext/client_config/resolver_result.c - src/core/ext/client_config/subchannel.c - - src/core/ext/client_config/subchannel_call_holder.c - src/core/ext/client_config/subchannel_index.c - src/core/ext/client_config/uri_parser.c plugin: grpc_client_config diff --git a/config.m4 b/config.m4 index 5b47074bcd7..038af4569a8 100644 --- a/config.m4 +++ b/config.m4 @@ -239,7 +239,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/client_config/resolver_registry.c \ src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ - src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 41ba1b1058b..1e58d328018 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -390,7 +390,6 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver_registry.h', 'src/core/ext/client_config/resolver_result.h', 'src/core/ext/client_config/subchannel.h', - 'src/core/ext/client_config/subchannel_call_holder.h', 'src/core/ext/client_config/subchannel_index.h', 'src/core/ext/client_config/uri_parser.h', 'src/core/ext/lb_policy/grpclb/grpclb.h', @@ -569,7 +568,6 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver_registry.c', 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', - 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', 'src/core/ext/client_config/uri_parser.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', @@ -751,7 +749,6 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver_registry.h', 'src/core/ext/client_config/resolver_result.h', 'src/core/ext/client_config/subchannel.h', - 'src/core/ext/client_config/subchannel_call_holder.h', 'src/core/ext/client_config/subchannel_index.h', 'src/core/ext/client_config/uri_parser.h', 'src/core/ext/lb_policy/grpclb/grpclb.h', diff --git a/grpc.gemspec b/grpc.gemspec index 95eb28bd1d7..31a99e9c126 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -309,7 +309,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/resolver_registry.h ) s.files += %w( src/core/ext/client_config/resolver_result.h ) s.files += %w( src/core/ext/client_config/subchannel.h ) - s.files += %w( src/core/ext/client_config/subchannel_call_holder.h ) s.files += %w( src/core/ext/client_config/subchannel_index.h ) s.files += %w( src/core/ext/client_config/uri_parser.h ) s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.h ) @@ -488,7 +487,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/resolver_registry.c ) s.files += %w( src/core/ext/client_config/resolver_result.c ) s.files += %w( src/core/ext/client_config/subchannel.c ) - s.files += %w( src/core/ext/client_config/subchannel_call_holder.c ) s.files += %w( src/core/ext/client_config/subchannel_index.c ) s.files += %w( src/core/ext/client_config/uri_parser.c ) s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2.c ) diff --git a/package.xml b/package.xml index 1df4940530d..39284b7a5ad 100644 --- a/package.xml +++ b/package.xml @@ -317,7 +317,6 @@ - @@ -496,7 +495,6 @@ - diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 566d3d5ce49..e4d7527ce8d 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -33,6 +33,7 @@ #include "src/core/ext/client_config/client_channel.h" +#include #include #include @@ -41,10 +42,11 @@ #include #include -#include "src/core/ext/client_config/subchannel_call_holder.h" +#include "src/core/ext/client_config/subchannel.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/channel.h" @@ -52,13 +54,60 @@ /* Client channel implementation */ -typedef grpc_subchannel_call_holder call_data; +#define GET_CALL(call_data) \ + ((grpc_subchannel_call *)(gpr_atm_acq_load(&(call_data)->subchannel_call))) + +#define CANCELLED_CALL ((grpc_subchannel_call *)1) + +/** Picks a subchannel. + Returns true if subchannel is available immediately (in which case on_ready + should not be called), or false otherwise (in which case on_ready should be + called when the subchannel is available) */ +typedef bool (*pick_subchannel_cb)( + grpc_exec_ctx *exec_ctx, void *arg, grpc_metadata_batch *initial_metadata, + uint32_t initial_metadata_flags, + grpc_connected_subchannel **connected_subchannel, grpc_closure *on_ready); + +typedef enum { + GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING, + GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL +} subchannel_creation_phase; + +/** Call data. Holds a pointer to grpc_subchannel_call and the + associated machinery to create such a pointer. + Handles queueing of stream ops until a call object is ready, waiting + for initial metadata before trying to create a call object, + and handling cancellation gracefully. */ +typedef struct client_channel_call_data { + /** either 0 for no call, 1 for cancelled, or a pointer to a + grpc_subchannel_call */ + gpr_atm subchannel_call; + /** Helper function to choose the subchannel on which to create + the call object. Channel filter delegates to the load + balancing policy (once it's ready). */ + pick_subchannel_cb pick_subchannel; + void *pick_subchannel_arg; + + gpr_mu mu; + + subchannel_creation_phase creation_phase; + grpc_connected_subchannel *connected_subchannel; + grpc_polling_entity *pollent; + + grpc_transport_stream_op *waiting_ops; + size_t waiting_ops_count; + size_t waiting_ops_capacity; + + grpc_closure next_step; + + grpc_call_stack *owning_call; +} call_data; typedef struct client_channel_channel_data { /** resolver for this channel */ grpc_resolver *resolver; /** have we started resolving this channel */ - int started_resolving; + bool started_resolving; /** mutex protecting client configuration, including all variables below in this data structure */ @@ -74,7 +123,7 @@ typedef struct client_channel_channel_data { /** connectivity state being tracked */ grpc_connectivity_state_tracker state_tracker; /** when an lb_policy arrives, should we try to exit idle */ - int exit_idle_when_lb_policy_arrives; + bool exit_idle_when_lb_policy_arrives; /** owning stack */ grpc_channel_stack *owning_stack; /** interested parties (owned) */ @@ -82,10 +131,8 @@ typedef struct client_channel_channel_data { } channel_data; /** We create one watcher for each new lb_policy that is returned from a - resolver, - to watch for state changes from the lb_policy. When a state change is seen, - we - update the channel, and create a new watcher */ + resolver, to watch for state changes from the lb_policy. When a state + change is seen, we update the channel, and create a new watcher. */ typedef struct { channel_data *chand; grpc_closure on_changed; @@ -98,15 +145,208 @@ typedef struct { grpc_call_element *elem; } waiting_call; +static void add_waiting_locked(call_data *calld, grpc_transport_stream_op *op) { + GPR_TIMER_BEGIN("add_waiting_locked", 0); + if (calld->waiting_ops_count == calld->waiting_ops_capacity) { + calld->waiting_ops_capacity = GPR_MAX(3, 2 * calld->waiting_ops_capacity); + calld->waiting_ops = + gpr_realloc(calld->waiting_ops, + calld->waiting_ops_capacity * sizeof(*calld->waiting_ops)); + } + calld->waiting_ops[calld->waiting_ops_count++] = *op; + GPR_TIMER_END("add_waiting_locked", 0); +} + +static void fail_locked(grpc_exec_ctx *exec_ctx, call_data *calld, + grpc_error *error) { + size_t i; + for (i = 0; i < calld->waiting_ops_count; i++) { + grpc_transport_stream_op_finish_with_failure( + exec_ctx, &calld->waiting_ops[i], GRPC_ERROR_REF(error)); + } + calld->waiting_ops_count = 0; + GRPC_ERROR_UNREF(error); +} + +typedef struct { + grpc_transport_stream_op *ops; + size_t nops; + grpc_subchannel_call *call; +} retry_ops_args; + +static void retry_ops(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) { + retry_ops_args *a = args; + size_t i; + for (i = 0; i < a->nops; i++) { + grpc_subchannel_call_process_op(exec_ctx, a->call, &a->ops[i]); + } + GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, a->call, "retry_ops"); + gpr_free(a->ops); + gpr_free(a); +} + +static void retry_waiting_locked(grpc_exec_ctx *exec_ctx, call_data *calld) { + retry_ops_args *a = gpr_malloc(sizeof(*a)); + a->ops = calld->waiting_ops; + a->nops = calld->waiting_ops_count; + a->call = GET_CALL(calld); + if (a->call == CANCELLED_CALL) { + gpr_free(a); + fail_locked(exec_ctx, calld, GRPC_ERROR_CANCELLED); + return; + } + calld->waiting_ops = NULL; + calld->waiting_ops_count = 0; + calld->waiting_ops_capacity = 0; + GRPC_SUBCHANNEL_CALL_REF(a->call, "retry_ops"); + grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(retry_ops, a), + GRPC_ERROR_NONE, NULL); +} + +static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { + call_data *calld = arg; + gpr_mu_lock(&calld->mu); + GPR_ASSERT(calld->creation_phase == + GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL); + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; + if (calld->connected_subchannel == NULL) { + gpr_atm_no_barrier_store(&calld->subchannel_call, 1); + fail_locked(exec_ctx, calld, GRPC_ERROR_CREATE_REFERENCING( + "Failed to create subchannel", &error, 1)); + } else if (1 == gpr_atm_acq_load(&calld->subchannel_call)) { + /* already cancelled before subchannel became ready */ + fail_locked(exec_ctx, calld, + GRPC_ERROR_CREATE_REFERENCING( + "Cancelled before creating subchannel", &error, 1)); + } else { + grpc_subchannel_call *subchannel_call = NULL; + grpc_error *new_error = grpc_connected_subchannel_create_call( + exec_ctx, calld->connected_subchannel, calld->pollent, + &subchannel_call); + if (new_error != GRPC_ERROR_NONE) { + new_error = grpc_error_add_child(new_error, error); + subchannel_call = CANCELLED_CALL; + fail_locked(exec_ctx, calld, new_error); + } + gpr_atm_rel_store(&calld->subchannel_call, + (gpr_atm)(uintptr_t)subchannel_call); + retry_waiting_locked(exec_ctx, calld); + } + gpr_mu_unlock(&calld->mu); + GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); +} + static char *cc_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { - return grpc_subchannel_call_holder_get_peer(exec_ctx, elem->call_data); + call_data *calld = elem->call_data; + grpc_subchannel_call *subchannel_call = GET_CALL(calld); + if (subchannel_call == NULL || subchannel_call == CANCELLED_CALL) { + return NULL; + } else { + return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call); + } } +// The logic here is fairly complicated, due to (a) the fact that we +// need to handle the case where we receive the send op before the +// initial metadata op, and (b) the need for efficiency, especially in +// the streaming case. +// TODO(ctiller): Explain this more thoroughly. static void cc_start_transport_stream_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op *op) { + call_data *calld = elem->call_data; GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - grpc_subchannel_call_holder_perform_op(exec_ctx, elem->call_data, op); + /* try to (atomically) get the call */ + grpc_subchannel_call *call = GET_CALL(calld); + GPR_TIMER_BEGIN("cc_start_transport_stream_op", 0); + if (call == CANCELLED_CALL) { + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, + GRPC_ERROR_CANCELLED); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + if (call != NULL) { + grpc_subchannel_call_process_op(exec_ctx, call, op); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + /* we failed; lock and figure out what to do */ + gpr_mu_lock(&calld->mu); +retry: + /* need to recheck that another thread hasn't set the call */ + call = GET_CALL(calld); + if (call == CANCELLED_CALL) { + gpr_mu_unlock(&calld->mu); + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, + GRPC_ERROR_CANCELLED); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + if (call != NULL) { + gpr_mu_unlock(&calld->mu); + grpc_subchannel_call_process_op(exec_ctx, call, op); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + /* if this is a cancellation, then we can raise our cancelled flag */ + if (op->cancel_error != GRPC_ERROR_NONE) { + if (!gpr_atm_rel_cas(&calld->subchannel_call, 0, + (gpr_atm)(uintptr_t)CANCELLED_CALL)) { + goto retry; + } else { + switch (calld->creation_phase) { + case GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING: + fail_locked(exec_ctx, calld, GRPC_ERROR_REF(op->cancel_error)); + break; + case GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL: + calld->pick_subchannel(exec_ctx, calld->pick_subchannel_arg, NULL, 0, + &calld->connected_subchannel, NULL); + break; + } + gpr_mu_unlock(&calld->mu); + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, + GRPC_ERROR_CANCELLED); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + } + /* if we don't have a subchannel, try to get one */ + if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && + calld->connected_subchannel == NULL && + op->send_initial_metadata != NULL) { + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL; + grpc_closure_init(&calld->next_step, subchannel_ready, calld); + GRPC_CALL_STACK_REF(calld->owning_call, "pick_subchannel"); + if (calld->pick_subchannel( + exec_ctx, calld->pick_subchannel_arg, op->send_initial_metadata, + op->send_initial_metadata_flags, &calld->connected_subchannel, + &calld->next_step)) { + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; + GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); + } + } + /* if we've got a subchannel, then let's ask it to create a call */ + if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && + calld->connected_subchannel != NULL) { + grpc_subchannel_call *subchannel_call = NULL; + grpc_error *error = grpc_connected_subchannel_create_call( + exec_ctx, calld->connected_subchannel, calld->pollent, + &subchannel_call); + if (error != GRPC_ERROR_NONE) { + subchannel_call = CANCELLED_CALL; + fail_locked(exec_ctx, calld, GRPC_ERROR_REF(error)); + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); + } + gpr_atm_rel_store(&calld->subchannel_call, + (gpr_atm)(uintptr_t)subchannel_call); + retry_waiting_locked(exec_ctx, calld); + goto retry; + } + /* nothing to be done but wait */ + add_waiting_locked(calld, op); + gpr_mu_unlock(&calld->mu); + GPR_TIMER_END("cc_start_transport_stream_op", 0); } static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand, @@ -183,7 +423,7 @@ static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_lb_policy *lb_policy = NULL; grpc_lb_policy *old_lb_policy; grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE; - int exit_idle = 0; + bool exit_idle = false; grpc_error *state_error = GRPC_ERROR_CREATE("No load balancing policy"); if (chand->resolver_result != NULL) { @@ -221,8 +461,8 @@ static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, } if (lb_policy != NULL && chand->exit_idle_when_lb_policy_arrives) { GRPC_LB_POLICY_REF(lb_policy, "exit_idle"); - exit_idle = 1; - chand->exit_idle_when_lb_policy_arrives = 0; + exit_idle = true; + chand->exit_idle_when_lb_policy_arrives = false; } if (error == GRPC_ERROR_NONE && chand->resolver) { @@ -339,11 +579,11 @@ typedef struct { grpc_closure closure; } continue_picking_args; -static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg, - grpc_metadata_batch *initial_metadata, - uint32_t initial_metadata_flags, - grpc_connected_subchannel **connected_subchannel, - grpc_closure *on_ready); +static bool cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg, + grpc_metadata_batch *initial_metadata, + uint32_t initial_metadata_flags, + grpc_connected_subchannel **connected_subchannel, + grpc_closure *on_ready); static void continue_picking(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { @@ -360,11 +600,11 @@ static void continue_picking(grpc_exec_ctx *exec_ctx, void *arg, gpr_free(cpa); } -static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, - grpc_metadata_batch *initial_metadata, - uint32_t initial_metadata_flags, - grpc_connected_subchannel **connected_subchannel, - grpc_closure *on_ready) { +static bool cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, + grpc_metadata_batch *initial_metadata, + uint32_t initial_metadata_flags, + grpc_connected_subchannel **connected_subchannel, + grpc_closure *on_ready) { GPR_TIMER_BEGIN("cc_pick_subchannel", 0); grpc_call_element *elem = elemp; @@ -392,7 +632,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, } gpr_mu_unlock(&chand->mu); GPR_TIMER_END("cc_pick_subchannel", 0); - return 1; + return true; } if (chand->lb_policy != NULL) { grpc_lb_policy *lb_policy = chand->lb_policy; @@ -407,7 +647,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, return r; } if (chand->resolver != NULL && !chand->started_resolving) { - chand->started_resolving = 1; + chand->started_resolving = true; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); @@ -429,15 +669,25 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, gpr_mu_unlock(&chand->mu); GPR_TIMER_END("cc_pick_subchannel", 0); - return 0; + return false; } /* Constructor for call_data */ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_call_element_args *args) { - grpc_subchannel_call_holder_init(elem->call_data, cc_pick_subchannel, elem, - args->call_stack); + call_data *calld = elem->call_data; + gpr_atm_rel_store(&calld->subchannel_call, 0); + calld->pick_subchannel = cc_pick_subchannel; + calld->pick_subchannel_arg = elem; + gpr_mu_init(&calld->mu); + calld->connected_subchannel = NULL; + calld->waiting_ops = NULL; + calld->waiting_ops_count = 0; + calld->waiting_ops_capacity = 0; + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; + calld->owning_call = args->call_stack; + calld->pollent = NULL; return GRPC_ERROR_NONE; } @@ -445,7 +695,15 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, const grpc_call_final_info *final_info, void *and_free_memory) { - grpc_subchannel_call_holder_destroy(exec_ctx, elem->call_data); + call_data *calld = elem->call_data; + grpc_subchannel_call *call = GET_CALL(calld); + if (call != NULL && call != CANCELLED_CALL) { + GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, call, "client_channel_destroy_call"); + } + GPR_ASSERT(calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING); + gpr_mu_destroy(&calld->mu); + GPR_ASSERT(calld->waiting_ops_count == 0); + gpr_free(calld->waiting_ops); gpr_free(and_free_memory); } @@ -523,7 +781,7 @@ void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, GRPC_RESOLVER_REF(resolver, "channel"); if (!grpc_closure_list_empty(chand->waiting_for_config_closures) || chand->exit_idle_when_lb_policy_arrives) { - chand->started_resolving = 1; + chand->started_resolving = true; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); grpc_resolver_next(exec_ctx, resolver, &chand->resolver_result, &chand->on_resolver_result_changed); @@ -541,10 +799,10 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state( if (chand->lb_policy != NULL) { grpc_lb_policy_exit_idle(exec_ctx, chand->lb_policy); } else { - chand->exit_idle_when_lb_policy_arrives = 1; + chand->exit_idle_when_lb_policy_arrives = true; if (!chand->started_resolving && chand->resolver != NULL) { GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - chand->started_resolving = 1; + chand->started_resolving = true; grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); } diff --git a/src/core/ext/client_config/subchannel_call_holder.c b/src/core/ext/client_config/subchannel_call_holder.c deleted file mode 100644 index be6d054af4e..00000000000 --- a/src/core/ext/client_config/subchannel_call_holder.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/ext/client_config/subchannel_call_holder.h" - -#include - -#include "src/core/lib/profiling/timers.h" - -#define GET_CALL(holder) \ - ((grpc_subchannel_call *)(gpr_atm_acq_load(&(holder)->subchannel_call))) - -#define CANCELLED_CALL ((grpc_subchannel_call *)1) - -static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *holder, - grpc_error *error); -static void retry_ops(grpc_exec_ctx *exec_ctx, void *retry_ops_args, - grpc_error *error); - -static void add_waiting_locked(grpc_subchannel_call_holder *holder, - grpc_transport_stream_op *op); -static void fail_locked(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder, grpc_error *error); -static void retry_waiting_locked(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder); - -void grpc_subchannel_call_holder_init( - grpc_subchannel_call_holder *holder, - grpc_subchannel_call_holder_pick_subchannel pick_subchannel, - void *pick_subchannel_arg, grpc_call_stack *owning_call) { - gpr_atm_rel_store(&holder->subchannel_call, 0); - holder->pick_subchannel = pick_subchannel; - holder->pick_subchannel_arg = pick_subchannel_arg; - gpr_mu_init(&holder->mu); - holder->connected_subchannel = NULL; - holder->waiting_ops = NULL; - holder->waiting_ops_count = 0; - holder->waiting_ops_capacity = 0; - holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; - holder->owning_call = owning_call; - holder->pollent = NULL; -} - -void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder) { - grpc_subchannel_call *call = GET_CALL(holder); - if (call != NULL && call != CANCELLED_CALL) { - GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, call, "holder"); - } - GPR_ASSERT(holder->creation_phase == - GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING); - gpr_mu_destroy(&holder->mu); - GPR_ASSERT(holder->waiting_ops_count == 0); - gpr_free(holder->waiting_ops); -} - -// The logic here is fairly complicated, due to (a) the fact that we -// need to handle the case where we receive the send op before the -// initial metadata op, and (b) the need for efficiency, especially in -// the streaming case. -// TODO(ctiller): Explain this more thoroughly. -void grpc_subchannel_call_holder_perform_op(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder, - grpc_transport_stream_op *op) { - /* try to (atomically) get the call */ - grpc_subchannel_call *call = GET_CALL(holder); - GPR_TIMER_BEGIN("grpc_subchannel_call_holder_perform_op", 0); - if (call == CANCELLED_CALL) { - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, - GRPC_ERROR_CANCELLED); - GPR_TIMER_END("grpc_subchannel_call_holder_perform_op", 0); - return; - } - if (call != NULL) { - grpc_subchannel_call_process_op(exec_ctx, call, op); - GPR_TIMER_END("grpc_subchannel_call_holder_perform_op", 0); - return; - } - /* we failed; lock and figure out what to do */ - gpr_mu_lock(&holder->mu); -retry: - /* need to recheck that another thread hasn't set the call */ - call = GET_CALL(holder); - if (call == CANCELLED_CALL) { - gpr_mu_unlock(&holder->mu); - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, - GRPC_ERROR_CANCELLED); - GPR_TIMER_END("grpc_subchannel_call_holder_perform_op", 0); - return; - } - if (call != NULL) { - gpr_mu_unlock(&holder->mu); - grpc_subchannel_call_process_op(exec_ctx, call, op); - GPR_TIMER_END("grpc_subchannel_call_holder_perform_op", 0); - return; - } - /* if this is a cancellation, then we can raise our cancelled flag */ - if (op->cancel_error != GRPC_ERROR_NONE) { - if (!gpr_atm_rel_cas(&holder->subchannel_call, 0, - (gpr_atm)(uintptr_t)CANCELLED_CALL)) { - goto retry; - } else { - switch (holder->creation_phase) { - case GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING: - fail_locked(exec_ctx, holder, GRPC_ERROR_REF(op->cancel_error)); - break; - case GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL: - holder->pick_subchannel(exec_ctx, holder->pick_subchannel_arg, NULL, - 0, &holder->connected_subchannel, NULL); - break; - } - gpr_mu_unlock(&holder->mu); - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, - GRPC_ERROR_CANCELLED); - GPR_TIMER_END("grpc_subchannel_call_holder_perform_op", 0); - return; - } - } - /* if we don't have a subchannel, try to get one */ - if (holder->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && - holder->connected_subchannel == NULL && - op->send_initial_metadata != NULL) { - holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL; - grpc_closure_init(&holder->next_step, subchannel_ready, holder); - GRPC_CALL_STACK_REF(holder->owning_call, "pick_subchannel"); - if (holder->pick_subchannel( - exec_ctx, holder->pick_subchannel_arg, op->send_initial_metadata, - op->send_initial_metadata_flags, &holder->connected_subchannel, - &holder->next_step)) { - holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; - GRPC_CALL_STACK_UNREF(exec_ctx, holder->owning_call, "pick_subchannel"); - } - } - /* if we've got a subchannel, then let's ask it to create a call */ - if (holder->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && - holder->connected_subchannel != NULL) { - grpc_subchannel_call *subchannel_call = NULL; - grpc_error *error = grpc_connected_subchannel_create_call( - exec_ctx, holder->connected_subchannel, holder->pollent, - &subchannel_call); - if (error != GRPC_ERROR_NONE) { - subchannel_call = CANCELLED_CALL; - fail_locked(exec_ctx, holder, GRPC_ERROR_REF(error)); - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); - } - gpr_atm_rel_store(&holder->subchannel_call, - (gpr_atm)(uintptr_t)subchannel_call); - retry_waiting_locked(exec_ctx, holder); - goto retry; - } - /* nothing to be done but wait */ - add_waiting_locked(holder, op); - gpr_mu_unlock(&holder->mu); - GPR_TIMER_END("grpc_subchannel_call_holder_perform_op", 0); -} - -static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_subchannel_call_holder *holder = arg; - gpr_mu_lock(&holder->mu); - GPR_ASSERT(holder->creation_phase == - GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL); - holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; - if (holder->connected_subchannel == NULL) { - gpr_atm_no_barrier_store(&holder->subchannel_call, 1); - fail_locked(exec_ctx, holder, - GRPC_ERROR_CREATE_REFERENCING("Failed to create subchannel", - &error, 1)); - } else if (1 == gpr_atm_acq_load(&holder->subchannel_call)) { - /* already cancelled before subchannel became ready */ - fail_locked(exec_ctx, holder, - GRPC_ERROR_CREATE_REFERENCING( - "Cancelled before creating subchannel", &error, 1)); - } else { - grpc_subchannel_call *subchannel_call = NULL; - grpc_error *new_error = grpc_connected_subchannel_create_call( - exec_ctx, holder->connected_subchannel, holder->pollent, - &subchannel_call); - if (new_error != GRPC_ERROR_NONE) { - new_error = grpc_error_add_child(new_error, error); - subchannel_call = CANCELLED_CALL; - fail_locked(exec_ctx, holder, new_error); - } - gpr_atm_rel_store(&holder->subchannel_call, - (gpr_atm)(uintptr_t)subchannel_call); - retry_waiting_locked(exec_ctx, holder); - } - gpr_mu_unlock(&holder->mu); - GRPC_CALL_STACK_UNREF(exec_ctx, holder->owning_call, "pick_subchannel"); -} - -typedef struct { - grpc_transport_stream_op *ops; - size_t nops; - grpc_subchannel_call *call; -} retry_ops_args; - -static void retry_waiting_locked(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder) { - retry_ops_args *a = gpr_malloc(sizeof(*a)); - a->ops = holder->waiting_ops; - a->nops = holder->waiting_ops_count; - a->call = GET_CALL(holder); - if (a->call == CANCELLED_CALL) { - gpr_free(a); - fail_locked(exec_ctx, holder, GRPC_ERROR_CANCELLED); - return; - } - holder->waiting_ops = NULL; - holder->waiting_ops_count = 0; - holder->waiting_ops_capacity = 0; - GRPC_SUBCHANNEL_CALL_REF(a->call, "retry_ops"); - grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(retry_ops, a), - GRPC_ERROR_NONE, NULL); -} - -static void retry_ops(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) { - retry_ops_args *a = args; - size_t i; - for (i = 0; i < a->nops; i++) { - grpc_subchannel_call_process_op(exec_ctx, a->call, &a->ops[i]); - } - GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, a->call, "retry_ops"); - gpr_free(a->ops); - gpr_free(a); -} - -static void add_waiting_locked(grpc_subchannel_call_holder *holder, - grpc_transport_stream_op *op) { - GPR_TIMER_BEGIN("add_waiting_locked", 0); - if (holder->waiting_ops_count == holder->waiting_ops_capacity) { - holder->waiting_ops_capacity = GPR_MAX(3, 2 * holder->waiting_ops_capacity); - holder->waiting_ops = - gpr_realloc(holder->waiting_ops, holder->waiting_ops_capacity * - sizeof(*holder->waiting_ops)); - } - holder->waiting_ops[holder->waiting_ops_count++] = *op; - GPR_TIMER_END("add_waiting_locked", 0); -} - -static void fail_locked(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder, - grpc_error *error) { - size_t i; - for (i = 0; i < holder->waiting_ops_count; i++) { - grpc_transport_stream_op_finish_with_failure( - exec_ctx, &holder->waiting_ops[i], GRPC_ERROR_REF(error)); - } - holder->waiting_ops_count = 0; - GRPC_ERROR_UNREF(error); -} - -char *grpc_subchannel_call_holder_get_peer( - grpc_exec_ctx *exec_ctx, grpc_subchannel_call_holder *holder) { - grpc_subchannel_call *subchannel_call = GET_CALL(holder); - - if (subchannel_call == NULL || subchannel_call == CANCELLED_CALL) { - return NULL; - } else { - return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call); - } -} diff --git a/src/core/ext/client_config/subchannel_call_holder.h b/src/core/ext/client_config/subchannel_call_holder.h deleted file mode 100644 index 8d2deb02f38..00000000000 --- a/src/core/ext/client_config/subchannel_call_holder.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_SUBCHANNEL_CALL_HOLDER_H -#define GRPC_CORE_EXT_CLIENT_CONFIG_SUBCHANNEL_CALL_HOLDER_H - -#include "src/core/ext/client_config/subchannel.h" -#include "src/core/lib/iomgr/polling_entity.h" - -/** Pick a subchannel for grpc_subchannel_call_holder; - Return 1 if subchannel is available immediately (in which case on_ready - should not be called), or 0 otherwise (in which case on_ready should be - called when the subchannel is available) */ -typedef int (*grpc_subchannel_call_holder_pick_subchannel)( - grpc_exec_ctx *exec_ctx, void *arg, grpc_metadata_batch *initial_metadata, - uint32_t initial_metadata_flags, - grpc_connected_subchannel **connected_subchannel, grpc_closure *on_ready); - -typedef enum { - GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING, - GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL -} grpc_subchannel_call_holder_creation_phase; - -/** Wrapper for holding a pointer to grpc_subchannel_call, and the - associated machinery to create such a pointer. - Handles queueing of stream ops until a call object is ready, waiting - for initial metadata before trying to create a call object, - and handling cancellation gracefully. - - The channel filter uses this as their call_data. */ -typedef struct grpc_subchannel_call_holder { - /** either 0 for no call, 1 for cancelled, or a pointer to a - grpc_subchannel_call */ - gpr_atm subchannel_call; - /** Helper function to choose the subchannel on which to create - the call object. Channel filter delegates to the load - balancing policy (once it's ready). */ - grpc_subchannel_call_holder_pick_subchannel pick_subchannel; - void *pick_subchannel_arg; - - gpr_mu mu; - - grpc_subchannel_call_holder_creation_phase creation_phase; - grpc_connected_subchannel *connected_subchannel; - grpc_polling_entity *pollent; - - grpc_transport_stream_op *waiting_ops; - size_t waiting_ops_count; - size_t waiting_ops_capacity; - - grpc_closure next_step; - - grpc_call_stack *owning_call; -} grpc_subchannel_call_holder; - -void grpc_subchannel_call_holder_init( - grpc_subchannel_call_holder *holder, - grpc_subchannel_call_holder_pick_subchannel pick_subchannel, - void *pick_subchannel_arg, grpc_call_stack *owning_call); -void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder); - -void grpc_subchannel_call_holder_perform_op(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder, - grpc_transport_stream_op *op); -char *grpc_subchannel_call_holder_get_peer(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder); - -#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_SUBCHANNEL_CALL_HOLDER_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 660e34d7420..a3ff66224a2 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -233,7 +233,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/resolver_registry.c', 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', - 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', 'src/core/ext/client_config/uri_parser.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 77f951af50e..94ade7787e9 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -928,7 +928,6 @@ src/core/ext/client_config/resolver_factory.h \ src/core/ext/client_config/resolver_registry.h \ src/core/ext/client_config/resolver_result.h \ src/core/ext/client_config/subchannel.h \ -src/core/ext/client_config/subchannel_call_holder.h \ src/core/ext/client_config/subchannel_index.h \ src/core/ext/client_config/uri_parser.h \ src/core/ext/lb_policy/grpclb/grpclb.h \ @@ -1107,7 +1106,6 @@ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ -src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index ce94c5d5e89..b6b220f449f 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6100,7 +6100,6 @@ "src/core/ext/client_config/resolver_registry.h", "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", - "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", "src/core/ext/client_config/uri_parser.h" ], @@ -6136,8 +6135,6 @@ "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel.h", - "src/core/ext/client_config/subchannel_call_holder.c", - "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/subchannel_index.h", "src/core/ext/client_config/uri_parser.c", diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index d805fdfdee5..9dcb76c48bc 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -437,7 +437,6 @@ - @@ -776,8 +775,6 @@ - - diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 991bbec9e25..637dade8e1f 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -475,9 +475,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -1079,9 +1076,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 66ec41d2c6a..e77ea8dd720 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -403,7 +403,6 @@ - @@ -692,8 +691,6 @@ - - diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 6f2dc3571e8..d97f8248c91 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -400,9 +400,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -917,9 +914,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config From 2a5959f2aeca2e86cc752288d890bc10b24c55d0 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 1 Sep 2016 08:20:27 -0700 Subject: [PATCH 25/25] A bit more cleanup. --- src/core/ext/client_config/client_channel.c | 679 ++++++++++---------- 1 file changed, 335 insertions(+), 344 deletions(-) diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index e4d7527ce8d..fff80abb802 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -54,54 +54,9 @@ /* Client channel implementation */ -#define GET_CALL(call_data) \ - ((grpc_subchannel_call *)(gpr_atm_acq_load(&(call_data)->subchannel_call))) - -#define CANCELLED_CALL ((grpc_subchannel_call *)1) - -/** Picks a subchannel. - Returns true if subchannel is available immediately (in which case on_ready - should not be called), or false otherwise (in which case on_ready should be - called when the subchannel is available) */ -typedef bool (*pick_subchannel_cb)( - grpc_exec_ctx *exec_ctx, void *arg, grpc_metadata_batch *initial_metadata, - uint32_t initial_metadata_flags, - grpc_connected_subchannel **connected_subchannel, grpc_closure *on_ready); - -typedef enum { - GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING, - GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL -} subchannel_creation_phase; - -/** Call data. Holds a pointer to grpc_subchannel_call and the - associated machinery to create such a pointer. - Handles queueing of stream ops until a call object is ready, waiting - for initial metadata before trying to create a call object, - and handling cancellation gracefully. */ -typedef struct client_channel_call_data { - /** either 0 for no call, 1 for cancelled, or a pointer to a - grpc_subchannel_call */ - gpr_atm subchannel_call; - /** Helper function to choose the subchannel on which to create - the call object. Channel filter delegates to the load - balancing policy (once it's ready). */ - pick_subchannel_cb pick_subchannel; - void *pick_subchannel_arg; - - gpr_mu mu; - - subchannel_creation_phase creation_phase; - grpc_connected_subchannel *connected_subchannel; - grpc_polling_entity *pollent; - - grpc_transport_stream_op *waiting_ops; - size_t waiting_ops_count; - size_t waiting_ops_capacity; - - grpc_closure next_step; - - grpc_call_stack *owning_call; -} call_data; +/************************************************************************* + * CHANNEL-WIDE FUNCTIONS + */ typedef struct client_channel_channel_data { /** resolver for this channel */ @@ -140,215 +95,6 @@ typedef struct { grpc_lb_policy *lb_policy; } lb_policy_connectivity_watcher; -typedef struct { - grpc_closure closure; - grpc_call_element *elem; -} waiting_call; - -static void add_waiting_locked(call_data *calld, grpc_transport_stream_op *op) { - GPR_TIMER_BEGIN("add_waiting_locked", 0); - if (calld->waiting_ops_count == calld->waiting_ops_capacity) { - calld->waiting_ops_capacity = GPR_MAX(3, 2 * calld->waiting_ops_capacity); - calld->waiting_ops = - gpr_realloc(calld->waiting_ops, - calld->waiting_ops_capacity * sizeof(*calld->waiting_ops)); - } - calld->waiting_ops[calld->waiting_ops_count++] = *op; - GPR_TIMER_END("add_waiting_locked", 0); -} - -static void fail_locked(grpc_exec_ctx *exec_ctx, call_data *calld, - grpc_error *error) { - size_t i; - for (i = 0; i < calld->waiting_ops_count; i++) { - grpc_transport_stream_op_finish_with_failure( - exec_ctx, &calld->waiting_ops[i], GRPC_ERROR_REF(error)); - } - calld->waiting_ops_count = 0; - GRPC_ERROR_UNREF(error); -} - -typedef struct { - grpc_transport_stream_op *ops; - size_t nops; - grpc_subchannel_call *call; -} retry_ops_args; - -static void retry_ops(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) { - retry_ops_args *a = args; - size_t i; - for (i = 0; i < a->nops; i++) { - grpc_subchannel_call_process_op(exec_ctx, a->call, &a->ops[i]); - } - GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, a->call, "retry_ops"); - gpr_free(a->ops); - gpr_free(a); -} - -static void retry_waiting_locked(grpc_exec_ctx *exec_ctx, call_data *calld) { - retry_ops_args *a = gpr_malloc(sizeof(*a)); - a->ops = calld->waiting_ops; - a->nops = calld->waiting_ops_count; - a->call = GET_CALL(calld); - if (a->call == CANCELLED_CALL) { - gpr_free(a); - fail_locked(exec_ctx, calld, GRPC_ERROR_CANCELLED); - return; - } - calld->waiting_ops = NULL; - calld->waiting_ops_count = 0; - calld->waiting_ops_capacity = 0; - GRPC_SUBCHANNEL_CALL_REF(a->call, "retry_ops"); - grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(retry_ops, a), - GRPC_ERROR_NONE, NULL); -} - -static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - call_data *calld = arg; - gpr_mu_lock(&calld->mu); - GPR_ASSERT(calld->creation_phase == - GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL); - calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; - if (calld->connected_subchannel == NULL) { - gpr_atm_no_barrier_store(&calld->subchannel_call, 1); - fail_locked(exec_ctx, calld, GRPC_ERROR_CREATE_REFERENCING( - "Failed to create subchannel", &error, 1)); - } else if (1 == gpr_atm_acq_load(&calld->subchannel_call)) { - /* already cancelled before subchannel became ready */ - fail_locked(exec_ctx, calld, - GRPC_ERROR_CREATE_REFERENCING( - "Cancelled before creating subchannel", &error, 1)); - } else { - grpc_subchannel_call *subchannel_call = NULL; - grpc_error *new_error = grpc_connected_subchannel_create_call( - exec_ctx, calld->connected_subchannel, calld->pollent, - &subchannel_call); - if (new_error != GRPC_ERROR_NONE) { - new_error = grpc_error_add_child(new_error, error); - subchannel_call = CANCELLED_CALL; - fail_locked(exec_ctx, calld, new_error); - } - gpr_atm_rel_store(&calld->subchannel_call, - (gpr_atm)(uintptr_t)subchannel_call); - retry_waiting_locked(exec_ctx, calld); - } - gpr_mu_unlock(&calld->mu); - GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); -} - -static char *cc_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { - call_data *calld = elem->call_data; - grpc_subchannel_call *subchannel_call = GET_CALL(calld); - if (subchannel_call == NULL || subchannel_call == CANCELLED_CALL) { - return NULL; - } else { - return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call); - } -} - -// The logic here is fairly complicated, due to (a) the fact that we -// need to handle the case where we receive the send op before the -// initial metadata op, and (b) the need for efficiency, especially in -// the streaming case. -// TODO(ctiller): Explain this more thoroughly. -static void cc_start_transport_stream_op(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op *op) { - call_data *calld = elem->call_data; - GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - /* try to (atomically) get the call */ - grpc_subchannel_call *call = GET_CALL(calld); - GPR_TIMER_BEGIN("cc_start_transport_stream_op", 0); - if (call == CANCELLED_CALL) { - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, - GRPC_ERROR_CANCELLED); - GPR_TIMER_END("cc_start_transport_stream_op", 0); - return; - } - if (call != NULL) { - grpc_subchannel_call_process_op(exec_ctx, call, op); - GPR_TIMER_END("cc_start_transport_stream_op", 0); - return; - } - /* we failed; lock and figure out what to do */ - gpr_mu_lock(&calld->mu); -retry: - /* need to recheck that another thread hasn't set the call */ - call = GET_CALL(calld); - if (call == CANCELLED_CALL) { - gpr_mu_unlock(&calld->mu); - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, - GRPC_ERROR_CANCELLED); - GPR_TIMER_END("cc_start_transport_stream_op", 0); - return; - } - if (call != NULL) { - gpr_mu_unlock(&calld->mu); - grpc_subchannel_call_process_op(exec_ctx, call, op); - GPR_TIMER_END("cc_start_transport_stream_op", 0); - return; - } - /* if this is a cancellation, then we can raise our cancelled flag */ - if (op->cancel_error != GRPC_ERROR_NONE) { - if (!gpr_atm_rel_cas(&calld->subchannel_call, 0, - (gpr_atm)(uintptr_t)CANCELLED_CALL)) { - goto retry; - } else { - switch (calld->creation_phase) { - case GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING: - fail_locked(exec_ctx, calld, GRPC_ERROR_REF(op->cancel_error)); - break; - case GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL: - calld->pick_subchannel(exec_ctx, calld->pick_subchannel_arg, NULL, 0, - &calld->connected_subchannel, NULL); - break; - } - gpr_mu_unlock(&calld->mu); - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, - GRPC_ERROR_CANCELLED); - GPR_TIMER_END("cc_start_transport_stream_op", 0); - return; - } - } - /* if we don't have a subchannel, try to get one */ - if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && - calld->connected_subchannel == NULL && - op->send_initial_metadata != NULL) { - calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL; - grpc_closure_init(&calld->next_step, subchannel_ready, calld); - GRPC_CALL_STACK_REF(calld->owning_call, "pick_subchannel"); - if (calld->pick_subchannel( - exec_ctx, calld->pick_subchannel_arg, op->send_initial_metadata, - op->send_initial_metadata_flags, &calld->connected_subchannel, - &calld->next_step)) { - calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; - GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); - } - } - /* if we've got a subchannel, then let's ask it to create a call */ - if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && - calld->connected_subchannel != NULL) { - grpc_subchannel_call *subchannel_call = NULL; - grpc_error *error = grpc_connected_subchannel_create_call( - exec_ctx, calld->connected_subchannel, calld->pollent, - &subchannel_call); - if (error != GRPC_ERROR_NONE) { - subchannel_call = CANCELLED_CALL; - fail_locked(exec_ctx, calld, GRPC_ERROR_REF(error)); - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); - } - gpr_atm_rel_store(&calld->subchannel_call, - (gpr_atm)(uintptr_t)subchannel_call); - retry_waiting_locked(exec_ctx, calld); - goto retry; - } - /* nothing to be done but wait */ - add_waiting_locked(calld, op); - gpr_mu_unlock(&calld->mu); - GPR_TIMER_END("cc_start_transport_stream_op", 0); -} - static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand, grpc_lb_policy *lb_policy, grpc_connectivity_state current_state); @@ -417,8 +163,8 @@ static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand, &w->on_changed); } -static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { channel_data *chand = arg; grpc_lb_policy *lb_policy = NULL; grpc_lb_policy *old_lb_policy; @@ -570,44 +316,225 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, gpr_mu_unlock(&chand->mu); } -typedef struct { - grpc_metadata_batch *initial_metadata; - uint32_t initial_metadata_flags; - grpc_connected_subchannel **connected_subchannel; - grpc_closure *on_ready; - grpc_call_element *elem; - grpc_closure closure; -} continue_picking_args; +/* Constructor for channel_data */ +static void cc_init_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_element_args *args) { + channel_data *chand = elem->channel_data; -static bool cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg, - grpc_metadata_batch *initial_metadata, - uint32_t initial_metadata_flags, - grpc_connected_subchannel **connected_subchannel, - grpc_closure *on_ready); + memset(chand, 0, sizeof(*chand)); -static void continue_picking(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - continue_picking_args *cpa = arg; - if (cpa->connected_subchannel == NULL) { + GPR_ASSERT(args->is_last); + GPR_ASSERT(elem->filter == &grpc_client_channel_filter); + + gpr_mu_init(&chand->mu); + grpc_closure_init(&chand->on_resolver_result_changed, + on_resolver_result_changed, chand); + chand->owning_stack = args->channel_stack; + + grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE, + "client_channel"); + chand->interested_parties = grpc_pollset_set_create(); +} + +/* Destructor for channel_data */ +static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem) { + channel_data *chand = elem->channel_data; + + if (chand->resolver != NULL) { + grpc_resolver_shutdown(exec_ctx, chand->resolver); + GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel"); + } + if (chand->lb_policy != NULL) { + grpc_pollset_set_del_pollset_set(exec_ctx, + chand->lb_policy->interested_parties, + chand->interested_parties); + GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel"); + } + grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker); + grpc_pollset_set_destroy(chand->interested_parties); + gpr_mu_destroy(&chand->mu); +} + +/************************************************************************* + * PER-CALL FUNCTIONS + */ + +#define GET_CALL(call_data) \ + ((grpc_subchannel_call *)(gpr_atm_acq_load(&(call_data)->subchannel_call))) + +#define CANCELLED_CALL ((grpc_subchannel_call *)1) + +typedef enum { + GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING, + GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL +} subchannel_creation_phase; + +/** Call data. Holds a pointer to grpc_subchannel_call and the + associated machinery to create such a pointer. + Handles queueing of stream ops until a call object is ready, waiting + for initial metadata before trying to create a call object, + and handling cancellation gracefully. */ +typedef struct client_channel_call_data { + /** either 0 for no call, 1 for cancelled, or a pointer to a + grpc_subchannel_call */ + gpr_atm subchannel_call; + + gpr_mu mu; + + subchannel_creation_phase creation_phase; + grpc_connected_subchannel *connected_subchannel; + grpc_polling_entity *pollent; + + grpc_transport_stream_op *waiting_ops; + size_t waiting_ops_count; + size_t waiting_ops_capacity; + + grpc_closure next_step; + + grpc_call_stack *owning_call; +} call_data; + +static void add_waiting_locked(call_data *calld, grpc_transport_stream_op *op) { + GPR_TIMER_BEGIN("add_waiting_locked", 0); + if (calld->waiting_ops_count == calld->waiting_ops_capacity) { + calld->waiting_ops_capacity = GPR_MAX(3, 2 * calld->waiting_ops_capacity); + calld->waiting_ops = + gpr_realloc(calld->waiting_ops, + calld->waiting_ops_capacity * sizeof(*calld->waiting_ops)); + } + calld->waiting_ops[calld->waiting_ops_count++] = *op; + GPR_TIMER_END("add_waiting_locked", 0); +} + +static void fail_locked(grpc_exec_ctx *exec_ctx, call_data *calld, + grpc_error *error) { + size_t i; + for (i = 0; i < calld->waiting_ops_count; i++) { + grpc_transport_stream_op_finish_with_failure( + exec_ctx, &calld->waiting_ops[i], GRPC_ERROR_REF(error)); + } + calld->waiting_ops_count = 0; + GRPC_ERROR_UNREF(error); +} + +typedef struct { + grpc_transport_stream_op *ops; + size_t nops; + grpc_subchannel_call *call; +} retry_ops_args; + +static void retry_ops(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) { + retry_ops_args *a = args; + size_t i; + for (i = 0; i < a->nops; i++) { + grpc_subchannel_call_process_op(exec_ctx, a->call, &a->ops[i]); + } + GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, a->call, "retry_ops"); + gpr_free(a->ops); + gpr_free(a); +} + +static void retry_waiting_locked(grpc_exec_ctx *exec_ctx, call_data *calld) { + retry_ops_args *a = gpr_malloc(sizeof(*a)); + a->ops = calld->waiting_ops; + a->nops = calld->waiting_ops_count; + a->call = GET_CALL(calld); + if (a->call == CANCELLED_CALL) { + gpr_free(a); + fail_locked(exec_ctx, calld, GRPC_ERROR_CANCELLED); + return; + } + calld->waiting_ops = NULL; + calld->waiting_ops_count = 0; + calld->waiting_ops_capacity = 0; + GRPC_SUBCHANNEL_CALL_REF(a->call, "retry_ops"); + grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(retry_ops, a), + GRPC_ERROR_NONE, NULL); +} + +static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { + call_data *calld = arg; + gpr_mu_lock(&calld->mu); + GPR_ASSERT(calld->creation_phase == + GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL); + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; + if (calld->connected_subchannel == NULL) { + gpr_atm_no_barrier_store(&calld->subchannel_call, 1); + fail_locked(exec_ctx, calld, GRPC_ERROR_CREATE_REFERENCING( + "Failed to create subchannel", &error, 1)); + } else if (1 == gpr_atm_acq_load(&calld->subchannel_call)) { + /* already cancelled before subchannel became ready */ + fail_locked(exec_ctx, calld, + GRPC_ERROR_CREATE_REFERENCING( + "Cancelled before creating subchannel", &error, 1)); + } else { + grpc_subchannel_call *subchannel_call = NULL; + grpc_error *new_error = grpc_connected_subchannel_create_call( + exec_ctx, calld->connected_subchannel, calld->pollent, + &subchannel_call); + if (new_error != GRPC_ERROR_NONE) { + new_error = grpc_error_add_child(new_error, error); + subchannel_call = CANCELLED_CALL; + fail_locked(exec_ctx, calld, new_error); + } + gpr_atm_rel_store(&calld->subchannel_call, + (gpr_atm)(uintptr_t)subchannel_call); + retry_waiting_locked(exec_ctx, calld); + } + gpr_mu_unlock(&calld->mu); + GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); +} + +static char *cc_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { + call_data *calld = elem->call_data; + grpc_subchannel_call *subchannel_call = GET_CALL(calld); + if (subchannel_call == NULL || subchannel_call == CANCELLED_CALL) { + return NULL; + } else { + return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call); + } +} + +typedef struct { + grpc_metadata_batch *initial_metadata; + uint32_t initial_metadata_flags; + grpc_connected_subchannel **connected_subchannel; + grpc_closure *on_ready; + grpc_call_element *elem; + grpc_closure closure; +} continue_picking_args; + +static bool pick_subchannel(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_metadata_batch *initial_metadata, + uint32_t initial_metadata_flags, + grpc_connected_subchannel **connected_subchannel, + grpc_closure *on_ready); + +static void continue_picking(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { + continue_picking_args *cpa = arg; + if (cpa->connected_subchannel == NULL) { /* cancelled, do nothing */ } else if (error != GRPC_ERROR_NONE) { grpc_exec_ctx_sched(exec_ctx, cpa->on_ready, GRPC_ERROR_REF(error), NULL); - } else if (cc_pick_subchannel(exec_ctx, cpa->elem, cpa->initial_metadata, - cpa->initial_metadata_flags, - cpa->connected_subchannel, cpa->on_ready)) { + } else if (pick_subchannel(exec_ctx, cpa->elem, cpa->initial_metadata, + cpa->initial_metadata_flags, + cpa->connected_subchannel, cpa->on_ready)) { grpc_exec_ctx_sched(exec_ctx, cpa->on_ready, GRPC_ERROR_NONE, NULL); } gpr_free(cpa); } -static bool cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, - grpc_metadata_batch *initial_metadata, - uint32_t initial_metadata_flags, - grpc_connected_subchannel **connected_subchannel, - grpc_closure *on_ready) { - GPR_TIMER_BEGIN("cc_pick_subchannel", 0); +static bool pick_subchannel(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_metadata_batch *initial_metadata, + uint32_t initial_metadata_flags, + grpc_connected_subchannel **connected_subchannel, + grpc_closure *on_ready) { + GPR_TIMER_BEGIN("pick_subchannel", 0); - grpc_call_element *elem = elemp; channel_data *chand = elem->channel_data; call_data *calld = elem->call_data; continue_picking_args *cpa; @@ -631,19 +558,19 @@ static bool cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, } } gpr_mu_unlock(&chand->mu); - GPR_TIMER_END("cc_pick_subchannel", 0); + GPR_TIMER_END("pick_subchannel", 0); return true; } if (chand->lb_policy != NULL) { grpc_lb_policy *lb_policy = chand->lb_policy; int r; - GRPC_LB_POLICY_REF(lb_policy, "cc_pick_subchannel"); + GRPC_LB_POLICY_REF(lb_policy, "pick_subchannel"); gpr_mu_unlock(&chand->mu); r = grpc_lb_policy_pick(exec_ctx, lb_policy, calld->pollent, initial_metadata, initial_metadata_flags, connected_subchannel, on_ready); - GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "cc_pick_subchannel"); - GPR_TIMER_END("cc_pick_subchannel", 0); + GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "pick_subchannel"); + GPR_TIMER_END("pick_subchannel", 0); return r; } if (chand->resolver != NULL && !chand->started_resolving) { @@ -668,18 +595,118 @@ static bool cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, } gpr_mu_unlock(&chand->mu); - GPR_TIMER_END("cc_pick_subchannel", 0); + GPR_TIMER_END("pick_subchannel", 0); return false; } +// The logic here is fairly complicated, due to (a) the fact that we +// need to handle the case where we receive the send op before the +// initial metadata op, and (b) the need for efficiency, especially in +// the streaming case. +// TODO(ctiller): Explain this more thoroughly. +static void cc_start_transport_stream_op(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_transport_stream_op *op) { + call_data *calld = elem->call_data; + GRPC_CALL_LOG_OP(GPR_INFO, elem, op); + /* try to (atomically) get the call */ + grpc_subchannel_call *call = GET_CALL(calld); + GPR_TIMER_BEGIN("cc_start_transport_stream_op", 0); + if (call == CANCELLED_CALL) { + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, + GRPC_ERROR_CANCELLED); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + if (call != NULL) { + grpc_subchannel_call_process_op(exec_ctx, call, op); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + /* we failed; lock and figure out what to do */ + gpr_mu_lock(&calld->mu); +retry: + /* need to recheck that another thread hasn't set the call */ + call = GET_CALL(calld); + if (call == CANCELLED_CALL) { + gpr_mu_unlock(&calld->mu); + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, + GRPC_ERROR_CANCELLED); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + if (call != NULL) { + gpr_mu_unlock(&calld->mu); + grpc_subchannel_call_process_op(exec_ctx, call, op); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + /* if this is a cancellation, then we can raise our cancelled flag */ + if (op->cancel_error != GRPC_ERROR_NONE) { + if (!gpr_atm_rel_cas(&calld->subchannel_call, 0, + (gpr_atm)(uintptr_t)CANCELLED_CALL)) { + goto retry; + } else { + switch (calld->creation_phase) { + case GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING: + fail_locked(exec_ctx, calld, GRPC_ERROR_REF(op->cancel_error)); + break; + case GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL: + pick_subchannel(exec_ctx, elem, NULL, 0, + &calld->connected_subchannel, NULL); + break; + } + gpr_mu_unlock(&calld->mu); + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, + GRPC_ERROR_CANCELLED); + GPR_TIMER_END("cc_start_transport_stream_op", 0); + return; + } + } + /* if we don't have a subchannel, try to get one */ + if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && + calld->connected_subchannel == NULL && + op->send_initial_metadata != NULL) { + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL; + grpc_closure_init(&calld->next_step, subchannel_ready, calld); + GRPC_CALL_STACK_REF(calld->owning_call, "pick_subchannel"); + if (pick_subchannel( + exec_ctx, elem, op->send_initial_metadata, + op->send_initial_metadata_flags, &calld->connected_subchannel, + &calld->next_step)) { + calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; + GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); + } + } + /* if we've got a subchannel, then let's ask it to create a call */ + if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && + calld->connected_subchannel != NULL) { + grpc_subchannel_call *subchannel_call = NULL; + grpc_error *error = grpc_connected_subchannel_create_call( + exec_ctx, calld->connected_subchannel, calld->pollent, + &subchannel_call); + if (error != GRPC_ERROR_NONE) { + subchannel_call = CANCELLED_CALL; + fail_locked(exec_ctx, calld, GRPC_ERROR_REF(error)); + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); + } + gpr_atm_rel_store(&calld->subchannel_call, + (gpr_atm)(uintptr_t)subchannel_call); + retry_waiting_locked(exec_ctx, calld); + goto retry; + } + /* nothing to be done but wait */ + add_waiting_locked(calld, op); + gpr_mu_unlock(&calld->mu); + GPR_TIMER_END("cc_start_transport_stream_op", 0); +} + /* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_call_element_args *args) { +static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_call_element_args *args) { call_data *calld = elem->call_data; gpr_atm_rel_store(&calld->subchannel_call, 0); - calld->pick_subchannel = cc_pick_subchannel; - calld->pick_subchannel_arg = elem; gpr_mu_init(&calld->mu); calld->connected_subchannel = NULL; calld->waiting_ops = NULL; @@ -692,9 +719,10 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, } /* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - void *and_free_memory) { +static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + const grpc_call_final_info *final_info, + void *and_free_memory) { call_data *calld = elem->call_data; grpc_subchannel_call *call = GET_CALL(calld); if (call != NULL && call != CANCELLED_CALL) { @@ -707,47 +735,6 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, gpr_free(and_free_memory); } -/* Constructor for channel_data */ -static void init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { - channel_data *chand = elem->channel_data; - - memset(chand, 0, sizeof(*chand)); - - GPR_ASSERT(args->is_last); - GPR_ASSERT(elem->filter == &grpc_client_channel_filter); - - gpr_mu_init(&chand->mu); - grpc_closure_init(&chand->on_resolver_result_changed, - cc_on_resolver_result_changed, chand); - chand->owning_stack = args->channel_stack; - - grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE, - "client_channel"); - chand->interested_parties = grpc_pollset_set_create(); -} - -/* Destructor for channel_data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) { - channel_data *chand = elem->channel_data; - - if (chand->resolver != NULL) { - grpc_resolver_shutdown(exec_ctx, chand->resolver); - GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel"); - } - if (chand->lb_policy != NULL) { - grpc_pollset_set_del_pollset_set(exec_ctx, - chand->lb_policy->interested_parties, - chand->interested_parties); - GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel"); - } - grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker); - grpc_pollset_set_destroy(chand->interested_parties); - gpr_mu_destroy(&chand->mu); -} - static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_polling_entity *pollent) { @@ -755,16 +742,20 @@ static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx, calld->pollent = pollent; } +/************************************************************************* + * EXPORTED SYMBOLS + */ + const grpc_channel_filter grpc_client_channel_filter = { cc_start_transport_stream_op, cc_start_transport_op, sizeof(call_data), - init_call_elem, + cc_init_call_elem, cc_set_pollset_or_pollset_set, - destroy_call_elem, + cc_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + cc_init_channel_elem, + cc_destroy_channel_elem, cc_get_peer, "client-channel", };