提交 e20e830b 编写于 作者: A aliguori

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: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5716 c046a42c-6fe2-441c-8c8c-71466251a162
上级 984b5181
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册