]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
COSS fixes by Guido.
authorhno <>
Sun, 19 May 2002 22:40:56 +0000 (22:40 +0000)
committerhno <>
Sun, 19 May 2002 22:40:56 +0000 (22:40 +0000)
Also triggered a small cleanup in the othere store implementations to
get rid of a unneccesary CYGWIN dependency. (binary file mode)

src/fs/aufs/store_dir_aufs.cc
src/fs/coss/store_dir_coss.cc
src/fs/diskd/store_dir_diskd.cc
src/fs/ufs/store_dir_ufs.cc

index 85e2e384ff5991b02e98673b0c43865c8b08562d..0af80c1437475e4891e03af3d8f28b4e8030f74b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_aufs.cc,v 1.44 2002/04/07 11:52:33 hno Exp $
+ * $Id: store_dir_aufs.cc,v 1.45 2002/05/19 16:40:56 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -912,14 +912,11 @@ storeAufsDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag)
     }
     aioinfo->swaplog_fd = fd;
     /* open a read-only stream of the old log */
-    fp = fopen(swaplog_path, "r");
+    fp = fopen(swaplog_path, "rb");
     if (fp == NULL) {
        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("Failed to open swap log for reading");
     }
-#if defined(_SQUID_CYGWIN_)
-    setmode(fileno(fp), O_BINARY);
-#endif
     memset(&clean_sb, '\0', sizeof(struct stat));
     if (stat(clean_path, &clean_sb) < 0)
        *clean_flag = 0;
index ca81999184d56b4cb33c0f053a18058c99f64a2b..15927dc4624f3239799c36048a979658e5e39460 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.33 2002/04/07 11:52:33 hno Exp $
+ * $Id: store_dir_coss.cc,v 1.34 2002/05/19 16:40:57 hno Exp $
  *
  * DEBUG: section 81    Store COSS Directory Routines
  * AUTHOR: Eric Stern
@@ -130,7 +130,7 @@ storeCossDirOpenSwapLog(SwapDir * sd)
     char *path;
     int fd;
     path = storeCossDirSwapLogFile(sd, NULL);
-    fd = file_open(path, O_WRONLY | O_CREAT);
+    fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY);
     if (fd < 0) {
        debug(81, 1) ("%s: %s\n", path, xstrerror());
        fatal("storeCossDirOpenSwapLog: Failed to open swap log.");
@@ -390,7 +390,7 @@ storeCossDirCloseTmpSwapLog(SwapDir * sd)
     char *new_path = xstrdup(storeCossDirSwapLogFile(sd, ".new"));
     int fd;
     file_close(cs->swaplog_fd);
-#ifdef _SQUID_OS2_
+#if defined (_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
     if (unlink(swaplog_path) < 0) {
        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("storeCossDirCloseTmpSwapLog: unlink failed");
@@ -399,7 +399,7 @@ storeCossDirCloseTmpSwapLog(SwapDir * sd)
     if (xrename(new_path, swaplog_path) < 0) {
        fatal("storeCossDirCloseTmpSwapLog: rename failed");
     }
-    fd = file_open(swaplog_path, O_WRONLY | O_CREAT);
+    fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY);
     if (fd < 0) {
        debug(50, 1) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("storeCossDirCloseTmpSwapLog: Failed to open swap log.");
@@ -433,14 +433,14 @@ storeCossDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag)
     if (cs->swaplog_fd >= 0)
        file_close(cs->swaplog_fd);
     /* open a write-only FD for the new log */
-    fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC);
+    fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY);
     if (fd < 0) {
        debug(50, 1) ("%s: %s\n", new_path, xstrerror());
        fatal("storeDirOpenTmpSwapLog: Failed to open swap log.");
     }
     cs->swaplog_fd = fd;
     /* open a read-only stream of the old log */
-    fp = fopen(swaplog_path, "r");
+    fp = fopen(swaplog_path, "rb");
     if (fp == NULL) {
        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("Failed to open swap log for reading");
@@ -484,7 +484,7 @@ storeCossDirWriteCleanStart(SwapDir * sd)
     struct stat sb;
 #endif
     state->new = xstrdup(storeCossDirSwapLogFile(sd, ".clean"));
-    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
+    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY);
     if (state->fd < 0) {
        xfree(state->new);
        xfree(state);
@@ -567,6 +567,7 @@ storeCossDirWriteCleanEntry(SwapDir * sd, const StoreEntry * e)
 static void
 storeCossDirWriteCleanDone(SwapDir * sd)
 {
+    int fd;
     struct _clean_state *state = sd->log.clean.state;
     if (NULL == state)
        return;
@@ -587,24 +588,26 @@ storeCossDirWriteCleanDone(SwapDir * sd)
      * so we have to close before renaming.
      */
     storeCossDirCloseSwapLog(sd);
+    /* save the fd value for a later test */
+    fd = state->fd;
     /* rename */
     if (state->fd >= 0) {
-#ifdef _SQUID_OS2_
+#if defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
        file_close(state->fd);
        state->fd = -1;
-       if (unlink(cur) < 0)
+       if (unlink(state->cur) < 0)
            debug(50, 0) ("storeCossDirWriteCleanLogs: unlinkd failed: %s, %s\n",
-               xstrerror(), cur);
+               xstrerror(), state->cur);
 #endif
        xrename(state->new, state->cur);
     }
     /* touch a timestamp file if we're not still validating */
     if (store_dirs_rebuilding)
        (void) 0;
-    else if (state->fd < 0)
+    else if (fd < 0)
        (void) 0;
     else
-       file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC));
+       file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY));
     /* close */
     safe_free(state->cur);
     safe_free(state->new);
index 32d66db52f92c7f8a4831aa845a6d920bfcda1c6..f8c29b5f6789ccbd6ba53c65cd9ea8a88a20d8c4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_diskd.cc,v 1.65 2002/04/14 16:10:03 hno Exp $
+ * $Id: store_dir_diskd.cc,v 1.66 2002/05/19 16:40:59 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -1099,7 +1099,7 @@ storeDiskdDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag)
     }
     diskdinfo->swaplog_fd = fd;
     /* open a read-only stream of the old log */
-    fp = fopen(swaplog_path, "r");
+    fp = fopen(swaplog_path, "rb");
     if (fp == NULL) {
        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("Failed to open swap log for reading");
index 818fbec97f5d403d5e1eba679cea512cd1ee8d01..61122f5f6d4ed402d360870771d65605e5fc0906 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.43 2002/04/07 11:52:34 hno Exp $
+ * $Id: store_dir_ufs.cc,v 1.44 2002/05/19 16:41:01 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -910,14 +910,11 @@ storeUfsDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag)
     }
     ufsinfo->swaplog_fd = fd;
     /* open a read-only stream of the old log */
-    fp = fopen(swaplog_path, "r");
+    fp = fopen(swaplog_path, "rb");
     if (fp == NULL) {
        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("Failed to open swap log for reading");
     }
-#if defined(_SQUID_CYGWIN_)
-    setmode(fileno(fp), O_BINARY);
-#endif
     memset(&clean_sb, '\0', sizeof(struct stat));
     if (stat(clean_path, &clean_sb) < 0)
        *clean_flag = 0;