From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPsDQ-0002w4-9G for qemu-devel@nongnu.org; Fri, 05 Sep 2014 08:02:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPsDH-0007hx-RK for qemu-devel@nongnu.org; Fri, 05 Sep 2014 08:02:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPsDH-0007ht-KX for qemu-devel@nongnu.org; Fri, 05 Sep 2014 08:01:59 -0400 From: Gerd Hoffmann Date: Fri, 5 Sep 2014 14:01:50 +0200 Message-Id: <1409918510-26053-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1409918510-26053-1-git-send-email-kraxel@redhat.com> References: <1409918510-26053-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/1] pty: Fix byte loss bug when connecting to pty List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sebastian Tanase , Gerd Hoffmann , Anthony Liguori From: Sebastian Tanase When trying to print data to the pty, we first check if it is connected. If not, we try to reconnect, but we drop the pending data even if we have successfully reconnected; this makes us lose the first byte of the very first transmission. This small fix addresses the issue by checking once more if the pty is connected after having tried to reconnect. Signed-off-by: Sebastian Tanase Signed-off-by: Gerd Hoffmann --- qemu-char.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index d4f327a..1a8d9aa 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1160,7 +1160,9 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len) if (!s->connected) { /* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked(chr); - return 0; + if (!s->connected) { + return 0; + } } return io_channel_send(s->fd, buf, len); } -- 1.8.3.1