Skip to content

Commit d4a6f98

Browse files
kgibmmattcolegate
authored andcommitted
Issue #99: Comment out stopped=true in WorkerThread::stop to avoid ThreadPool destructing a WorkerThread while it's in processLoop
1 parent f7ebe20 commit d4a6f98

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ibmras/monitoring/agent/threads/WorkerThread.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ void WorkerThread::start() {
4545
void WorkerThread::stop() {
4646
source->complete(NULL);
4747
running = false;
48-
stopped = true;
48+
49+
// Issue 99: By setting stopped to true too early, ThreadPool
50+
// might intermittently destruct us while we're still in processLoop.
51+
// We've already set running=false, so processLoop will finish the
52+
// next chance it gets and only then will set stopped=true.
53+
//stopped = true;
54+
4955
semaphore.inc();
50-
IBMRAS_DEBUG_1(debug, "Worker thread for %s stopped", source->header.name);
56+
IBMRAS_DEBUG_1(debug, "Worker thread for %s stopping", source->header.name);
5157
}
5258

5359
void* WorkerThread::cleanUp(ibmras::common::port::ThreadData* data) {

0 commit comments

Comments
 (0)