]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Fix a small memory leak in HTTPInput.
[cubemap] / main.cpp
index 064537cd79a0572ef706e66c52106ce522f8026d..be3e8ebcce8e81ca462c34937b3068cdc12e24b1 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -16,6 +16,7 @@
 #include <utility>
 #include <vector>
 
+#include "accesslog.h"
 #include "acceptor.h"
 #include "config.h"
 #include "input.h"
@@ -29,6 +30,7 @@
 
 using namespace std;
 
+AccessLogThread *access_log = NULL;
 ServerPool *servers = NULL;
 volatile bool hupped = false;
 volatile bool stopped = false;
@@ -275,11 +277,11 @@ int main(int argc, char **argv)
        char config_filename_canon[PATH_MAX];
 
        if (realpath(argv[0], argv0_canon) == NULL) {
-               log_perror("realpath");
+               log_perror(argv[0]);
                exit(1);
        }
        if (realpath(config_filename.c_str(), config_filename_canon) == NULL) {
-               log_perror("realpath");
+               log_perror(config_filename.c_str());
                exit(1);
        }
 
@@ -307,6 +309,14 @@ start:
        open_logs(config.log_destinations);
 
        log(INFO, "Cubemap " SERVER_VERSION " starting.");
+       if (config.access_log_file.empty()) {
+               // Create a dummy logger.
+               access_log = new AccessLogThread();
+       } else {
+               access_log = new AccessLogThread(config.access_log_file);
+       }
+       access_log->run();
+
        servers = new ServerPool(config.num_servers);
 
        CubemapStateProto loaded_state;
@@ -420,6 +430,8 @@ start:
                }
        }
        delete servers;
+       access_log->stop();
+       delete access_log;
        shut_down_logging();
 
        if (stopped) {