Skip to content

Commit

Permalink
Issue #99: Comment out stopped=true in WorkerThread::stop to avoid Th…
Browse files Browse the repository at this point in the history
…readPool destructing a WorkerThread while it's in processLoop
  • Loading branch information
kgibm authored and mattcolegate committed Feb 22, 2021
1 parent f7ebe20 commit d4a6f98
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ibmras/monitoring/agent/threads/WorkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ void WorkerThread::start() {
void WorkerThread::stop() {
source->complete(NULL);
running = false;
stopped = true;

// Issue 99: By setting stopped to true too early, ThreadPool
// might intermittently destruct us while we're still in processLoop.
// We've already set running=false, so processLoop will finish the
// next chance it gets and only then will set stopped=true.
//stopped = true;

semaphore.inc();
IBMRAS_DEBUG_1(debug, "Worker thread for %s stopped", source->header.name);
IBMRAS_DEBUG_1(debug, "Worker thread for %s stopping", source->header.name);
}

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

0 comments on commit d4a6f98

Please sign in to comment.