X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=cf728cadca6e04a709bc9e49ffa46ac1386ab209;hp=8d60826fb3d7a8436607446f27b572ba294bc237;hb=4615dd4bda03a3e73bdeab2e9e81b950d266a6f5;hpb=adbeb2f8972672ed1059509662d006df47762228 diff --git a/main.cpp b/main.cpp index 8d60826..cf728ca 100644 --- a/main.cpp +++ b/main.cpp @@ -20,6 +20,7 @@ #include "accesslog.h" #include "config.h" #include "input.h" +#include "input_stats.h" #include "log.h" #include "markpool.h" #include "serverpool.h" @@ -176,9 +177,10 @@ void create_streams(const Config &config, string src = stream_config.src; if (!src.empty()) { multimap::iterator input_it = inputs->find(src); - assert(input_it != inputs->end()); - input_it->second.input->add_destination(stream_index); - ++input_it->second.refcount; + if (input_it != inputs->end()) { + input_it->second.input->add_destination(stream_index); + ++input_it->second.refcount; + } } } @@ -448,6 +450,18 @@ start: stats_thread->run(); } + InputStatsThread *input_stats_thread = NULL; + if (!config.input_stats_file.empty()) { + vector inputs_no_refcount; + for (multimap::iterator input_it = inputs.begin(); + input_it != inputs.end(); ++input_it) { + inputs_no_refcount.push_back(input_it->second.input); + } + + input_stats_thread = new InputStatsThread(config.input_stats_file, config.input_stats_interval, inputs_no_refcount); + input_stats_thread->run(); + } + struct timeval server_start; gettimeofday(&server_start, NULL); if (state_fd != -1) { @@ -466,6 +480,10 @@ start: // OK, we've been HUPed. Time to shut down everything, serialize, and re-exec. gettimeofday(&serialize_start, NULL); + if (input_stats_thread != NULL) { + input_stats_thread->stop(); + delete input_stats_thread; + } if (stats_thread != NULL) { stats_thread->stop(); delete stats_thread;