bug 1754: add missing GIL lock in generated callback destructor
authorAlexander Afanasyev <alexander.afanasyev@ucla.edu>
Tue, 13 Aug 2013 22:56:39 -0700
changeset 10142 3dc19f3ac5a7
parent 10141 b02ae0cab0ce
child 10143 48f66512ec9b
bug 1754: add missing GIL lock in generated callback destructor
bindings/python/ns3modulegen_core_customizations.py
--- a/bindings/python/ns3modulegen_core_customizations.py	Tue Aug 13 22:54:45 2013 -0700
+++ b/bindings/python/ns3modulegen_core_customizations.py	Tue Aug 13 22:56:39 2013 -0700
@@ -177,8 +177,11 @@
     }
     virtual ~%s()
     {
+        PyGILState_STATE __py_gil_state;
+        __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
         Py_DECREF(m_callback);
         m_callback = NULL;
+        PyGILState_Release(__py_gil_state);
     }
 
     virtual bool IsEqual(ns3::Ptr<const ns3::CallbackImplBase> other_base) const