X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=55548bae91e832c02450a2196bf9778cea39453f;hp=8430c207134ee026bb9fcb45713eea70ee0c746e;hb=0f8e26eb85f86b7b543243f8e98938eeec909e31;hpb=92100dd95f705d079c926783c9009fbb6d8b984a diff --git a/main.cpp b/main.cpp index 8430c20..55548ba 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,7 @@ #include #include +#include "accesslog.h" #include "acceptor.h" #include "config.h" #include "input.h" @@ -29,7 +30,9 @@ using namespace std; +AccessLogThread *access_log = NULL; ServerPool *servers = NULL; +vector mark_pools; volatile bool hupped = false; volatile bool stopped = false; @@ -140,7 +143,6 @@ void create_streams(const Config &config, const set &deserialized_stream_ids, map *deserialized_inputs) { - vector mark_pools; // FIXME: leak for (unsigned i = 0; i < config.mark_pools.size(); ++i) { const MarkPoolConfig &mp_config = config.mark_pools[i]; mark_pools.push_back(new MarkPool(mp_config.from, mp_config.to)); @@ -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; @@ -396,6 +406,7 @@ start: if (stats_thread != NULL) { stats_thread->stop(); + delete stats_thread; } for (size_t i = 0; i < acceptors.size(); ++i) { acceptors[i]->stop(); @@ -420,6 +431,14 @@ start: } } delete servers; + + for (unsigned i = 0; i < mark_pools.size(); ++i) { + delete mark_pools[i]; + } + mark_pools.clear(); + + access_log->stop(); + delete access_log; shut_down_logging(); if (stopped) {