--------------------- PatchSet 11856 Date: 2008/01/02 15:50:39 Author: hno Branch: SQUID_2_7 Tag: (none) Log: MFC: 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.66->1.66.2.1 src/cf.data.pre:1.450->1.450.2.1 src/net_db.c:1.176->1.176.2.1 src/structs.h:1.538.2.1->1.538.2.2 Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid/squid/src/Makefile.am,v retrieving revision 1.66 retrieving revision 1.66.2.1 diff -u -r1.66 -r1.66.2.1 --- squid/src/Makefile.am 23 Nov 2007 11:06:46 -0000 1.66 +++ squid/src/Makefile.am 2 Jan 2008 15:50:39 -0000 1.66.2.1 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.66 2007/11/23 11:06:46 hno Exp $ +# $Id: Makefile.am,v 1.66.2.1 2008/01/02 15:50:39 hno Exp $ # # Uncomment and customize the following to suit your needs: # @@ -345,6 +345,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)/'` @@ -403,6 +404,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: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid/src/cf.data.pre,v retrieving revision 1.450 retrieving revision 1.450.2.1 diff -u -r1.450 -r1.450.2.1 --- squid/src/cf.data.pre 20 Dec 2007 10:16:03 -0000 1.450 +++ squid/src/cf.data.pre 2 Jan 2008 15:50:39 -0000 1.450.2.1 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.450 2007/12/20 10:16:03 amosjeffries Exp $ +# $Id: cf.data.pre,v 1.450.2.1 2008/01/02 15:50:39 hno Exp $ # # SQUID Web Proxy Cache http://www.squid-cache.org/ # ---------------------------------------------------------- @@ -2463,6 +2463,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: squid/src/net_db.c =================================================================== RCS file: /cvsroot/squid/squid/src/net_db.c,v retrieving revision 1.176 retrieving revision 1.176.2.1 diff -u -r1.176 -r1.176.2.1 --- squid/src/net_db.c 23 Sep 2007 14:48:55 -0000 1.176 +++ squid/src/net_db.c 2 Jan 2008 15:50:39 -0000 1.176.2.1 @@ -1,6 +1,6 @@ /* - * $Id: net_db.c,v 1.176 2007/09/23 14:48:55 adrian Exp $ + * $Id: net_db.c,v 1.176.2.1 2008/01/02 15:50:39 hno Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -370,13 +370,13 @@ static void netdbSaveState(void *foo) { - LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN); Logfile *lf; netdbEntry *n; net_db_name *x; struct timeval start = current_time; int count = 0; - snprintf(path, SQUID_MAXPATHLEN, "%s/netdb_state", storeSwapDir(0)); + if (strcmp(Config.netdbFilename, "none") == 0) + return; /* * This was nicer when we were using stdio, but thanks to * Solaris bugs, its a bad idea. fopen can fail if more than @@ -386,10 +386,10 @@ * 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) { - debug(50, 1) ("netdbSaveState: %s: %s\n", path, xstrerror()); + debug(50, 1) ("netdbSaveState: %s: %s\n", Config.netdbFilename, xstrerror()); return; } hash_first(addr_table); @@ -420,7 +420,6 @@ static void netdbReloadState(void) { - LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN); char *buf; char *t; char *s; @@ -432,13 +431,16 @@ struct in_addr addr; int count = 0; struct timeval start = current_time; - snprintf(path, SQUID_MAXPATHLEN, "%s/netdb_state", storeSwapDir(0)); + + if (strcmp(Config.netdbFilename, "none") == 0) + return; + /* * 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; if (fstat(fd, &sb) < 0) { Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.538.2.1 retrieving revision 1.538.2.2 diff -u -r1.538.2.1 -r1.538.2.2 --- squid/src/structs.h 2 Jan 2008 15:49:31 -0000 1.538.2.1 +++ squid/src/structs.h 2 Jan 2008 15:50:39 -0000 1.538.2.2 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.538.2.1 2008/01/02 15:49:31 hno Exp $ + * $Id: structs.h,v 1.538.2.2 2008/01/02 15:50:39 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -580,6 +580,7 @@ int appendDomainLen; char *debugOptions; char *pidFilename; + char *netdbFilename; char *mimeTablePathname; char *etcHostsPath; char *visibleHostname;