From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56213 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PITx8-0003oA-68 for qemu-devel@nongnu.org; Tue, 16 Nov 2010 17:24:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PITx7-00011t-3s for qemu-devel@nongnu.org; Tue, 16 Nov 2010 17:24:37 -0500 Received: from e3.ny.us.ibm.com ([32.97.182.143]:60869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PITx7-00011h-1T for qemu-devel@nongnu.org; Tue, 16 Nov 2010 17:24:37 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oAGM78JA024213 for ; Tue, 16 Nov 2010 17:07:08 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oAGMOa0a143902 for ; Tue, 16 Nov 2010 17:24:36 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oAGMOZ4s006632 for ; Tue, 16 Nov 2010 20:24:35 -0200 Message-ID: <4CE304A6.3040108@linux.vnet.ibm.com> Date: Tue, 16 Nov 2010 16:24:38 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Delete IOHandlers after potentially running them References: <1288794584-6099-1-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1288794584-6099-1-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Juan Quintela On 11/03/2010 09:29 AM, Stefan Hajnoczi wrote: > Since commit 4bed9837309e58d208183f81d8344996744292cf an .fd_read() > handler that deletes its IOHandler is exposed to .fd_write() being > called on the deleted IOHandler. > > This patch fixes deletion so that .fd_read() and .fd_write() are never > called on an IOHandler that is marked for deletion. > > Signed-off-by: Stefan Hajnoczi > Applied. Thanks. Regards, Anthony Liguori > --- > vl.c | 15 ++++++++------- > 1 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/vl.c b/vl.c > index 7038952..6f56123 100644 > --- a/vl.c > +++ b/vl.c > @@ -1252,17 +1252,18 @@ void main_loop_wait(int nonblocking) > IOHandlerRecord *pioh; > > QLIST_FOREACH_SAFE(ioh,&io_handlers, next, pioh) { > - if (ioh->deleted) { > - QLIST_REMOVE(ioh, next); > - qemu_free(ioh); > - continue; > - } > - if (ioh->fd_read&& FD_ISSET(ioh->fd,&rfds)) { > + if (!ioh->deleted&& ioh->fd_read&& FD_ISSET(ioh->fd,&rfds)) { > ioh->fd_read(ioh->opaque); > } > - if (ioh->fd_write&& FD_ISSET(ioh->fd,&wfds)) { > + if (!ioh->deleted&& ioh->fd_write&& FD_ISSET(ioh->fd,&wfds)) { > ioh->fd_write(ioh->opaque); > } > + > + /* Do this last in case read/write handlers marked it for deletion */ > + if (ioh->deleted) { > + QLIST_REMOVE(ioh, next); > + qemu_free(ioh); > + } > } > } > >