Merge pull request #1946 from MaaAssistantArknights/fix/process_still_active

fix: 修复 hProcess 返回值 259(STILL_ACTIVE)导致重连的问题
This commit is contained in:
MistEO
2022-09-27 23:57:46 +08:00
committed by GitHub

View File

@@ -258,6 +258,7 @@ std::optional<std::string> asst::Controller::call_command(const std::string& cmd
Log.trace("AcceptEx failed, err:", err);
accept_pending = false;
socket_eof = true;
closesocket(client_socket);
}
}
}
@@ -286,6 +287,25 @@ std::optional<std::string> asst::Controller::call_command(const std::string& cmd
}
else if (wait_result == WAIT_TIMEOUT) {
if (wait_time == 0) {
std::vector<std::string> handle_string {};
for (auto handle : wait_handles) {
if (handle == process_info.hProcess) {
handle_string.emplace_back("process_info.hProcess");
}
else if (handle == pipeov.hEvent) {
handle_string.emplace_back("pipeov.hEvent");
}
else if (recv_by_socket && handle == sockov.hEvent) {
handle_string.emplace_back("sockov.hEvent");
}
else {
handle_string.emplace_back("UnknownHandle");
}
}
Log.warn("Wait handles:", handle_string, "timeout.");
if (process_running) {
TerminateProcess(process_info.hProcess, 0);
}
break;
}
continue;
@@ -359,6 +379,7 @@ std::optional<std::string> asst::Controller::call_command(const std::string& cmd
else {
// err = GetLastError();
socket_eof = true;
closesocket(client_socket);
}
}
}