Jacek Caban : server: Close async wait handle when wait is satisfied.

Alexandre Julliard julliard at winehq.org
Wed Jun 28 15:10:25 CDT 2017


Module: wine
Branch: master
Commit: 0e0834ae92291e9857ed01f3cb116240abda642b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0e0834ae92291e9857ed01f3cb116240abda642b

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Jun 26 12:17:51 2017 +0200

server: Close async wait handle when wait is satisfied.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/file.c |  1 -
 server/async.c    | 21 ++++++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index fd5a690..5329c79 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -589,7 +589,6 @@ static NTSTATUS server_read_file( HANDLE handle, HANDLE event, PIO_APC_ROUTINE a
     {
         NtWaitForSingleObject( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), NULL );
         status = io->u.Status;
-        NtClose( wait_handle );
     }
 
     return status;
diff --git a/server/async.c b/server/async.c
index 4c6c6a9..f50cdc5 100644
--- a/server/async.c
+++ b/server/async.c
@@ -53,6 +53,7 @@ struct async
 
 static void async_dump( struct object *obj, int verbose );
 static int async_signaled( struct object *obj, struct wait_queue_entry *entry );
+static void async_satisfied( struct object * obj, struct wait_queue_entry *entry );
 static void async_destroy( struct object *obj );
 
 static const struct object_ops async_ops =
@@ -63,7 +64,7 @@ static const struct object_ops async_ops =
     add_queue,                 /* add_queue */
     remove_queue,              /* remove_queue */
     async_signaled,            /* signaled */
-    no_satisfied,              /* satisfied */
+    async_satisfied,           /* satisfied */
     no_signal,                 /* signal */
     no_get_fd,                 /* get_fd */
     no_map_access,             /* map_access */
@@ -132,6 +133,19 @@ static int async_signaled( struct object *obj, struct wait_queue_entry *entry )
     return async->signaled;
 }
 
+static void async_satisfied( struct object *obj, struct wait_queue_entry *entry )
+{
+    struct async *async = (struct async *)obj;
+    assert( obj->ops == &async_ops );
+
+    /* close wait handle here to avoid extra server round trip */
+    if (async->wait_handle)
+    {
+        close_handle( async->thread->process, async->wait_handle );
+        async->wait_handle = 0;
+    }
+}
+
 static void async_destroy( struct object *obj )
 {
     struct async *async = (struct async *)obj;
@@ -300,7 +314,6 @@ struct async *create_request_async( struct thread *thread, const async_data_t *d
 /* return async object status and wait handle to client */
 obj_handle_t async_handoff( struct async *async, int success )
 {
-    obj_handle_t handle;
     if (!success)
     {
         close_handle( async->thread->process, async->wait_handle );
@@ -313,10 +326,8 @@ obj_handle_t async_handoff( struct async *async, int success )
         close_handle( async->thread->process, async->wait_handle);
         async->wait_handle = 0;
     }
-    handle = async->wait_handle;
-    async->wait_handle = 0;
     set_error( STATUS_PENDING );
-    return handle;
+    return async->wait_handle;
 }
 
 /* set the timeout of an async operation */




More information about the wine-cvs mailing list