diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 71b37e4f172..ff27d982915 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -1045,7 +1045,6 @@ static void test_iocp_fileio(HANDLE h) /* using APCs on handle with associated completion port is not allowed */ res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL ); - todo_wine ok(res == STATUS_INVALID_PARAMETER, "NtReadFile returned %x\n", res); } @@ -1094,7 +1093,6 @@ static void test_iocp_fileio(HANDLE h) /* using APCs on handle with associated completion port is not allowed */ res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL ); - todo_wine ok(res == STATUS_INVALID_PARAMETER, "NtReadFile returned %x\n", res); } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 2790fea1243..efe10b32fde 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -6824,7 +6824,6 @@ static void test_WSARecv(void) memset(&ov, 0, sizeof(ov)); completion_called = 0; iret = WSARecv(dest, bufs, 1, NULL, &flags, &ov, io_completion); - todo_wine ok(iret == SOCKET_ERROR && GetLastError() == WSAEINVAL, "WSARecv failed - %d error %d\n", iret, GetLastError()); ok(!completion_called, "completion called\n"); diff --git a/server/async.c b/server/async.c index 020580728de..1cb020f7d42 100644 --- a/server/async.c +++ b/server/async.c @@ -192,7 +192,7 @@ void free_async_queue( struct async_queue *queue ) LIST_FOR_EACH_ENTRY_SAFE( async, next, &queue->queue, struct async, queue_entry ) { - async->completion = fd_get_completion( async->fd, &async->comp_key ); + if (!async->completion) async->completion = fd_get_completion( async->fd, &async->comp_key ); async->fd = NULL; async_terminate( async, STATUS_HANDLES_CLOSED ); async->queue = NULL; @@ -236,7 +236,7 @@ struct async *create_async( struct fd *fd, struct thread *thread, const async_da async->signaled = 0; async->wait_handle = 0; async->direct_result = 0; - async->completion = NULL; + async->completion = fd_get_completion( fd, &async->comp_key ); if (iosb) async->iosb = (struct iosb *)grab_object( iosb ); else async->iosb = NULL; @@ -244,6 +244,13 @@ struct async *create_async( struct fd *fd, struct thread *thread, const async_da list_add_head( &thread->process->asyncs, &async->process_entry ); if (event) reset_event( event ); + if (async->completion && data->apc) + { + release_object( async ); + set_error( STATUS_INVALID_PARAMETER ); + return NULL; + } + return async; }