- Added options::negcache_rebuild configuration option
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Wed, 7 Jan 2015 18:01:01 +0000 (18:01 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Wed, 7 Jan 2015 18:01:01 +0000 (18:01 +0000)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@5332 82007160-df01-0410-b94d-b575c5fd34c7

doc/reference.conf
src/config-lexer.l
src/config-parser.y
src/config.c
src/config.h
src/options.h
src/scan.c

index 724f52cf0aab650dd93eb4b56309432075396c38..754d2675f8bd9b790adaf5c739d24262b93a61c1 100644 (file)
@@ -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.
index 0d51e6a58d573ef5a40097a800c79232adcaed3e..b7a4ba64f6f2552332674cf6070d5199e02c7a89 100644 (file)
@@ -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;         }
index 2f7ae5c5fb5fa60df2bddaace4e33c121bda068b..67c67e513e1a3e6bd255d8e584ff334eb5b0a90d 100644 (file)
@@ -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);
index f89686e21d270d218925ca39b2b4d5329bd56fa7..423d00aeea2acd96f656e6fc00fe17f9b9c23b65 100644 (file)
@@ -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;
index 5e56b814182ff4707967cae6c734be526198d821..b3a7ab4cd1a5192204b2777ab8555a2f27f323c2 100644 (file)
@@ -43,6 +43,7 @@ struct ChannelConf
 struct OptionsConf
 {
   int negcache;
+  time_t negcache_rebuild;
   unsigned int dns_fdlimit;
   char *pidfile;
   char *scanlog;
index 67425e0003121804f18777d0c67e6bf5167e4dcf..7d11bef36e595548acf4c1d23683251cdc869a19 100644 (file)
 
 /* 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 */
index 6eabd6eca063d3373307910b0dd9a90c6a1f2bd4..b3d3a5b0704e7627b1f306c5323d0f53f3cdf067 100644 (file)
@@ -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");