changeset 18:041ea016b684

add scanning for bare hostnames
author carl
date Fri, 30 Apr 2004 00:32:44 -0700
parents b6a4b72bb96e
children b8f5fa3dd5b8
files src/dnsbl.cpp src/scanner.cpp
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/dnsbl.cpp	Thu Apr 29 22:05:03 2004 -0700
+++ b/src/dnsbl.cpp	Fri Apr 30 00:32:44 2004 -0700
@@ -150,6 +150,7 @@
 }
 
 static bool debug_syslog = false;
+static bool loader_run   = true;    // used to stop the config loader thread
 static string_set all_strings;      // owns all the strings, only modified by the config loader thread
 static CONFIG * config = NULL;      // protected by the config_mutex
 
@@ -973,8 +974,9 @@
 static void* config_loader(void *arg) {
     typedef set<CONFIG *> configp_set;
     configp_set old_configs;
-    while (true) {
+    while (loader_run) {
         sleep(180);  // look for modifications every 3 minutes
+        if (!loader_run) break;
         CONFIG &dc = *config;
         time_t then = dc.load_time;
         struct stat st;
@@ -1004,6 +1006,7 @@
             else i++;
         }
     }
+    return NULL;
 }
 
 
@@ -1118,6 +1121,13 @@
         fclose(f);
     }
 
-    return smfi_main();
+    time_t starting = time(NULL);
+    int rc = smfi_main();
+    if (time(NULL) > starting+5*60) {
+        my_syslog("trying to restart after smfi_main()");
+        loader_run = false;     // eventually the config loader thread will terminate
+        execvp(argv[0], argv);
+    }
+    exit((rc == MI_SUCCESS) ? 0 : EX_UNAVAILABLE);
 }
 
--- a/src/scanner.cpp	Thu Apr 29 22:05:03 2004 -0700
+++ b/src/scanner.cpp	Fri Apr 30 00:32:44 2004 -0700
@@ -881,8 +881,7 @@
             //////////////////////////////
             //  host name recognizer
             case h_end: {
-                count--;
-                pending[count] = 0;
+                pending[--count] = '\0';  // null terminate host name by overwriting the terminator
                 char *tld;
                 for (int i=0; (tld = tlds[i]); i++) {
                     int n = strlen(tld);
@@ -900,13 +899,13 @@
                 } break;
 
             //////////////////////////////
-            //  html tag { discarder
-            case t_end:
+            //  html tag discarder
+            case t_end: {
                 st = t_init;
-                // fall thru
+                } // fall thru
 
             case t_disc: {
-                    count = 0;
+                count = 0;  // discard all characters
                 } break;
 
             case t_init: {