diff mbox series

[v6,24/28] io: let watcher of the channel run in same ctx

Message ID 20180208103132.28452-25-peterx@redhat.com
State New
Headers show
Series [v6,01/28] migration: better error handling with QEMUFile | expand

Commit Message

Peter Xu Feb. 8, 2018, 10:31 a.m. UTC
Per-thread gcontext is only used in IOThread (please refer to callers of
g_main_context_push_thread_default), so this patch only affects anything
that will be run in an IOThread.  It lets the watcher object be run in
the same context as the caller that added the watcher.

This patch is critical to make sure that migration stream accept()
procedure will also be run in the monitor IOThread rather than the
default main thread, so it can survive even if main thread hangs.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 io/channel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/io/channel.c b/io/channel.c
index ec4b86de7c..d6018ddfb6 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -312,7 +312,7 @@  guint qio_channel_add_watch(QIOChannel *ioc,
 
     g_source_set_callback(source, (GSourceFunc)func, user_data, notify);
 
-    id = g_source_attach(source, NULL);
+    id = g_source_attach(source, g_main_context_get_thread_default());
     g_source_unref(source);
 
     return id;