mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
gio/tests: DuplicateHandle() is inappropriate for SOCKET
This commit is contained in:
parent
86a24bb19a
commit
2a925f273b
@ -1187,23 +1187,25 @@ test_timed_wait (void)
|
||||
}
|
||||
|
||||
static int
|
||||
duplicate_fd (int fd)
|
||||
duplicate_socket_fd (int fd)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
HANDLE newfd;
|
||||
WSAPROTOCOL_INFO info;
|
||||
|
||||
if (!DuplicateHandle (GetCurrentProcess (),
|
||||
(HANDLE)fd,
|
||||
GetCurrentProcess (),
|
||||
&newfd,
|
||||
0,
|
||||
FALSE,
|
||||
DUPLICATE_SAME_ACCESS))
|
||||
if (WSADuplicateSocket ((SOCKET)fd,
|
||||
GetCurrentProcessId (),
|
||||
&info))
|
||||
{
|
||||
gchar *emsg = g_win32_error_message (WSAGetLastError ());
|
||||
g_test_message ("Error duplicating socket: %s", emsg);
|
||||
g_free (emsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (int)(gintptr)newfd;
|
||||
return (int)WSASocket (FROM_PROTOCOL_INFO,
|
||||
FROM_PROTOCOL_INFO,
|
||||
FROM_PROTOCOL_INFO,
|
||||
&info, 0, 0);
|
||||
#else
|
||||
return dup (fd);
|
||||
#endif
|
||||
@ -1249,7 +1251,7 @@ test_fd_reuse (void)
|
||||
g_object_unref (addr);
|
||||
|
||||
/* we have to dup otherwise the fd gets closed twice on unref */
|
||||
fd = duplicate_fd (g_socket_get_fd (client));
|
||||
fd = duplicate_socket_fd (g_socket_get_fd (client));
|
||||
client2 = g_socket_new_from_fd (fd, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user