diff --git a/src/components/latency/LatencyTestThread.cpp b/src/components/latency/LatencyTestThread.cpp index 2487cd38..5ef60244 100644 --- a/src/components/latency/LatencyTestThread.cpp +++ b/src/components/latency/LatencyTestThread.cpp @@ -19,7 +19,7 @@ namespace Qv2ray::components::latency void LatencyTestThread::pushRequest(const ConnectionId &id, int totalTestCount, Qv2rayLatencyTestingMethod method) { - if(isStop) + if (isStop) return; std::unique_lock lockGuard{ m }; const auto &[protocol, host, port] = GetConnectionInfo(id); @@ -33,16 +33,18 @@ namespace Qv2ray::components::latency stopTimer->on([this](auto &, auto &handle) { if (isStop) { - if(!requests.empty()) + if (!requests.empty()) requests.clear(); - int timer_count=0; - //LOG(MODULE_NETWORK,"fuck") - loop->walk([&timer_count,this](uvw::BaseHandle&h) - { - if(!h.closing()) - timer_count++; - }); - if(timer_count==1)//only current timer + int timer_count = 0; + uv_walk( + loop->raw(), + [](uv_handle_t *handle, void *arg) { + int &counter = *static_cast(arg); + if (uv_is_closing(handle) == 0) + counter++; + }, + &timer_count); + if (timer_count == 1) // only current timer { handle.stop(); handle.close(); @@ -64,11 +66,11 @@ namespace Qv2ray::components::latency case ICMPING: { #ifdef Q_OS_UNIX - auto ptr = std::make_shared(30,loop,req,parent); + auto ptr = std::make_shared(30, loop, req, parent); ptr->start(); #else auto ptr = std::make_shared(30); - ptr->start(loop,req,parent); + ptr->start(loop, req, parent); #endif } break; @@ -89,7 +91,7 @@ namespace Qv2ray::components::latency } void LatencyTestThread::pushRequest(const QList &ids, int totalTestCount, Qv2rayLatencyTestingMethod method) { - if(isStop) + if (isStop) return; std::unique_lock lockGuard{ m }; for (const auto &id : ids)