Skip to content

Commit 257e9cf

Browse files
Sebastian Tanasemdroth
authored andcommitted
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 <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]> (cherry picked from commit cf7330c) Signed-off-by: Michael Roth <[email protected]>
1 parent 1aa87d3 commit 257e9cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

qemu-char.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,9 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
11601160
if (!s->connected) {
11611161
/* guest sends data, check for (re-)connect */
11621162
pty_chr_update_read_handler_locked(chr);
1163-
return 0;
1163+
if (!s->connected) {
1164+
return 0;
1165+
}
11641166
}
11651167
return io_channel_send(s->fd, buf, len);
11661168
}

0 commit comments

Comments
 (0)