Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1015-0001Eu-SK for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1012-0001Dn-1s for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:55 -0400 Received: from [199.232.76.173] (port=48087 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1011-0001Di-Py for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26369) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N1011-000418-5r for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:51 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9MFtodl003224 for ; Thu, 22 Oct 2009 11:55:50 -0400 From: Kevin Wolf Date: Thu, 22 Oct 2009 17:54:35 +0200 Message-Id: <1256226882-26434-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1256226882-26434-1-git-send-email-kwolf@redhat.com> References: <1256226882-26434-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 1/8] posix-aio-compat: Split out posix_aio_process_queue List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf We need to process the request queue and run callbacks separately from reading out the queue in a later patch, so split it out. Signed-off-by: Kevin Wolf --- posix-aio-compat.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/posix-aio-compat.c b/posix-aio-compat.c index 400d898..e9f789c 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -413,36 +413,25 @@ static int qemu_paio_error(struct qemu_paiocb *aiocb) return ret; } -static void posix_aio_read(void *opaque) +static int posix_aio_process_queue(void *opaque) { PosixAioState *s = opaque; struct qemu_paiocb *acb, **pacb; int ret; - ssize_t len; - - /* read all bytes from signal pipe */ - for (;;) { - char bytes[16]; - - len = read(s->rfd, bytes, sizeof(bytes)); - if (len == -1 && errno == EINTR) - continue; /* try again */ - if (len == sizeof(bytes)) - continue; /* more to read */ - break; - } + int result = 0; for(;;) { pacb = &s->first_aio; for(;;) { acb = *pacb; if (!acb) - goto the_end; + return result; ret = qemu_paio_error(acb); if (ret == ECANCELED) { /* remove the request */ *pacb = acb->next; qemu_aio_release(acb); + result = 1; } else if (ret != EINPROGRESS) { /* end of aio */ if (ret == 0) { @@ -459,13 +448,35 @@ static void posix_aio_read(void *opaque) /* call the callback */ acb->common.cb(acb->common.opaque, ret); qemu_aio_release(acb); + result = 1; break; } else { pacb = &acb->next; } } } - the_end: ; + + return result; +} + +static void posix_aio_read(void *opaque) +{ + PosixAioState *s = opaque; + ssize_t len; + + /* read all bytes from signal pipe */ + for (;;) { + char bytes[16]; + + len = read(s->rfd, bytes, sizeof(bytes)); + if (len == -1 && errno == EINTR) + continue; /* try again */ + if (len == sizeof(bytes)) + continue; /* more to read */ + break; + } + + posix_aio_process_queue(s); } static int posix_aio_flush(void *opaque) -- 1.6.2.5