qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC 2/5] aio: Add io_read_poll() callback


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC 2/5] aio: Add io_read_poll() callback
Date: Wed, 4 Jun 2014 13:59:51 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Sat, May 31, 2014 at 08:43:09PM +0200, Max Reitz wrote:
> Similar to how qemu_set_fd_handler2() allows defining a function which
> checks whether the recipient is ready to read, add aio_set_fd_handler2()
> with a parameter for defining such a callback.
> 
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  aio-posix.c              | 26 ++++++++++++++++++++------
>  include/block/aio.h      | 12 ++++++++++++
>  include/qemu/main-loop.h |  1 -
>  3 files changed, 32 insertions(+), 7 deletions(-)
> 
> diff --git a/aio-posix.c b/aio-posix.c
> index f921d4f..267df35 100644
> --- a/aio-posix.c
> +++ b/aio-posix.c
> @@ -21,6 +21,7 @@
>  struct AioHandler
>  {
>      GPollFD pfd;
> +    IOCanReadHandler *io_read_poll;

I don't like the io_read_poll() mechanism because it is easy to
deadlock.  In the network layer these problems are common because it
relies on io_read_poll().

Any piece of code that affects the return value of io_read_poll() must
remember to call aio_notify() to force a new event loop iteration.
Otherwise the thread stays stuck in poll(2) and fails to add the file
descriptor back to its fdset.

If you really need io_read_poll() then it's fine.  Just wanted to say
that code using io_read_poll() can be tricky.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]