[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 2/3] chardev: let g_idle_add() be with chardev gc
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH v3 2/3] chardev: let g_idle_add() be with chardev gcontext |
Date: |
Thu, 4 Jan 2018 18:43:35 +0800 |
The idle task will be attached to main gcontext even if the chardev
backend is running in another gcontext. Fix the only caller by
extending the g_idle_add() logic into the more powerful
g_source_attach(). It's basically g_idle_add_full() implementation, but
with the chardev's gcontext passed in.
Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
---
chardev/char-pty.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index 761ae6dec1..dd17b1b823 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -210,9 +210,14 @@ static void pty_chr_state(Chardev *chr, int connected)
s->timer_tag = 0;
}
if (!s->connected) {
+ GSource *source = g_idle_source_new();
+
g_assert(s->open_tag == 0);
s->connected = 1;
- s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr);
+ g_source_set_callback(source, qemu_chr_be_generic_open_func,
+ chr, NULL);
+ s->open_tag = g_source_attach(source, chr->gcontext);
+ g_source_unref(source);
}
if (!chr->gsource) {
chr->gsource = io_add_watch_poll(chr, s->ioc,
--
2.14.3