Skip to content

Commit a93455d

Browse files
committed
fixed ping utility found log message
1 parent 59bb669 commit a93455d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/utils/ping_util.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022-2023 The Pastel Core developers
1+
// Copyright (c) 2022-2024 The Pastel Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
44
#include <utils/ping_util.h>
@@ -9,9 +9,10 @@
99
using namespace std;
1010
using namespace chrono;
1111

12-
CPingUtility::CPingUtility() :
12+
CPingUtility::CPingUtility() noexcept :
1313
m_bPingUtilityChecked(false),
14-
m_bPingUtilityAvailable(false)
14+
m_bPingUtilityAvailable(false),
15+
m_bPingUtilityFound(false)
1516
{}
1617

1718
bool CPingUtility::pingHostInternal(const std::string& sHostName)
@@ -34,6 +35,7 @@ CPingUtility::PingResult CPingUtility::pingHost(const string& sHostName)
3435
if (!m_bPingUtilityAvailable)
3536
{
3637
LogPrintf("%s\n", error);
38+
m_bPingUtilityFound = false;
3739
}
3840
m_bPingUtilityChecked = true;
3941
m_lastCheckTime = steady_clock::now();
@@ -67,7 +69,11 @@ bool CPingUtility::checkPingUtility(string &error)
6769
}
6870

6971
m_sPingPath = stdOut;
70-
LogPrintf("Found ping utility at [%s]\n", m_sPingPath);
72+
if (!m_bPingUtilityFound)
73+
{
74+
LogPrintf("Found ping utility at [%s]\n", m_sPingPath);
75+
m_bPingUtilityFound = true;
76+
}
7177
if (!pingHostInternal("127.0.0.1"))
7278
{
7379
error = "Ping utility is not working";

src/utils/ping_util.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
// Copyright (c) 2022-2023 The Pastel Core developers
2+
// Copyright (c) 2022-2024 The Pastel Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
55
#include <chrono>
@@ -9,7 +9,7 @@
99
class CPingUtility
1010
{
1111
public:
12-
CPingUtility();
12+
CPingUtility() noexcept;
1313

1414
enum class PingResult
1515
{
@@ -23,6 +23,8 @@ class CPingUtility
2323
private:
2424
std::atomic_bool m_bPingUtilityChecked;
2525
std::atomic_bool m_bPingUtilityAvailable;
26+
std::atomic_bool m_bPingUtilityFound;
27+
2628
std::string m_sPingPath; // Path to the ping utility
2729
std::chrono::time_point<std::chrono::steady_clock> m_lastCheckTime;
2830
static constexpr int m_recheckIntervalSeconds = 3600; // Recheck every 6 hours

0 commit comments

Comments
 (0)