This simple patch adds a clean_schedule option to the squid.conf to
force a full garbage collection at a scheduled time.
I think it may help preventing the cache from becoming very slow each time
the disk gets full and the clean routines start.
I've specified a clean_schedule 04:00 in my squid.conf so that older
objects are cleaned up during the night at 4am (the format is 24h). The
default clean rate is one day but you can also change it using the old
clean_rate option.
Nico.
-- Nico Tranquilli CINECA - Interuniversity Computing Centre Networks and Distributed Systems group phone: +39 (51) 6171519 email: nico@cineca.it --- cut here --- cut here --- *** src/cache_cf.c Fri Mar 28 21:28:11 1997 --- patched/cache_cf.c Tue Apr 1 16:45:04 1997 *************** *** 129,134 **** --- 129,135 ---- #define DefaultLifetimeShutdown 30 /* 30 seconds */ #define DefaultConnectTimeout (2 * 60) /* 2 min */ #define DefaultCleanRate -1 /* disabled */ + #define DefaultCleanSchedule -1 /* disabled */ #define DefaultDnsChildren 5 /* 5 processes */ #define DefaultOptionsResDefnames 0 /* default off */ #define DefaultOptionsAnonymizer 0 /* default off */ *************** *** 262,267 **** --- 263,269 ---- static void parseVisibleHostnameLine _PARAMS((void)); static void parseWAISRelayLine _PARAMS((void)); static void parseMinutesLine _PARAMS((int *)); + static void parse24HoursLine _PARAMS((time_t *)); static void ip_acl_destroy _PARAMS((ip_acl **)); static void parseCachemgrPasswd _PARAMS((void)); static void parsePathname _PARAMS((char **)); *************** *** 636,641 **** --- 638,661 ---- } static void + parse24HoursLine(time_t *sct) + { + char *m; + char *token; + + token = strtok(NULL, w_space); + if (token == NULL) + self_destruct(); + m=strchr(token,':'); + if (m) { + *m=0; + m++; + } + *sct = (time_t)atoi(token)*3600+atoi(m)*60; + } + + + static void parseKilobytes(int *val) { char *token; *************** *** 1213,1218 **** --- 1233,1241 ---- parseMinutesLine(&Config.readTimeout); else if (!strcmp(token, "clean_rate")) parseMinutesLine(&Config.cleanRate); + else if (!strcmp(token, "clean_schedule")) + parse24HoursLine(&Config.cleanSchedule); + else if (!strcmp(token, "client_lifetime")) parseMinutesLine(&Config.lifetimeDefault); else if (!strcmp(token, "reference_age")) *************** *** 1432,1439 **** printf(" Change your configuration file.\n"); fflush(stdout); /* print message */ } ! if (Config.cleanRate < 1) ! Config.cleanRate = 86400 * 365; /* one year */ if (Config.Announce.rate < 1) { Config.Announce.rate = 86400 * 365; /* one year */ Config.Announce.on = 0; --- 1455,1464 ---- printf(" Change your configuration file.\n"); fflush(stdout); /* print message */ } ! if (Config.cleanRate < 1 && Config.cleanSchedule<1 ) ! Config.cleanRate = 86400 * 365; /* one year */ ! if (Config.cleanRate < 1 && Config.cleanSchedule>1 ) ! Config.cleanRate = 86400; /* one day */ if (Config.Announce.rate < 1) { Config.Announce.rate = 86400 * 365; /* one year */ Config.Announce.on = 0; *************** *** 1546,1551 **** --- 1571,1577 ---- Config.maxRequestSize = DefaultMaxRequestSize; Config.connectTimeout = DefaultConnectTimeout; Config.cleanRate = DefaultCleanRate; + Config.cleanSchedule = DefaultCleanSchedule; Config.dnsChildren = DefaultDnsChildren; Config.redirectChildren = DefaultRedirectChildren; Config.sourcePing = DefaultSourcePing; *** src/cache_cf.h Fri Mar 28 21:28:12 1997 --- patched/cache_cf.h Tue Apr 1 16:46:32 1997 *************** *** 161,166 **** --- 161,167 ---- int lifetimeShutdown; int connectTimeout; int cleanRate; + time_t cleanSchedule; int maxRequestSize; struct { u_short http; *** src/event.c Mon Mar 3 02:43:22 1997 --- patched/event.c Tue Apr 1 16:46:06 1997 *************** *** 51,57 **** event->arg = arg; event->name = name; event->when = squid_curtime + when; ! debug(41, 3, "eventAdd: Adding '%s', in %d seconds\n", name, when); /* Insert after the last event with the same or earlier time */ for (E = &tasks; *E; E = &(*E)->next) { if ((*E)->when > event->when) --- 51,57 ---- event->arg = arg; event->name = name; event->when = squid_curtime + when; ! debug(41, 3, "eventAdd: Adding '%s', in %ld seconds\n", name, when); /* Insert after the last event with the same or earlier time */ for (E = &tasks; *E; E = &(*E)->next) { if ((*E)->when > event->when) *** src/main.c Sat Mar 29 00:25:36 1997 --- patched/main.c Tue Apr 1 16:51:23 1997 *************** *** 604,610 **** debug(1, 0, "Ready to serve requests.\n"); if (first_time) { ! eventAdd("storePurgeOld", storePurgeOld, NULL, Config.cleanRate); eventAdd("storeMaintain", storeMaintainSwapSpace, NULL, 1); eventAdd("storeDirClean", storeDirClean, NULL, 15); if (Config.Announce.on) --- 604,621 ---- debug(1, 0, "Ready to serve requests.\n"); if (first_time) { ! if (Config.cleanSchedule>0) { ! struct tm *curtime; ! time_t nnow; ! nnow=time(NULL); ! curtime=localtime(&nnow); ! nnow=curtime->tm_sec+curtime->tm_min*60+curtime->tm_hour*60*60; ! nnow=Config.cleanSchedule-nnow; ! if (nnow<0) ! nnow+=24*60*60; ! eventAdd("storePurgeOld", storePurgeOld, NULL, nnow); ! } else ! eventAdd("storePurgeOld", storePurgeOld, NULL, Config.cleanRate); eventAdd("storeMaintain", storeMaintainSwapSpace, NULL, 1); eventAdd("storeDirClean", storeDirClean, NULL, 15); if (Config.Announce.on)Received on Tue Apr 01 1997 - 10:29:31 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:34:55 MST