From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6Mhl-0006Ei-IH for qemu-devel@nongnu.org; Wed, 21 Sep 2011 09:19:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6Mhd-0001ju-NB for qemu-devel@nongnu.org; Wed, 21 Sep 2011 09:19:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6Mhd-0001jj-Dp for qemu-devel@nongnu.org; Wed, 21 Sep 2011 09:19:05 -0400 From: Kevin Wolf Date: Wed, 21 Sep 2011 15:21:55 +0200 Message-Id: <1316611316-11773-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1316611316-11773-1-git-send-email-kwolf@redhat.com> References: <1316611316-11773-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 3/4] block/curl: Implement a flush function on the fd handlers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Nick Thomas Signed-off-by: Nick Thomas Signed-off-by: Kevin Wolf --- 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... -- 1.7.6.2