Skip to content

Commit

Permalink
Keep mutex locked when changing the variable that change the condition (
Browse files Browse the repository at this point in the history
  • Loading branch information
swebb2066 authored Apr 25, 2024
1 parent 57295d2 commit 691d679
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/main/cpp/filewatchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ bool FileWatchdog::is_active()
void FileWatchdog::stop()
{
LogLog::debug(LOG4CXX_STR("Stopping file watchdog"));
m_priv->interrupted = 0xFFFF;
{
std::lock_guard<std::mutex> lock(m_priv->interrupt_mutex);
m_priv->interrupted = 0xFFFF;
}
m_priv->interrupt.notify_all();
m_priv->thread.join();
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/cpp/socketappenderskeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ void SocketAppenderSkeleton::activateOptions(Pool& p)

void SocketAppenderSkeleton::close()
{
std::lock_guard<std::recursive_mutex> lock(_priv->mutex);

if (_priv->closed)
{
return;
}
std::lock_guard<std::mutex> lock(_priv->interrupt_mutex);

if (_priv->closed)
{
return;
}

_priv->closed = true;
cleanUp(_priv->pool);
_priv->closed = true;
cleanUp(_priv->pool);
}
_priv->interrupt.notify_all();
if ( _priv->thread.joinable() )
{
Expand Down

0 comments on commit 691d679

Please sign in to comment.