--------------------- PatchSet 1053 Date: 2001/01/03 16:57:52 Author: rbcollins Branch: cygwin Tag: (none) Log: Had the wrong mode for swap.state log files; fixed the problem with getting a clean state. Members: src/fs/ufs/store_dir_ufs.c:1.5.10.1->1.5.10.2 Index: squid/src/fs/ufs/store_dir_ufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/ufs/store_dir_ufs.c,v retrieving revision 1.5.10.1 retrieving revision 1.5.10.2 diff -u -r1.5.10.1 -r1.5.10.2 --- squid/src/fs/ufs/store_dir_ufs.c 3 Jan 2001 15:22:20 -0000 1.5.10.1 +++ squid/src/fs/ufs/store_dir_ufs.c 3 Jan 2001 16:57:52 -0000 1.5.10.2 @@ -323,7 +323,7 @@ int fd; path = storeUfsDirSwapLogFile(sd, NULL); #if defined(_SQUID_CYGWIN_) - fd = file_open(path, O_WRONLY | O_CREAT | O_TEXT); + fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY); #else fd = file_open(path, O_WRONLY | O_CREAT); #endif @@ -868,7 +868,7 @@ char *new_path = xstrdup(storeUfsDirSwapLogFile(sd, ".new")); int fd; file_close(ufsinfo->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("storeUfsDirCloseTmpSwapLog: unlink failed"); @@ -878,7 +878,7 @@ fatal("storeUfsDirCloseTmpSwapLog: rename failed"); } #if defined(_SQUID_CYGWIN_) - fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_TEXT); + fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY); #else fd = file_open(swaplog_path, O_WRONLY | O_CREAT); #endif @@ -916,7 +916,7 @@ file_close(ufsinfo->swaplog_fd); /* open a write-only FD for the new log */ #if defined(_SQUID_CYGWIN_) - fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT); + fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); #else fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC); #endif @@ -932,7 +932,7 @@ fatal("Failed to open swap log for reading"); } #if defined(_SQUID_CYGWIN_) - setmode(fileno(fp), O_TEXT); + setmode(fileno(fp), O_BINARY); #endif memset(&clean_sb, '\0', sizeof(struct stat)); if (stat(clean_path, &clean_sb) < 0) @@ -973,7 +973,7 @@ sd->log.clean.state = NULL; state->new = xstrdup(storeUfsDirSwapLogFile(sd, ".clean")); #if defined(_SQUID_CYGWIN_) - state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT); + state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); #else state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC); #endif @@ -987,7 +987,9 @@ state->outbuf = xcalloc(CLEAN_BUF_SZ, 1); state->outbuf_offset = 0; state->walker = sd->repl->WalkInit(sd->repl); +#if !(defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_)) unlink(state->new); +#endif unlink(state->cln); debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", state->new, state->fd); @@ -1055,6 +1057,7 @@ static void storeUfsDirWriteCleanDone(SwapDir * sd) { + int fd; struct _clean_state *state = sd->log.clean.state; if (NULL == state) return; @@ -1076,25 +1079,27 @@ * so we have to close before renaming. */ storeUfsDirCloseSwapLog(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) ("storeDirWriteCleanLogs: 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 #if defined(_SQUID_CYGWIN_) - file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT)); + file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)); #else file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC)); #endif