[RFC PATCH v2 09/11] ntdll: Don't interrupt sock_recv with an I/O synchronous completion APC.

Jinoh Kang jinoh.kang.kr at gmail.com
Sat Jan 22 08:36:59 CST 2022


The synchronous completion request APC will be delivered via
"inline_apc" instead of interrupting the current thread.

Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---

Notes:
    The synchronous I/O-case logic was inside the requestor function (sock_recv)
    in the previous patch, but has now been moved into the asynchronous I/O
    completion callback (async_recv_proc) for this patch serie.

 dlls/ntdll/unix/socket.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c
index 7d3795a953e..3ab3c55d6e4 100644
--- a/dlls/ntdll/unix/socket.c
+++ b/dlls/ntdll/unix/socket.c
@@ -690,6 +690,7 @@ static NTSTATUS sock_recv( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
     NTSTATUS status;
     unsigned int i;
     ULONG options;
+    inline_apc_t inline_apc;
 
     if (unix_flags & MSG_OOB)
     {
@@ -751,12 +752,14 @@ static NTSTATUS sock_recv( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
     if (status == STATUS_DEVICE_NOT_READY && force_async)
         status = STATUS_PENDING;
 
+    memset( &inline_apc, 0, sizeof(inline_apc) );
     SERVER_START_REQ( recv_socket )
     {
         req->status = status;
         req->total  = information;
         req->async  = server_async( handle, &async->io, event, apc, apc_user, iosb_client_ptr(io) );
         req->oob    = !!(unix_flags & MSG_OOB);
+        wine_server_set_reply( req, &inline_apc, sizeof(inline_apc) );
         status = wine_server_call( req );
         wait_handle = wine_server_ptr_handle( reply->wait );
         options     = reply->options;
@@ -770,8 +773,7 @@ static NTSTATUS sock_recv( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
 
     if (!is_completion_deferred( status )) release_fileio( &async->io );
 
-    if (wait_handle) status = wait_async( wait_handle, options & FILE_SYNCHRONOUS_IO_ALERT );
-    return status;
+    return wait_async_after_apc( wait_handle, options & FILE_SYNCHRONOUS_IO_ALERT, status, &inline_apc );
 }
 
 
-- 
2.31.1




More information about the wine-devel mailing list