[PATCH 0/2] MR10894: ws2_32: Return WSAENOTSOCK instead of WSAENOTSUPP from select().
That helps War Thunder which otherwise may complain that select() returned 10045 in a message box when going in game. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10894
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/ws2_32/tests/sock.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index d861f303367..f8658d1a15f 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4360,6 +4360,8 @@ static void test_select(void) unsigned int apc_count; unsigned int maxfd, i; char *page_pair; + char path[MAX_PATH]; + HANDLE file; fdRead = socket(AF_INET, SOCK_STREAM, 0); ok( (fdRead != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() ); @@ -4459,8 +4461,42 @@ static void test_select(void) maxfd = fdRead; if(fdWrite > maxfd) maxfd = fdWrite; + GetSystemWindowsDirectoryA(path, ARRAY_SIZE(path)); + strcat(path, "\\system.ini"); + + file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0x0, NULL); + ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %lu\n", GetLastError()); + + if ((SOCKET)file > maxfd) maxfd = (SOCKET)file; + + FD_ZERO_ALL(); + FD_SET((SOCKET)file, &readfds); + SetLastError(0); + ret = select(maxfd + 1, &readfds, &writefds, &exceptfds, &select_timeout); + ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret); + todo_wine ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); + ok ( !FD_ISSET(fdRead, &readfds), "FD should not be set\n"); + FD_ZERO(&readfds); FD_SET(fdRead, &readfds); + FD_SET(fdRead, &exceptfds); + FD_SET((SOCKET)file, &writefds); + ret = select(maxfd + 1, &readfds, &writefds, &exceptfds, &select_timeout); + ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret); + ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); + + FD_ZERO_ALL(); + FD_SET(fdRead, &readfds); + FD_SET(fdWrite, &writefds); + FD_SET((SOCKET)file, &exceptfds); + ret = select(maxfd + 1, &readfds, &writefds, &exceptfds, &select_timeout); + ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret); + todo_wine ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); + + CloseHandle(file); + + FD_ZERO_ALL(); + FD_SET(fdRead, &readfds); apc_count = 0; ret = QueueUserAPC(apc_func, GetCurrentThread(), (ULONG_PTR)&apc_count); ok(ret, "QueueUserAPC returned %d\n", ret); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10894
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/ws2_32/socket.c | 1 + dlls/ws2_32/tests/sock.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index f5580cab4e3..b2601c6e4af 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3022,6 +3022,7 @@ int WINAPI select( int count, fd_set *read_ptr, fd_set *write_ptr, status = NtDeviceIoControlFile( (HANDLE)poll_socket, sync_event, NULL, NULL, &io, IOCTL_AFD_POLL, params, params_size, params, params_size ); + if (status == STATUS_NOT_SUPPORTED) status = STATUS_INVALID_HANDLE; if (status == STATUS_PENDING) { if (wait_event_alertable( sync_event ) == WAIT_FAILED) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index f8658d1a15f..191f45ccca8 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4474,7 +4474,7 @@ static void test_select(void) SetLastError(0); ret = select(maxfd + 1, &readfds, &writefds, &exceptfds, &select_timeout); ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret); - todo_wine ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); + ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); ok ( !FD_ISSET(fdRead, &readfds), "FD should not be set\n"); FD_ZERO(&readfds); @@ -4491,7 +4491,7 @@ static void test_select(void) FD_SET((SOCKET)file, &exceptfds); ret = select(maxfd + 1, &readfds, &writefds, &exceptfds, &select_timeout); ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret); - todo_wine ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); + ok ( WSAGetLastError() == WSAENOTSOCK, "expected WSAENOTSOCK, got %i\n", WSAGetLastError()); CloseHandle(file); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10894
It might want to be socket_list_find() instead... what if you use DuplicateHandle()? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10894#note_139851
Thanks, I will add a test for such a case and update the change if necessary. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10894#note_139852
participants (3)
-
Elizabeth Figura (@zfigura) -
Paul Gofman -
Paul Gofman (@gofman)