diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-04-07 14:32:15 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-04-07 14:32:15 -0700 |
commit | a99157f4dd74583f1fb879792270553443bea34b (patch) | |
tree | 406a911454ec3147987700210b6b34875f73ae92 /test/core | |
parent | 6c963cd784e555a5294cfb9609785224cacd0a68 (diff) |
Fix server shutdown
A previous fix to make close() occur later can cause socket reuse by servers to fail as previous sockets are left asynchronously open.
This change:
- adds a callback to TCP server shutdown to signal that the server is completely shutdown
- wait for that callback before destroying listeners in the server (and before destroying the server)
- handles fallout
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/end2end/tests/cancel_after_invoke.c | 5 | ||||
-rw-r--r-- | test/core/end2end/tests/cancel_test_helpers.h | 5 | ||||
-rw-r--r-- | test/core/iomgr/tcp_server_posix_test.c | 10 |
3 files changed, 11 insertions, 9 deletions
diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index e15fa7fcd9..326321f4e2 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -51,10 +51,11 @@ static void *tag(gpr_intptr t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, + cancellation_mode mode, grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + gpr_log(GPR_INFO, "%s/%s/%s", test_name, config.name, mode.name); f = config.create_fixture(client_args, server_args); config.init_client(&f, client_args); config.init_server(&f, server_args); @@ -109,7 +110,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_op ops[6]; grpc_op *op; grpc_call *c; - grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL); + grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, mode, NULL, NULL); gpr_timespec deadline = five_seconds_time(); cq_verifier *v_client = cq_verifier_create(f.client_cq); grpc_metadata_array initial_metadata_recv; diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h index f2581dc32f..3d92b64ae4 100644 --- a/test/core/end2end/tests/cancel_test_helpers.h +++ b/test/core/end2end/tests/cancel_test_helpers.h @@ -35,6 +35,7 @@ #define GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H typedef struct { + const char *name; grpc_call_error (*initiate_cancel)(grpc_call *call); grpc_status_code expect_status; const char *expect_details; @@ -45,7 +46,7 @@ static grpc_call_error wait_for_deadline(grpc_call *call) { } static const cancellation_mode cancellation_modes[] = { - {grpc_call_cancel, GRPC_STATUS_CANCELLED, ""}, - {wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, }; + {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, ""}, + {"deadline", wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, }; #endif /* GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H */ diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index 2689c3f38e..6b80ee1ee8 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -60,14 +60,14 @@ static void on_connect(void *arg, grpc_endpoint *tcp) { static void test_no_op(void) { grpc_tcp_server *s = grpc_tcp_server_create(); - grpc_tcp_server_destroy(s); + grpc_tcp_server_destroy(s, NULL, NULL); } static void test_no_op_with_start(void) { grpc_tcp_server *s = grpc_tcp_server_create(); LOG_TEST(); grpc_tcp_server_start(s, NULL, 0, on_connect, NULL); - grpc_tcp_server_destroy(s); + grpc_tcp_server_destroy(s, NULL, NULL); } static void test_no_op_with_port(void) { @@ -80,7 +80,7 @@ static void test_no_op_with_port(void) { GPR_ASSERT( grpc_tcp_server_add_port(s, (struct sockaddr *)&addr, sizeof(addr))); - grpc_tcp_server_destroy(s); + grpc_tcp_server_destroy(s, NULL, NULL); } static void test_no_op_with_port_and_start(void) { @@ -95,7 +95,7 @@ static void test_no_op_with_port_and_start(void) { grpc_tcp_server_start(s, NULL, 0, on_connect, NULL); - grpc_tcp_server_destroy(s); + grpc_tcp_server_destroy(s, NULL, NULL); } static void test_connect(int n) { @@ -144,7 +144,7 @@ static void test_connect(int n) { gpr_mu_unlock(&mu); - grpc_tcp_server_destroy(s); + grpc_tcp_server_destroy(s, NULL, NULL); } int main(int argc, char **argv) { |