Received: from [140.186.70.92] (port=40614 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDeUX-00055s-GT for qemu-devel@nongnu.org; Wed, 03 Nov 2010 10:39:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDeUU-0007bL-FE for qemu-devel@nongnu.org; Wed, 03 Nov 2010 10:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDeUU-0007an-8R for qemu-devel@nongnu.org; Wed, 03 Nov 2010 10:39:06 -0400 From: Juan Quintela In-Reply-To: <1288794584-6099-1-git-send-email-stefanha@linux.vnet.ibm.com> (Stefan Hajnoczi's message of "Wed, 3 Nov 2010 14:29:44 +0000") References: <1288794584-6099-1-git-send-email-stefanha@linux.vnet.ibm.com> Date: Wed, 03 Nov 2010 15:39:01 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH] Delete IOHandlers after potentially running them List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org 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. Reviewed by: Juan Quintela But once here, what (appart from networking) reads and writes to the same fd? And that removes the IOHandler on read while there are write stuff pending? Later, Juan. > Signed-off-by: Stefan Hajnoczi > --- > 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); > + } > } > }