--------------------- PatchSet 11282 Date: 2007/12/27 14:55:47 Author: Henrik Nordstrom Branch: HEAD Tag: (none) Log: netdb_filename directive to specify location of netdb state file was hardcoded to use the first cache_dir. This moves the default location to the logs directory and may be overridden at compile time by setting DEFAULT_NETDB_FILE Members: src/Makefile.am:1.195->1.196 src/cf.data.pre:1.489->1.490 src/net_db.cc:1.199->1.200 src/structs.h:1.570->1.571 Index: squid3/src/Makefile.am =================================================================== RCS file: /cvsroot/squid/squid3/src/Makefile.am,v retrieving revision 1.195 retrieving revision 1.196 diff -u -r1.195 -r1.196 --- squid3/src/Makefile.am 26 Dec 2007 22:33:31 -0000 1.195 +++ squid3/src/Makefile.am 27 Dec 2007 14:55:47 -0000 1.196 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.195 2007/12/26 22:33:31 hno Exp $ +# $Id: Makefile.am,v 1.196 2007/12/27 14:55:47 hno Exp $ # # Uncomment and customize the following to suit your needs: # @@ -1014,6 +1014,7 @@ DEFAULT_ACCESS_LOG = $(DEFAULT_LOG_PREFIX)/access.log DEFAULT_STORE_LOG = $(DEFAULT_LOG_PREFIX)/store.log DEFAULT_PID_FILE = $(DEFAULT_LOG_PREFIX)/squid.pid +DEFAULT_NETDB_FILE = $(DEFAULT_LOG_PREFIX)/netdb.state DEFAULT_SWAP_DIR = $(localstatedir)/cache DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'` DEFAULT_UNLINKD = $(libexecdir)/`echo unlinkd | sed '$(transform);s/$$/$(EXEEXT)/'` @@ -1071,6 +1072,7 @@ s%@DEFAULT_ACCESS_LOG@%$(DEFAULT_ACCESS_LOG)%g;\ s%@DEFAULT_STORE_LOG@%$(DEFAULT_STORE_LOG)%g;\ s%@DEFAULT_PID_FILE@%$(DEFAULT_PID_FILE)%g;\ + s%@DEFAULT_NETDB_FILE@%$(DEFAULT_NETDB_FILE)%g;\ s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g;\ s%@DEFAULT_ICON_DIR@%$(DEFAULT_ICON_DIR)%g;\ s%@DEFAULT_MIB_PATH@%$(DEFAULT_MIB_PATH)%g;\ Index: squid3/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid3/src/cf.data.pre,v retrieving revision 1.489 retrieving revision 1.490 diff -u -r1.489 -r1.490 --- squid3/src/cf.data.pre 14 Dec 2007 23:11:46 -0000 1.489 +++ squid3/src/cf.data.pre 27 Dec 2007 14:55:47 -0000 1.490 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.489 2007/12/14 23:11:46 amosjeffries Exp $ +# $Id: cf.data.pre,v 1.490 2007/12/27 14:55:47 hno Exp $ # # SQUID Web Proxy Cache http://www.squid-cache.org/ # ---------------------------------------------------------- @@ -2274,6 +2274,15 @@ enabled in which case performance will suffer badly anyway..). DOC_END +NAME: netdb_filename +TYPE: string +DEFAULT: @DEFAULT_NETDB_FILE@ +LOC: Config.netdbFilename +DOC_START + A filename where Squid stores it's netdb state between restarts. + To disable, enter "none". +DOC_END + COMMENT_START OPTIONS FOR FTP GATEWAYING ----------------------------------------------------------------------------- Index: squid3/src/net_db.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/net_db.cc,v retrieving revision 1.199 retrieving revision 1.200 diff -u -r1.199 -r1.200 --- squid3/src/net_db.cc 14 Dec 2007 23:11:47 -0000 1.199 +++ squid3/src/net_db.cc 27 Dec 2007 14:55:47 -0000 1.200 @@ -1,5 +1,5 @@ /* - * $Id: net_db.cc,v 1.199 2007/12/14 23:11:47 amosjeffries Exp $ + * $Id: net_db.cc,v 1.200 2007/12/27 14:55:47 hno Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -464,27 +464,17 @@ } static void -netdbPath(char *path) -{ - /* this is completely wrong. the netdb location should be memoised - * separately from the cache dirs, and also be settable in - * squid.conf RBC 20041225 - */ - snprintf(path, SQUID_MAXPATHLEN, "%s/netdb_state", - dynamic_cast(Config.cacheSwap.swapDirs[0].getRaw())->path); -} - -static void netdbSaveState(void *foo) { - LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN); + if (strcmp(config.netdbFilename, "none") == 0) + return; + Logfile *lf; netdbEntry *n; net_db_name *x; struct timeval start = current_time; int count = 0; - netdbPath(path); /* * This was nicer when we were using stdio, but thanks to * Solaris bugs, its a bad idea. fopen can fail if more than @@ -494,8 +484,8 @@ * unlink() is here because there is currently no way to make * logfileOpen() use O_TRUNC. */ - unlink(path); - lf = logfileOpen(path, 4096, 0); + unlink(Config.netdbFilename); + lf = logfileOpen(Config.netdbFilename, 4096, 0); if (NULL == lf) { debugs(50, 1, "netdbSaveState: " << path << ": " << xstrerror()); @@ -539,7 +529,9 @@ static void netdbReloadState(void) { - LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN); + if (strcmp(config.netdbFilename, "none") == 0) + return; + char *s; int fd; int l; @@ -552,13 +544,12 @@ int count = 0; struct timeval start = current_time; - netdbPath(path); /* * This was nicer when we were using stdio, but thanks to * Solaris bugs, its a bad idea. fopen can fail if more than * 256 FDs are open. */ - fd = file_open(path, O_RDONLY | O_BINARY); + fd = file_open(Config.netdbFilename, O_RDONLY | O_BINARY); if (fd < 0) return; Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid3/src/structs.h,v retrieving revision 1.570 retrieving revision 1.571 diff -u -r1.570 -r1.571 --- squid3/src/structs.h 26 Dec 2007 23:39:55 -0000 1.570 +++ squid3/src/structs.h 27 Dec 2007 14:55:47 -0000 1.571 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.570 2007/12/26 23:39:55 hno Exp $ + * $Id: structs.h,v 1.571 2007/12/27 14:55:47 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -407,6 +407,7 @@ size_t appendDomainLen; char *debugOptions; char *pidFilename; + char *netdbFilename; char *mimeTablePathname; char *etcHostsPath; char *visibleHostname;