Skip to content

Commit

Permalink
logger: fix thread deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
dusan19 authored and bkueng committed Mar 6, 2020
1 parent 4698a09 commit d7a9b12
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modules/logger/log_writer_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,12 @@ void LogWriterFile::run()
/* Wait for a call to notify(), which indicates new data is available.
* Note that at this point there could already be new data available (because of a longer write),
* and calling pthread_cond_wait() will still wait for the next notify(). But this is generally
* not an issue because notify() is called regularly. */
pthread_cond_wait(&_cv, &_mtx);
* not an issue because notify() is called regularly.
* If the logger was switched off in the meantime, do not wait for data, instead run this loop
* once more to write remaining data and close the file. */
if (_buffers[0]._should_run) {
pthread_cond_wait(&_cv, &_mtx);
}
}

// go back to idle
Expand Down

0 comments on commit d7a9b12

Please sign in to comment.