[PATCH libvirt-glib] Don't hold events lock when dispatching free callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The _event_timeout_remove and _event_handle_remove methods
were holding onto the global lock when invoking the free
callback. This is a violation of the libvirt events API
contract which requires free callbacks to be invoked in
a re-entrant safe context.
---
 libvirt-glib/libvirt-glib-event.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libvirt-glib/libvirt-glib-event.c b/libvirt-glib/libvirt-glib-event.c
index 657c1bf..2a9ee23 100644
--- a/libvirt-glib/libvirt-glib-event.c
+++ b/libvirt-glib/libvirt-glib-event.c
@@ -256,13 +256,11 @@ _event_handle_remove(gpointer data)
 {
     struct gvir_event_handle *h = data;
 
-    g_mutex_lock(eventlock);
-
     if (h->ff)
         (h->ff)(h->opaque);
 
+    g_mutex_lock(eventlock);
     g_ptr_array_remove_fast(handles, h);
-
     g_mutex_unlock(eventlock);
 
     return FALSE;
@@ -414,13 +412,11 @@ _event_timeout_remove(gpointer data)
 {
     struct gvir_event_timeout *t = data;
 
-    g_mutex_lock(eventlock);
-
     if (t->ff)
         (t->ff)(t->opaque);
 
+    g_mutex_lock(eventlock);
     g_ptr_array_remove_fast(timeouts, t);
-
     g_mutex_unlock(eventlock);
 
     return FALSE;
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]