diff --git a/sunshine/httpcommon.cpp b/sunshine/httpcommon.cpp index a5f3f144..5f796595 100644 --- a/sunshine/httpcommon.cpp +++ b/sunshine/httpcommon.cpp @@ -36,7 +36,7 @@ bool user_creds_exist(const std::string &file); std::string unique_id; net::net_e origin_pin_allowed; -void init(std::shared_ptr shutdown_event) { +int init() { bool clean_slate = config::sunshine.flags[config::flag::FRESH_STATE]; origin_pin_allowed = net::from_enum_string(config::nvhttp.origin_pin_allowed); if(clean_slate) { @@ -48,20 +48,19 @@ void init(std::shared_ptr shutdown_event) { if(!fs::exists(config::nvhttp.pkey) || !fs::exists(config::nvhttp.cert)) { if(create_creds(config::nvhttp.pkey, config::nvhttp.cert)) { - shutdown_event->raise(true); - return; + return -1; } } if(!user_creds_exist(config::sunshine.credentials_file)) { if(save_user_creds(config::sunshine.credentials_file, "sunshine"s, crypto::rand_alphabet(16), true)) { - shutdown_event->raise(true); - return; + return -1; } } if(reload_user_creds(config::sunshine.credentials_file)) { - shutdown_event->raise(true); - return; + return -1; } + + return 0; } int save_user_creds(const std::string &file, const std::string &username, const std::string &password, bool run_our_mouth) { diff --git a/sunshine/httpcommon.h b/sunshine/httpcommon.h index 2153bce1..fbd43253 100644 --- a/sunshine/httpcommon.h +++ b/sunshine/httpcommon.h @@ -3,7 +3,7 @@ namespace http { -void init(std::shared_ptr shutdown_event); +int init(); int create_creds(const std::string &pkey, const std::string &cert); int save_user_creds( const std::string &file, diff --git a/sunshine/main.cpp b/sunshine/main.cpp index caf820fc..44b9bda1 100644 --- a/sunshine/main.cpp +++ b/sunshine/main.cpp @@ -196,7 +196,10 @@ int main(int argc, char *argv[]) { if(video::init()) { return 2; } - http::init(shutdown_event); + if(http::init()) { + return 3; + } + task_pool.start(1); std::thread httpThread { nvhttp::start, shutdown_event };