aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/fuzzers
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/end2end/fuzzers')
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc83
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc210
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc135
3 files changed, 212 insertions, 216 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index 75117218e4..967a6d560f 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -376,8 +376,7 @@ typedef struct addr_req {
grpc_lb_addresses** lb_addrs;
} addr_req;
-static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void finish_resolve(void* arg, grpc_error* error) {
addr_req* r = static_cast<addr_req*>(arg);
if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) {
@@ -395,9 +394,9 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
nullptr);
*r->lb_addrs = lb_addrs;
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->on_done, GRPC_ERROR_NONE);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done,
+ GRPC_CLOSURE_SCHED(r->on_done,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Resolution failed", &error, 1));
}
@@ -406,8 +405,7 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
gpr_free(r);
}
-void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses) {
@@ -417,22 +415,24 @@ void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
r->addrs = addresses;
r->lb_addrs = nullptr;
grpc_timer_init(
- exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
}
-grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
- char** service_config_json) {
+grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs,
+ bool check_grpclb,
+ char** service_config_json) {
addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = nullptr;
r->lb_addrs = lb_addrs;
grpc_timer_init(
- exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
return nullptr;
}
@@ -442,12 +442,12 @@ grpc_ares_request* my_dns_lookup_ares(
// defined in tcp_client_posix.c
extern void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep,
+ grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
const grpc_resolved_address* addr, grpc_millis deadline);
-static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_endpoint** ep, gpr_timespec deadline);
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline);
typedef struct {
grpc_timer timer;
@@ -456,11 +456,11 @@ typedef struct {
gpr_timespec deadline;
} future_connect;
-static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void do_connect(void* arg, grpc_error* error) {
future_connect* fc = static_cast<future_connect*>(arg);
if (error != GRPC_ERROR_NONE) {
*fc->ep = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_REF(error));
} else if (g_server != nullptr) {
grpc_endpoint* client;
grpc_endpoint* server;
@@ -468,25 +468,23 @@ static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
*fc->ep = client;
grpc_transport* transport =
- grpc_create_chttp2_transport(exec_ctx, nullptr, server, false);
- grpc_server_setup_transport(exec_ctx, g_server, transport, nullptr,
- nullptr);
- grpc_chttp2_transport_start_reading(exec_ctx, transport, nullptr, nullptr);
+ grpc_create_chttp2_transport(nullptr, server, false);
+ grpc_server_setup_transport(g_server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_NONE);
} else {
- sched_connect(exec_ctx, fc->closure, fc->ep, fc->deadline);
+ sched_connect(fc->closure, fc->ep, fc->deadline);
}
gpr_free(fc);
}
-static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_endpoint** ep, gpr_timespec deadline) {
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
*ep = nullptr;
- GRPC_CLOSURE_SCHED(
- exec_ctx, closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connect deadline exceeded"));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Connect deadline exceeded"));
return;
}
@@ -495,17 +493,16 @@ static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
fc->ep = ep;
fc->deadline = deadline;
grpc_timer_init(
- exec_ctx, &fc->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &fc->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx));
}
-static void my_tcp_client_connect(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_endpoint** ep,
+static void my_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_millis deadline) {
- sched_connect(exec_ctx, closure, ep,
+ sched_connect(closure, ep,
grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC));
}
@@ -751,9 +748,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_init();
grpc_timer_manager_set_threading(false);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(false);
}
grpc_resolve_address = my_resolve_address;
grpc_dns_lookup_ares = my_dns_lookup_ares;
@@ -846,9 +842,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_channel = grpc_insecure_channel_create(target_uri, args, nullptr);
GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
@@ -874,9 +869,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_server = grpc_server_create(args, nullptr);
GPR_ASSERT(g_server != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
grpc_server_register_completion_queue(g_server, cq, nullptr);
grpc_server_start(g_server);
@@ -1205,9 +1199,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_secure_channel_create(creds, target_uri, args, nullptr);
GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
index 5871f0f43e..c17d581d8b 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -43,112 +43,114 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
-
- grpc_resource_quota* resource_quota =
- grpc_resource_quota_create("client_fuzzer");
- grpc_endpoint* mock_endpoint =
- grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
-
- grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
- grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, true);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
-
- grpc_channel* channel = grpc_channel_create(
- &exec_ctx, "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
- grpc_slice host = grpc_slice_from_static_string("localhost");
- grpc_call* call = grpc_channel_create_call(
- channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
-
- grpc_metadata_array initial_metadata_recv;
- grpc_metadata_array_init(&initial_metadata_recv);
- grpc_byte_buffer* response_payload_recv = nullptr;
- grpc_metadata_array trailing_metadata_recv;
- grpc_metadata_array_init(&trailing_metadata_recv);
- grpc_status_code status;
- grpc_slice details = grpc_empty_slice();
-
- grpc_op ops[6];
- memset(ops, 0, sizeof(ops));
- grpc_op* op = ops;
- op->op = GRPC_OP_SEND_INITIAL_METADATA;
- op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = nullptr;
- op++;
- op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
- op->flags = 0;
- op->reserved = nullptr;
- op++;
- op->op = GRPC_OP_RECV_INITIAL_METADATA;
- op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
- op->flags = 0;
- op->reserved = nullptr;
- op++;
- op->op = GRPC_OP_RECV_MESSAGE;
- op->data.recv_message.recv_message = &response_payload_recv;
- op->flags = 0;
- op->reserved = nullptr;
- op++;
- op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
- op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
- op->data.recv_status_on_client.status = &status;
- op->data.recv_status_on_client.status_details = &details;
- op->flags = 0;
- op->reserved = nullptr;
- op++;
- grpc_call_error error =
- grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
- int requested_calls = 1;
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
-
- grpc_event ev;
- while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
- switch (ev.type) {
- case GRPC_QUEUE_TIMEOUT:
- goto done;
- case GRPC_QUEUE_SHUTDOWN:
- break;
- case GRPC_OP_COMPLETE:
- requested_calls--;
- break;
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(false);
+
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("client_fuzzer");
+ grpc_endpoint* mock_endpoint =
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
+
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, true);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
+
+ grpc_channel* channel = grpc_channel_create(
+ "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_slice host = grpc_slice_from_static_string("localhost");
+ grpc_call* call = grpc_channel_create_call(
+ channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host,
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
+
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_byte_buffer* response_payload_recv = nullptr;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_status_code status;
+ grpc_slice details = grpc_empty_slice();
+
+ grpc_op ops[6];
+ memset(ops, 0, sizeof(ops));
+ grpc_op* op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata =
+ &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message = &response_payload_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ grpc_call_error error =
+ grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
+ int requested_calls = 1;
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ grpc_mock_endpoint_put_read(
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
+
+ grpc_event ev;
+ while (1) {
+ grpc_core::ExecCtx::Get()->Flush();
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ switch (ev.type) {
+ case GRPC_QUEUE_TIMEOUT:
+ goto done;
+ case GRPC_QUEUE_SHUTDOWN:
+ break;
+ case GRPC_OP_COMPLETE:
+ requested_calls--;
+ break;
+ }
}
- }
-done:
- if (requested_calls) {
- grpc_call_cancel(call, nullptr);
- }
- for (int i = 0; i < requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- }
- grpc_completion_queue_shutdown(cq);
- for (int i = 0; i < requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
- GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
- }
- grpc_call_unref(call);
- grpc_completion_queue_destroy(cq);
- grpc_metadata_array_destroy(&initial_metadata_recv);
- grpc_metadata_array_destroy(&trailing_metadata_recv);
- grpc_slice_unref(details);
- grpc_channel_destroy(channel);
- if (response_payload_recv != nullptr) {
- grpc_byte_buffer_destroy(response_payload_recv);
+ done:
+ if (requested_calls) {
+ grpc_call_cancel(call, nullptr);
+ }
+ for (int i = 0; i < requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+ }
+ grpc_completion_queue_shutdown(cq);
+ for (int i = 0; i < requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
+ }
+ grpc_call_unref(call);
+ grpc_completion_queue_destroy(cq);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_slice_unref(details);
+ grpc_channel_destroy(channel);
+ if (response_payload_recv != nullptr) {
+ grpc_byte_buffer_destroy(response_payload_recv);
+ }
}
grpc_shutdown();
if (leak_check) {
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index 67caf4e720..61c55e0afd 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -41,81 +41,82 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(false);
- grpc_resource_quota* resource_quota =
- grpc_resource_quota_create("server_fuzzer");
- grpc_endpoint* mock_endpoint =
- grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("server_fuzzer");
+ grpc_endpoint* mock_endpoint =
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_mock_endpoint_put_read(
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
- grpc_server* server = grpc_server_create(nullptr, nullptr);
- grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
- grpc_server_register_completion_queue(server, cq, nullptr);
- // TODO(ctiller): add registered methods (one for POST, one for PUT)
- // void *registered_method =
- // grpc_server_register_method(server, "/reg", NULL, 0);
- grpc_server_start(server);
- grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, false);
- grpc_server_setup_transport(&exec_ctx, server, transport, nullptr, nullptr);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server, cq, nullptr);
+ // TODO(ctiller): add registered methods (one for POST, one for PUT)
+ // void *registered_method =
+ // grpc_server_register_method(server, "/reg", NULL, 0);
+ grpc_server_start(server);
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, false);
+ grpc_server_setup_transport(server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
- grpc_call* call1 = nullptr;
- grpc_call_details call_details1;
- grpc_metadata_array request_metadata1;
- grpc_call_details_init(&call_details1);
- grpc_metadata_array_init(&request_metadata1);
- int requested_calls = 0;
+ grpc_call* call1 = nullptr;
+ grpc_call_details call_details1;
+ grpc_metadata_array request_metadata1;
+ grpc_call_details_init(&call_details1);
+ grpc_metadata_array_init(&request_metadata1);
+ int requested_calls = 0;
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_server_request_call(server, &call1, &call_details1,
- &request_metadata1, cq, cq, tag(1)));
- requested_calls++;
+ GPR_ASSERT(GRPC_CALL_OK ==
+ grpc_server_request_call(server, &call1, &call_details1,
+ &request_metadata1, cq, cq, tag(1)));
+ requested_calls++;
- grpc_event ev;
- while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
- switch (ev.type) {
- case GRPC_QUEUE_TIMEOUT:
- goto done;
- case GRPC_QUEUE_SHUTDOWN:
- break;
- case GRPC_OP_COMPLETE:
- switch (detag(ev.tag)) {
- case 1:
- requested_calls--;
- // TODO(ctiller): keep reading that call!
- break;
- }
+ grpc_event ev;
+ while (1) {
+ grpc_core::ExecCtx::Get()->Flush();
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ switch (ev.type) {
+ case GRPC_QUEUE_TIMEOUT:
+ goto done;
+ case GRPC_QUEUE_SHUTDOWN:
+ break;
+ case GRPC_OP_COMPLETE:
+ switch (detag(ev.tag)) {
+ case 1:
+ requested_calls--;
+ // TODO(ctiller): keep reading that call!
+ break;
+ }
+ }
}
- }
-done:
- if (call1 != nullptr) grpc_call_unref(call1);
- grpc_call_details_destroy(&call_details1);
- grpc_metadata_array_destroy(&request_metadata1);
- grpc_server_shutdown_and_notify(server, cq, tag(0xdead));
- grpc_server_cancel_all_calls(server);
- for (int i = 0; i <= requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- }
- grpc_completion_queue_shutdown(cq);
- for (int i = 0; i <= requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
- GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
+ done:
+ if (call1 != nullptr) grpc_call_unref(call1);
+ grpc_call_details_destroy(&call_details1);
+ grpc_metadata_array_destroy(&request_metadata1);
+ grpc_server_shutdown_and_notify(server, cq, tag(0xdead));
+ grpc_server_cancel_all_calls(server);
+ for (int i = 0; i <= requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+ }
+ grpc_completion_queue_shutdown(cq);
+ for (int i = 0; i <= requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
+ }
+ grpc_server_destroy(server);
+ grpc_completion_queue_destroy(cq);
}
- grpc_server_destroy(server);
- grpc_completion_queue_destroy(cq);
grpc_shutdown();
if (leak_check) {
counters = grpc_memory_counters_snapshot();