Merge pull request #116 from AleksanderZdunek/master

Fix HttpServer::init() erroneous return value
This commit is contained in:
Andrea Bondavalli 2023-02-26 17:05:56 +01:00 committed by GitHub
commit 461c007a04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -351,11 +351,12 @@ bool HttpServer::init() {
httplib::Client cli(config_->get_ip_addr_str().c_str(), httplib::Client cli(config_->get_ip_addr_str().c_str(),
config_->get_http_port()); config_->get_http_port());
int retry = 3; int retry = 3;
while (retry--) { while (retry) {
auto res = cli.Get("/api/config"); auto res = cli.Get("/api/config");
if (res && res->status == 200) { if (res && res->status == 200) {
break; break;
} }
--retry;
std::this_thread::sleep_for(std::chrono::seconds(1)); std::this_thread::sleep_for(std::chrono::seconds(1));
} }
return retry; return retry;