http: Properly stop server on stop server.

This commit is contained in:
Unknown W. Brackets committed 2016-07-04 07:24:04 -07:00
1 parent 429346bb94
commit 287d1967a5
3 files changed
+19 -4

No files matched your search

+7 -3
View File
@@ -79,7 +79,7 @@ static void RegisterServer(int port) {
static void ExecuteServer() {
setCurrentThreadName("HTTPServer");
net::Init();
net::AutoInit netInit;
auto http = new http::Server(new threading::SameThreadExecutor());
std::map<std::string, std::string> paths;
@@ -156,7 +156,11 @@ static void ExecuteServer() {
}
if (!http->Listen(g_Config.iRemoteISOPort)) {
http->Listen(0);
if (!http->Listen(0)) {
ERROR_LOG(COMMON, "Unable to listen on any port");
UpdateStatus(ServerStatus::STOPPED);
return;
}
}
UpdateStatus(ServerStatus::RUNNING);
@@ -173,7 +177,7 @@ static void ExecuteServer() {
}
}
net::Shutdown();
http->Stop();
UpdateStatus(ServerStatus::STOPPED);
}