From 424a379f641465cde3b3a8a5e9a39e5865f926f2 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 20 Nov 2018 14:50:21 +0100 Subject: [PATCH] server: Return a WSA error code in create_socket. Signed-off-by: Alexandre Julliard --- dlls/ws2_32/socket.c | 11 +--------- dlls/ws2_32/tests/sock.c | 1 - server/sock.c | 5 ++--- server/trace.c | 43 ++++++++++++++++++++++++++++++++++++++++ tools/make_requests | 4 ++++ 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index c6805d88b91..2207586dd82 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -7619,7 +7619,7 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol, req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE; req->attributes = (dwFlags & WSA_FLAG_NO_HANDLE_INHERIT) ? 0 : OBJ_INHERIT; req->flags = dwFlags & ~WSA_FLAG_NO_HANDLE_INHERIT; - set_error( wine_server_call( req ) ); + err = NtStatusToWSAError( wine_server_call( req ) ); ret = HANDLE2SOCKET( wine_server_ptr_handle( reply->handle )); } SERVER_END_REQ; @@ -7655,7 +7655,6 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol, return ret; } - err = GetLastError(); if (err == WSAEACCES) /* raw socket denied */ { if (type == SOCK_RAW) @@ -7663,14 +7662,6 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol, else ERR_(winediag)("Failed to create socket, this requires special permissions.\n"); } - else - { - /* invalid combination of valid parameters, like SOCK_STREAM + IPPROTO_UDP */ - if (err == WSAEINVAL) - err = WSAESOCKTNOSUPPORT; - else if (err == WSAEOPNOTSUPP) - err = WSAEPROTONOSUPPORT; - } done: WARN("\t\tfailed, error %d!\n", err); diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index c058869059f..b32d1c053df 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2773,7 +2773,6 @@ static void test_WSASocket(void) if (sock == INVALID_SOCKET) { err = WSAGetLastError(); -todo_wine ok(err == WSAEAFNOSUPPORT || broken(err == WSAEPROTONOSUPPORT), "Expected 10047, received %d\n", err); skip("IPX is not supported\n"); } diff --git a/server/sock.c b/server/sock.c index 3be24b396b2..6620b51717e 100644 --- a/server/sock.c +++ b/server/sock.c @@ -661,11 +661,10 @@ static struct object *create_socket( int family, int type, int protocol, unsigne int sockfd; sockfd = socket( family, type, protocol ); - if (debug_level) - fprintf(stderr,"socket(%d,%d,%d)=%d\n",family,type,protocol,sockfd); if (sockfd == -1) { - sock_set_error(); + if (errno == EINVAL) set_win32_error( WSAESOCKTNOSUPPORT ); + else set_win32_error( sock_get_error( errno )); return NULL; } fcntl(sockfd, F_SETFL, O_NONBLOCK); /* make socket nonblocking */ diff --git a/server/trace.c b/server/trace.c index 9a840676621..41bbe4a5167 100644 --- a/server/trace.c +++ b/server/trace.c @@ -5549,6 +5549,49 @@ static const struct { "USER_MAPPED_FILE", STATUS_USER_MAPPED_FILE }, { "VOLUME_DISMOUNTED", STATUS_VOLUME_DISMOUNTED }, { "WAS_LOCKED", STATUS_WAS_LOCKED }, + { "WSAEACCES", 0xc0010000 | WSAEACCES }, + { "WSAEADDRINUSE", 0xc0010000 | WSAEADDRINUSE }, + { "WSAEADDRNOTAVAIL", 0xc0010000 | WSAEADDRNOTAVAIL }, + { "WSAEAFNOSUPPORT", 0xc0010000 | WSAEAFNOSUPPORT }, + { "WSAEALREADY", 0xc0010000 | WSAEALREADY }, + { "WSAEBADF", 0xc0010000 | WSAEBADF }, + { "WSAECONNABORTED", 0xc0010000 | WSAECONNABORTED }, + { "WSAECONNREFUSED", 0xc0010000 | WSAECONNREFUSED }, + { "WSAECONNRESET", 0xc0010000 | WSAECONNRESET }, + { "WSAEDESTADDRREQ", 0xc0010000 | WSAEDESTADDRREQ }, + { "WSAEDQUOT", 0xc0010000 | WSAEDQUOT }, + { "WSAEFAULT", 0xc0010000 | WSAEFAULT }, + { "WSAEHOSTDOWN", 0xc0010000 | WSAEHOSTDOWN }, + { "WSAEHOSTUNREACH", 0xc0010000 | WSAEHOSTUNREACH }, + { "WSAEINPROGRESS", 0xc0010000 | WSAEINPROGRESS }, + { "WSAEINTR", 0xc0010000 | WSAEINTR }, + { "WSAEINVAL", 0xc0010000 | WSAEINVAL }, + { "WSAEISCONN", 0xc0010000 | WSAEISCONN }, + { "WSAELOOP", 0xc0010000 | WSAELOOP }, + { "WSAEMFILE", 0xc0010000 | WSAEMFILE }, + { "WSAEMSGSIZE", 0xc0010000 | WSAEMSGSIZE }, + { "WSAENAMETOOLONG", 0xc0010000 | WSAENAMETOOLONG }, + { "WSAENETDOWN", 0xc0010000 | WSAENETDOWN }, + { "WSAENETRESET", 0xc0010000 | WSAENETRESET }, + { "WSAENETUNREACH", 0xc0010000 | WSAENETUNREACH }, + { "WSAENOBUFS", 0xc0010000 | WSAENOBUFS }, + { "WSAENOPROTOOPT", 0xc0010000 | WSAENOPROTOOPT }, + { "WSAENOTCONN", 0xc0010000 | WSAENOTCONN }, + { "WSAENOTEMPTY", 0xc0010000 | WSAENOTEMPTY }, + { "WSAENOTSOCK", 0xc0010000 | WSAENOTSOCK }, + { "WSAEOPNOTSUPP", 0xc0010000 | WSAEOPNOTSUPP }, + { "WSAEPFNOSUPPORT", 0xc0010000 | WSAEPFNOSUPPORT }, + { "WSAEPROCLIM", 0xc0010000 | WSAEPROCLIM }, + { "WSAEPROTONOSUPPORT", 0xc0010000 | WSAEPROTONOSUPPORT }, + { "WSAEPROTOTYPE", 0xc0010000 | WSAEPROTOTYPE }, + { "WSAEREMOTE", 0xc0010000 | WSAEREMOTE }, + { "WSAESHUTDOWN", 0xc0010000 | WSAESHUTDOWN }, + { "WSAESOCKTNOSUPPORT", 0xc0010000 | WSAESOCKTNOSUPPORT }, + { "WSAESTALE", 0xc0010000 | WSAESTALE }, + { "WSAETIMEDOUT", 0xc0010000 | WSAETIMEDOUT }, + { "WSAETOOMANYREFS", 0xc0010000 | WSAETOOMANYREFS }, + { "WSAEUSERS", 0xc0010000 | WSAEUSERS }, + { "WSAEWOULDBLOCK", 0xc0010000 | WSAEWOULDBLOCK }, { NULL, 0 } }; diff --git a/tools/make_requests b/tools/make_requests index 3a81f36bbff..367f2456538 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -298,6 +298,10 @@ sub GET_ERROR_NAMES() { $errors{$1} = "0xc0010000 | $1"; } + while (/\breturn\s+(WSA\w+)/g) + { + $errors{$1} = "0xc0010000 | $1"; + } } close FILE; }