]> xenbits.xensource.com Git - libvirt.git/commitdiff
give up python interpreter lock before calling cb
authorDan Kenigsberg <danken@redhat.com>
Tue, 3 Nov 2009 17:42:16 +0000 (18:42 +0100)
committerDaniel Veillard <veillard@redhat.com>
Tue, 3 Nov 2009 17:42:16 +0000 (18:42 +0100)
suggested by danpb on irc, patch by danken fixed for proper C syntax

* python/libvirt-override.c: on event callback release the python
  interpreter lock and take it again when coming back so that the
  callback can reinvoke libvirt.

python/libvirt-override.c

index 5d24fd2277d7ea4349c83c96baf1da6cca12aa85..6c6155b9f28835cf25e09ef5fea6036bdcd8f19f 100644 (file)
@@ -2354,8 +2354,11 @@ libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED,
     cb     = (virEventHandleCallback) PyvirEventHandleCallback_Get(py_f);
     opaque = (void *) PyvirVoidPtr_Get(py_opaque);
 
-    if(cb)
+    if(cb) {
+        LIBVIRT_BEGIN_ALLOW_THREADS;
         cb (watch, fd, event, opaque);
+        LIBVIRT_END_ALLOW_THREADS;
+    }
 
     return VIR_PY_INT_SUCCESS;
 }
@@ -2378,8 +2381,11 @@ libvirt_virEventInvokeTimeoutCallback(PyObject *self ATTRIBUTE_UNUSED,
 
     cb     = (virEventTimeoutCallback) PyvirEventTimeoutCallback_Get(py_f);
     opaque = (void *) PyvirVoidPtr_Get(py_opaque);
-    if(cb)
+    if(cb) {
+        LIBVIRT_BEGIN_ALLOW_THREADS;
         cb (timer, opaque);
+        LIBVIRT_END_ALLOW_THREADS;
+    }
 
     return VIR_PY_INT_SUCCESS;
 }