]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Make read_tempfile() much faster, and make it close the file also on error.
[cubemap] / main.cpp
index 07273141fe04b5ec17bf0e3de7394deb414b501a..64cab64f40c7def8dd7ce744d29b2cd95a9fbef1 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1,7 +1,6 @@
 #include <assert.h>
 #include <errno.h>
 #include <getopt.h>
-#include <google/protobuf/stubs/common.h>
 #include <signal.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -214,6 +213,8 @@ bool dry_run_config(const std::string &argv0, const std::string &config_filename
 
 int main(int argc, char **argv)
 {
+       signal(SIGHUP, hup);
+       
        // Parse options.
        int state_fd = -1;
        bool test_config = false;
@@ -302,8 +303,6 @@ start:
        // Find all streams in the configuration file, and create them.
        create_streams(config, deserialized_stream_ids, &deserialized_inputs);
 
-       servers->run();
-
        vector<Acceptor *> acceptors = create_acceptors(config, &deserialized_acceptors);
        vector<Input *> inputs = create_inputs(config, &deserialized_inputs);
        
@@ -316,6 +315,8 @@ start:
        for (int i = 0; i < loaded_state.clients_size(); ++i) {
                servers->add_client_from_serialized(loaded_state.clients(i));
        }
+       
+       servers->run();
 
        // Start writing statistics.
        StatsThread *stats_thread = NULL;
@@ -324,8 +325,6 @@ start:
                stats_thread->run();
        }
 
-       signal(SIGHUP, hup);
-       
        struct timeval server_start;
        gettimeofday(&server_start, NULL);
        if (state_fd != -1) {