From: wessels <> Date: Sat, 16 Nov 1996 14:07:07 +0000 (+0000) Subject: make netdb params configurable X-Git-Tag: SQUID_3_0_PRE1~5453 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0f4739d1ab515aaa7dfc6da89ace03e950007fa;p=thirdparty%2Fsquid.git make netdb params configurable --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 95ba0af71e..dc504518f8 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,5 +1,5 @@ /* - * $Id: cache_cf.cc,v 1.139 1996/11/15 07:51:05 wessels Exp $ + * $Id: cache_cf.cc,v 1.140 1996/11/16 07:07:07 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -113,6 +113,8 @@ struct SquidConfig Config; #define DefaultSwapMaxSize (100 << 10) /* 100 MB (100*1024 kbytes) */ #define DefaultSwapHighWaterMark 90 /* 90% */ #define DefaultSwapLowWaterMark 75 /* 75% */ +#define DefaultNetdbHigh 1000 /* counts, not percents */ +#define DefaultNetdbLow 900 #define DefaultWaisRelayHost (char *)NULL #define DefaultWaisRelayPort 0 @@ -1349,6 +1351,13 @@ parseConfigFile(const char *file_name) else if (!strcmp(token, "swap_level2_dirs")) parseIntegerValue(&Config.levelTwoDirs); + else if (!strcmp(token, "netdb_high")) + parseIntegerValue(&Config.Netdb.high); + else if (!strcmp(token, "netdb_low")) + parseIntegerValue(&Config.Netdb.low); + else if (!strcmp(token, "netdb_ttl")) + parseIntegerValue(&Config.Netdb.ttl); + /* If unknown, treat as a comment line */ else { debug(3, 0, "parseConfigFile: line %d unrecognized: '%s'\n", @@ -1462,6 +1471,8 @@ configSetFactoryDefaults(void) Config.Swap.maxSize = DefaultSwapMaxSize; Config.Swap.highWaterMark = DefaultSwapHighWaterMark; Config.Swap.lowWaterMark = DefaultSwapLowWaterMark; + Config.Netdb.high = DefaultNetdbHigh; + Config.Netdb.low = DefaultNetdbLow; Config.Wais.relayHost = safe_xstrdup(DefaultWaisRelayHost); Config.Wais.relayPort = DefaultWaisRelayPort; diff --git a/src/net_db.cc b/src/net_db.cc index eea9745fd4..7961047948 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -3,11 +3,6 @@ #if USE_ICMP -#define NET_DB_TTL 300 - -#define NETDB_LOW_MARK 900 -#define NETDB_HIGH_MARK 1000 - static HashID addr_table; static HashID host_table; @@ -136,7 +131,7 @@ netdbPurgeLRU(void) sizeof(netdbEntry *), (QS) netdbLRU); for (k = 0; k < list_count; k++) { - if (meta_data.netdb_addrs < NETDB_LOW_MARK) + if (meta_data.netdb_addrs < Config.Netdb.low) break; netdbRelease(*(list + k)); removed++; @@ -155,7 +150,7 @@ static netdbEntry * netdbAdd(struct in_addr addr, const char *hostname) { netdbEntry *n; - if (meta_data.netdb_addrs > NETDB_HIGH_MARK) + if (meta_data.netdb_addrs > Config.Netdb.high) netdbPurgeLRU(); if ((n = netdbLookupAddr(addr)) == NULL) { n = xcalloc(1, sizeof(netdbEntry)); @@ -181,7 +176,7 @@ netdbSendPing(int fdunused, const ipcache_addrs * ia, void *data) debug(37, 3, "netdbSendPing: pinging %s\n", hostname); icmpDomainPing(addr, hostname); n->pings_sent++; - n->next_ping_time = squid_curtime + NET_DB_TTL; + n->next_ping_time = squid_curtime + Config.Netdb.ttl; n->last_use_time = squid_curtime; xfree(hostname); }