|
|
@ -57,8 +57,6 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( |
|
|
|
|
|
|
|
|
|
|
|
f.fixture_data = ffd; |
|
|
|
f.fixture_data = ffd; |
|
|
|
f.cq = grpc_completion_queue_create_for_next(nullptr); |
|
|
|
f.cq = grpc_completion_queue_create_for_next(nullptr); |
|
|
|
f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return f; |
|
|
|
return f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -270,27 +268,13 @@ static void drain_cq(grpc_completion_queue* cq) { |
|
|
|
} while (ev.type != GRPC_QUEUE_SHUTDOWN); |
|
|
|
} while (ev.type != GRPC_QUEUE_SHUTDOWN); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Shuts down the server.
|
|
|
|
|
|
|
|
// Side effect - Also shuts down and drains the completion queue.
|
|
|
|
static void shutdown_server(grpc_end2end_test_fixture* f) { |
|
|
|
static void shutdown_server(grpc_end2end_test_fixture* f) { |
|
|
|
if (!f->server) return; |
|
|
|
if (!f->server) return; |
|
|
|
/* Perform a completion queue next, so that any pending operations can be
|
|
|
|
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); |
|
|
|
* finished, and resources can be released. This is so that, shutdown does not |
|
|
|
grpc_completion_queue_shutdown(f->cq); |
|
|
|
* hang. For example, the server might be stuck in the handshaking code, which |
|
|
|
drain_cq(f->cq); |
|
|
|
* keeps a ref to a listener. Unless, it is unref'd, shutdown won't be able |
|
|
|
|
|
|
|
* to proceed. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* (If shutdown times out, it is probably because 100ms wasn't enough. In that |
|
|
|
|
|
|
|
* case, the deadline can be increased. Or, we could simply have another |
|
|
|
|
|
|
|
* thread for the server to poll the completion queue while the shutdown |
|
|
|
|
|
|
|
* progresses.) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
GPR_ASSERT(grpc_completion_queue_next( |
|
|
|
|
|
|
|
f->cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) |
|
|
|
|
|
|
|
.type == GRPC_QUEUE_TIMEOUT); |
|
|
|
|
|
|
|
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); |
|
|
|
|
|
|
|
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), |
|
|
|
|
|
|
|
grpc_timeout_seconds_to_deadline(5), |
|
|
|
|
|
|
|
nullptr) |
|
|
|
|
|
|
|
.type == GRPC_OP_COMPLETE); |
|
|
|
|
|
|
|
grpc_server_destroy(f->server); |
|
|
|
grpc_server_destroy(f->server); |
|
|
|
f->server = nullptr; |
|
|
|
f->server = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
@ -304,11 +288,7 @@ static void shutdown_client(grpc_end2end_test_fixture* f) { |
|
|
|
static void end_test(grpc_end2end_test_fixture* f) { |
|
|
|
static void end_test(grpc_end2end_test_fixture* f) { |
|
|
|
shutdown_client(f); |
|
|
|
shutdown_client(f); |
|
|
|
shutdown_server(f); |
|
|
|
shutdown_server(f); |
|
|
|
|
|
|
|
|
|
|
|
grpc_completion_queue_shutdown(f->cq); |
|
|
|
|
|
|
|
drain_cq(f->cq); |
|
|
|
|
|
|
|
grpc_completion_queue_destroy(f->cq); |
|
|
|
grpc_completion_queue_destroy(f->cq); |
|
|
|
grpc_completion_queue_destroy(f->shutdown_cq); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void simple_request_body(grpc_end2end_test_fixture f, |
|
|
|
static void simple_request_body(grpc_end2end_test_fixture f, |
|
|
|