From f4c818af82df301d030041e4523c707cb973ff7f Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Mon, 20 Jul 2015 11:44:12 +0200 Subject: [PATCH] Check success of logfile rotations in debug.cc (CID 740321) --- src/debug.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index 85a03772d4..213be8f4f3 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -487,10 +487,18 @@ _db_rotate_log(void) if (Debug::rotateNumber > 0) { snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0); #if _SQUID_WINDOWS_ - remove - (to); + errno = 0; + if (remove(to) == -1) { + const auto saved_errno = errno; + debugs(0, DBG_IMPORTANT, "removal of log file " << to << " failed: " << xstrerr(saved_errno)); + } #endif - rename(debug_log_file, to); + errno = 0; + if (rename(debug_log_file, to) == -1) { + const auto saved_errno = errno; + debugs(0, DBG_IMPORTANT, "renaming file " << debug_log_file << " to " + << to << "failed: " << xstrerr(saved_errno)); + } } /* Close and reopen the log. It may have been renamed "manually" -- 2.47.3