Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/ws2_32/socket.c | 20 +++----------------- dlls/ws2_32/tests/sock.c | 7 ++----- 2 files changed, 5 insertions(+), 22 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 12126372d5..a25a2cf738 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1119,8 +1119,8 @@ static DWORD NtStatusToWSAError( DWORD status ) { case STATUS_SUCCESS: return 0; case STATUS_PENDING: return WSA_IO_PENDING; + case STATUS_INVALID_HANDLE: case STATUS_OBJECT_TYPE_MISMATCH: return WSAENOTSOCK; - case STATUS_INVALID_HANDLE: return WSAEBADF; case STATUS_INVALID_PARAMETER: return WSAEINVAL; case STATUS_PIPE_DISCONNECTED: return WSAESHUTDOWN; case STATUS_NETWORK_BUSY: return WSAEALREADY; @@ -2890,18 +2890,12 @@ static BOOL WINAPI WS2_AcceptEx(SOCKET listener, SOCKET acceptor, PVOID dest, DW
fd = get_sock_fd( listener, FILE_READ_DATA, NULL ); if (fd == -1) - { - SetLastError(WSAENOTSOCK); return FALSE; - } release_sock_fd( listener, fd );
fd = get_sock_fd( acceptor, FILE_READ_DATA, NULL ); if (fd == -1) - { - SetLastError(WSAENOTSOCK); return FALSE; - } release_sock_fd( acceptor, fd );
wsa = (struct ws2_accept_async *)alloc_async_io( sizeof(*wsa), WS2_async_accept ); @@ -3148,10 +3142,8 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
fd = get_sock_fd( s, FILE_WRITE_DATA, NULL ); if (fd == -1) - { - WSASetLastError( WSAENOTSOCK ); return FALSE; - } + if (getpeername( fd, &uaddr.addr, &uaddrlen ) != 0) { release_sock_fd( s, fd ); @@ -3497,8 +3489,6 @@ int WINAPI WS_closesocket(SOCKET s) if (CloseHandle(SOCKET2HANDLE(s))) res = 0; } - else - SetLastError(WSAENOTSOCK); } else SetLastError(WSANOTINITIALISED); @@ -3610,10 +3600,7 @@ static BOOL WINAPI WS2_ConnectEx(SOCKET s, const struct WS_sockaddr* name, int n
fd = get_sock_fd( s, FILE_READ_DATA, NULL ); if (fd == -1) - { - SetLastError( WSAENOTSOCK ); return FALSE; - }
TRACE("socket %04lx, ptr %p %s, length %d, sendptr %p, len %d, ov %p\n", s, name, debugstr_sockaddr(name), namelen, sendBuf, sendBufLen, ov); @@ -5207,8 +5194,7 @@ int WINAPI WS_listen(SOCKET s, int backlog) SetLastError(wsaErrno()); release_sock_fd( s, fd ); } - else - SetLastError(WSAENOTSOCK); + return ret; }
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index d9ceca98cc..b7a3fc4453 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1565,7 +1565,6 @@ todo_wine size = sizeof(i); i = 1234; err = getsockopt(s, SOL_SOCKET, SO_ERROR, (char *) &i, &size); -todo_wine ok( (err == SOCKET_ERROR) && (WSAGetLastError() == WSAENOTSOCK), "got %d with %d (expected SOCKET_ERROR with WSAENOTSOCK)\n", err, WSAGetLastError()); @@ -3850,8 +3849,7 @@ static void test_select(void) SetLastError(0xdeadbeef); ret = select(0, &readfds, NULL, &exceptfds, &select_timeout); ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret); -todo_wine - ok(GetLastError() == WSAENOTSOCK, "expected 10038, got %d\n", GetLastError()); + ok(GetLastError() == WSAENOTSOCK, "got %d\n", GetLastError()); /* descriptor sets are unchanged */ ok(readfds.fd_count == 2, "expected 2, got %d\n", readfds.fd_count); ok(exceptfds.fd_count == 2, "expected 2, got %d\n", exceptfds.fd_count); @@ -3878,8 +3876,7 @@ todo_wine ret = select(0, NULL, NULL, &exceptfds, &select_timeout); todo_wine ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret); -todo_wine - ok(GetLastError() == WSAENOTSOCK, "expected 10038, got %d\n", GetLastError()); + ok(GetLastError() == WSAENOTSOCK, "got %d\n", GetLastError()); WaitForSingleObject (thread_handle, 1000); closesocket(fdRead);