Periodically rebuild the negcache (if enabled) to remove entries
that are too old. Note that even though this might only happen
every 12 hours or so, old entries are ignored by nc_search()
anyway. This is just to free up some memory.
#include "opercmd.h"
#include "scan.h"
#include "stats.h"
+#include "negcache.h"
#include "options.h"
extern string_list *CONF_SCAN_WARNING;
+extern unsigned int CONF_NEG_CACHE;
+extern struct cnode *nc_head;
static RETSIGTYPE do_signal(int signum);
char spid[16];
pid_t pid;
int c, lenc, lenl, lenp;
+ unsigned int nc_counter;
FILE *pidout;
+ nc_counter = 0;
+
do_stats_init();
do_scan_init();
fclose(pidout);
}
+ /* Initialise negative cache */
+ if (CONF_NEG_CACHE)
+ nc_init(&nc_head);
+
if (CONF_SCAN_WARNING)
do_scanwarn_init();
scanwarn_timer();
scan_timer();
ALARMED = 0;
+
+ if (CONF_NEG_CACHE) {
+ if (nc_counter++ >= NEG_CACHE_REBUILD) {
+ /*
+ * Time to rebuild the negative
+ * cache.
+ */
+ negcache_rebuild();
+ nc_counter = 0;
+ }
+ }
}
}