Skip to content

Commit 6aab8b2

Browse files
Small change to stop thread on exit, should prevent weird crashes
1 parent 6fff81c commit 6aab8b2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

libs/ofxLibwebsockets/src/Reactor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ namespace ofxLibwebsockets {
5959
void Reactor::exit(){
6060
if (context != NULL)
6161
{
62-
waitForThread(true);
62+
if (isThreadRunning()){
63+
// this is the strategy from ofxKinect
64+
stopThread();
65+
ofSleepMillis(10);
66+
waitForThread(false);
67+
}
6368
// on windows the app does crash if the context is destroyed
6469
// while the thread or the library still might hold pointers
6570
// better to live with non deleted memory, or?

libs/ofxLibwebsockets/src/Server.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ namespace ofxLibwebsockets {
141141

142142
//--------------------------------------------------------------
143143
void Server::close() {
144-
waitForThread(true);
144+
if (isThreadRunning()){
145+
// this is the strategy from ofxKinect
146+
stopThread();
147+
ofSleepMillis(10);
148+
waitForThread(false);
149+
}
145150
libwebsocket_context_destroy(context);
146151
}
147152

0 commit comments

Comments
 (0)