Mercurial > syslog2iptables
comparison src/syslog2iptables.cpp @ 4:2737ab01659a
initial coding
author | carl |
---|---|
date | Thu, 01 Dec 2005 17:17:37 -0800 |
parents | 8fe310e5cd44 |
children | 276c4edc8521 |
comparison
equal
deleted
inserted
replaced
3:8fe310e5cd44 | 4:2737ab01659a |
---|---|
28 #include <errno.h> | 28 #include <errno.h> |
29 #include <sysexits.h> | 29 #include <sysexits.h> |
30 #include <unistd.h> | 30 #include <unistd.h> |
31 #include <pthread.h> | 31 #include <pthread.h> |
32 #include <syslog.h> | 32 #include <syslog.h> |
33 #include <sys/types.h> | |
34 #include <sys/stat.h> | |
35 #include <sys/wait.h> /* header for waitpid() and various macros */ | 33 #include <sys/wait.h> /* header for waitpid() and various macros */ |
36 #include <signal.h> /* header for signal functions */ | 34 #include <signal.h> /* header for signal functions */ |
37 #include "includes.h" | 35 #include "includes.h" |
38 | 36 |
39 extern "C" { | 37 extern "C" { |
194 } | 192 } |
195 | 193 |
196 if (check) { | 194 if (check) { |
197 use_syslog = false; | 195 use_syslog = false; |
198 debug_syslog = 10; | 196 debug_syslog = 10; |
199 CONFIG *conf = new_conf(); | 197 config = new_conf(); |
200 if (conf) { | 198 if (config) { |
201 conf->dump(); | 199 config->dump(); |
202 for (int i=0; i<2; i++) { | 200 { |
203 conf->read(); | 201 // just for testing |
204 conf->sleep(5); | 202 // initialize the thread sync objects |
205 } | 203 pthread_mutex_init(&config_mutex, 0); |
206 delete conf; | 204 pthread_mutex_init(&syslog_mutex, 0); |
205 | |
206 time_t t = time(NULL); | |
207 CONFIG *c; | |
208 pthread_mutex_lock(&config_mutex); | |
209 c = config; | |
210 c->reference_count++; | |
211 pthread_mutex_unlock(&config_mutex); | |
212 while (true) { | |
213 if (c != config) { | |
214 pthread_mutex_lock(&config_mutex); | |
215 c->reference_count--; | |
216 c = config; | |
217 c->reference_count++; | |
218 pthread_mutex_unlock(&config_mutex); | |
219 } | |
220 c->read(); | |
221 c->sleep(10, t); | |
222 } | |
223 } | |
224 delete config; | |
207 return 0; | 225 return 0; |
208 } | 226 } |
209 else { | 227 else { |
210 return 1; // config failed to load | 228 return 1; // config failed to load |
211 } | 229 } |