mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 19:30:26 +08:00
avoid collapse when quit (msvc)
This commit is contained in:
parent
7e9f3ca9f2
commit
4174a18343
@ -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<std::mutex> lockGuard{ m };
|
||||
const auto &[protocol, host, port] = GetConnectionInfo(id);
|
||||
@ -33,16 +33,18 @@ namespace Qv2ray::components::latency
|
||||
stopTimer->on<uvw::TimerEvent>([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<int *>(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<icmping::ICMPPing>(30,loop,req,parent);
|
||||
auto ptr = std::make_shared<icmping::ICMPPing>(30, loop, req, parent);
|
||||
ptr->start();
|
||||
#else
|
||||
auto ptr = std::make_shared<icmping::ICMPPing>(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<ConnectionId> &ids, int totalTestCount, Qv2rayLatencyTestingMethod method)
|
||||
{
|
||||
if(isStop)
|
||||
if (isStop)
|
||||
return;
|
||||
std::unique_lock<std::mutex> lockGuard{ m };
|
||||
for (const auto &id : ids)
|
||||
|
Loading…
Reference in New Issue
Block a user