[5716] block: make raw aio signaling non-blocking (Gerd Hoffman)
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 <[email protected]>
Signed-off-by Anthony Liguori <[email protected]>
Modified Paths:
--------------
trunk/block-raw-posix.c
Modified: trunk/block-raw-posix.c
===================================================================
block-raw-posix.c +10 -7
@@ -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);