From e9f46d35291b8b34dac88a9b5b7fcaeb3ca0ba51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 23 Mar 2022 19:12:59 +0400 Subject: [PATCH] gio/tests: fix socket /socket/credentials/unix_socketpair on win32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When I enabled unix socketpair test on win32, I left the existing g_close(fds[1]), but _g_win32_socketpair() returns native sockets descriptors that must be closed with closesocket() on win32. Let GSocket handle the socket pair cleanup. Signed-off-by: Marc-André Lureau --- gio/tests/socket.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index 747ddfd1f..d271310c0 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -2243,7 +2243,7 @@ test_credentials_unix_socketpair (void) { gint fds[2]; gint status; - GSocket *sock; + GSocket *sock[2]; GError *error = NULL; GCredentials *creds; @@ -2259,9 +2259,12 @@ test_credentials_unix_socketpair (void) #endif g_assert_cmpint (status, ==, 0); - sock = g_socket_new_from_fd (fds[0], &error); + sock[0] = g_socket_new_from_fd (fds[0], &error); + g_assert_no_error (error); + sock[1] = g_socket_new_from_fd (fds[1], &error); + g_assert_no_error (error); - creds = g_socket_get_credentials (sock, &error); + creds = g_socket_get_credentials (sock[0], &error); if (creds != NULL) { gchar *str = g_credentials_to_string (creds); @@ -2276,8 +2279,8 @@ test_credentials_unix_socketpair (void) g_clear_error (&error); } - g_object_unref (sock); - g_close (fds[1], NULL); + g_object_unref (sock[0]); + g_object_unref (sock[1]); } #endif