From: Francesco Chemolli Date: Mon, 20 Jul 2015 09:44:12 +0000 (+0200) Subject: Check success of logfile rotations in debug.cc (CID 740321) X-Git-Tag: merge-candidate-3-v1~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4c818af82df301d030041e4523c707cb973ff7f;p=thirdparty%2Fsquid.git Check success of logfile rotations in debug.cc (CID 740321) --- 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"