]> git.proxmox.com Git - mirror_qemu.git/commit - util/thread-pool.c
thread-pool: Convert thread_pool_aiocb_info.cancel to cancel_async
authorFam Zheng <famz@redhat.com>
Thu, 11 Sep 2014 05:41:12 +0000 (13:41 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 22 Sep 2014 10:39:02 +0000 (11:39 +0100)
commit3391f5e51c4b55bf72fd33d9bc542a49114e48cd
tree96f6d6f6977058d8f05dbaa861abaab3a341db05
parentf600ac19027e67dd73f1adad50a67a2cdb4f3218
thread-pool: Convert thread_pool_aiocb_info.cancel to cancel_async

The .cancel_async shares the same the first half with .cancel: try to
steal the request if not submitted yet. In this case set the elem to
THREAD_DONE status and ret to -ECANCELED, which means
thread_pool_completion_bh will call the cb with -ECANCELED.

If the request is already submitted, do nothing, as we know the normal
completion will happen in the future.

Testing code update:

Before, done_cb is only called if the request is already submitted by
thread pool. Now done_cb is always called, even before it is submitted,
because we emulate bdrv_aio_cancel with bdrv_aio_cancel_async. So also
update the test criteria accordingly.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tests/test-thread-pool.c
thread-pool.c