From a99157f4dd74583f1fb879792270553443bea34b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 7 Apr 2015 14:32:15 -0700 Subject: 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 --- test/core/iomgr/tcp_server_posix_test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/core/iomgr') 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) { -- cgit v1.2.3