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 <mre...@redhat.com> > --- > 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