diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -38,6 +38,7 @@ #include "heap.h" #include "filter.h" #include "child.h" +#include "loop.h" #include "log.h" #include "reqs.h" #include "sock.h" @@ -256,6 +257,8 @@ int reload_config (int reload_logging) int ret; struct config_s *c_next = get_next_config(); + log_message (LOG_NOTICE, "Reloading config file"); + if (reload_logging) shutdown_logging (); ret = reload_config_file (config_file, c_next); @@ -264,9 +267,11 @@ int reload_config (int reload_logging) goto done; } + if(config) free_config (config); config = c_next; if (reload_logging) ret = setup_logging (); + log_message (LOG_NOTICE, "Reloading config file finished"); done: return ret; @@ -295,7 +300,8 @@ main (int argc, char **argv) log_message (LOG_NOTICE, "Initializing " PACKAGE " ..."); - if (config_compile_regex()) { + if (config_init()) { + fprintf(stderr, "ERROR: config_init() failed\n"); exit (EX_SOFTWARE); } @@ -336,8 +342,8 @@ main (int argc, char **argv) * HTTP/1.0 request. Also add the Content-Type header since it * goes hand in hand with Content-Length. */ if (is_anonymous_enabled (config)) { - anonymous_insert (config, "Content-Length"); - anonymous_insert (config, "Content-Type"); + anonymous_insert (config, safestrdup("Content-Length")); + anonymous_insert (config, safestrdup("Content-Type")); } if (daemonized == TRUE) { @@ -375,7 +381,7 @@ main (int argc, char **argv) if (geteuid () == 0) change_user (argv[0]); else - log_message (LOG_WARNING, + log_message (LOG_INFO, "Not running as root, so not changing UID/GID."); /* Create log file after we drop privileges */ @@ -388,9 +394,12 @@ main (int argc, char **argv) setup_sig (SIGCHLD, takesig, "SIGCHLD", argv[0]); setup_sig (SIGTERM, takesig, "SIGTERM", argv[0]); + setup_sig (SIGINT, takesig, "SIGINT", argv[0]); if (daemonized) setup_sig (SIGHUP, takesig, "SIGHUP", argv[0]); setup_sig (SIGUSR1, takesig, "SIGUSR1", argv[0]); + loop_records_init(); + /* Start the main loop */ log_message (LOG_INFO, "Starting main loop. Accepting connections."); @@ -400,6 +409,9 @@ main (int argc, char **argv) child_kill_children (SIGTERM); child_close_sock (); + child_free_children(); + + loop_records_destroy(); /* Remove the PID file */ if (config->pidpath != NULL && unlink (config->pidpath) < 0) { @@ -413,6 +425,8 @@ main (int argc, char **argv) filter_destroy (); #endif /* FILTER_ENABLE */ + free_config (config); + shutdown_logging (); return EXIT_SUCCESS; |