David Curtiss : ws2_32: Allow getsockname after AcceptEx.
Alexandre Julliard
julliard at winehq.org
Mon Jun 20 16:57:22 CDT 2022
Module: wine
Branch: master
Commit: 68d4643a6758cbe87f90054fdcabf0558fc353ca
URL: https://source.winehq.org/git/wine.git/?a=commit;h=68d4643a6758cbe87f90054fdcabf0558fc353ca
Author: David Curtiss <david.curtiss at 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 at ni.com>
---
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 af4226e6258..3ec0ab67040 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -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);
diff --git a/server/sock.c b/server/sock.c
index b11ebddb51d..2f1b33a333d 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -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;
More information about the wine-cvs
mailing list