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

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



From: "Daniel P. Berrange" <berrange redhat com>

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


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