Remove use shutdown signal inside init function
This commit is contained in:
@@ -36,7 +36,7 @@ bool user_creds_exist(const std::string &file);
|
|||||||
std::string unique_id;
|
std::string unique_id;
|
||||||
net::net_e origin_pin_allowed;
|
net::net_e origin_pin_allowed;
|
||||||
|
|
||||||
void init(std::shared_ptr<safe::signal_t> shutdown_event) {
|
int init() {
|
||||||
bool clean_slate = config::sunshine.flags[config::flag::FRESH_STATE];
|
bool clean_slate = config::sunshine.flags[config::flag::FRESH_STATE];
|
||||||
origin_pin_allowed = net::from_enum_string(config::nvhttp.origin_pin_allowed);
|
origin_pin_allowed = net::from_enum_string(config::nvhttp.origin_pin_allowed);
|
||||||
if(clean_slate) {
|
if(clean_slate) {
|
||||||
@@ -48,20 +48,19 @@ void init(std::shared_ptr<safe::signal_t> shutdown_event) {
|
|||||||
|
|
||||||
if(!fs::exists(config::nvhttp.pkey) || !fs::exists(config::nvhttp.cert)) {
|
if(!fs::exists(config::nvhttp.pkey) || !fs::exists(config::nvhttp.cert)) {
|
||||||
if(create_creds(config::nvhttp.pkey, config::nvhttp.cert)) {
|
if(create_creds(config::nvhttp.pkey, config::nvhttp.cert)) {
|
||||||
shutdown_event->raise(true);
|
return -1;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!user_creds_exist(config::sunshine.credentials_file)) {
|
if(!user_creds_exist(config::sunshine.credentials_file)) {
|
||||||
if(save_user_creds(config::sunshine.credentials_file, "sunshine"s, crypto::rand_alphabet(16), true)) {
|
if(save_user_creds(config::sunshine.credentials_file, "sunshine"s, crypto::rand_alphabet(16), true)) {
|
||||||
shutdown_event->raise(true);
|
return -1;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(reload_user_creds(config::sunshine.credentials_file)) {
|
if(reload_user_creds(config::sunshine.credentials_file)) {
|
||||||
shutdown_event->raise(true);
|
return -1;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int save_user_creds(const std::string &file, const std::string &username, const std::string &password, bool run_our_mouth) {
|
int save_user_creds(const std::string &file, const std::string &username, const std::string &password, bool run_our_mouth) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
void init(std::shared_ptr<safe::signal_t> shutdown_event);
|
int init();
|
||||||
int create_creds(const std::string &pkey, const std::string &cert);
|
int create_creds(const std::string &pkey, const std::string &cert);
|
||||||
int save_user_creds(
|
int save_user_creds(
|
||||||
const std::string &file,
|
const std::string &file,
|
||||||
|
|||||||
+4
-1
@@ -196,7 +196,10 @@ int main(int argc, char *argv[]) {
|
|||||||
if(video::init()) {
|
if(video::init()) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
http::init(shutdown_event);
|
if(http::init()) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
task_pool.start(1);
|
task_pool.start(1);
|
||||||
|
|
||||||
std::thread httpThread { nvhttp::start, shutdown_event };
|
std::thread httpThread { nvhttp::start, shutdown_event };
|
||||||
|
|||||||
Reference in New Issue
Block a user