comparison src/dnsbl.cpp @ 18:041ea016b684

add scanning for bare hostnames
author carl
date Fri, 30 Apr 2004 00:32:44 -0700
parents 2ae8d953f1d0
children c21b888cc175
comparison
equal deleted inserted replaced
17:b6a4b72bb96e 18:041ea016b684
148 delete d; 148 delete d;
149 } 149 }
150 } 150 }
151 151
152 static bool debug_syslog = false; 152 static bool debug_syslog = false;
153 static bool loader_run = true; // used to stop the config loader thread
153 static string_set all_strings; // owns all the strings, only modified by the config loader thread 154 static string_set all_strings; // owns all the strings, only modified by the config loader thread
154 static CONFIG * config = NULL; // protected by the config_mutex 155 static CONFIG * config = NULL; // protected by the config_mutex
155 156
156 static pthread_mutex_t config_mutex; 157 static pthread_mutex_t config_mutex;
157 static pthread_mutex_t syslog_mutex; 158 static pthread_mutex_t syslog_mutex;
971 // 972 //
972 static void* config_loader(void *arg); 973 static void* config_loader(void *arg);
973 static void* config_loader(void *arg) { 974 static void* config_loader(void *arg) {
974 typedef set<CONFIG *> configp_set; 975 typedef set<CONFIG *> configp_set;
975 configp_set old_configs; 976 configp_set old_configs;
976 while (true) { 977 while (loader_run) {
977 sleep(180); // look for modifications every 3 minutes 978 sleep(180); // look for modifications every 3 minutes
979 if (!loader_run) break;
978 CONFIG &dc = *config; 980 CONFIG &dc = *config;
979 time_t then = dc.load_time; 981 time_t then = dc.load_time;
980 struct stat st; 982 struct stat st;
981 bool reload = false; 983 bool reload = false;
982 for (string_list::iterator i=dc.config_files.begin(); i!=dc.config_files.end(); i++) { 984 for (string_list::iterator i=dc.config_files.begin(); i!=dc.config_files.end(); i++) {
1002 old_configs.erase(i++); 1004 old_configs.erase(i++);
1003 } 1005 }
1004 else i++; 1006 else i++;
1005 } 1007 }
1006 } 1008 }
1009 return NULL;
1007 } 1010 }
1008 1011
1009 1012
1010 static void usage(char *prog); 1013 static void usage(char *prog);
1011 static void usage(char *prog) 1014 static void usage(char *prog)
1116 if (f) { 1119 if (f) {
1117 fprintf(f, "-%d\n", (u_int)getpgrp()); 1120 fprintf(f, "-%d\n", (u_int)getpgrp());
1118 fclose(f); 1121 fclose(f);
1119 } 1122 }
1120 1123
1121 return smfi_main(); 1124 time_t starting = time(NULL);
1122 } 1125 int rc = smfi_main();
1123 1126 if (time(NULL) > starting+5*60) {
1127 my_syslog("trying to restart after smfi_main()");
1128 loader_run = false; // eventually the config loader thread will terminate
1129 execvp(argv[0], argv);
1130 }
1131 exit((rc == MI_SUCCESS) ? 0 : EX_UNAVAILABLE);
1132 }
1133