diff --git a/Source/Plugins/NetworkEvents/NetworkEvents.cpp b/Source/Plugins/NetworkEvents/NetworkEvents.cpp index 2e36d150b791e31009ea61e8a3b851c22b1262a5..38efd1b84f4d6d4b5520c3e483d18f2c6bc30d1a 100644 --- a/Source/Plugins/NetworkEvents/NetworkEvents.cpp +++ b/Source/Plugins/NetworkEvents/NetworkEvents.cpp @@ -216,8 +216,14 @@ bool NetworkEvents::closesocket() zmq_ctx_destroy (zmqcontext); // this will cause the thread to exit zmqcontext = nullptr; + if (!stopThread(500)) + { + std::cerr << "Network thread timeout. Forcing thread termination, system could be lefr in an unstable state" << std::endl; + } + if (! shutdown) createZmqContext();// and this will take care that processor graph doesn't attempt to delete the context again + } #endif return true; diff --git a/Source/Plugins/NetworkEvents/NetworkEvents.h b/Source/Plugins/NetworkEvents/NetworkEvents.h index a8388a0440282e783d838204355488ef6d0ef5dc..1f92a282214e92c21d79e488852c13d95bfbf464 100644 --- a/Source/Plugins/NetworkEvents/NetworkEvents.h +++ b/Source/Plugins/NetworkEvents/NetworkEvents.h @@ -117,7 +117,7 @@ public: int urlport; String socketStatus; - bool threadRunning; + std::atomic<bool> threadRunning; private: