]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Check success of logfile rotations in debug.cc (CID 740321)
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 20 Jul 2015 09:44:12 +0000 (11:44 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 20 Jul 2015 09:44:12 +0000 (11:44 +0200)
src/debug.cc

index 85a03772d41008e579dfa064169ba522ec3df9cc..213be8f4f37f8259b4a89b0a7f29dc54169c89c4 100644 (file)
@@ -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"