Index: configure.in =================================================================== RCS file: /cvsroot/squid/squid/configure.in,v retrieving revision 1.1.1.3.4.6 diff -u -p -r1.1.1.3.4.6 configure.in --- configure.in 2001/01/06 12:57:32 1.1.1.3.4.6 +++ configure.in 2001/06/18 19:01:40 @@ -288,7 +288,7 @@ AC_ARG_ENABLE(icmp, ]) AC_ARG_ENABLE(delay_pools, -[ --enable-delay-pools Enable delay pools to limit bandwith usage], +[ --enable-delay-pools Enable delay pools to limit bandwidth usage], [ if test "$enableval" = "yes" ; then echo "Delay pools enabled" DELAY_OBJS='$(DELAY_OBJS)' @@ -533,7 +533,7 @@ AC_ARG_ENABLE(truncate, dnl Enable underscore in hostnames AC_ARG_ENABLE(underscores, [ --enable-underscores Squid by default rejects any host names with _ - in their name to conform with internet standars. + in their name to conform with internet standards. If you disagree with this you may allow _ in hostnames by using this switch, provided that the resolver library on the host where Squid runs @@ -914,12 +914,12 @@ dnl during compile. ;; esac -# Remove optimization for GCC 2.95.[12] +# Remove optimization for GCC 2.95.[123] # gcc -O[2] on *BSD and Linux (x86) causes pointers to magically become NULL if test "$GCC" = "yes"; then GCCVER=`$CC -v 2>&1 | awk '$2 == "version" {print $3}'` case "$GCCVER" in - [2.95.[12]]) + [2.95.[123]]) echo "Removing -O for gcc on $host with GCC $GCCVER" CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]*//'`" ;; Index: include/snmp-internal.h =================================================================== RCS file: /cvsroot/squid/squid/include/snmp-internal.h,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 snmp-internal.h --- include/snmp-internal.h 2000/01/26 03:21:47 1.1.1.1 +++ include/snmp-internal.h 2001/06/18 19:01:41 @@ -32,10 +32,4 @@ #define SNMP_TRAP_PORT 162 #define SNMP_MAX_LEN 484 -#ifdef DEBUG -#define ERROR(string) printf("%s(%d): %s\n",__FILE__, __LINE__, string); -#else -#define ERROR(string) -#endif - #endif /* _SNMP_INTERNAL_H_ */ Index: lib/rfc1123.c =================================================================== RCS file: /cvsroot/squid/squid/lib/rfc1123.c,v retrieving revision 1.1.1.3.4.1 diff -u -p -r1.1.1.3.4.1 rfc1123.c --- lib/rfc1123.c 2000/04/17 00:56:52 1.1.1.3.4.1 +++ lib/rfc1123.c 2001/06/18 19:01:41 @@ -61,6 +61,7 @@ #if HAVE_SYS_TIME_H #include #endif +#include "assert.h" #include "util.h" #include "snprintf.h" @@ -68,6 +69,8 @@ #define RFC850_STRFTIME "%A, %d-%b-%y %H:%M:%S GMT" #define RFC1123_STRFTIME "%a, %d %b %Y %H:%M:%S GMT" +static const char *const w_space = " \t\r\n"; + static int make_month(const char *s); static int make_num(const char *s); @@ -103,85 +106,152 @@ make_month(const char *s) return 0; } +static int +tmSaneValues(struct tm *tm) +{ + if (tm->tm_sec < 0 || tm->tm_sec > 59) + return 0; + if (tm->tm_min < 0 || tm->tm_min > 59) + return 0; + if (tm->tm_hour < 0 || tm->tm_hour > 23) + return 0; + if (tm->tm_mday < 1 || tm->tm_mday > 31) + return 0; + if (tm->tm_mon < 0 || tm->tm_mon > 11) + return 0; + if (tm->tm_year < 70 || tm->tm_year > 120) + return 0; + return 1; +} -time_t -parse_rfc1123(const char *str) +static struct tm * +parse_date1(const char *str) +{ + /* Thursday, 10-Jun-93 01:29:59 GMT */ + const char *s; + static struct tm tm; + assert(NULL != str); + memset(&tm, '\0', sizeof(struct tm)); + s = strchr(str, ','); + if (NULL == s) + return NULL; + while (*s == ' ') + s++; + /* backup if month is only one digit */ + if (xisdigit(*s) && !xisdigit(*(s + 1))) + s--; + if (!strchr(s, '-')) + return NULL; + if ((int) strlen(s) < 18) + return NULL; + memset(&tm, '\0', sizeof(tm)); + tm.tm_mday = make_num(s); + tm.tm_mon = make_month(s + 3); + tm.tm_year = make_num(s + 7); + /* + * Y2K: Arjan de Vet + * if tm.tm_year < 70, assume it's after the year 2000. + */ + if (tm.tm_year < 70) + tm.tm_year += 100; + tm.tm_hour = make_num(s + 10); + tm.tm_min = make_num(s + 13); + tm.tm_sec = make_num(s + 16); + return tmSaneValues(&tm) ? &tm : NULL; +} + +static struct tm * +parse_date2(const char *str) { + /* Thu, 10 Jan 1993 01:29:59 GMT */ const char *s; struct tm tm; - time_t t; + assert(NULL != str); + memset(&tm, '\0', sizeof(struct tm)); + s = strchr(str, ','); + if (NULL == s) + return NULL; + while (*s == ' ') + s++; + /* backup if month is only one digit */ + if (xisdigit(*s) && !xisdigit(*(s + 1))) + s--; + if (strchr(s, '-')) + return NULL; + if ((int) strlen(s) < 20) + return NULL; + memset(&tm, '\0', sizeof(tm)); + tm.tm_mday = make_num(s); + tm.tm_mon = make_month(s + 3); + tm.tm_year = (100 * make_num(s + 7) - 1900) + make_num(s + 9); + tm.tm_hour = make_num(s + 12); + tm.tm_min = make_num(s + 15); + tm.tm_sec = make_num(s + 18); + return tmSaneValues(&tm) ? &tm : NULL; +} - if (!str) - return -1; +static struct tm * +parse_date3(const char *str) +{ + /* Wed Jun 9 01:29:59 1993 GMT */ + static struct tm tm; + char *s; + static char buf[128]; + while (*str && *str == ' ') + str++; + xstrncpy(buf, str, 128); + if (NULL == (s = strtok(buf, w_space))) + return NULL; + if (NULL == (s = strtok(NULL, w_space))) + return NULL; + tm.tm_mon = make_month(s); + if (NULL == (s = strtok(NULL, w_space))) + return NULL; + tm.tm_mday = atoi(s); + if (NULL == (s = strtok(NULL, ":"))) + return NULL; + tm.tm_hour = atoi(s); + if (NULL == (s = strtok(NULL, ":"))) + return NULL; + tm.tm_min = atoi(s); + if (NULL == (s = strtok(NULL, w_space))) + return NULL; + tm.tm_sec = atoi(s); + if (NULL == (s = strtok(NULL, w_space))) + return NULL; + /* Y2K fix, richard.kettlewell@kewill.com */ + tm.tm_year = atoi(s) - 1900; + return tmSaneValues(&tm) ? &tm : NULL; +} - memset(&tm, '\0', sizeof(struct tm)); - if ((s = strchr(str, ','))) { /* Thursday, 10-Jun-93 01:29:59 GMT */ - s++; /* or: Thu, 10 Jan 1993 01:29:59 GMT */ - while (*s == ' ') - s++; - if (xisdigit(*s) && !xisdigit(*(s + 1))) /* backoff if only one digit */ - s--; - if (strchr(s, '-')) { /* First format */ - if ((int) strlen(s) < 18) - return -1; - tm.tm_mday = make_num(s); - tm.tm_mon = make_month(s + 3); - tm.tm_year = make_num(s + 7); - /* - * Y2K: Arjan de Vet - * if tm.tm_year < 70, assume it's after the year 2000. - */ - if (tm.tm_year < 70) - tm.tm_year += 100; - tm.tm_hour = make_num(s + 10); - tm.tm_min = make_num(s + 13); - tm.tm_sec = make_num(s + 16); - } else { /* Second format */ - if ((int) strlen(s) < 20) +time_t +parse_rfc1123(const char *str) +{ + struct tm *tm; + time_t t; + if (NULL == str) + return -1; + tm = parse_date1(str); + if (NULL == tm) { + tm = parse_date2(str); + if (NULL == tm) { + tm = parse_date3(str); + if (NULL == tm) return -1; - tm.tm_mday = make_num(s); - tm.tm_mon = make_month(s + 3); - tm.tm_year = (100 * make_num(s + 7) - 1900) + make_num(s + 9); - tm.tm_hour = make_num(s + 12); - tm.tm_min = make_num(s + 15); - tm.tm_sec = make_num(s + 18); - } - } else { /* Try the other format: */ - s = str; /* Wed Jun 9 01:29:59 1993 GMT */ - while (*s && *s == ' ') - s++; - if ((int) strlen(s) < 24) - return -1; - tm.tm_mday = make_num(s + 8); - tm.tm_mon = make_month(s + 4); - /* Y2K fix, richard.kettlewell@kewill.com */ - tm.tm_year = atoi(s + 20) - 1900; - tm.tm_hour = make_num(s + 11); - tm.tm_min = make_num(s + 14); - tm.tm_sec = make_num(s + 17); } - if (tm.tm_sec < 0 || tm.tm_sec > 59 || - tm.tm_min < 0 || tm.tm_min > 59 || - tm.tm_hour < 0 || tm.tm_hour > 23 || - tm.tm_mday < 1 || tm.tm_mday > 31 || - tm.tm_mon < 0 || tm.tm_mon > 11 || - tm.tm_year < 70 || tm.tm_year > 120) { - return -1; - } - tm.tm_isdst = -1; - + tm->tm_isdst = -1; #ifdef HAVE_TIMEGM - t = timegm(&tm); + t = timegm(tm); #elif HAVE_TM_GMTOFF - t = mktime(&tm); + t = mktime(tm); { struct tm *local = localtime(&t); t += local->tm_gmtoff; } #else /* some systems do not have tm_gmtoff so we fake it */ - t = mktime(&tm); + t = mktime(tm); { time_t dst = 0; #if defined (_TIMEZONE) @@ -194,7 +264,7 @@ parse_rfc1123(const char *str) * The following assumes a fixed DST offset of 1 hour, * which is probably wrong. */ - if (tm.tm_isdst > 0) + if (tm->tm_isdst > 0) dst = -3600; #ifdef _timezone t -= (_timezone + dst); Index: src/acl.c =================================================================== RCS file: /cvsroot/squid/squid/src/acl.c,v retrieving revision 1.1.1.3.4.3 diff -u -p -r1.1.1.3.4.3 acl.c --- src/acl.c 2000/12/31 05:24:17 1.1.1.3.4.3 +++ src/acl.c 2001/06/18 19:01:42 @@ -1006,7 +1006,7 @@ aclDecodeProxyAuth(const char *proxy_aut return 0; debug(28, 6) ("aclDecodeProxyAuth: header = '%s'\n", proxy_auth); if (strncasecmp(proxy_auth, "Basic ", 6) != 0) { - debug(28, 1) ("aclDecodeProxyAuth: Unsupported proxy-auth sheme, '%s'\n", proxy_auth); + debug(28, 1) ("aclDecodeProxyAuth: Unsupported proxy-auth scheme, '%s'\n", proxy_auth); return 0; } proxy_auth += 6; /* "Basic " */ Index: src/asn.c =================================================================== RCS file: /cvsroot/squid/squid/src/asn.c,v retrieving revision 1.1.1.3.4.2 diff -u -p -r1.1.1.3.4.2 asn.c --- src/asn.c 2000/05/22 11:00:39 1.1.1.3.4.2 +++ src/asn.c 2001/06/18 19:01:42 @@ -407,6 +407,8 @@ int mask_len(int mask) { int len = 32; + if (mask == 0) + return 0; while ((mask & 1) == 0) { len--; mask >>= 1; Index: src/cache_cf.c =================================================================== RCS file: /cvsroot/squid/squid/src/cache_cf.c,v retrieving revision 1.1.1.3.4.4 diff -u -p -r1.1.1.3.4.4 cache_cf.c --- src/cache_cf.c 2000/07/01 12:05:14 1.1.1.3.4.4 +++ src/cache_cf.c 2001/06/18 19:01:43 @@ -178,7 +178,7 @@ parseConfigFile(const char *file_name) char *token = NULL; char *tmp_line; int err_count = 0; - free_all(); + configFreeMemory(); default_all(); if ((fp = fopen(file_name, "r")) == NULL) fatalf("Unable to open configuration file: %s: %s", @@ -1735,6 +1735,7 @@ check_null_sockaddr_in_list(const sockad void configFreeMemory(void) { + safe_free(Config2.Accel.prefix); free_all(); } Index: src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid/src/cf.data.pre,v retrieving revision 1.1.1.3.4.3 diff -u -p -r1.1.1.3.4.3 cf.data.pre --- src/cf.data.pre 2000/07/01 12:05:14 1.1.1.3.4.3 +++ src/cf.data.pre 2001/06/18 19:01:45 @@ -3235,5 +3235,27 @@ DOC_START client_persistent_connections on server_persistent_connections on DOC_END + +NAME: ie_refresh +TYPE: onoff +LOC: Config.onoff.ie_refresh +DEFAULT: off +DOC_START + Microsoft Internet Explorer up until version 5.5 Service Pack 1 has + an issue with transparent proxies, wherein it is impossible to + force a refresh. Turning this on provides a partial fix to the + problem, by causing all IMS-REFRESH requests from older IE versions + to check the origin server for fresh content. This reduces hit + ratio by some amount (~10% in my experience), but allows users + to actually get fresh content when they want it. Note that because + Squid cannot tell if the user is using 5.5 or 5.5SP1, the behavior + of 5.5 is unchanged from old versions of Squid (i.e. a forced + refresh is impossible). Newer versions of IE will, hopefully, + continue to have the new behavior and will be handled based on that + assumption. This option defaults to the old Squid behavior, which + is better for hit ratios but worse for clients using IE, if they + need to be able to force fresh content. +ie_refresh off +DOC_END EOF Index: src/client_side.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side.c,v retrieving revision 1.1.1.3.4.6 diff -u -p -r1.1.1.3.4.6 client_side.c --- src/client_side.c 2000/10/21 14:44:59 1.1.1.3.4.6 +++ src/client_side.c 2001/06/18 19:01:46 @@ -761,9 +761,7 @@ clientInterpretRequestHeaders(clientHttp request_t *request = http->request; const HttpHeader *req_hdr = &request->header; int no_cache = 0; -#if USE_USERAGENT_LOG const char *str; -#endif request->imslen = -1; request->ims = httpHeaderGetTime(req_hdr, HDR_IF_MODIFIED_SINCE); if (request->ims > 0) @@ -778,6 +776,27 @@ clientInterpretRequestHeaders(clientHttp if (request->cache_control) if (EBIT_TEST(request->cache_control->mask, CC_NO_CACHE)) no_cache++; + /* Work around for supporting the Reload button in IE browsers + * when Squid is used as an accelerator or transparent proxy, + * by turning accelerated IMS request to no-cache requests. + * Now knows about IE 5.5 fix (is actually only fixed in SP1, + * but we can't tell whether we are talking to SP1 or not so + * all 5.5 versions are treated 'normally'). + */ + if (Config.onoff.ie_refresh) { + if (http->flags.accel && request->flags.ims) { + if ( (str = httpHeaderGetStr(req_hdr, HDR_USER_AGENT)) ) { + if (strstr(str, "MSIE 5.01") != NULL) + no_cache++; + else if (strstr(str, "MSIE 5.0") != NULL) + no_cache++; + else if (strstr(str, "MSIE 4.") != NULL) + no_cache++; + else if (strstr(str, "MSIE 3.") != NULL) + no_cache++; + } + } + } if (no_cache) { #if HTTP_VIOLATIONS if (Config.onoff.reload_into_ims) Index: src/main.c =================================================================== RCS file: /cvsroot/squid/squid/src/main.c,v retrieving revision 1.1.1.3.4.2 diff -u -p -r1.1.1.3.4.2 main.c --- src/main.c 2000/04/17 00:56:53 1.1.1.3.4.2 +++ src/main.c 2001/06/18 19:01:47 @@ -872,6 +872,7 @@ SquidShutdown(void *unused) #endif storeLogClose(); accessLogClose(); + useragentLogClose(); #if USE_ASYNC_IO aioSync(); /* flush log close */ #endif Index: src/protos.h =================================================================== RCS file: /cvsroot/squid/squid/src/protos.h,v retrieving revision 1.1.1.3.4.1 diff -u -p -r1.1.1.3.4.1 protos.h --- src/protos.h 2000/04/17 00:56:53 1.1.1.3.4.1 +++ src/protos.h 2001/06/18 19:01:48 @@ -950,6 +950,8 @@ extern void storeDirMapBitSet(int fn); extern void storeDirOpenSwapLogs(void); extern void storeDirSwapLog(const StoreEntry *, int op); extern void storeDirUpdateSwapSize(int fn, size_t size, int sign); +extern int storeDirGetBlkSize(const char *path, int *blksize); +extern int storeDirGetUFSStats(const char *, int *, int *, int *, int *); /* * store_dir_ufs.c @@ -1068,6 +1070,7 @@ extern char *urlHostname(const char *url extern void useragentOpenLog(void); extern void useragentRotateLog(void); extern void logUserAgent(const char *, const char *); +extern void useragentLogClose(void); extern peer_t parseNeighborType(const char *s); extern void errorInitialize(void); Index: src/snmp_core.c =================================================================== RCS file: /cvsroot/squid/squid/src/snmp_core.c,v retrieving revision 1.1.1.3.4.1 diff -u -p -r1.1.1.3.4.1 snmp_core.c --- src/snmp_core.c 2000/04/17 00:56:53 1.1.1.3.4.1 +++ src/snmp_core.c 2001/06/18 19:01:48 @@ -73,7 +73,6 @@ static oid_ParseFn *snmpTreeNext(oid * C static oid_ParseFn *snmpTreeGet(oid * Current, snint CurrentLen); static mib_tree_entry *snmpTreeEntry(oid entry, snint len, mib_tree_entry * current); static mib_tree_entry *snmpTreeSiblingEntry(oid entry, snint len, mib_tree_entry * current); -static oid *snmpOidDup(oid * A, snint ALen); static void snmpSnmplibDebug(int lvl, char *buf); @@ -503,7 +502,8 @@ snmpDecodePacket(snmp_request_t * rq) checklist.src_addr = rq->from.sin_addr; checklist.snmp_community = (char *) Community; - allow = aclCheckFast(Config.accessList.snmp, &checklist); + if (Community) + allow = aclCheckFast(Config.accessList.snmp, &checklist); if ((snmp_coexist_V2toV1(PDU)) && (Community) && (allow)) { rq->community = Community; rq->PDU = PDU; @@ -948,7 +948,7 @@ snmpAddNode(va_alist) va_start(args, children); entry = xmalloc(sizeof(mib_tree_entry)); - entry->name = snmpOidDup(name, len); + entry->name = name; entry->len = len; entry->parsefunction = parsefunction; entry->instancefunction = instancefunction; @@ -999,6 +999,7 @@ snmpCreateOid(va_alist) return (new_oid); } +#if UNUSED_CODE /* * Allocate space for, and copy, an OID. Returns new oid. */ @@ -1009,6 +1010,7 @@ snmpOidDup(oid * A, snint ALen) xmemcpy(Ans, A, (sizeof(oid) * ALen)); return Ans; } +#endif /* * Debug calls, prints out the OID for debugging purposes. Index: src/stat.c =================================================================== RCS file: /cvsroot/squid/squid/src/stat.c,v retrieving revision 1.1.1.3.4.1 diff -u -p -r1.1.1.3.4.1 stat.c --- src/stat.c 2000/04/17 00:56:53 1.1.1.3.4.1 +++ src/stat.c 2001/06/18 19:01:49 @@ -961,6 +961,7 @@ statCountersClean(StatCounters * C) statHistClean(&C->dns.svc_time); statHistClean(&C->cd.on_xition_count); statHistClean(&C->comm_icp_incoming); + statHistClean(&C->comm_dns_incoming); statHistClean(&C->comm_http_incoming); statHistClean(&C->select_fds_hist); } Index: src/store.c =================================================================== RCS file: /cvsroot/squid/squid/src/store.c,v retrieving revision 1.1.1.3.4.5 diff -u -p -r1.1.1.3.4.5 store.c --- src/store.c 2000/08/01 00:14:35 1.1.1.3.4.5 +++ src/store.c 2001/06/18 19:01:50 @@ -1290,11 +1290,14 @@ storeTimestampsSet(StoreEntry * entry) if (served_date < 0 || served_date > squid_curtime) served_date = squid_curtime; /* - * Compensate with Age header if origin server clock is ahead of us - * and there is a cache in between us and the origin server + * Compensate with Age header if origin server clock is ahead + * of us and there is a cache in between us and the origin + * server. But DONT compensate if the age value is larger than + * squid_curtime because it results in a negative served_date. */ if (age > squid_curtime - served_date) - served_date = squid_curtime - age; + if (squid_curtime > age) + served_date = squid_curtime - age; entry->expires = reply->expires; entry->lastmod = reply->last_modified; entry->timestamp = served_date; Index: src/store_dir.c =================================================================== RCS file: /cvsroot/squid/squid/src/store_dir.c,v retrieving revision 1.1.1.3.4.2 diff -u -p -r1.1.1.3.4.2 store_dir.c --- src/store_dir.c 2000/05/22 11:07:55 1.1.1.3.4.2 +++ src/store_dir.c 2001/06/18 19:01:50 @@ -35,6 +35,16 @@ #include "squid.h" +#if HAVE_STATVFS +#if HAVE_SYS_STATVFS_H +#include +#endif +#endif +/* Windows uses sys/vfs.h */ +#if HAVE_SYS_VFS_H +#include +#endif + const char *SwapDirType[] = { "ufs", @@ -275,7 +285,9 @@ void storeDirUpdateSwapSize(int fn, size_t size, int sign) { int dirn = (fn >> SWAP_DIR_SHIFT) % Config.cacheSwap.n_configured; - int k = ((size + 1023) >> 10) * sign; + SwapDir *sd = &Config.cacheSwap.swapDirs[dirn]; + int blks = (size + sd->fs.blksize - 1) / sd->fs.blksize; + int k = (blks * sd->fs.blksize >> 10) * sign; Config.cacheSwap.swapDirs[dirn].cur_size += k; store_swap_size += k; if (sign > 0) @@ -344,7 +356,8 @@ storeDirOpenSwapLogs(void) SwapDir *sd; for (dirn = 0; dirn < Config.cacheSwap.n_configured; dirn++) { sd = &Config.cacheSwap.swapDirs[dirn]; - sd->log.open(sd); + if (sd->log.open) + sd->log.open(sd); } } @@ -355,7 +368,8 @@ storeDirCloseSwapLogs(void) SwapDir *sd; for (dirn = 0; dirn < Config.cacheSwap.n_configured; dirn++) { sd = &Config.cacheSwap.swapDirs[dirn]; - sd->log.close(sd); + if (sd->log.close) + sd->log.close(sd); } } @@ -447,3 +461,54 @@ storeDirWriteCleanLogs(int reopen) return n; } #undef CLEAN_BUF_SZ + +int +storeDirGetBlkSize(const char *path, int *blksize) +{ +#if HAVE_STATVFS + struct statvfs sfs; + if (statvfs(path, &sfs)) { + debug(50, 1) ("%s: %s\n", path, xstrerror()); + return 1; + } + *blksize = (int) sfs.f_frsize; +#else + struct statfs sfs; + if (statfs(path, &sfs)) { + debug(50, 1) ("%s: %s\n", path, xstrerror()); + return 1; + } + *blksize = (int) sfs.f_bsize; +#endif + return 0; +} + +#define fsbtoblk(num, fsbs, bs) \ + (((fsbs) != 0 && (fsbs) < (bs)) ? \ + (num) / ((bs) / (fsbs)) : (num) * ((fsbs) / (bs))) +int +storeDirGetUFSStats(const char *path, int *totl_kb, int *free_kb, int *totl_in, int *free_in) +{ +#if HAVE_STATVFS + struct statvfs sfs; + if (statvfs(path, &sfs)) { + debug(50, 1) ("%s: %s\n", path, xstrerror()); + return 1; + } + *totl_kb = (int) fsbtoblk(sfs.f_blocks, sfs.f_frsize, 1024); + *free_kb = (int) fsbtoblk(sfs.f_bfree, sfs.f_frsize, 1024); + *totl_in = (int) sfs.f_files; + *free_in = (int) sfs.f_ffree; +#else + struct statfs sfs; + if (statfs(path, &sfs)) { + debug(50, 1) ("%s: %s\n", path, xstrerror()); + return 1; + } + *totl_kb = (int) fsbtoblk(sfs.f_blocks, sfs.f_bsize, 1024); + *free_kb = (int) fsbtoblk(sfs.f_bfree, sfs.f_bsize, 1024); + *totl_in = (int) sfs.f_files; + *free_in = (int) sfs.f_ffree; +#endif + return 0; +} Index: src/store_dir_ufs.c =================================================================== RCS file: /cvsroot/squid/squid/src/Attic/store_dir_ufs.c,v retrieving revision 1.1.1.1.4.1 diff -u -p -r1.1.1.1.4.1 store_dir_ufs.c --- src/store_dir_ufs.c 2000/04/17 00:56:53 1.1.1.1.4.1 +++ src/store_dir_ufs.c 2001/06/18 19:01:51 @@ -261,6 +261,7 @@ storeUfsDirInit(SwapDir * sd) eventAdd("storeDirClean", storeUfsDirCleanEvent, NULL, 15.0, 1); started_clean_event = 1; } + (void) storeDirGetBlkSize(sd->path, &sd->fs.blksize); } static void @@ -914,9 +915,9 @@ storeUfsDirWriteCleanClose(SwapDir * sd) #ifdef _SQUID_OS2_ 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); } @@ -1134,13 +1135,18 @@ storeUfsDirStats(StoreEntry * sentry) { int i; SwapDir *SD; -#if HAVE_STATVFS - struct statvfs sfs; -#endif + int totl_kb = 0; + int free_kb = 0; + int totl_in = 0; + int free_in = 0; + int x; + for (i = 0; i < Config.cacheSwap.n_configured; i++) { SD = &Config.cacheSwap.swapDirs[i]; storeAppendPrintf(sentry, "\n"); storeAppendPrintf(sentry, "Store Directory #%d: %s\n", i, SD->path); + storeAppendPrintf(sentry, "FS Block Size %d Bytes\n", + SD->fs.blksize); storeAppendPrintf(sentry, "First level subdirectories: %d\n", SD->u.ufs.l1); storeAppendPrintf(sentry, "Second level subdirectories: %d\n", SD->u.ufs.l2); storeAppendPrintf(sentry, "Maximum Size: %d KB\n", SD->max_size); @@ -1150,20 +1156,17 @@ storeUfsDirStats(StoreEntry * sentry) storeAppendPrintf(sentry, "Filemap bits in use: %d of %d (%d%%)\n", SD->map->n_files_in_map, SD->map->max_n_files, percent(SD->map->n_files_in_map, SD->map->max_n_files)); -#if HAVE_STATVFS -#define fsbtoblk(num, fsbs, bs) \ - (((fsbs) != 0 && (fsbs) < (bs)) ? \ - (num) / ((bs) / (fsbs)) : (num) * ((fsbs) / (bs))) - if (!statvfs(SD->path, &sfs)) { + x = storeDirGetUFSStats(SD->path, &totl_kb, &free_kb, &totl_in, &free_in); + if (0 == x) { storeAppendPrintf(sentry, "Filesystem Space in use: %d/%d KB (%d%%)\n", - fsbtoblk((sfs.f_blocks - sfs.f_bfree), sfs.f_frsize, 1024), - fsbtoblk(sfs.f_blocks, sfs.f_frsize, 1024), - percent(sfs.f_blocks - sfs.f_bfree, sfs.f_blocks)); + totl_kb - free_kb, + totl_kb, + percent(totl_kb - free_kb, totl_kb)); storeAppendPrintf(sentry, "Filesystem Inodes in use: %d/%d (%d%%)\n", - sfs.f_files - sfs.f_ffree, sfs.f_files, - percent(sfs.f_files - sfs.f_ffree, sfs.f_files)); + totl_in - free_in, + totl_in, + percent(totl_in - free_in, totl_in)); } -#endif storeAppendPrintf(sentry, "Flags:"); if (SD->flags.selected) storeAppendPrintf(sentry, " SELECTED"); Index: src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.1.1.3.4.2 diff -u -p -r1.1.1.3.4.2 structs.h --- src/structs.h 2000/04/17 00:56:54 1.1.1.3.4.2 +++ src/structs.h 2001/06/18 19:01:56 @@ -417,6 +417,7 @@ struct _SquidConfig { #if USE_CACHE_DIGESTS int digest_generation; #endif + int ie_refresh; } onoff; acl *aclList; struct { @@ -1350,6 +1351,9 @@ struct _SwapDir { void *state; } clean; } log; + struct { + int blksize; + } fs; union { struct { int l1; Index: src/useragent.c =================================================================== RCS file: /cvsroot/squid/squid/src/useragent.c,v retrieving revision 1.1.1.3.4.1 diff -u -p -r1.1.1.3.4.1 useragent.c --- src/useragent.c 2000/04/17 00:56:54 1.1.1.3.4.1 +++ src/useragent.c 2001/06/18 19:01:56 @@ -125,3 +125,13 @@ logUserAgent(const char *client, const c fflush(cache_useragent_log); #endif } + +void +useragentLogClose(void) +{ +#if USE_USERAGENT_LOG + if (cache_useragent_log) + fclose(cache_useragent_log); + cache_useragent_log = NULL; +#endif +}