ws2_32: Fix UDP LINGER support in getsockopt.
This commit is contained in:
parent
38982ddf11
commit
d278834dab
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue