On 9/10/21 12:33 PM, Guillaume Charifi wrote:
@@ -787,7 +789,13 @@ static void free_poll_req( void *private ) if (req->timeout) remove_timeout_user( req->timeout );
for (i = 0; i < req->count; ++i)
- {
if (req->sockets[i].sock->main_poll == req)
req->sockets[i].sock->main_poll = NULL;
release_object( req->sockets[i].sock );
- }
release_object( req->async ); release_object( req->iosb ); list_remove( &req->entry );
This needs to be done earlier, which is why you need the cancel_async callback.
Asyncs terminated by the server aren't destroyed immediately; they're kept around until an APC_ASYNC_IO is delivered and processed by the client. Only then is the completion callback called. This is because some asyncs can be restarted by the client.
However, this means that if a new poll_socket request arrives after the async is canceled or completed, but before APC_ASYNC_IO is processed, with this patch it won't be appropriately marked as the main one. So the main poll needs to get reset immediately when the async is terminated, including via cancellation.