From: hno <> Date: Sun, 1 Sep 2002 21:16:33 +0000 (+0000) Subject: WIN32 port update by Guido X-Git-Tag: SQUID_3_0_PRE1~794 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e24070c52544f43101dc1ee530a179af8497bab4;p=thirdparty%2Fsquid.git WIN32 port update by Guido fix the problems on Windows related to open file renaming and text/binary file issues --- diff --git a/src/acl.cc b/src/acl.cc index cbd2ee3fb1..7ae7258c3d 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $Id: acl.cc,v 1.281 2002/08/09 10:57:43 robertc Exp $ + * $Id: acl.cc,v 1.282 2002/09/01 15:16:33 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -128,7 +128,7 @@ strtokFile(void) debug(28, 0) ("strtokFile: %s not found\n", fn); return (NULL); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(aclFile), O_TEXT); #endif aclFromFile = 1; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index b812970d87..d9e122f4a5 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.410 2002/09/01 13:54:16 hno Exp $ + * $Id: cache_cf.cc,v 1.411 2002/09/01 15:16:33 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -275,7 +275,7 @@ parseConfigFile(const char *file_name) if (fp == NULL) fatalf("Unable to open configuration file: %s: %s", file_name, xstrerror()); -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif cfg_filename = file_name; diff --git a/src/cache_diff.cc b/src/cache_diff.cc index ce9e6fec43..a1024a88c6 100644 --- a/src/cache_diff.cc +++ b/src/cache_diff.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_diff.cc,v 1.15 2001/01/12 00:37:15 wessels Exp $ + * $Id: cache_diff.cc,v 1.16 2002/09/01 15:16:33 hno Exp $ * * AUTHOR: Alex Rousskov * @@ -137,7 +137,7 @@ cacheIndexAddLog(CacheIndex * idx, const char *fname) fprintf(stderr, "cannot open %s: %s\n", fname, strerror(errno)); return 0; } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(file), O_BINARY); #endif scanned_count = cacheIndexScan(idx, fname, file); diff --git a/src/cf_gen.cc b/src/cf_gen.cc index 2527bd5097..d7c80dbce8 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -1,6 +1,6 @@ /* - * $Id: cf_gen.cc,v 1.45 2002/08/22 12:29:15 hno Exp $ + * $Id: cf_gen.cc,v 1.46 2002/09/01 15:16:35 hno Exp $ * * DEBUG: none Generate squid.conf.default and cf_parser.h * AUTHOR: Max Okumoto @@ -66,7 +66,7 @@ #if HAVE_ASSERT_H #include #endif -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) #include #endif #if HAVE_FCNTL_H @@ -158,7 +158,7 @@ main(int argc, char *argv[]) perror(input_filename); exit(1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif state = sSTART; @@ -345,7 +345,7 @@ main(int argc, char *argv[]) perror(output_filename); exit(1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif fprintf(fp, @@ -370,7 +370,7 @@ main(int argc, char *argv[]) perror(conf_filename); exit(1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif gen_conf(entries, fp); diff --git a/src/client.cc b/src/client.cc index 8963b57b8b..28b72eb200 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,6 +1,6 @@ /* - * $Id: client.cc,v 1.99 2002/07/15 21:24:48 hno Exp $ + * $Id: client.cc,v 1.100 2002/09/01 15:16:35 hno Exp $ * * DEBUG: section 0 WWW Client * AUTHOR: Harvest Derived @@ -223,7 +223,7 @@ main(int argc, char *argv[]) xstrerror()); exit(-1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(put_fd, O_BINARY); #endif fstat(put_fd, &sb); diff --git a/src/debug.cc b/src/debug.cc index 539f8c9967..3aa5a7bcaa 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1,6 +1,6 @@ /* - * $Id: debug.cc,v 1.84 2001/12/17 18:01:54 wessels Exp $ + * $Id: debug.cc,v 1.85 2002/09/01 15:16:35 hno Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -177,7 +177,7 @@ debugOpenLog(const char *logfile) fflush(stderr); debug_log = stderr; } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_CYGWIN_)||defined(_SQUID_MSWIN_) setmode(fileno(debug_log), O_TEXT); #endif } @@ -237,6 +237,14 @@ _db_rotate_log(void) snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i); rename(from, to); } +/* + * You can't rename open files on Microsoft "operating systems" + * so we close before renaming. + */ +#ifdef _SQUID_MSWIN_ + if (debug_log != stderr) + fclose(debug_log); +#endif /* Rotate the current log to .0 */ if (Config.Log.rotateNumber > 0) { snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0); diff --git a/src/disk.cc b/src/disk.cc index 91ff433d76..dca265d439 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,6 +1,6 @@ /* - * $Id: disk.cc,v 1.159 2002/08/08 20:12:45 hno Exp $ + * $Id: disk.cc,v 1.160 2002/09/01 15:16:35 hno Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -92,7 +92,7 @@ file_close(int fd) read_callback(-1, F->read_data); } if (F->flags.write_daemon) { -#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_) /* * on some operating systems, you can not delete or rename * open files, so we won't allow delayed close. diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index f7ad79d93e..b1ef74eb52 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.48 2002/08/09 10:57:46 robertc Exp $ + * $Id: store_dir_ufs.cc,v 1.49 2002/09/01 15:16:36 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -860,7 +860,7 @@ storeUfsDirCloseTmpSwapLog(SwapDir * sd) char *new_path = xstrdup(storeUfsDirSwapLogFile(sd, ".new")); int fd; file_close(ufsinfo->swaplog_fd); -#if defined (_SQUID_OS2_) || defined (_SQUID_CYGWIN_) +#if defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) if (unlink(swaplog_path) < 0) { debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); fatal("storeUfsDirCloseTmpSwapLog: unlink failed"); @@ -1060,7 +1060,7 @@ storeUfsDirWriteCleanDone(SwapDir * sd) fd = state->fd; /* rename */ if (state->fd >= 0) { -#if defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_) +#if defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) file_close(state->fd); state->fd = -1; if (unlink(state->cur) < 0) diff --git a/src/mime.cc b/src/mime.cc index 950c08261d..c7a41c10c4 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -1,6 +1,6 @@ /* - * $Id: mime.cc,v 1.102 2001/11/13 17:32:15 hno Exp $ + * $Id: mime.cc,v 1.103 2002/09/01 15:16:35 hno Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -297,7 +297,7 @@ mimeInit(char *filename) debug(50, 1) ("mimeInit: %s: %s\n", filename, xstrerror()); return; } -#if defined (_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif mimeFreeMemory(); diff --git a/src/squid.h b/src/squid.h index 5050d505e6..e603bf35ef 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.221 2002/08/09 10:57:43 robertc Exp $ + * $Id: squid.h,v 1.222 2002/09/01 15:16:35 hno Exp $ * * AUTHOR: Duane Wessels * @@ -202,7 +202,7 @@ #if HAVE_LIMITS_H #include #endif -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) #include #endif diff --git a/src/tools.cc b/src/tools.cc index 7334772a58..244577029f 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.220 2002/08/22 12:29:15 hno Exp $ + * $Id: tools.cc,v 1.221 2002/09/01 15:16:35 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -895,6 +895,9 @@ int xrename(const char *from, const char *to) { debug(21, 2) ("xrename: renaming %s to %s\n", from, to); +#ifdef _SQUID_MSWIN_ + remove(to); +#endif if (0 == rename(from, to)) return 0; debug(21, errno == ENOENT ? 2 : 1) ("xrename: Cannot rename %s to %s: %s\n",