Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions proxy/logging/LogFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ LogFile::LogFile(const LogFile &copy)
LogFile::~LogFile()
{
Debug("log-file", "entering LogFile destructor, this=%p", this);

// close_file() checks whether a file is open before attempting to close, so
// this is safe to call even if a file had not been opened. Further, calling
// close_file() here ensures that we do not leak file descriptors.
close_file();

delete m_log;
ats_free(m_header);
ats_free(m_name);
Expand Down
19 changes: 7 additions & 12 deletions proxy/logging/LogObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -961,24 +961,20 @@ LogObjectManager::_solve_filename_conflicts(LogObject *log_object, int maxConfli
LogUtils::manager_alarm(LogUtils::LOG_ALARM_ERROR, msg, filename);
retVal = CANNOT_SOLVE_FILENAME_CONFLICTS;
} else {
// either the meta file could not be read, or the new object's
// signature and the metafile signature do not match ==>
// roll old filename so the new object can use the filename
// Either the meta file could not be read, or the new object's
// signature and the metafile signature do not match.
// Roll the old filename so the new object can use the filename
// it requested (previously we used to rename the NEW file
// but now we roll the OLD file), or if the log object writes
// to a pipe, just remove the file if it was open as a pipe
// but now we roll the OLD file). However, if the log object writes to
// a pipe don't roll because rolling is not applicable to pipes.

bool roll_file = true;

if (log_object->writes_to_pipe()) {
// determine if existing file is a pipe, and remove it if
// that is the case so the right metadata for the new pipe
// is created later
//
// Verify whether the existing file is a pipe. If it is,
// disable the roll_file flag so we don't attempt rolling.
struct stat s;
if (stat(filename, &s) < 0) {
// an error happened while trying to get file info
//
const char *msg = "Cannot stat log file %s: %s";
char *se = strerror(errno);

Expand All @@ -988,7 +984,6 @@ LogObjectManager::_solve_filename_conflicts(LogObject *log_object, int maxConfli
roll_file = false;
} else {
if (S_ISFIFO(s.st_mode)) {
unlink(filename);
roll_file = false;
}
}
Expand Down