From ad4d2dde0052efbbf49d64b0843c45f0381cfeb3 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 6 Dec 2017 09:05:05 -0800 Subject: Revert "All instances of exec_ctx being passed around in src/core removed" --- test/core/bad_client/bad_client.cc | 49 ++++++++++++---------- test/core/bad_client/tests/badreq.cc | 4 -- test/core/bad_client/tests/connection_prefix.cc | 3 -- .../core/bad_client/tests/head_of_line_blocking.cc | 3 -- test/core/bad_client/tests/headers.cc | 2 - .../bad_client/tests/initial_settings_frame.cc | 2 - .../bad_client/tests/server_registered_method.cc | 2 - test/core/bad_client/tests/simple_request.cc | 4 -- test/core/bad_client/tests/unknown_frame.cc | 2 - test/core/bad_client/tests/window_overflow.cc | 3 -- 10 files changed, 28 insertions(+), 46 deletions(-) (limited to 'test/core/bad_client') diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index 4c1642aa5d..d8bb092e14 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -50,19 +50,20 @@ static void thd_func(void* arg) { gpr_event_set(&a->done_thd, (void*)1); } -static void done_write(void* arg, grpc_error* error) { +static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { thd_args* a = (thd_args*)arg; gpr_event_set(&a->done_write, (void*)1); } static void server_setup_transport(void* ts, grpc_transport* transport) { thd_args* a = (thd_args*)ts; - grpc_core::ExecCtx exec_ctx; - grpc_server_setup_transport(a->server, transport, nullptr, + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_server_setup_transport(&exec_ctx, a->server, transport, nullptr, grpc_server_get_channel_args(a->server)); + grpc_exec_ctx_finish(&exec_ctx); } -static void read_done(void* arg, grpc_error* error) { +static void read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { gpr_event* read_done = (gpr_event*)arg; gpr_event_set(read_done, (void*)1); } @@ -80,7 +81,7 @@ void grpc_run_bad_client_test( grpc_slice_from_copied_buffer(client_payload, client_payload_length); grpc_slice_buffer outgoing; grpc_closure done_write_closure; - grpc_core::ExecCtx exec_ctx; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_completion_queue* shutdown_cq; if (client_payload_length < 4 * 1024) { @@ -114,13 +115,15 @@ void grpc_run_bad_client_test( GRPC_BAD_CLIENT_REGISTERED_HOST, GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0); grpc_server_start(a.server); - transport = grpc_create_chttp2_transport(nullptr, sfd.server, false); + transport = + grpc_create_chttp2_transport(&exec_ctx, nullptr, sfd.server, false); server_setup_transport(&a, transport); - grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr); + grpc_exec_ctx_finish(&exec_ctx); /* Bind everything into the same pollset */ - grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq)); - grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq)); + grpc_endpoint_add_to_pollset(&exec_ctx, sfd.client, grpc_cq_pollset(a.cq)); + grpc_endpoint_add_to_pollset(&exec_ctx, sfd.server, grpc_cq_pollset(a.cq)); /* Check a ground truth */ GPR_ASSERT(grpc_server_has_open_connections(a.server)); @@ -134,8 +137,8 @@ void grpc_run_bad_client_test( grpc_schedule_on_exec_ctx); /* Write data */ - grpc_endpoint_write(sfd.client, &outgoing, &done_write_closure); - grpc_core::ExecCtx::Get()->Flush(); + grpc_endpoint_write(&exec_ctx, sfd.client, &outgoing, &done_write_closure); + grpc_exec_ctx_finish(&exec_ctx); /* Await completion, unless the request is large and write may not finish * before the peer shuts down. */ @@ -146,9 +149,10 @@ void grpc_run_bad_client_test( if (flags & GRPC_BAD_CLIENT_DISCONNECT) { grpc_endpoint_shutdown( - sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect")); - grpc_endpoint_destroy(sfd.client); - grpc_core::ExecCtx::Get()->Flush(); + &exec_ctx, sfd.client, + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect")); + grpc_endpoint_destroy(&exec_ctx, sfd.client); + grpc_exec_ctx_finish(&exec_ctx); sfd.client = nullptr; } @@ -167,8 +171,9 @@ void grpc_run_bad_client_test( grpc_closure read_done_closure; GRPC_CLOSURE_INIT(&read_done_closure, read_done, &read_done_event, grpc_schedule_on_exec_ctx); - grpc_endpoint_read(sfd.client, &incoming, &read_done_closure); - grpc_core::ExecCtx::Get()->Flush(); + grpc_endpoint_read(&exec_ctx, sfd.client, &incoming, + &read_done_closure); + grpc_exec_ctx_finish(&exec_ctx); do { GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0); GPR_ASSERT( @@ -181,13 +186,14 @@ void grpc_run_bad_client_test( "client validator failed; trying additional read " "in case we didn't get all the data"); } - grpc_slice_buffer_destroy_internal(&incoming); + grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming); } // Shutdown. grpc_endpoint_shutdown( - sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown")); - grpc_endpoint_destroy(sfd.client); - grpc_core::ExecCtx::Get()->Flush(); + &exec_ctx, sfd.client, + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown")); + grpc_endpoint_destroy(&exec_ctx, sfd.client); + grpc_exec_ctx_finish(&exec_ctx); } GPR_ASSERT( @@ -201,7 +207,8 @@ void grpc_run_bad_client_test( grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); - grpc_slice_buffer_destroy_internal(&outgoing); + grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing); + grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); } diff --git a/test/core/bad_client/tests/badreq.cc b/test/core/bad_client/tests/badreq.cc index eeaf4c9974..c30244e0cd 100644 --- a/test/core/bad_client/tests/badreq.cc +++ b/test/core/bad_client/tests/badreq.cc @@ -20,8 +20,6 @@ #include -#include - #include "src/core/lib/surface/server.h" #include "test/core/end2end/cq_verifier.h" @@ -40,7 +38,6 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); /* invalid content type */ GRPC_RUN_BAD_CLIENT_TEST( @@ -129,6 +126,5 @@ int main(int argc, char** argv) { "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", GRPC_BAD_CLIENT_DISCONNECT); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc index 4aab234d3e..47252f9f10 100644 --- a/test/core/bad_client/tests/connection_prefix.cc +++ b/test/core/bad_client/tests/connection_prefix.cc @@ -30,7 +30,6 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "X", 0); GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PX", 0); @@ -58,7 +57,5 @@ int main(int argc, char** argv) { 0); GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nSM\r\n\rX", 0); - - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc index f56c4d71dd..bbc5611991 100644 --- a/test/core/bad_client/tests/head_of_line_blocking.cc +++ b/test/core/bad_client/tests/head_of_line_blocking.cc @@ -20,7 +20,6 @@ #include -#include #include #include "src/core/lib/surface/server.h" @@ -110,7 +109,6 @@ static void addbuf(const void* data, size_t len) { int main(int argc, char** argv) { int i; grpc_test_init(argc, argv); - grpc_init(); #define NUM_FRAMES 10 #define FRAME_SIZE 1000 @@ -133,7 +131,6 @@ int main(int argc, char** argv) { } grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count, 0); gpr_free(g_buffer); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/headers.cc b/test/core/bad_client/tests/headers.cc index 2aa1b280ce..50bb72c493 100644 --- a/test/core/bad_client/tests/headers.cc +++ b/test/core/bad_client/tests/headers.cc @@ -34,7 +34,6 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); /* partial http2 header prefixes */ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00", @@ -336,6 +335,5 @@ int main(int argc, char** argv) { "15 seconds", GRPC_BAD_CLIENT_DISCONNECT); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/initial_settings_frame.cc b/test/core/bad_client/tests/initial_settings_frame.cc index 0220000ece..edc52f503e 100644 --- a/test/core/bad_client/tests/initial_settings_frame.cc +++ b/test/core/bad_client/tests/initial_settings_frame.cc @@ -33,7 +33,6 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); /* various partial prefixes */ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00", @@ -107,6 +106,5 @@ int main(int argc, char** argv) { PFX_STR ONE_SETTING_HDR "\x00\x99\x00\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/server_registered_method.cc b/test/core/bad_client/tests/server_registered_method.cc index c2dc9c66af..6613c94b41 100644 --- a/test/core/bad_client/tests/server_registered_method.cc +++ b/test/core/bad_client/tests/server_registered_method.cc @@ -77,7 +77,6 @@ static void verifier_fails(grpc_server* server, grpc_completion_queue* cq, int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); /* body generated with * tools/codegen/core/gen_server_registered_method_bad_client_test_body.py */ @@ -124,6 +123,5 @@ int main(int argc, char** argv) { "\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00", 0); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/simple_request.cc b/test/core/bad_client/tests/simple_request.cc index c80fc5cb4a..9f4a03e69b 100644 --- a/test/core/bad_client/tests/simple_request.cc +++ b/test/core/bad_client/tests/simple_request.cc @@ -20,8 +20,6 @@ #include -#include - #include "src/core/lib/surface/server.h" #include "test/core/end2end/cq_verifier.h" @@ -124,7 +122,6 @@ static void failure_verifier(grpc_server* server, grpc_completion_queue* cq, int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); /* basic request: check that things are working */ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR, 0); @@ -167,6 +164,5 @@ int main(int argc, char** argv) { GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr, PFX_STR "\x00\x00\x00\x03\x10\x00\x00\x00\x01", 0); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index b1b618a43f..d962a4244d 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -33,7 +33,6 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, } int main(int argc, char** argv) { - grpc_init(); grpc_test_init(argc, argv); /* test adding prioritization data */ @@ -41,6 +40,5 @@ int main(int argc, char** argv) { PFX_STR "\x00\x00\x00\x88\x00\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); - grpc_shutdown(); return 0; } diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc index ed8279c951..f4bd81828b 100644 --- a/test/core/bad_client/tests/window_overflow.cc +++ b/test/core/bad_client/tests/window_overflow.cc @@ -20,7 +20,6 @@ #include -#include #include #include "src/core/lib/surface/server.h" @@ -73,7 +72,6 @@ int main(int argc, char** argv) { #define SEND_SIZE (6 * 1024 * 1024) #define NUM_FRAMES (SEND_SIZE / FRAME_SIZE + 1) grpc_test_init(argc, argv); - grpc_init(); addbuf(PFX_STR, sizeof(PFX_STR) - 1); for (i = 0; i < NUM_FRAMES; i++) { @@ -95,7 +93,6 @@ int main(int argc, char** argv) { grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count, GRPC_BAD_CLIENT_LARGE_REQUEST); gpr_free(g_buffer); - grpc_shutdown(); return 0; } -- cgit v1.2.3