From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KMHaQ-00061C-JE for qemu-devel@nongnu.org; Fri, 25 Jul 2008 03:19:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KMHaO-00060y-BL for qemu-devel@nongnu.org; Fri, 25 Jul 2008 03:19:33 -0400 Received: from [199.232.76.173] (port=43486 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KMHaO-00060v-4s for qemu-devel@nongnu.org; Fri, 25 Jul 2008 03:19:32 -0400 Received: from mx20.gnu.org ([199.232.41.8]:38467) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KMHaN-0003CK-N3 for qemu-devel@nongnu.org; Fri, 25 Jul 2008 03:19:31 -0400 Received: from mx1.redhat.com ([66.187.233.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KMHaM-00027k-Uw for qemu-devel@nongnu.org; Fri, 25 Jul 2008 03:19:31 -0400 Message-ID: <48897D83.9020707@redhat.com> Date: Fri, 25 Jul 2008 09:15:15 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd. References: <48874D4A.8000604@codemonkey.ws> <48875849.60200@redhat.com> <200807231744.28969.paul@codesourcery.com> In-Reply-To: <200807231744.28969.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 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: Paul Brook Cc: qemu-devel@nongnu.org Paul Brook wrote: > On Wednesday 23 July 2008, Gerd Hoffmann wrote: >> Anthony Liguori wrote: >>> Gerd Hoffmann wrote: >>>> Comments on this one? >>> Checking every 100ms for every pty device really makes me cringe. >> Only when unconnected, and the interval can be changed. >> And I'm certainly open for better ideas ... > > Anything that requires periodic polling is almost certainly wrong. > > If it's unconnected then why do we need to poll at all? If we're discarding > data then we aren't going to retry, so it should be sufficient to check > whenever we send data. Fundamental problem is there is no easy way to figure whenever we are connected or not. Well, detecting the "connected -> disconnected" transition is easy, as read() starts giving us -EIO then. The problematic case is the "(initial state | disconnected) -> (re-)connected" transition. We have to try read() now and then to check whenever we still get -EIO or not. Doing the read() check in the write path is an good idea. Alone it still doesn't solve the problem because we would depend on the guest writing stuff to the serial line to detect a (re-)connect then. But it makes large poll intervalls suck less. I'll go send an updated patch later today. cheers, Gerd -- http://kraxel.fedorapeople.org/xenner/