From: wessels <> Date: Wed, 2 Apr 1997 12:22:14 +0000 (+0000) Subject: more compiler fixes X-Git-Tag: SQUID_3_0_PRE1~5057 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4683e377ed933d883836bf597a13c64f762d69c8;p=thirdparty%2Fsquid.git more compiler fixes --- diff --git a/src/squid.h b/src/squid.h index 795d3eab3c..849c34a76a 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.102 1997/04/02 04:39:58 wessels Exp $ + * $Id: squid.h,v 1.103 1997/04/02 05:22:14 wessels Exp $ * * AUTHOR: Duane Wessels * @@ -233,7 +233,7 @@ typedef struct _aclCheck_t aclCheck_t; typedef struct _request request_t; typedef struct _MemObject MemObject; typedef struct _cachemgr_passwd cachemgr_passwd; -typedef struct _filemap fileMap; +typedef struct _fileMap fileMap; /* 32 bit integer compatability hack */ #if SIZEOF_INT == 4 diff --git a/src/store.cc b/src/store.cc index 8b34f77342..5aac7d34a0 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.216 1997/04/02 04:39:59 wessels Exp $ + * $Id: store.cc,v 1.217 1997/04/02 05:22:15 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -317,7 +317,6 @@ static int swapfileno = 0; static int store_swap_size = 0; /* kilobytes !! */ static int store_swap_high = 0; static int store_swap_low = 0; -static int swaplog_fd = -1; static int storelog_fd = -1; /* key temp buffer */ @@ -496,30 +495,6 @@ storeSetMemStatus(StoreEntry * e, mem_status_t status) /* -------------------------------------------------------------------------- */ -#ifdef OLD_CODE -static char * -time_describe(time_t t) -{ - LOCAL_ARRAY(char, buf, 128); - if (t < 60) { - sprintf(buf, "%ds", (int) t); - } else if (t < 3600) { - sprintf(buf, "%dm", (int) t / 60); - } else if (t < 86400) { - sprintf(buf, "%dh", (int) t / 3600); - } else if (t < 604800) { - sprintf(buf, "%dD", (int) t / 86400); - } else if (t < 2592000) { - sprintf(buf, "%dW", (int) t / 604800); - } else if (t < 31536000) { - sprintf(buf, "%dM", (int) t / 2592000); - } else { - sprintf(buf, "%dY", (int) t / 31536000); - } - return buf; -} -#endif - static void storeLog(int tag, const StoreEntry * e) { @@ -1234,26 +1209,6 @@ storeSwapInStartComplete(void *data, int fd) xfree(ctrlp); } -static void -storeSwapLog(const StoreEntry * e) -{ - LOCAL_ARRAY(char, logmsg, MAX_URL << 1); - /* Note this printf format appears in storeWriteCleanLog() too */ - sprintf(logmsg, "%08x %08x %08x %08x %9d %s\n", - (int) e->swap_file_number, - (int) e->timestamp, - (int) e->expires, - (int) e->lastmod, - e->object_len, - e->url); - file_write(swaplog_fd, - xstrdup(logmsg), - strlen(logmsg), - NULL, - NULL, - xfree); -} - static void storeSwapOutHandle(int fd, int flag, StoreEntry * e) { @@ -2509,16 +2464,7 @@ storeInit(void) if (ncache_dirs < 1) fatal("No cache_dir's specified in config file"); dir_created = storeVerifySwapDirs(); - if (Config.Log.swap) - xstrncpy(swaplog_file, Config.Log.swap, SQUID_MAXPATHLEN); - else - sprintf(swaplog_file, "%s/log", storeSwapDir(0)); - swaplog_fd = file_open(swaplog_file, NULL, O_WRONLY | O_CREAT, NULL, NULL); - debug(20, 3, "swaplog_fd %d is now '%s'\n", swaplog_fd, swaplog_file); - if (swaplog_fd < 0) { - sprintf(tmp_error_buf, "Cannot open swap logfile: %s", swaplog_file); - fatal(tmp_error_buf); - } + if (!opt_zap_disk_store) storeStartRebuildFromDisk(); else diff --git a/src/store_dir.cc b/src/store_dir.cc index 280cb746d6..f31f319640 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -195,3 +195,63 @@ storeSwapDir(int dirn) fatal_dump("storeSwapDir: bad index"); return SwapDirs[dirn].path; } + +void +storeDirSwapLog(const StoreEntry * e) +{ + LOCAL_ARRAY(char, logmsg, MAX_URL << 1); + int dirn; + if (e->swap_file_number < 0) + fatal_dump("storeDirSwapLog: swap_file_number < 0"); + dirn = e->swap_file_number >> SWAP_DIR_SHIFT; + /* Note this printf format appears in storeWriteCleanLog() too */ + sprintf(logmsg, "%08x %08x %08x %08x %9d %s\n", + (int) e->swap_file_number, + (int) e->timestamp, + (int) e->expires, + (int) e->lastmod, + e->object_len, + e->url); + file_write(SwapDirs[dirn].swaplog_fd, + xstrdup(logmsg), + strlen(logmsg), + NULL, + NULL, + xfree); +} + +static char * +storeDirSwapLogFile(int dirn) +{ + LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN); + LOCAL_ARRAY(char, digit, 32); + if (Config.Log.swap) { + xstrncpy(path, Config.Log.swap, SQUID_MAXPATHLEN - 64); + strcat(path, "."); + sprintf(digit, "%02d", dirn); + strncat(path, digit, 32); + } else { + xstrncpy(path, storeSwapDir(dirn), SQUID_MAXPATHLEN - 64); + strcat(path, "/log"); + } + return path; +} + +void +storeDirOpenSwapLogs(void) +{ + int i; + int fd; + char *path; + SwapDir *SD; + for (i = 0; i < ncache_dirs; i++) { + SD = &SwapDirs[i]; + path = storeDirSwapLogFile(i); + fd = file_open(path, NULL, O_WRONLY | O_CREAT, NULL, NULL); + if (fd < 0) { + debug(50, 1, "%s: %s\n", path, xstrerror()); + fatal("storeDirOpenSwapLogs: Failed to open swap log."); + } + SD->swaplog_fd = fd; + } +}