X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=69f0e9b7cb686b19293a4aef184e6b54941584b7;hp=e270141e62941f6c33202d34f15786d62fca9200;hb=99738bd173040bf4e2d2d42ffc8c7ab8c105cf75;hpb=ac50b1104f5f525e838f80fa6dc50be13f7d35b6 diff --git a/main.cpp b/main.cpp index e270141..69f0e9b 100644 --- a/main.cpp +++ b/main.cpp @@ -265,8 +265,8 @@ int main(int argc, char **argv) servers->run(); - pthread_t acceptor_thread; - pthread_create(&acceptor_thread, NULL, acceptor_thread_run, reinterpret_cast(server_sock)); + AcceptorThread acceptor_thread(server_sock); + acceptor_thread.run(); // Find all streams in the configuration file, and create inputs for them. vector inputs; @@ -302,6 +302,9 @@ int main(int argc, char **argv) inputs.push_back(input); } + // All deserialized inputs should now have been taken care of, one way or the other. + assert(deserialized_inputs.empty()); + if (is_reexec) { // Put back the existing clients. It doesn't matter which server we // allocate them to, so just do round-robin. However, we need to add @@ -311,9 +314,6 @@ int main(int argc, char **argv) } } - // All deserialized inputs should now have been taken care of, one way or the other. - assert(deserialized_inputs.empty()); - // Start writing statistics. if (stats_thread != NULL) { stats_thread->run(); @@ -342,11 +342,7 @@ int main(int argc, char **argv) if (stats_thread != NULL) { stats_thread->stop(); } - pthread_kill(acceptor_thread, SIGHUP); - if (pthread_join(acceptor_thread, NULL) == -1) { - perror("pthread_join"); - exit(1); - } + acceptor_thread.stop(); CubemapStateProto state; state.set_serialize_start_sec(serialize_start.tv_sec);