ws2_32: Allow getsockname after AcceptEx.

.NET 6's HTTP/Socket code queries this. Winsock allows getsockname
on the AcceptEx AcceptSocket, but only if SO_UPDATE_ACCEPT_CONTEXT
is set.

Signed-off-by: David Curtiss <david.curtiss@ni.com>
This commit is contained in:
David Curtiss 2022-06-06 15:34:12 -05:00 committed by Alexandre Julliard
parent 26ab701072
commit 68d4643a67
2 changed files with 10 additions and 0 deletions

View file

@ -8143,6 +8143,15 @@ static void test_AcceptEx(void)
ok(bret, "GetOverlappedResult failed, error %ld\n", GetLastError());
ok(bytesReturned == 0, "bytesReturned isn't supposed to be %ld\n", bytesReturned);
/* Try to call getsockname on the acceptor socket.
*
* On Windows, this requires setting SO_UPDATE_ACCEPT_CONTEXT. */
iret = setsockopt(acceptor, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, (char *)&listener, sizeof(SOCKET));
ok(!iret, "Failed to set accept context %ld\n", GetLastError());
iret = getsockname(acceptor, (struct sockaddr *)&peerAddress, &remoteSize);
ok(!iret, "getsockname failed.\n");
ok(remoteSize == sizeof(struct sockaddr_in), "got remote size %u\n", remoteSize);
closesocket(connector);
connector = INVALID_SOCKET;
closesocket(acceptor);

View file

@ -1846,6 +1846,7 @@ static int accept_into_socket( struct sock *sock, struct sock *acceptsock )
}
acceptsock->state = SOCK_CONNECTED;
acceptsock->bound = 1;
acceptsock->pending_events = 0;
acceptsock->reported_events = 0;
acceptsock->proto = sock->proto;