Skip to content

Commit 4e059a9

Browse files
roumingelmarco
authored andcommitted
chardev/char-pty: send CHR_EVENT_CLOSED on disconnect
Change makes code symmetric to the code, which handles the "connected" state, i.e. send CHR_EVENT_CLOSED when state changes from "connected" to "disconnected". This behavior is similar to char-socket, for example. Signed-off-by: Roman Penyaev <[email protected]> Reviewed-by: "Marc-André Lureau" <[email protected]> Reviewed-by: "Alex Bennée" <[email protected]> Cc: [email protected] Message-ID: <[email protected]>
1 parent 6fccaa2 commit 4e059a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

chardev/char-pty.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ static void pty_chr_state(Chardev *chr, int connected)
181181

182182
if (!connected) {
183183
remove_fd_in_watch(chr);
184+
if (s->connected) {
185+
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
186+
}
184187
s->connected = 0;
185188
/* (re-)connect poll interval for idle guests: once per second.
186189
* We check more frequently in case the guests sends data to
@@ -215,7 +218,6 @@ static void char_pty_finalize(Object *obj)
215218
pty_chr_state(chr, 0);
216219
object_unref(OBJECT(s->ioc));
217220
pty_chr_timer_cancel(s);
218-
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
219221
}
220222

221223
#if defined HAVE_PTY_H

0 commit comments

Comments
 (0)