Skip to content

Commit

Permalink
fix potential deadlock when reopening logfile on SIGUSR1
Browse files Browse the repository at this point in the history
The bug was introduced by my previous commit.
  • Loading branch information
dspeterson committed Sep 4, 2021
1 parent 82028c9 commit 391df63
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/log/log_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include <mutex>
#include <optional>
#include <string>
#include <system_error>
#include <utility>

#include <base/error_util.h>
#include <log/combined_log_writer.h>
#include <log/log.h>

using namespace Base;
using namespace Log;
Expand Down Expand Up @@ -75,12 +75,12 @@ bool Log::HandleLogfileReopenRequest() {
auto err = writer->GetFileOpenError();

if (err.has_value()) {
LOG(TPri::ERR) << "Failed to reopen logfile [" << LogWriter->GetFilePath()
<< "]: " << err->what();
} else {
LogWriter = std::move(writer);
// We failed to reopen the logfile. Keep writing to the old file
// descriptor. Our caller will catch the exception and report an error.
throw std::system_error(*err);
}

LogWriter = std::move(writer);
return true;
}

Expand Down

0 comments on commit 391df63

Please sign in to comment.