--------------------- PatchSet 6558 Date: 2005/03/28 08:13:57 Author: serassio Branch: nt-2_5 Tag: (none) Log: Updated awin32 with latest aufs changes Members: src/fs/awin32/store_dir_aufs.c:1.1.62.19->1.1.62.20 Index: squid/src/fs/awin32/store_dir_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/awin32/Attic/store_dir_aufs.c,v retrieving revision 1.1.62.19 retrieving revision 1.1.62.20 diff -u -r1.1.62.19 -r1.1.62.20 --- squid/src/fs/awin32/store_dir_aufs.c 26 Mar 2005 15:18:37 -0000 1.1.62.19 +++ squid/src/fs/awin32/store_dir_aufs.c 28 Mar 2005 08:13:57 -0000 1.1.62.20 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.c,v 1.1.62.19 2005/03/26 15:18:37 serassio Exp $ + * $Id: store_dir_aufs.c,v 1.1.62.20 2005/03/28 08:13:57 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -1118,6 +1118,31 @@ debug(47, 3) ("Cache Dir #%d log opened on FD %d\n", sd->index, fd); } +static void +storeSwapLogDataFree(void *s) +{ + memFree(s, MEM_SWAP_LOG_DATA); +} + +static void +storeAufsWriteSwapLogheader(int fd) +{ + storeSwapLogHeader *hdr = memAllocate(MEM_SWAP_LOG_DATA); + hdr->op = SWAP_LOG_VERSION; + hdr->version = 1; + hdr->record_size = sizeof(storeSwapLogData); + /* The header size is a full log record to keep some level of backward + * compatibility even if the actual header is smaller + */ + file_write(fd, + -1, + hdr, + sizeof(storeSwapLogData), + NULL, + NULL, + (FREE *) storeSwapLogDataFree); +} + static FILE * storeAufsDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag) { @@ -1129,10 +1154,6 @@ struct stat clean_sb; FILE *fp; int fd; - union { - storeSwapLogHeader hdr; - storeSwapLogData _data; - } hd; if (stat(swaplog_path, &log_sb) < 0) { debug(47, 1) ("Cache Dir #%d: No log file\n", sd->index); safe_free(swaplog_path); @@ -1150,15 +1171,8 @@ debug(50, 1) ("%s: %s\n", new_path, xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); } - memset(&hd, 0, sizeof(hd)); - hd.hdr.op = SWAP_LOG_VERSION; - hd.hdr.version = 1; - hd.hdr.record_size = sizeof(storeSwapLogData); - if (FD_WRITE_METHOD(fd, (const char *)&hd, sizeof(hd)) != sizeof(hd)) { - debug(50, 1) ("%s: %s\n", new_path, xstrerror()); - fatal("storeDirOpenTmpSwapLog: Failed to write swap log header."); - } aioinfo->swaplog_fd = fd; + storeAufsWriteSwapLogheader(fd); /* open a read-only stream of the old log */ fp = fopen(swaplog_path, "rb"); if (fp == NULL) { @@ -1199,10 +1213,6 @@ storeAufsDirWriteCleanStart(SwapDir * sd) { struct _clean_state *state = xcalloc(1, sizeof(*state)); - union { - storeSwapLogHeader hdr; - storeSwapLogData _data; - } hd; #if HAVE_FCHMOD struct stat sb; #endif @@ -1219,21 +1229,14 @@ xfree(state); return -1; } - memset(&hd, 0, sizeof(hd)); - hd.hdr.op = SWAP_LOG_VERSION; - hd.hdr.version = 1; - hd.hdr.record_size = sizeof(storeSwapLogData); - if (FD_WRITE_METHOD(state->fd, (const char *)&hd, sizeof(hd)) != sizeof(hd)) { - debug(50, 1) ("%s: %s\n", state->new, xstrerror()); - fatal("storeAufsDirWriteCleanStart: Failed to write swap log header."); - } + storeAufsWriteSwapLogheader(state->fd); state->cur = xstrdup(storeAufsDirSwapLogFile(sd, NULL)); state->cln = xstrdup(storeAufsDirSwapLogFile(sd, ".last-clean")); state->outbuf = xcalloc(CLEAN_BUF_SZ, 1); state->outbuf_offset = 0; state->walker = sd->repl->WalkInit(sd->repl); unlink(state->cln); - debug(50, 3) ("storeDirWriteCleanStart: opened %s, FD %d\n", + debug(47, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", state->new, state->fd); #if HAVE_FCHMOD if (stat(state->cur, &sb) == 0) @@ -1352,12 +1355,6 @@ } static void -storeSwapLogDataFree(void *s) -{ - memFree(s, MEM_SWAP_LOG_DATA); -} - -static void storeAufsDirSwapLog(const SwapDir * sd, const StoreEntry * e, int op) { squidaioinfo_t *aioinfo = (squidaioinfo_t *) sd->fsdata;