Skip to contentSkip to conversation

libvhost-user-glib: use g_main_context_get_thread_default()

PATCH In review Johannes Berg 3 participants 3 messages Sep 17, 2019 – Sep 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libvhost-user-glib: use g_main_context_get_thread_default()

From: Johannes Berg <[email protected]>

If we use NULL, we just get the main program default mainloop here. Using g_main_context_get_thread_default() has basically the same effect, but it lets us start different devices in different threads with different mainloops, which can be useful.

---
 contrib/libvhost-user/libvhost-user-glib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/libvhost-user/libvhost-user-glib.c +1 -1
index 824c7780de61..53f1ca4cdd73 100644
@@ -89,7 +89,7 @@ vug_source_new(VugDev *gdev, int fd, GIOCondition cond,
     src->gfd.events = cond;
 
     g_source_add_poll(gsrc, &src->gfd);
-    id = g_source_attach(gsrc, NULL);
+    id = g_source_attach(gsrc, g_main_context_get_thread_default());
     g_assert(id);
 
     return gsrc;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Johannes Berg

From: Johannes Berg <[email protected]>

If we use NULL, we just get the main program default mainloop here. Using g_main_context_get_thread_default() has basically the same effect, but it lets us start different devices in different threads with different mainloops, which can be useful.

Quoted 21 lines
---
 contrib/libvhost-user/libvhost-user-glib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/libvhost-user/libvhost-user-glib.c +1 -2
index 824c7780de61..53f1ca4cdd73 100644
@@ -89,7 +89,7 @@ vug_source_new(VugDev *gdev, int fd, GIOCondition cond,
     src->gfd.events = cond;
 
     g_source_add_poll(gsrc, &src->gfd);
-    id = g_source_attach(gsrc, NULL);
+    id = g_source_attach(gsrc, g_main_context_get_thread_default());
     g_assert(id);
 
     return gsrc;
--

2.20.1

Signature · 1 line
Marc-André Lureau
Reviewed-by on v1 1/1
#2 lore raw
In reply to Johannes Berg
Quoted 11 lines · Johannes Berg

From: Johannes Berg <[email protected]>

If we use NULL, we just get the main program default mainloop here. Using g_main_context_get_thread_default() has basically the same effect, but it lets us start different devices in different threads with different mainloops, which can be useful.

---
 contrib/libvhost-user/libvhost-user-glib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)