server: Store I/O completion information in async structure.

This is to allow completions to be sent on handle close. Also this can
be helpful for AcceptEx/TransmitFile implementation.
diff --git a/server/async.c b/server/async.c
index ae58636..ff5f7a6 100644
--- a/server/async.c
+++ b/server/async.c
@@ -42,6 +42,8 @@
     struct timeout_user *timeout;
     unsigned int         timeout_status;  /* status to report upon timeout */
     struct event        *event;
+    struct completion   *completion;
+    unsigned long        comp_key;
     async_data_t         data;            /* data for async I/O call */
 };
 
@@ -121,6 +123,7 @@
 
     if (async->timeout) remove_timeout_user( async->timeout );
     if (async->event) release_object( async->event );
+    if (async->completion) release_object( async->completion );
     release_object( async->queue );
     release_object( async->thread );
 }
@@ -146,10 +149,6 @@
         return;
     }
 
-    /* send error completion event */
-    if (status != STATUS_ALERTED && async->data.cvalue && async->queue->fd)
-        fd_add_completion( async->queue->fd, async->data.cvalue, status, 0 );
-
     memset( &data, 0, sizeof(data) );
     data.type            = APC_ASYNC_IO;
     data.async_io.func   = async->data.callback;
@@ -214,6 +213,7 @@
     async->data    = *data;
     async->timeout = NULL;
     async->queue   = (struct async_queue *)grab_object( queue );
+    fd_assign_completion( queue->fd, &async->completion, &async->comp_key );
 
     list_add_tail( &queue->queue, &async->queue_entry );
     grab_object( async );
@@ -257,8 +257,8 @@
         if (async->timeout) remove_timeout_user( async->timeout );
         async->timeout = NULL;
         async->status = status;
-        if (async->data.cvalue && async->queue->fd)
-            fd_add_completion( async->queue->fd, async->data.cvalue, status, total );
+        if (async->completion && async->data.cvalue)
+            add_completion( async->completion, async->comp_key, async->data.cvalue, status, total );
         if (async->data.apc)
         {
             apc_call_t data;