From patchwork Wed Mar 10 10:03:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 915F8B7CE8 for ; Wed, 10 Mar 2010 21:21:28 +1100 (EST) Received: from localhost ([127.0.0.1]:48172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpIxs-00082L-L9 for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2010 05:16:32 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpIlS-0003r2-MF for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:43 -0500 Received: from [199.232.76.173] (port=49328 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpIlR-0003qX-KA for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:41 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpIlP-0001s4-2I for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57064) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpIlN-0001ra-LR for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:37 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2AA3aSY003241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Mar 2010 05:03:37 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2AA3SbG017099; Wed, 10 Mar 2010 05:03:35 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Mar 2010 11:03:19 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 05/14] Handle deleted IOHandlers in a single pass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Previous code 1st call normal functions and then remove deleted handlers in the following pass. Calllapse the two walks. Signed-off-by: Juan Quintela --- vl.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-) diff --git a/vl.c b/vl.c index 354ea31..c2ae185 100644 --- a/vl.c +++ b/vl.c @@ -3846,20 +3846,17 @@ void main_loop_wait(int timeout) if (ret > 0) { IOHandlerRecord *pioh; - QTAILQ_FOREACH(ioh, &io_handlers, next) { - if (!ioh->deleted && ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) { - ioh->fd_read(ioh->opaque); - } - if (!ioh->deleted && ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) { - ioh->fd_write(ioh->opaque); - } - } - - /* remove deleted IO handlers */ QTAILQ_FOREACH_SAFE(ioh, &io_handlers, next, pioh) { if (ioh->deleted) { QTAILQ_REMOVE(&io_handlers, ioh, next); qemu_free(ioh); + continue; + } + if (ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) { + ioh->fd_read(ioh->opaque); + } + if (ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) { + ioh->fd_write(ioh->opaque); } } }