]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polish: Improve the messages output by UFS swap log management.
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 Dec 2012 07:26:27 +0000 (00:26 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 Dec 2012 07:26:27 +0000 (00:26 -0700)
It also includes a small local variable symbol change from "new_path" to
"tmp_path" to prevent future developer mistakes like the one seen in
bug 3663 mistaking "new_path" for the new destination path of xrename().

src/fs/ufs/UFSSwapDir.cc

index 0ec2ed81bb1e042d3f7d59092d2cf3a5fe90f5b4..2c436de1d96a82661f650470ff33fb38dfeed4c9 100644 (file)
@@ -809,27 +809,26 @@ Fs::Ufs::UFSSwapDir::rebuild()
 void
 Fs::Ufs::UFSSwapDir::closeTmpSwapLog()
 {
-    char *swaplog_path = xstrdup(logFile(NULL));
-    char *new_path = xstrdup(logFile(".new"));
+    char *swaplog_path = xstrdup(logFile(NULL)); // where the swaplog should be
+    char *tmp_path = xstrdup(logFile(".new")); // the temporary file we have generated
     int fd;
     file_close(swaplog_fd);
 
-    if (xrename(new_path, swaplog_path) < 0) {
-        debugs(50, DBG_IMPORTANT, HERE << "ERROR: " << swaplog_path << ": " << xstrerror());
-        fatalf("Failed to rename log file %s to %s.new", swaplog_path, swaplog_path);
+    if (xrename(tmp_path, swaplog_path) < 0) {
+        fatalf("Failed to rename log file %s to %s", tmp_path, swaplog_path);
     }
 
     fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY);
 
     if (fd < 0) {
-        debugs(50, DBG_IMPORTANT, HERE << "ERROR: " << swaplog_path << ": " << xstrerror());
+        debugs(50, DBG_IMPORTANT, "ERROR: " << swaplog_path << ": " << xstrerror());
         fatalf("Failed to open swap log %s", swaplog_path);
     }
 
-    safe_free(swaplog_path);
-    safe_free(new_path);
+    xfree(swaplog_path);
+    xfree(tmp_path);
     swaplog_fd = fd;
-    debugs(47, 3, HERE << "Cache Dir #" << index << " log opened on FD " << fd);
+    debugs(47, 3, "Cache Dir #" << index << " log opened on FD " << fd);
 }
 
 FILE *
@@ -846,7 +845,7 @@ Fs::Ufs::UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag)
     int fd;
 
     if (::stat(swaplog_path, &log_sb) < 0) {
-        debugs(47, DBG_IMPORTANT, HERE << "Cache Dir #" << index << ": No log file");
+        debugs(47, DBG_IMPORTANT, "Cache Dir #" << index << ": No log file");
         safe_free(swaplog_path);
         safe_free(clean_path);
         safe_free(new_path);
@@ -864,7 +863,7 @@ Fs::Ufs::UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag)
 
     if (fd < 0) {
         debugs(50, DBG_IMPORTANT, "ERROR: while opening swap log" << new_path << ": " << xstrerror());
-        fatal("UFSSwapDir::openTmpSwapLog: Failed to open swap log.");
+        fatalf("Failed to open swap log %s", new_path);
     }
 
     swaplog_fd = fd;
@@ -886,7 +885,7 @@ Fs::Ufs::UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag)
 
     if (fp == NULL) {
         debugs(50, DBG_CRITICAL, "ERROR: while opening " << swaplog_path << ": " << xstrerror());
-        fatal("Failed to open swap log for reading");
+        fatalf("Failed to open swap log for reading %s", swaplog_path);
     }
 
     memset(&clean_sb, '\0', sizeof(struct stat));