From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws9rQ-0005AF-SK for qemu-devel@nongnu.org; Wed, 04 Jun 2014 08:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ws9rH-00063F-QW for qemu-devel@nongnu.org; Wed, 04 Jun 2014 08:00:04 -0400 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]:55889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws9rH-00062z-JO for qemu-devel@nongnu.org; Wed, 04 Jun 2014 07:59:55 -0400 Received: by mail-wg0-f52.google.com with SMTP id l18so8182385wgh.23 for ; Wed, 04 Jun 2014 04:59:54 -0700 (PDT) Date: Wed, 4 Jun 2014 13:59:51 +0200 From: Stefan Hajnoczi Message-ID: <20140604115951.GC11073@stefanha-thinkpad.redhat.com> References: <1401561792-13410-1-git-send-email-mreitz@redhat.com> <1401561792-13410-3-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1401561792-13410-3-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [RFC 2/5] aio: Add io_read_poll() callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi 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 > --- > 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