From d607ae00f3c89570fa74e4dac70131ee8b5c4606 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sat, 27 Sep 2008 15:32:04 +0100 Subject: [PATCH] Need to acquire the Python GIL also in ~PythonEventImpl, as it may be called at any time from the C++ code, from any thread. --- bindings/python/ns3module_helpers.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bindings/python/ns3module_helpers.cc b/bindings/python/ns3module_helpers.cc index 51e7e0d9b..cb2fab4a9 100644 --- a/bindings/python/ns3module_helpers.cc +++ b/bindings/python/ns3module_helpers.cc @@ -28,8 +28,14 @@ public: } virtual ~PythonEventImpl () { + PyGILState_STATE __py_gil_state; + __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); + Py_DECREF(m_callback); Py_DECREF(m_args); + + if (PyEval_ThreadsInitialized()) + PyGILState_Release(__py_gil_state); } virtual void Notify () {