diff --git a/src/child.c b/src/child.c index 60f8ead..64771ea 100644 --- a/src/child.c +++ b/src/child.c @@ -33,6 +33,7 @@ #include "conf.h" static vector_t listen_fds; +volatile int children; /* referenced from main.c */ /* * Stores the internal data needed for each child (connection) @@ -202,6 +203,11 @@ static void child_main (struct child_s *ptr) ptr->connects = 0; srand(time(NULL)); +#ifdef FILTER_ENABLE + if (config.filter) + filter_init (); +#endif /* FILTER_ENABLE */ + /* * We have to wait for connections on multiple fds, * so use select. @@ -226,7 +232,6 @@ static void child_main (struct child_s *ptr) FD_SET(*fd, &rfds); maxfd = max(maxfd, *fd); } - ptr->status = T_WAITING; clilen = sizeof(struct sockaddr_storage); @@ -358,8 +363,10 @@ static pid_t child_make (struct child_s *ptr) { pid_t pid; - if ((pid = fork ()) > 0) + if ((pid = fork ()) > 0) { + ++children; return pid; /* parent */ + } /* * Reset the SIGNALS so that the child can be reaped. @@ -513,10 +520,7 @@ void child_main_loop (void) * This should actually be handled somehow... */ reload_config (); - -#ifdef FILTER_ENABLE filter_reload (); -#endif /* FILTER_ENABLE */ /* propagate filter reload to all children */ child_kill_children (SIGHUP); diff --git a/src/filter.c b/src/filter.c index 3164191..9fd054e 100644 --- a/src/filter.c +++ b/src/filter.c @@ -61,7 +61,9 @@ void filter_init (void) fd = fopen (config.filter, "r"); if (!fd) { - return; + log_message(LOG_ERR, "Can't read the filter from %s: %s", + config.filter, strerror(errno)); + exit(3); } p = NULL; diff --git a/src/main.c b/src/main.c index 43170c5..9e40b03 100644 --- a/src/main.c +++ b/src/main.c @@ -50,6 +50,7 @@ struct config_s config; struct config_s config_defaults; unsigned int received_sighup = FALSE; /* boolean */ +extern volatile int children; /* defined in child.c */ /* * Handle a signal @@ -374,11 +375,6 @@ main (int argc, char **argv) exit (EX_OSERR); } -#ifdef FILTER_ENABLE - if (config.filter) - filter_init (); -#endif /* FILTER_ENABLE */ - /* Start listening on the selected port. */ if (child_listening_sockets(config.listen_addrs, config.port) < 0) { fprintf (stderr, "%s: Could not create listening sockets.\n",