Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0hmh-0004tc-Pt for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:23:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0hmh-0004tL-C5 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:23:19 -0500 Received: from [199.232.76.173] (port=59650 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0hmh-0004tE-3L for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:23:19 -0500 Received: from savannah.gnu.org ([199.232.41.3]:53329 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0hmh-0005A3-16 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:23:19 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L0hmg-0008GW-8U for qemu-devel@nongnu.org; Thu, 13 Nov 2008 19:23:18 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L0hmg-0008GS-10 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 19:23:18 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Thu, 13 Nov 2008 19:23:18 +0000 Subject: [Qemu-devel] [5716] block: make raw aio signaling non-blocking (Gerd Hoffman) 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 Revision: 5716 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5716 Author: aliguori Date: 2008-11-13 19:23:17 +0000 (Thu, 13 Nov 2008) Log Message: ----------- block: make raw aio signaling non-blocking (Gerd Hoffman) 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 Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/block-raw-posix.c Modified: trunk/block-raw-posix.c =================================================================== --- trunk/block-raw-posix.c 2008-11-13 19:21:00 UTC (rev 5715) +++ trunk/block-raw-posix.c 2008-11-13 19:23:17 UTC (rev 5716) @@ -497,15 +497,17 @@ 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 @@ 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);