Skip to content

Commit 2cf6509

Browse files
committed
Add some extra thread safety to the network events module
1 parent 2ed9bd3 commit 2cf6509

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Source/Plugins/NetworkEvents/NetworkEvents.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,14 @@ bool NetworkEvents::closesocket()
216216
zmq_ctx_destroy (zmqcontext); // this will cause the thread to exit
217217
zmqcontext = nullptr;
218218

219+
if (!stopThread(500))
220+
{
221+
std::cerr << "Network thread timeout. Forcing thread termination, system could be lefr in an unstable state" << std::endl;
222+
}
223+
219224
if (! shutdown)
220225
createZmqContext();// and this will take care that processor graph doesn't attempt to delete the context again
226+
221227
}
222228
#endif
223229
return true;

Source/Plugins/NetworkEvents/NetworkEvents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class NetworkEvents : public GenericProcessor
117117

118118
int urlport;
119119
String socketStatus;
120-
bool threadRunning;
120+
std::atomic<bool> threadRunning;
121121

122122

123123
private:

0 commit comments

Comments
 (0)