Bruno Jesus : ws2_32: Fix UDP LINGER support in getsockopt.
Alexandre Julliard
julliard at winehq.org
Tue Oct 4 17:43:04 CDT 2011
Module: wine
Branch: master
Commit: d278834dabc29e4f37027c39e1e6ca31ea961d5b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d278834dabc29e4f37027c39e1e6ca31ea961d5b
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Tue Oct 4 00:10:25 2011 -0300
ws2_32: Fix UDP LINGER support in getsockopt.
---
dlls/ws2_32/socket.c | 10 ++++++++--
dlls/ws2_32/tests/sock.c | 8 ++++----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index f0313fc..7a1947f 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2575,7 +2575,8 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
case WS_SO_LINGER:
{
struct linger lingval;
- unsigned int len = sizeof(struct linger);
+ int so_type;
+ unsigned int len = sizeof(struct linger), slen = sizeof(int);
/* struct linger and LINGER have different sizes */
if (!optlen || *optlen < sizeof(LINGER) || !optval)
@@ -2586,7 +2587,12 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
return SOCKET_ERROR;
- if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0 )
+ if ((getsockopt(fd, SOL_SOCKET, SO_TYPE, &so_type, &slen) == 0 && so_type == SOCK_DGRAM))
+ {
+ SetLastError(WSAENOPROTOOPT);
+ ret = SOCKET_ERROR;
+ }
+ else if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0)
{
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno());
ret = SOCKET_ERROR;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index b358250..7a64e0e 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -2630,12 +2630,12 @@ static void test_extendedSocketOptions(void)
"got %d with %d and optval: 0x%x/%d (expected SOCKET_ERROR with WSAEINVAL)\n",
ret, WSAGetLastError(), optval, optval);
+ SetLastError(0xdeadbeef);
optlen = sizeof(LINGER);
ret = getsockopt(sock, SOL_SOCKET, SO_LINGER, (char *)&linger_val, &optlen);
- todo_wine{
- ok(ret == SOCKET_ERROR, "getsockopt should fail for UDP sockets but return value is 0x%08x\n", ret);
- }
-
+ ok( (ret == SOCKET_ERROR) && (WSAGetLastError() == WSAENOPROTOOPT),
+ "getsockopt should fail for UDP sockets setting last error to WSAENOPROTOOPT, got %d with %d\n",
+ ret, WSAGetLastError());
closesocket(sock);
if((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_IP)) == INVALID_SOCKET) {
More information about the wine-cvs
mailing list