From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFXsB-0007DN-PF for qemu-devel@nongnu.org; Tue, 01 Dec 2009 13:54:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFXs8-0007B2-1T for qemu-devel@nongnu.org; Tue, 01 Dec 2009 13:54:51 -0500 Received: from [199.232.76.173] (port=60117 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFXs7-0007At-NG for qemu-devel@nongnu.org; Tue, 01 Dec 2009 13:54:47 -0500 Received: from mail-qy0-f194.google.com ([209.85.221.194]:56859) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFXs7-0002wo-BT for qemu-devel@nongnu.org; Tue, 01 Dec 2009 13:54:47 -0500 Received: by qyk32 with SMTP id 32so2146030qyk.4 for ; Tue, 01 Dec 2009 10:54:46 -0800 (PST) Message-ID: <4B156672.1010008@codemonkey.ws> Date: Tue, 01 Dec 2009 12:54:42 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Socket reconnection. References: <4B0DCC45.5080308@collabora.co.uk> <4B13FE66.2080401@codemonkey.ws> <4B1503EF.6090806@collabora.co.uk> <58BD0469C48A7443A479A13D101685E30380B88A@ala-mail09.corp.ad.wrs.com> In-Reply-To: <58BD0469C48A7443A479A13D101685E30380B88A@ala-mail09.corp.ad.wrs.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: "Krumme, Chris" Cc: Ian Molton , qemu-devel@nongnu.org Krumme, Chris wrote: > Hello Ian, > > Since you did not inline your source I will paste in a chunk: > > > @@ -2030,10 +2036,18 @@ static void tcp_chr_read(void *opaque) > if (s->listen_fd >= 0) { > qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, > chr); > } > - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); > + if (!s->reconnect) > + qemu_set_fd_handler(s->fd, NULL, NULL, NULL); > closesocket(s->fd); > s->fd = -1; > - qemu_chr_event(chr, CHR_EVENT_CLOSED); > + if (!s->reconnect) { > + qemu_chr_event(chr, CHR_EVENT_CLOSED); > + } else { > + do { > + sleep(s->reconnect); > + } while(!qemu_chr_connect_socket(s)); > + qemu_chr_event(chr, CHR_EVENT_RECONNECTED); > + } > } else if (size > 0) { > if (s->do_telnetopt) > tcp_chr_process_IAC_bytes(chr, s, buf, &size); > > > Should you be introducing a while sleep loop into Qemu here? > > I would think you should be returning 'no data', maybe after trying > once. > > Hope this helps. > > Chris > sleep() in qemu is very, very wrong. It will pause the guest's execution and all sorts of badness can ensue. The right thing to do is set a timer and not generate data while disconnected. I still am not confident this is really a great thing to do. Regards, Anthony Liguori