Squid-2.2.STABLE4: dns_restart option to keep dnsserver in bay Adds dns_restart option to have dnsservers periodically restart themselves to purge memory. This is to work around apparent leaks in dnsserver (or the resolver librarby). dnsserver processes has seen growing from a few MB up to 50MB in size. Index: squid/src/cf.data.pre diff -u squid/src/cf.data.pre:1.1.1.38.2.7 squid/src/cf.data.pre:1.1.1.38.2.8 --- squid/src/cf.data.pre:1.1.1.38.2.7 Sun Aug 1 17:44:26 1999 +++ squid/src/cf.data.pre Mon Aug 2 22:27:13 1999 @@ -872,6 +872,18 @@ dns_children 5 DOC_END +NAME: dns_restart +TYPE: int +DEFAULT: 0 +LOC: Config.dnsRestart +DOC_START + dnsserver (or perhaps the resolver library) seems to be leaking + memory. This option can be used to make the dnsserver slave processes + restart every now and then (restarts after N requests). + The default is 0 to disable restarts. + +dns_restart 0 +DOC_END NAME: dns_defnames COMMENT: on|off Index: squid/src/dns.c diff -u squid/src/dns.c:1.1.1.21.2.1 squid/src/dns.c:1.1.1.21.2.2 --- squid/src/dns.c:1.1.1.21.2.1 Tue Jul 13 00:40:00 1999 +++ squid/src/dns.c Mon Aug 2 22:27:14 1999 @@ -48,6 +48,7 @@ dnsInit(void) { static int init = 0; + static char restart_freq[256]; wordlist *w; if (!Config.Program.dnsserver) return; @@ -62,6 +63,11 @@ for (w = Config.dns_nameservers; w != NULL; w = w->next) { wordlistAdd(&dnsservers->cmdline, "-s"); wordlistAdd(&dnsservers->cmdline, w->key); + } + if (Config.dnsRestart) { + wordlistAdd(&dnsservers->cmdline, "-n"); + snprintf(restart_freq, 256, "%d", Config.dnsRestart); + wordlistAdd(&dnsservers->cmdline, restart_freq); } helperOpenServers(dnsservers); if (!init) { Index: squid/src/dnsserver.c diff -u squid/src/dnsserver.c:1.1.1.15 squid/src/dnsserver.c:1.1.1.15.24.1 --- squid/src/dnsserver.c:1.1.1.15 Sun Jan 24 09:34:09 1999 +++ squid/src/dnsserver.c Mon Aug 2 22:27:14 1999 @@ -260,6 +260,8 @@ char *t = NULL; int c; int opt_s = 0; + int req_num = 0; + int max_req = 0; extern char *optarg; safe_inet_addr("255.255.255.255", &no_addr); @@ -277,7 +279,7 @@ #endif #endif - while ((c = getopt(argc, argv, "Dhs:v")) != -1) { + while ((c = getopt(argc, argv, "Dhs:vn:")) != -1) { switch (c) { case 'D': #ifdef RES_DEFNAMES @@ -325,6 +327,9 @@ printf("dnsserver version %s\n", SQUID_VERSION); exit(0); break; + case 'n': + max_req = atoi(optarg); + break; case 'h': default: usage(); @@ -333,7 +338,7 @@ } } - for (;;) { + for (req_num = 0 ; req_num < max_req || max_req == 0; req_num++) { memset(request, '\0', REQ_SZ); if (fgets(request, REQ_SZ, stdin) == NULL) exit(1); @@ -346,6 +351,7 @@ lookup(request); fflush(stdout); } - /* NOTREACHED */ - return 0; + execv(argv[0], argv); + /* NOT REACHED */ + return(-1); } Index: squid/src/helper.c diff -u squid/src/helper.c:1.1.1.6.2.1 squid/src/helper.c:1.1.1.6.2.2 --- squid/src/helper.c:1.1.1.6.2.1 Sun Aug 1 18:13:01 1999 +++ squid/src/helper.c Mon Aug 2 22:27:14 1999 @@ -18,7 +18,7 @@ char *s; char *progname; char *shortname; - char *procname; + char *procname = NULL; char *args[HELPER_MAX_ARGS]; char fd_note_buf[FD_DESC_SZ]; helper_server *srv; @@ -37,9 +37,13 @@ shortname = xstrdup(progname); debug(29, 1) ("helperOpenServers: Starting %d '%s' processes\n", hlp->n_to_start, shortname); +#if 0 /* dns_restarts requires dnsserver to know it's full pathname */ procname = xmalloc(strlen(shortname) + 3); snprintf(procname, strlen(shortname) + 3, "(%s)", shortname); args[nargs++] = procname; +#else + args[nargs++] = progname; +#endif for (w = hlp->cmdline->next; w && nargs < HELPER_MAX_ARGS; w = w->next) args[nargs++] = w->key; args[nargs++] = NULL; Index: squid/src/structs.h diff -u squid/src/structs.h:1.1.1.39.2.11 squid/src/structs.h:1.1.1.39.2.12 --- squid/src/structs.h:1.1.1.39.2.11 Tue Jul 27 19:34:38 1999 +++ squid/src/structs.h Mon Aug 2 22:27:14 1999 @@ -296,6 +296,7 @@ char *unlinkd; } Program; int dnsChildren; + int dnsRestart; int redirectChildren; int authenticateChildren; int authenticateTTL;