mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
ws2_32: Return the right value for SO_CONNECT_TIME if the socket is not connected.
This commit is contained in:
parent
895e7a5f5b
commit
c42989ed9a
@ -2548,14 +2548,21 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
|
||||
case WS_SO_CONNECT_TIME:
|
||||
{
|
||||
static int pretendtime = 0;
|
||||
struct WS_sockaddr addr;
|
||||
int len = sizeof(addr);
|
||||
|
||||
if (!pretendtime) FIXME("WS_SO_CONNECT_TIME - faking results\n");
|
||||
if (!optlen || *optlen < sizeof(DWORD) || !optval)
|
||||
{
|
||||
SetLastError(WSAEFAULT);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
*(DWORD*)optval = pretendtime++;
|
||||
if (WS_getpeername(s, &addr, &len) == SOCKET_ERROR)
|
||||
*(DWORD *)optval = ~0u;
|
||||
else
|
||||
{
|
||||
if (!pretendtime) FIXME("WS_SO_CONNECT_TIME - faking results\n");
|
||||
*(DWORD *)optval = pretendtime++;
|
||||
}
|
||||
*optlen = sizeof(DWORD);
|
||||
return ret;
|
||||
}
|
||||
|
@ -4496,14 +4496,14 @@ static void test_AcceptEx(void)
|
||||
SOCKET connector = INVALID_SOCKET;
|
||||
SOCKET connector2 = INVALID_SOCKET;
|
||||
struct sockaddr_in bindAddress, peerAddress, *readBindAddress, *readRemoteAddress;
|
||||
int socklen;
|
||||
int socklen, optlen;
|
||||
GUID acceptExGuid = WSAID_ACCEPTEX, getAcceptExGuid = WSAID_GETACCEPTEXSOCKADDRS;
|
||||
LPFN_ACCEPTEX pAcceptEx = NULL;
|
||||
LPFN_GETACCEPTEXSOCKADDRS pGetAcceptExSockaddrs = NULL;
|
||||
fd_set fds_accept, fds_send;
|
||||
struct timeval timeout = {0,10}; /* wait for 10 milliseconds */
|
||||
int got, conn1, i;
|
||||
DWORD bytesReturned;
|
||||
DWORD bytesReturned, connect_time;
|
||||
char buffer[1024];
|
||||
OVERLAPPED overlapped;
|
||||
int iret, localSize = sizeof(struct sockaddr_in), remoteSize = localSize;
|
||||
@ -4695,9 +4695,21 @@ static void test_AcceptEx(void)
|
||||
&bytesReturned, &overlapped);
|
||||
ok(bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING, "AcceptEx returned %d + errno %d\n", bret, WSAGetLastError());
|
||||
|
||||
connect_time = 0xdeadbeef;
|
||||
optlen = sizeof(connect_time);
|
||||
iret = getsockopt(connector, SOL_SOCKET, SO_CONNECT_TIME, (char *)&connect_time, &optlen);
|
||||
ok(!iret, "getsockopt failed %d\n", WSAGetLastError());
|
||||
ok(connect_time == ~0u, "unexpected connect time %u\n", connect_time);
|
||||
|
||||
iret = connect(connector, (struct sockaddr*)&bindAddress, sizeof(bindAddress));
|
||||
ok(iret == 0, "connecting to accepting socket failed, error %d\n", WSAGetLastError());
|
||||
|
||||
connect_time = 0xdeadbeef;
|
||||
optlen = sizeof(connect_time);
|
||||
iret = getsockopt(connector, SOL_SOCKET, SO_CONNECT_TIME, (char *)&connect_time, &optlen);
|
||||
ok(!iret, "getsockopt failed %d\n", WSAGetLastError());
|
||||
ok(connect_time < 0xdeadbeef, "unexpected connect time %u\n", connect_time);
|
||||
|
||||
dwret = WaitForSingleObject(overlapped.hEvent, 0);
|
||||
ok(dwret == WAIT_TIMEOUT, "Waiting for accept event timeout failed with %d + errno %d\n", dwret, GetLastError());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user