]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Do not crash on invalid src= URLs.
[cubemap] / main.cpp
index 8d60826fb3d7a8436607446f27b572ba294bc237..cf728cadca6e04a709bc9e49ffa46ac1386ab209 100644 (file)
--- 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<string, InputWithRefcount>::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<Input*> inputs_no_refcount;
+               for (multimap<string, InputWithRefcount>::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;