mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Extract time skip warning code to a static function.
This commit is contained in:
parent
59d2dab8a1
commit
a3df29ba49
@ -135,6 +135,21 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
// Checks whether the server clock has skipped too much and warn about it if it has.
|
||||
void CheckTimeSkip(time_t oldtime, time_t newtime)
|
||||
{
|
||||
if (!ServerInstance->Config->TimeSkipWarn)
|
||||
return;
|
||||
|
||||
time_t timediff = oldtime - newtime;
|
||||
|
||||
if (timediff > ServerInstance->Config->TimeSkipWarn)
|
||||
ServerInstance->SNO->WriteToSnoMask('a', "\002Performance warning!\002 Server clock jumped forwards by %lu seconds!", timediff);
|
||||
|
||||
else if (timediff < -ServerInstance->Config->TimeSkipWarn)
|
||||
ServerInstance->SNO->WriteToSnoMask('a', "\002Performance warning!\002 Server clock jumped backwards by %lu seconds!", labs(timediff));
|
||||
}
|
||||
|
||||
// Drops to the unprivileged user/group specified in <security:runas{user,group}>.
|
||||
void DropRoot()
|
||||
{
|
||||
@ -667,17 +682,7 @@ void InspIRCd::Run()
|
||||
if (TIME.tv_sec != OLDTIME)
|
||||
{
|
||||
CollectStats();
|
||||
|
||||
if (Config->TimeSkipWarn)
|
||||
{
|
||||
time_t timediff = TIME.tv_sec - OLDTIME;
|
||||
|
||||
if (timediff > Config->TimeSkipWarn)
|
||||
SNO->WriteToSnoMask('a', "\002Performance warning!\002 Server clock jumped forwards by %lu seconds!", timediff);
|
||||
|
||||
else if (timediff < -Config->TimeSkipWarn)
|
||||
SNO->WriteToSnoMask('a', "\002Performance warning!\002 Server clock jumped backwards by %lu seconds!", labs(timediff));
|
||||
}
|
||||
CheckTimeSkip(OLDTIME, TIME.tv_sec);
|
||||
|
||||
OLDTIME = TIME.tv_sec;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user