From b18fb8a82c16ecb7ee7dd2aa6575efbb3e9b275d Mon Sep 17 00:00:00 2001 From: Krista Bennett Date: Sun, 1 Oct 2017 18:14:00 +0200 Subject: [PATCH] mutex on init() and release() --- src/pEpmodule.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pEpmodule.cc b/src/pEpmodule.cc index 738e388..ceabced 100644 --- a/src/pEpmodule.cc +++ b/src/pEpmodule.cc @@ -7,6 +7,8 @@ #include "message_api.hh" #include "sync_mixin.hh" +#include + #include #include @@ -22,10 +24,13 @@ namespace pEp { return version; } + std::mutex init_mutex; + PEP_SESSION session = NULL; static void free_module(void *) { + std::lock_guard lock(init_mutex); release(session); } @@ -428,6 +433,7 @@ BOOST_PYTHON_MODULE(pEp) PyModuleDef * _def = PyModule_GetDef(scope().ptr()); _def->m_free = free_module; + std::lock_guard lock(init_mutex); PEP_STATUS status = ::init(&session); if (status != PEP_STATUS_OK) { stringstream ss; @@ -437,4 +443,3 @@ BOOST_PYTHON_MODULE(pEp) throw runtime_error(s); } } -