libzmq (https://github.com/zeromq/libzmq) which is used by some apps (Glyph launcher is an example) does it this way and currently breaks with assert with Wine.
From: Paul Gofman pgofman@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/ws2_32/tests/afd.c | 15 ++++++++++++--- server/sock.c | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index fe3c2ef2ff6..f84e7084a27 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -172,15 +172,17 @@ static void test_poll(void) GUID acceptex_guid = WSAID_ACCEPTEX; SOCKET client, server, listener; OVERLAPPED overlapped = {0}; + HANDLE event, afd_handle; LPFN_ACCEPTEX pAcceptEx; struct sockaddr_in addr; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING string; DWORD size, flags = 0; char *large_buffer; IO_STATUS_BLOCK io; LARGE_INTEGER now; ULONG params_size; WSABUF wsabuf; - HANDLE event; int ret, len;
large_buffer = malloc(large_buffer_size); @@ -189,6 +191,11 @@ static void test_poll(void) event = CreateEventW(NULL, TRUE, FALSE, NULL); overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
+ RtlInitUnicodeString(&string, L"\Device\Afd\deadbeef"); + InitializeObjectAttributes(&attr, &string, 0, NULL, NULL); + ret = NtOpenFile(&afd_handle, SYNCHRONIZE, &attr, &io, 0, 0); + ok(!ret, "got %#x\n", ret); + listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ret = bind(listener, (const struct sockaddr *)&bind_addr, sizeof(bind_addr)); ok(!ret, "got error %u\n", WSAGetLastError()); @@ -246,7 +253,7 @@ static void test_poll(void) in_params->sockets[0].status = 0xdeadbeef;
memset(out_params, 0, params_size); - ret = NtDeviceIoControlFile((HANDLE)listener, event, NULL, NULL, &io, + ret = NtDeviceIoControlFile(afd_handle, event, NULL, NULL, &io, IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); ok(!ret, "got %#x\n", ret); ok(!io.Status, "got %#lx\n", io.Status); @@ -260,7 +267,7 @@ static void test_poll(void) NtQuerySystemTime(&now); in_params->timeout = now.QuadPart;
- ret = NtDeviceIoControlFile((HANDLE)listener, event, NULL, NULL, &io, + ret = NtDeviceIoControlFile(afd_handle, event, NULL, NULL, &io, IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); ok(ret == STATUS_PENDING, "got %#x\n", ret); ret = WaitForSingleObject(event, 100); @@ -899,6 +906,8 @@ static void test_poll(void) CloseHandle(overlapped.hEvent); CloseHandle(event); free(large_buffer); + + CloseHandle(afd_handle); }
struct poll_exclusive_thread_cb_ctx diff --git a/server/sock.c b/server/sock.c index 2f1b33a333d..caa68dd213b 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2186,11 +2186,12 @@ static struct accept_req *alloc_accept_req( struct sock *sock, struct sock *acce static void sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) { struct sock *sock = get_fd_user( fd ); - int unix_fd; + int unix_fd = -1;
assert( sock->obj.ops == &sock_ops );
- if (code != IOCTL_AFD_WINE_CREATE && (unix_fd = get_unix_fd( fd )) < 0) return; + if (code != IOCTL_AFD_WINE_CREATE && code != IOCTL_AFD_POLL && (unix_fd = get_unix_fd( fd )) < 0) + return;
switch(code) {
This merge request was approved by Zebediah Figura.