From: Paul Gofman pgofman@codeweavers.com
--- server/async.c | 4 +++- server/handle.c | 15 +++++++++++++++ server/handle.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/server/async.c b/server/async.c index 26946b5f5ce..95e86c6f603 100644 --- a/server/async.c +++ b/server/async.c @@ -622,7 +622,9 @@ restart: LIST_FOR_EACH_ENTRY( async, &thread->process->asyncs, struct async, process_entry ) { if (async->thread != thread || async->terminated || async->canceled) continue; - if (async->completion && async->data.apc_context && !async->event) continue; + if (async->completion && async->data.apc_context && !async->event + && get_obj_handle_count( thread->process, get_fd_user( async->fd ))) + continue;
async->canceled = 1; fd_cancel_async( async->fd, async ); diff --git a/server/handle.c b/server/handle.c index 38ad80da267..d6a8b40830c 100644 --- a/server/handle.c +++ b/server/handle.c @@ -501,6 +501,21 @@ unsigned int get_handle_access( struct process *process, obj_handle_t handle ) return entry->access & ~RESERVED_ALL; }
+/* return number of open handles to the object in the process */ +unsigned int get_obj_handle_count( struct process *process, const struct object *obj ) +{ + struct handle_table *table = process->handles; + struct handle_entry *ptr; + unsigned int count = 0; + int i; + + if (!table) return 0; + + for (i = 0, ptr = table->entries; i <= table->last; i++, ptr++) + if (ptr->ptr == obj) ++count; + return count; +} + /* find the first inherited handle of the given type */ /* this is needed for window stations and desktops (don't ask...) */ obj_handle_t find_inherited_handle( struct process *process, const struct object_ops *ops ) diff --git a/server/handle.h b/server/handle.h index ac3104dc003..16967c1e0bd 100644 --- a/server/handle.h +++ b/server/handle.h @@ -47,6 +47,7 @@ extern obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_hand extern obj_handle_t open_object( struct process *process, obj_handle_t parent, unsigned int access, const struct object_ops *ops, const struct unicode_str *name, unsigned int attr ); +extern unsigned int get_obj_handle_count( struct process *process, const struct object *obj ); extern obj_handle_t find_inherited_handle( struct process *process, const struct object_ops *ops ); extern void close_process_handles( struct process *process ); extern struct handle_table *alloc_handle_table( struct process *process, int count );