Merge pull request #12849 from unknownbrackets/debugger

http: Fix thread join on enable/disable
This commit is contained in:
Henrik Rydgård 2020-04-23 09:17:46 +02:00 committed by GitHub
commit b5a0af635f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ enum class ServerStatus {
STARTING,
RUNNING,
STOPPING,
FINISHED,
};
static const char *REPORT_HOSTNAME = "report.ppsspp.org";
@ -248,7 +249,7 @@ static void ExecuteWebServer() {
if (!http->Listen(g_Config.iRemoteISOPort)) {
if (!http->Listen(0)) {
ERROR_LOG(FILESYS, "Unable to listen on any port");
UpdateStatus(ServerStatus::STOPPED);
UpdateStatus(ServerStatus::FINISHED);
return;
}
}
@ -271,7 +272,7 @@ static void ExecuteWebServer() {
StopAllDebuggers();
delete http;
UpdateStatus(ServerStatus::STOPPED);
UpdateStatus(ServerStatus::FINISHED);
}
bool StartWebServer(WebServerFlags flags) {
@ -284,6 +285,9 @@ bool StartWebServer(WebServerFlags flags) {
serverFlags |= (int)flags;
return true;
case ServerStatus::FINISHED:
serverThread.join();
// Intentional fallthrough.
case ServerStatus::STOPPED:
serverStatus = ServerStatus::STARTING;
serverFlags = (int)flags;
@ -318,11 +322,13 @@ bool WebServerStopped(WebServerFlags flags) {
if (serverStatus == ServerStatus::RUNNING) {
return (serverFlags & (int)flags) == 0;
}
return serverStatus == ServerStatus::STOPPED;
return serverStatus == ServerStatus::STOPPED || serverStatus == ServerStatus::FINISHED;
}
void ShutdownWebServer() {
StopWebServer(WebServerFlags::ALL);
if (serverThread.joinable())
if (serverStatus != ServerStatus::STOPPED)
serverThread.join();
serverStatus = ServerStatus::STOPPED;
}