From 09d58f0aff03cfa4712f38323e7e191095b49d96 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Fri, 20 Jun 2025 04:26:55 +0800 Subject: [PATCH] fix: Limit `WaitForDialogOpen` waiting time --- client/IOCPClient.cpp | 1 + client/Manager.cpp | 2 +- common/commands.h | 11 +++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client/IOCPClient.cpp b/client/IOCPClient.cpp index c79b4b7..274e39d 100644 --- a/client/IOCPClient.cpp +++ b/client/IOCPClient.cpp @@ -539,5 +539,6 @@ VOID IOCPClient::RunEventLoop(const BOOL &bCondition) Mprintf("======> RunEventLoop begin\n"); while (m_bIsRunning && bCondition) Sleep(200); + setManagerCallBack(NULL, NULL); Mprintf("======> RunEventLoop end\n"); } diff --git a/client/Manager.cpp b/client/Manager.cpp index 05877ad..33358a3 100644 --- a/client/Manager.cpp +++ b/client/Manager.cpp @@ -189,7 +189,7 @@ int CManager::Send(LPBYTE lpData, UINT nSize) VOID CManager::WaitForDialogOpen() { - WaitForSingleObject(m_hEventDlgOpen, INFINITE); + WaitForSingleObject(m_hEventDlgOpen, 8000); //必须的Sleep,因为远程窗口从InitDialog中发送COMMAND_NEXT到显示还要一段时间 Sleep(150); } diff --git a/common/commands.h b/common/commands.h index 4373ac3..892832e 100644 --- a/common/commands.h +++ b/common/commands.h @@ -79,9 +79,16 @@ typedef void* LPVOID, * HANDLE; #define GET_FILEPATH(dir,file) [](char*d,const char*f){char*p=d;while(*p)++p;while('\\'!=*p&&p!=d)--p;strcpy(p+1,f);return d;}(dir,file) #endif -inline int isValid() { +inline int isValid_30s() { static time_t tm = time(nullptr); - return time(nullptr) - tm <= 60; + int span = int(time(nullptr) - tm); + return span <= 30; +} + +inline int isValid_10s() { + static time_t tm = time(nullptr); + int span = int(time(nullptr) - tm); + return span <= 10; } // 当程序功能明显发生变化时,应该更新这个值,以便对被控程序进行区分