mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
chore.改了些有的没的
This commit is contained in:
@@ -281,12 +281,12 @@ std::optional<std::vector<unsigned char>> asst::Controller::call_command(const s
|
||||
std::unique_lock<std::mutex> pipe_lock(m_pipe_mutex);
|
||||
fd_set fdset = { 0 };
|
||||
FD_SET(m_server_sock, &fdset);
|
||||
timeval select_timeout = { 3, 0 };
|
||||
constexpr int TimeoutMilliseconds = 3000;
|
||||
timeval select_timeout = { 0, TimeoutMilliseconds };
|
||||
select(static_cast<int>(m_server_sock) + 1, &fdset, NULL, NULL, &select_timeout);
|
||||
if (FD_ISSET(m_server_sock, &fdset)) {
|
||||
SOCKET client_sock = ::accept(m_server_sock, NULL, NULL);
|
||||
constexpr int RectTimeout = 3000;
|
||||
setsockopt(client_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&RectTimeout, sizeof(int));
|
||||
setsockopt(client_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&TimeoutMilliseconds, sizeof(int));
|
||||
int recv_size = 0;
|
||||
do {
|
||||
recv_size = ::recv(client_sock, (char*)m_socket_buffer.get(), SocketBuffSize, NULL);
|
||||
@@ -298,7 +298,7 @@ std::optional<std::vector<unsigned char>> asst::Controller::call_command(const s
|
||||
} while (recv_size > 0 && !check_timeout());
|
||||
::closesocket(client_sock);
|
||||
}
|
||||
::WaitForSingleObject(process_info.hProcess, 3000);
|
||||
::WaitForSingleObject(process_info.hProcess, TimeoutMilliseconds);
|
||||
}
|
||||
DWORD exit_ret = 0;
|
||||
::GetExitCodeProcess(process_info.hProcess, &exit_ret);
|
||||
@@ -342,7 +342,7 @@ std::optional<std::vector<unsigned char>> asst::Controller::call_command(const s
|
||||
else {
|
||||
// failed to create child process
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Log.trace("Call `", cmd, "` ret", exit_ret, ", output size:", pipe_data.size());
|
||||
@@ -548,7 +548,7 @@ std::optional<unsigned short> asst::Controller::try_to_init_socket(const std::st
|
||||
void asst::Controller::wait(unsigned id) const noexcept
|
||||
{
|
||||
while (id > m_completed_id) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user