/*
- * $Id: aiops.cc,v 1.7 2001/01/12 00:37:32 wessels Exp $
+ * $Id: aiops.cc,v 1.8 2001/03/17 13:31:16 hno Exp $
*
* DEBUG: section 43 AIOPS
* AUTHOR: Stewart Forster <slf@connect.com.au>
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 *
#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
}
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
#else
yield();
#endif
+#endif
}
aio_result_t *
/*
- * $Id: store_dir_aufs.cc,v 1.33 2001/03/14 22:28:37 wessels Exp $
+ * $Id: store_dir_aufs.cc,v 1.34 2001/03/17 13:31:16 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
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.");
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
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");
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.");
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;
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);
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);
static void
storeAufsDirWriteCleanDone(SwapDir * sd)
{
+ int fd;
struct _clean_state *state = sd->log.clean.state;
if (NULL == state)
return;
* 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);
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;
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
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;
((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