From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0eu0-0005bt-8j for qemu-devel@nongnu.org; Thu, 13 Nov 2008 11:18:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0ety-0005bX-KK for qemu-devel@nongnu.org; Thu, 13 Nov 2008 11:18:39 -0500 Received: from [199.232.76.173] (port=46557 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0ety-0005bU-H8 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 11:18:38 -0500 Received: from mx2.redhat.com ([66.187.237.31]:38164) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L0ety-0004Zt-GN for qemu-devel@nongnu.org; Thu, 13 Nov 2008 11:18:38 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mADGIbic030760 for ; Thu, 13 Nov 2008 11:18:37 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mADGIaip014901 for ; Thu, 13 Nov 2008 11:18:36 -0500 Received: from zweiblum.travel.kraxel.org (vpn-4-130.str.redhat.com [10.32.4.130]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mADGIYNG011997 for ; Thu, 13 Nov 2008 11:18:35 -0500 Message-ID: <491C535A.7030904@redhat.com> Date: Thu, 13 Nov 2008 17:18:34 +0100 From: Gerd Hoffmann MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020806020603080205030608" Subject: [Qemu-devel] [patch] block: make raw aio signaling non-blocking. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020806020603080205030608 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, This patch switches the read handle of the signaling pipe into non-blocking mode. This avoids unwanted blocking reads and also allows to read all bytes out of the signaling pipe in case we got signaled more that once before the handler ran. cheers, Gerd --------------020806020603080205030608 Content-Type: text/plain; name="0049-block-make-raw-aio-signaling-non-blocking.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0049-block-make-raw-aio-signaling-non-blocking.patch" >>From 2b75aad0848fb231a0b942bd768f1e84462d1525 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 13 Nov 2008 14:21:19 +0100 Subject: [PATCH] block: make raw aio signaling non-blocking. This patch switches the read handle of the signaling pipe into non-blocking mode. This avoids unwanted blocking reads and also allows to read all bytes out of the signaling pipe in case we got signaled more that once before the handler ran. Signed-off-by: Gerd Hoffmann --- block-raw-posix.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/block-raw-posix.c b/block-raw-posix.c index c06e38d..0a06a12 100644 --- a/block-raw-posix.c +++ b/block-raw-posix.c @@ -497,15 +497,17 @@ static void posix_aio_read(void *opaque) int ret; ssize_t len; - do { - char byte; + /* read all bytes from signal pipe */ + for (;;) { + char bytes[16]; - len = read(s->rfd, &byte, 1); + len = read(s->rfd, bytes, sizeof(bytes)); if (len == -1 && errno == EINTR) - continue; - if (len == -1 && errno == EAGAIN) - break; - } while (len == -1); + continue; /* try again */ + if (len == sizeof(bytes)) + continue; /* more to read */ + break; + } for(;;) { pacb = &s->first_aio; @@ -591,6 +593,7 @@ static int posix_aio_init(void) s->rfd = fds[0]; s->wfd = fds[1]; + fcntl(s->rfd, F_SETFL, O_NONBLOCK); fcntl(s->wfd, F_SETFL, O_NONBLOCK); qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s); -- 1.5.6.5 --------------020806020603080205030608--