From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H51Pc-0003Wm-Nn for qemu-devel@nongnu.org; Thu, 11 Jan 2007 10:00:16 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H51Pa-0003UB-Ua for qemu-devel@nongnu.org; Thu, 11 Jan 2007 10:00:16 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H51Pa-0003U5-R1 for qemu-devel@nongnu.org; Thu, 11 Jan 2007 10:00:14 -0500 Received: from [81.255.54.11] (helo=mx.laposte.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H51PZ-0008NP-U6 for qemu-devel@nongnu.org; Thu, 11 Jan 2007 10:00:14 -0500 Received: from smtp.laposte.net (10.150.9.36) by mx.laposte.net (7.2.060.1) id 457DD27D0275F00A for qemu-devel@nongnu.org; Thu, 11 Jan 2007 16:00:15 +0100 Received: from smtpin.laposte.net (10.150.9.72) by smtp.laposte.net (7.3.105.2) id 459A252D00AFA511 for qemu-devel@nongnu.org; Thu, 11 Jan 2007 16:00:12 +0100 Received: from bibi (217.128.241.130) by smtpin.laposte.net (7.2.060.1) (authenticated as jerome.arbez-gindre) id 458960EF001CD4C2 for qemu-devel@nongnu.org; Thu, 11 Jan 2007 15:58:27 +0100 Subject: Re: [Qemu-devel] [PATCH] better handling of removal in IOHandlerRecord list From: jerome Arbez-Gindre In-Reply-To: <1168523801.4765.10.camel@bibi> References: <1168446890.24524.11.camel@bibi> <1168523801.4765.10.camel@bibi> Content-Type: text/plain Date: Thu, 11 Jan 2007 16:00:10 +0100 Message-Id: <1168527610.4765.12.camel@bibi> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Thu, 2007-01-11 at 14:56 +0100, jerome Arbez-Gindre wrote: > On Wed, 2007-01-10 at 17:34 +0100, jerome Arbez-Gindre wrote: > > Hi, > > > > by a call to qemu_set_fd_handler(fd,NULL,NULL,NULL) in the fd_read > > callback, I have generated a "Segmentation fault" in vl.c. > > > > My solution is not very smart... but it is very simple. > > I reply to myself because I did not sleep last night: > > Here is the fix without the double IOHandlerRecord list iteration. Here is a little fix to handle the case when a IOHandler removes an other IOHandler. --- vl.c.mine 2007-01-11 15:06:47.000000000 +0100 +++ vl.c 2007-01-11 15:27:27.000000000 +0100 @@ -5912,11 +5912,13 @@ pioh = &first_io_handler ; for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) { ioh_next = ioh->next; - if (FD_ISSET(ioh->fd, &rfds)) { + /* ioh->fd_read could have been set to null by an other + IOHandlerRecord callback */ + if (ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) { ioh->fd_read(ioh->opaque); } /* ioh->fd_write could have been set to null */ - if ((ioh->fd_write) && (FD_ISSET(ioh->fd, &wfds))) { + if (ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) { ioh->fd_write(ioh->opaque); } /* the ioh could have been supressed */