From a2f945ddda6e523fb901640a710b70b283b6e4c4 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Wed, 17 Sep 2008 15:47:07 +0100 Subject: [PATCH] Add missing Python GIL locking in PythonEventImpl::Notify --- 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 69e3f7288..51e7e0d9b 100644 --- a/bindings/python/ns3module_helpers.cc +++ b/bindings/python/ns3module_helpers.cc @@ -33,6 +33,9 @@ public: } virtual void Notify () { + PyGILState_STATE __py_gil_state; + __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); + PyObject *retval = PyObject_CallObject(m_callback, m_args); if (retval) { if (retval != Py_None) { @@ -43,6 +46,9 @@ public: } else { PyErr_Print(); } + + if (PyEval_ThreadsInitialized()) + PyGILState_Release(__py_gil_state); } };