Index: src/stat.c =================================================================== RCS file: /cvsroot/squid/squid/src/stat.c,v retrieving revision 1.9 diff -u -r1.9 stat.c --- src/stat.c 2001/03/03 10:44:32 1.9 +++ src/stat.c 2001/03/17 11:06:21 @@ -900,7 +900,6 @@ StatCounters *p = &CountHist[1]; StatCounters *c = &statCounter; struct rusage rusage; - eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1); squid_getrusage(&rusage); c->page_faults = rusage_pagefaults(&rusage); c->cputime = rusage_cputime(&rusage); @@ -947,6 +946,7 @@ if (Config.warnings.high_memory < i) debug(18, 0) ("WARNING: Memory usage at %d MB\n", i >> 20); } + eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1); } static void Index: src/fs/aufs/aiops.c =================================================================== RCS file: /cvsroot/squid/squid/src/fs/aufs/aiops.c,v retrieving revision 1.6 diff -u -r1.6 aiops.c --- src/fs/aufs/aiops.c 2001/01/12 08:20:34 1.6 +++ src/fs/aufs/aiops.c 2001/03/17 11:06:34 @@ -169,7 +169,9 @@ NULL, &done_requests.head }; static pthread_attr_t globattr; +#if HAVE_SCHED_H static struct sched_param globsched; +#endif static pthread_t main_thread; static MemPool * @@ -254,13 +256,17 @@ #if HAVE_PTHREAD_ATTR_SETSCOPE pthread_attr_setscope(&globattr, PTHREAD_SCOPE_SYSTEM); #endif +#if HAVE_SCHED_H globsched.sched_priority = 1; +#endif main_thread = pthread_self(); -#if HAVE_PTHREAD_SETSCHEDPARAM +#if HAVE_SCHED_H && HAVE_PTHREAD_SETSCHEDPARAM pthread_setschedparam(main_thread, SCHED_OTHER, &globsched); #endif +#if HAVE_SCHED_H globsched.sched_priority = 2; -#if HAVE_PTHREAD_ATTR_SETSCHEDPARAM +#endif +#if HAVE_SCHED_H && HAVE_PTHREAD_ATTR_SETSCHEDPARAM pthread_attr_setschedparam(&globattr, &globsched); #endif @@ -808,6 +814,7 @@ } done_requests.tailp = &requests->next; } +#if HAVE_SCHED_H /* Give up the CPU to allow the threads to do their work */ /* * For Andres thoughts about yield(), see @@ -818,6 +825,7 @@ sched_yield(); #else yield(); +#endif #endif } Index: src/fs/aufs/store_dir_aufs.c =================================================================== RCS file: /cvsroot/squid/squid/src/fs/aufs/store_dir_aufs.c,v retrieving revision 1.16 diff -u -r1.16 store_dir_aufs.c --- src/fs/aufs/store_dir_aufs.c 2001/03/16 17:22:13 1.16 +++ src/fs/aufs/store_dir_aufs.c 2001/03/17 11:06:44 @@ -322,7 +322,7 @@ char *path; int fd; path = storeAufsDirSwapLogFile(sd, NULL); - fd = file_open(path, O_WRONLY | O_CREAT); + fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY); if (fd < 0) { debug(50, 1) ("%s: %s\n", path, xstrerror()); fatal("storeAufsDirOpenSwapLog: Failed to open swap log."); @@ -755,7 +755,7 @@ snprintf(rb->fullfilename, SQUID_MAXPATHLEN, "%s/%s", rb->fullpath, rb->entry->d_name); debug(20, 3) ("storeAufsDirGetNextFile: Opening %s\n", rb->fullfilename); - fd = file_open(rb->fullfilename, O_RDONLY); + fd = file_open(rb->fullfilename, O_RDONLY | O_BINARY); if (fd < 0) debug(50, 1) ("storeAufsDirGetNextFile: %s: %s\n", rb->fullfilename, xstrerror()); else @@ -864,7 +864,7 @@ char *new_path = xstrdup(storeAufsDirSwapLogFile(sd, ".new")); int fd; file_close(aioinfo->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("storeAufsDirCloseTmpSwapLog: unlink failed"); @@ -873,7 +873,7 @@ if (xrename(new_path, swaplog_path) < 0) { fatal("storeAufsDirCloseTmpSwapLog: 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("storeAufsDirCloseTmpSwapLog: Failed to open swap log."); @@ -919,6 +919,9 @@ 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; @@ -957,7 +960,7 @@ sd->log.clean.write = NULL; sd->log.clean.state = NULL; state->new = xstrdup(storeAufsDirSwapLogFile(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); @@ -968,7 +971,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); @@ -1036,6 +1041,7 @@ static void storeAufsDirWriteCleanDone(SwapDir * sd) { + int fd; struct _clean_state *state = sd->log.clean.state; if (NULL == state) return; @@ -1057,24 +1063,26 @@ * so we have to close before renaming. */ storeAufsDirCloseSwapLog(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 - 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: src/fs/aufs/store_io_aufs.c =================================================================== RCS file: /cvsroot/squid/squid/src/fs/aufs/store_io_aufs.c,v retrieving revision 1.7 diff -u -r1.7 store_io_aufs.c --- src/fs/aufs/store_io_aufs.c 2001/03/03 10:44:33 1.7 +++ src/fs/aufs/store_io_aufs.c 2001/03/17 11:06:44 @@ -47,7 +47,7 @@ return NULL; #endif #if !ASYNC_OPEN - fd = file_open(path, O_RDONLY); + fd = file_open(path, O_RDONLY | O_BINARY); if (fd < 0) { debug(78, 3) ("storeAufsOpen: got failude (%d)\n", errno); return NULL; @@ -67,7 +67,7 @@ cbdataLock(callback_data); Opening_FD++; #if ASYNC_OPEN - aioOpen(path, O_RDONLY, 0644, storeAufsOpenDone, sio); + aioOpen(path, O_RDONLY | O_BINARY, 0644, storeAufsOpenDone, sio); #else storeAufsOpenDone(fd, sio, fd, 0); #endif @@ -102,7 +102,7 @@ return NULL; #endif #if !ASYNC_CREATE - fd = file_open(path, O_WRONLY | O_CREAT | O_TRUNC); + fd = file_open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); if (fd < 0) { debug(78, 3) ("storeAufsCreate: got failude (%d)\n", errno); return NULL; @@ -115,14 +115,14 @@ ((aiostate_t *) (sio->fsstate))->flags.opening = 1; sio->swap_filen = filn; sio->swap_dirn = dirn; - sio->mode = O_WRONLY; + sio->mode = O_WRONLY | O_BINARY; sio->callback = callback; sio->callback_data = callback_data; sio->e = (StoreEntry *) e; cbdataLock(callback_data); Opening_FD++; #if ASYNC_CREATE - aioOpen(path, O_WRONLY | O_CREAT | O_TRUNC, 0644, storeAufsOpenDone, sio); + aioOpen(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644, storeAufsOpenDone, sio); #else storeAufsOpenDone(fd, sio, fd, 0); #endif