From 062594076b79f8be04f9205a15897029869b413b Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Tue, 7 Jul 2020 11:28:28 +0800 Subject: [PATCH] fix?: may have fixed the ICMPing helper --- makespec/BUILDVERSION | 2 +- src/components/latency/LatencyTestThread.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/makespec/BUILDVERSION b/makespec/BUILDVERSION index 3f779df9..028dd108 100644 --- a/makespec/BUILDVERSION +++ b/makespec/BUILDVERSION @@ -1 +1 @@ -5717 +5718 diff --git a/src/components/latency/LatencyTestThread.cpp b/src/components/latency/LatencyTestThread.cpp index 6aeb2cf8..5f67c261 100644 --- a/src/components/latency/LatencyTestThread.cpp +++ b/src/components/latency/LatencyTestThread.cpp @@ -30,13 +30,11 @@ namespace Qv2ray::components::latency { case ICMPING: { - icmping::ICMPPing ping(30); + icmping::ICMPPing pingHelper(30); for (auto i = 0; i < count; i++) { resultData.totalCount++; - const auto pair = ping.ping(host); - const auto &errMessage = pair.second; - const long _latency = pair.first; + const auto [_latency, errMessage] = pingHelper.ping(host); if (!errMessage.isEmpty()) { resultData.errorMessage.append(NEWLINE + errMessage); @@ -54,9 +52,10 @@ namespace Qv2ray::components::latency resultData.worst = std::max(resultData.worst, _latency); } } - if (resultData.totalCount != 0 && resultData.failedCount != 0) + if (resultData.totalCount > 0 && resultData.failedCount != resultData.totalCount) { resultData.errorMessage.clear(); + // ms to s resultData.avg = resultData.avg / (resultData.totalCount - resultData.failedCount) / 1000; } else