Alexandre Julliard : server: Return a WSA error code in create_socket.
Alexandre Julliard
julliard at winehq.org
Tue Nov 20 15:39:50 CST 2018
Module: wine
Branch: master
Commit: 424a379f641465cde3b3a8a5e9a39e5865f926f2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=424a379f641465cde3b3a8a5e9a39e5865f926f2
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Nov 20 14:50:21 2018 +0100
server: Return a WSA error code in create_socket.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 c6805d8..2207586 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 c058869..b32d1c0 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 3be24b3..6620b51 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 9a84067..41bbe4a 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 3a81f36..367f245 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;
}
More information about the wine-cvs
mailing list