Skip to content

Commit

Permalink
threadpool updates and a hack in ~CometSearchManager() to avoid segfa…
Browse files Browse the repository at this point in the history
…ult in linux Crux-Comet on search exit
  • Loading branch information
jke000 committed Dec 9, 2021
1 parent 1dc63b9 commit 68671fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CometSearch/CometSearchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,11 @@ CometSearchManager::~CometSearchManager()

_mapStaticParams.clear();

if (_tp != NULL) delete _tp;

#ifndef CRUX // hack to avoid segfault observed on linux Crux-Comet search exit
if (_tp != NULL)
delete _tp;
_tp = NULL;
#endif
}

bool CometSearchManager::InitializeStaticParams()
Expand Down
13 changes: 11 additions & 2 deletions CometSearch/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ inline void* threadStart(void* ptr)
int i = data->thread_no;
ThreadPool* tp = (ThreadPool*)data->tp;
bool did_job = false;
while (1)
while (&tp->jobs_)
{
tp->LOCK(&tp->lock_);

Expand Down Expand Up @@ -381,7 +381,16 @@ inline void* threadStart(void* ptr)
else
{
//std::cerr << "Thread " << i << " does a job" << std::endl;
job = std::move (tp->jobs_.front ());
if (&tp->jobs_)
{
job = std::move (tp->jobs_.front ());
}
else
{
tp->UNLOCK(&tp->lock_);
continue;
}

tp->jobs_.pop_front();

if (!did_job)
Expand Down

0 comments on commit 68671fa

Please sign in to comment.