Hi,

On Windows (native and Cygwin) and OS/2, when running UFSSwapDir::closeTmpSwapLog() in store_dir_ufs.cc, Squid can be fail if the target file for a rename operation was already deleted.

Because xrename() already try to remove the destination target on Windows, a previous unlink() is not needed.

This patch extended the native Windows xrename() behaviour to Cygwin and OS/2 too and remove not needed unlink().

Regards

Guido



-
========================================================
Guido Serassio
Acme Consulting S.r.l.
Via Gorizia, 69             10136 - Torino - ITALY
Tel. : +39.011.3249426      Fax. : +39.011.3293665
Email: [EMAIL PROTECTED]
WWW: http://www.acmeconsulting.it/

Index: tools.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tools.cc,v
retrieving revision 1.13
diff -u -p -r1.13 tools.cc
--- tools.cc    25 Jun 2003 02:12:39 -0000      1.13
+++ tools.cc    3 Aug 2003 09:10:27 -0000
@@ -1118,7 +1118,7 @@ int
 xrename(const char *from, const char *to)
 {
     debug(21, 2) ("xrename: renaming %s to %s\n", from, to);
-#ifdef _SQUID_MSWIN_
+#if defined (_SQUID_OS2_) || defined (_SQUID_WIN32_)
 
     remove
         (to);
Index: fs/ufs/store_dir_ufs.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/fs/ufs/store_dir_ufs.cc,v
retrieving revision 1.10
diff -u -p -r1.10 store_dir_ufs.cc
--- fs/ufs/store_dir_ufs.cc     23 Jul 2003 02:12:52 -0000      1.10
+++ fs/ufs/store_dir_ufs.cc     3 Aug 2003 09:10:27 -0000
@@ -723,14 +723,6 @@ UFSSwapDir::closeTmpSwapLog()
     char *new_path = xstrdup(logFile(".new"));
     int fd;
     file_close(swaplog_fd);
-#if defined (_SQUID_OS2_) || defined (_SQUID_WIN32_)
-
-    if (::unlink(swaplog_path) < 0) {
-        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
-        fatal("commonUfsDirCloseTmpSwapLog: unlink failed");
-    }
-
-#endif
     if (xrename(new_path, swaplog_path) < 0) {
         fatal("commonUfsDirCloseTmpSwapLog: rename failed");
     }
@@ -972,10 +964,6 @@ UFSSwapDir::writeCleanDone()
 #if defined(_SQUID_OS2_) || defined (_SQUID_WIN32_)
         file_close(state->fd);
         state->fd = -1;
-
-        if (::unlink(state->cur) < 0)
-            debug(50, 0) ("storeDirWriteCleanLogs: unlinkd failed: %s, %s\n",
-                          xstrerror(), state->cur);
 
 #endif
 

Reply via email to