From 61eae9834a60a30a75e93ca1897f83e3a1ff65d2 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 7 Jan 2015 18:01:01 +0000 Subject: [PATCH] - Added options::negcache_rebuild configuration option git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@5332 82007160-df01-0410-b94d-b575c5fd34c7 --- doc/reference.conf | 8 ++++++++ src/config-lexer.l | 1 + src/config-parser.y | 7 +++++++ src/config.c | 1 + src/config.h | 1 + src/options.h | 7 ------- src/scan.c | 7 +++---- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/doc/reference.conf b/doc/reference.conf index 724f52c..754d267 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -42,6 +42,14 @@ options { */ # negcache = 1 hour; + /* + * How long between rebuilds of the negative cache. The negcache + * is only rebuilt to free up memory used by entries that are too old. + * You probably don't need to tweak this unless you have huge amounts + * of people connecting (hundreds per minute). Default is 12 hours. + */ + negcache_rebuild = 12 hours; + /* * Amount of file descriptors to allocate to asynchronous DNS. 64 * should be plenty for almost anyone. diff --git a/src/config-lexer.l b/src/config-lexer.l index 0d51e6a..b7a4ba6 100644 --- a/src/config-lexer.l +++ b/src/config-lexer.l @@ -112,6 +112,7 @@ MAX_READ { return MAX_READ; } MODE { return MODE; } NAME { return NAME; } NEGCACHE { return NEGCACHE; } +NEGCACHE_REBUILD { return NEGCACHE_REBUILD; } NICK { return NICK; } NICKSERV { return NICKSERV; } OPER { return OPER; } diff --git a/src/config-parser.y b/src/config-parser.y index 2f7ae5c..67c67e5 100644 --- a/src/config-parser.y +++ b/src/config-parser.y @@ -55,6 +55,7 @@ void *tmp; /* Variable to temporarily hold nodes before insertion to list %token MODE %token NAME %token NEGCACHE +%token NEGCACHE_REBUILD %token NICK %token NICKSERV %token OPER @@ -135,6 +136,7 @@ options_items: options_items options_item | options_item; options_item: options_negcache | + options_negcache_rebuild | options_pidfile | options_dns_fdlimit | options_scanlog | @@ -145,6 +147,11 @@ options_negcache: NEGCACHE '=' timespec ';' OptionsItem->negcache = $3; }; +options_negcache_rebuild: NEGCACHE_REBUILD '=' timespec ';' +{ + OptionsItem->negcache_rebuild = $3; +}; + options_pidfile: PIDFILE '=' STRING ';' { MyFree(OptionsItem->pidfile); diff --git a/src/config.c b/src/config.c index f89686e..423d00a 100644 --- a/src/config.c +++ b/src/config.c @@ -92,6 +92,7 @@ config_setup(void) /* Setup options block defaults */ OptionsItem->negcache = 0; /* 0 disabled negcache */ + OptionsItem->negcache_rebuild = 43200; OptionsItem->pidfile = xstrdup("hopm.pid"); OptionsItem->dns_fdlimit = 50; OptionsItem->scanlog = NULL; diff --git a/src/config.h b/src/config.h index 5e56b81..b3a7ab4 100644 --- a/src/config.h +++ b/src/config.h @@ -43,6 +43,7 @@ struct ChannelConf struct OptionsConf { int negcache; + time_t negcache_rebuild; unsigned int dns_fdlimit; char *pidfile; char *scanlog; diff --git a/src/options.h b/src/options.h index 67425e0..7d11bef 100644 --- a/src/options.h +++ b/src/options.h @@ -25,11 +25,4 @@ /* Interval in how often we try to reconnect (in seconds) */ #define RECONNECTINTERVAL 30 - -/* How long (in seconds) between rebuilds of the negative cache. The negcache - * is only rebuilt to free up memory used by entries that are too old. You - * probably don't need to tweak this unless you have huge amounts of people - * connecting (hundreds per minute). Default is 12 hours. - */ -#define NEG_CACHE_REBUILD (60 * 60 * 12) #endif /* OPTIONS_H */ diff --git a/src/scan.c b/src/scan.c index 6eabd6e..b3d3a5b 100644 --- a/src/scan.c +++ b/src/scan.c @@ -113,15 +113,14 @@ scan_cycle(void) void scan_timer(void) { - static unsigned int nc_counter; + static time_t nc_counter; if (OptionsItem->negcache > 0) { - if (nc_counter++ >= NEG_CACHE_REBUILD) + if (nc_counter++ >= OptionsItem->negcache_rebuild) { /* - * Time to rebuild the negative - * cache. + * Time to rebuild the negative cache. */ if (OPT_DEBUG) log_printf("SCAN -> Rebuilding negative cache"); -- 2.30.2