Module: wine Branch: oldstable Commit: 88c2d88df0e5ca94dccf50fb521b459359e0b98e URL: https://gitlab.winehq.org/wine/wine/-/commit/88c2d88df0e5ca94dccf50fb521b459...
Author: David Curtiss david.curtiss@ni.com Date: Mon Jun 6 15:34:12 2022 -0500
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 (cherry picked from commit 68d4643a6758cbe87f90054fdcabf0558fc353ca) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ws2_32/tests/sock.c | 9 +++++++++ server/sock.c | 1 + 2 files changed, 10 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 09ec6009c3f..23b50117c58 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -7507,6 +7507,15 @@ todo_wine ok(bret, "GetOverlappedResult failed, error %d\n", GetLastError()); ok(bytesReturned == 0, "bytesReturned isn't supposed to be %d\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 %d\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); diff --git a/server/sock.c b/server/sock.c index 650e67a2e0a..af756a45c42 100644 --- a/server/sock.c +++ b/server/sock.c @@ -1785,6 +1785,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;