From patchwork Fri Sep 28 17:56:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 187869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2F7BB2C00C8 for ; Sat, 29 Sep 2012 04:50:50 +1000 (EST) Received: from localhost ([::1]:37062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THepB-0004I8-Qi for incoming@patchwork.ozlabs.org; Fri, 28 Sep 2012 13:58:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THeoX-0002eu-F0 for qemu-devel@nongnu.org; Fri, 28 Sep 2012 13:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THeoU-0007Pw-Rd for qemu-devel@nongnu.org; Fri, 28 Sep 2012 13:57:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THeoU-0007PK-Ji for qemu-devel@nongnu.org; Fri, 28 Sep 2012 13:57:22 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8SHvKT2017459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Sep 2012 13:57:20 -0400 Received: from dhcp-5-188.str.redhat.com (vpn1-7-84.ams2.redhat.com [10.36.7.84]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8SHvF36020617; Fri, 28 Sep 2012 13:57:19 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 28 Sep 2012 19:56:46 +0200 Message-Id: <1348855033-17174-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1348855033-17174-1-git-send-email-kwolf@redhat.com> References: <1348855033-17174-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 03/30] aio: Fix qemu_aio_wait() to maintain correct walking_handlers count 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: Paolo Bonzini Fix qemu_aio_wait() to ensure that registered aio handlers don't get deleted when they are still active. This is ensured by maintaning the right count of walking_handlers. Signed-off-by: Paolo Bonzini Signed-off-by: Bharata B Rao Signed-off-by: Kevin Wolf --- aio.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aio.c b/aio.c index 0a9eb10..99b8b72 100644 --- a/aio.c +++ b/aio.c @@ -119,7 +119,7 @@ bool qemu_aio_wait(void) return true; } - walking_handlers = 1; + walking_handlers++; FD_ZERO(&rdfds); FD_ZERO(&wrfds); @@ -147,7 +147,7 @@ bool qemu_aio_wait(void) } } - walking_handlers = 0; + walking_handlers--; /* No AIO operations? Get us out of here */ if (!busy) { @@ -159,7 +159,7 @@ bool qemu_aio_wait(void) /* if we have any readable fds, dispatch event */ if (ret > 0) { - walking_handlers = 1; + walking_handlers++; /* we have to walk very carefully in case * qemu_aio_set_fd_handler is called while we're walking */ @@ -187,7 +187,7 @@ bool qemu_aio_wait(void) } } - walking_handlers = 0; + walking_handlers--; } return true;