From: Sebastian Tanase Date: Mon, 28 Jul 2014 11:39:14 +0000 (+0200) Subject: pty: Fix byte loss bug when connecting to pty X-Git-Tag: v2.1.1~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=257e9cfce21e8f2f0db99992cfc2452fb83debe8;p=thirdparty%2Fqemu.git pty: Fix byte loss bug when connecting to pty 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 (cherry picked from commit cf7330c759345de2efe9c0df7921189ac5ff11d3) Signed-off-by: Michael Roth --- diff --git a/qemu-char.c b/qemu-char.c index 956be49ecd7..2abb330a617 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); }