printfd(__FILE__, "Parameter 'PingDelay' not found\n");
return -1;
}
-if (ParseIntInRange(pvi->value[0], 5, 3600, &pingDelay))
+if (ParseIntInRange(pvi->value[0], 5, 3600, &pingDelay) != 0)
{
errorStr = "Cannot parse parameter \'PingDelay\': " + errorStr;
printfd(__FILE__, "Canot parse parameter 'PingDelay'\n");
}
//-----------------------------------------------------------------------------
PING::PING()
- : users(NULL),
+ : users(nullptr),
isRunning(false),
onAddUserNotifier(*this),
onDelUserNotifier(*this),
{
}
//-----------------------------------------------------------------------------
-PING::~PING()
-{
-}
-//-----------------------------------------------------------------------------
int PING::ParseSettings()
{
-int ret = pingSettings.ParseSettings(settings);
-if (ret)
+auto ret = pingSettings.ParseSettings(settings);
+if (ret != 0)
errorStr = pingSettings.GetStrError();
return ret;
}
pinger.SetDelayTime(pingSettings.GetPingDelay());
pinger.Start();
-m_thread = std::jthread([this](auto token){ Run(token); });
+m_thread = std::jthread([this](auto token){ Run(std::move(token)); });
return 0;
}
if (!isRunning)
break;
- nanosleep(&ts, NULL);
+ nanosleep(&ts, nullptr);
}
users->DelNotifierUserAdd(&onAddUserNotifier);
if (isRunning)
m_thread.detach();
+else
+ m_thread.join();
return 0;
}
{
sigset_t signalSet;
sigfillset(&signalSet);
-pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
+pthread_sigmask(SIG_BLOCK, &signalSet, nullptr);
isRunning = true;
while (!token.stop_requested())
{
- std::list<UserPtr>::iterator iter = usersList.begin();
+ auto iter = usersList.begin();
{
std::lock_guard lock(m_mutex);
while (iter != usersList.end())
time_t t;
if (pinger.GetIPTime(ip, &t) == 0)
{
- if (t)
+ if (t != 0)
(*iter)->UpdatePingTime(t);
}
}
else
{
uint32_t ip = (*iter)->GetCurrIP();
- if (ip)
+ if (ip != 0)
{
time_t t;
if (pinger.GetIPTime(ip, &t) == 0)
{
- if (t)
+ if (t != 0)
(*iter)->UpdatePingTime(t);
}
}
{
if (!token.stop_requested())
{
- nanosleep(&ts, NULL);
+ nanosleep(&ts, nullptr);
}
}
}
else
{
uint32_t ip = u->GetCurrIP();
- if (ip)
+ if (ip != 0)
pinger.AddIP(ip);
}
}
void CHG_CURRIP_NOTIFIER_PING::Notify(const uint32_t & oldIP, const uint32_t & newIP)
{
ping.pinger.DelIP(oldIP);
-if (newIP)
+if (newIP != 0)
ping.pinger.AddIP(newIP);
}
//-----------------------------------------------------------------------------