From patchwork Wed Sep 21 10:55:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Thomas X-Patchwork-Id: 115756 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 24A6CB6F7C for ; Wed, 21 Sep 2011 20:56:39 +1000 (EST) Received: from localhost ([::1]:43489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6KTj-0002E1-Mc for incoming@patchwork.ozlabs.org; Wed, 21 Sep 2011 06:56:35 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6KTH-00017K-V5 for qemu-devel@nongnu.org; Wed, 21 Sep 2011 06:56:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6KTG-0003yj-OE for qemu-devel@nongnu.org; Wed, 21 Sep 2011 06:56:07 -0400 Received: from nog.sh.bytemark.co.uk ([212.110.161.168]:57447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6KTG-0003xY-Ia; Wed, 21 Sep 2011 06:56:06 -0400 Received: from bytemail.bytemark.co.uk ([212.110.161.227]) by nog.sh.bytemark.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1R6KTC-00023H-AZ; Wed, 21 Sep 2011 11:56:02 +0100 Received: from desk4.office.bytemark.co.uk ([89.16.168.152] helo=localhost.localdomain) by bytemail.bytemark.co.uk with esmtp (Exim 4.72) (envelope-from ) id 1R6KTC-0004WD-0N; Wed, 21 Sep 2011 11:56:02 +0100 From: nick@bytemark.co.uk To: nick@bytemark.co.uk, qemu-devel@nongnu.org Date: Wed, 21 Sep 2011 11:55:49 +0100 Message-Id: <1316602550-13597-2-git-send-email-nick@bytemark.co.uk> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1316602550-13597-1-git-send-email-nick@bytemark.co.uk> References: <1316602550-13597-1-git-send-email-nick@bytemark.co.uk> Organization: Bytemark Computer Consulting Ltd. The Raylor Centre, James Street, York YO10 3DW, UK. Company registered in England and Wales no. 4484629. VAT registration no. GB 804 6718 29. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.110.161.168 Cc: qemu-trivial@nongnu.org Subject: [Qemu-devel] [PATCH 1/2] block/curl: Implement a flush function on the fd handlers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Nick Thomas Signed-off-by: Nick Thomas --- block/curl.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/block/curl.c b/block/curl.c index f3f61cc..21fed93 100644 --- a/block/curl.c +++ b/block/curl.c @@ -76,6 +76,7 @@ typedef struct BDRVCURLState { static void curl_clean_state(CURLState *s); static void curl_multi_do(void *arg); +static int curl_aio_flush(void *opaque); static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, void *s, void *sp) @@ -83,14 +84,16 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, DPRINTF("CURL (AIO): Sock action %d on fd %d\n", action, fd); switch (action) { case CURL_POLL_IN: - qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, NULL, NULL, s); + qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, curl_aio_flush, + NULL, s); break; case CURL_POLL_OUT: - qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, NULL, NULL, s); + qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, curl_aio_flush, + NULL, s); break; case CURL_POLL_INOUT: - qemu_aio_set_fd_handler(fd, curl_multi_do, - curl_multi_do, NULL, NULL, s); + qemu_aio_set_fd_handler(fd, curl_multi_do, curl_multi_do, + curl_aio_flush, NULL, s); break; case CURL_POLL_REMOVE: qemu_aio_set_fd_handler(fd, NULL, NULL, NULL, NULL, NULL); @@ -412,6 +415,21 @@ out_noclean: return -EINVAL; } +static int curl_aio_flush(void *opaque) +{ + BDRVCURLState *s = opaque; + int i, j; + + for (i=0; i < CURL_NUM_STATES; i++) { + for(j=0; j < CURL_NUM_ACB; j++) { + if (s->states[i].acb[j]) { + return 1; + } + } + } + return 0; +} + static void curl_aio_cancel(BlockDriverAIOCB *blockacb) { // Do we have to implement canceling? Seems to work without...