Patchwork [4/9] char: introduce pty_chr_detach()

login
register
mail settings
Submitter Amit Shah
Date Aug. 28, 2013, 5:10 a.m.
Message ID <9807d5cb755dfc5e231cac33b4e4518dd3cdae06.1377666450.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/270334/
State New
Headers show

Comments

Amit Shah - Aug. 28, 2013, 5:10 a.m.
Remove any registered callbacks if a frontend is detached.

CC: <qemu-stable@nongnu.org>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 91ae1da..befecf2 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1036,6 +1036,16 @@  typedef struct {
 static void pty_chr_update_read_handler(CharDriverState *chr);
 static void pty_chr_state(CharDriverState *chr, int connected);
 
+static void pty_chr_detach(struct CharDriverState *chr)
+{
+    PtyCharDriver *s = chr->opaque;
+
+    if (s->fd_tag) {
+        io_remove_watch_poll(s->fd_tag);
+        s->fd_tag = 0;
+    }
+}
+
 static gboolean pty_chr_timer(gpointer opaque)
 {
     struct CharDriverState *chr = opaque;
@@ -1215,6 +1225,7 @@  static CharDriverState *qemu_chr_open_pty(const char *id,
     chr->chr_update_read_handler = pty_chr_update_read_handler;
     chr->chr_close = pty_chr_close;
     chr->chr_add_watch = pty_chr_add_watch;
+    chr->chr_detach = pty_chr_detach;
     chr->explicit_be_open = true;
 
     s->fd = io_channel_from_fd(master_fd);