X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspircd.cpp;h=956fb115567f6fba09d5e478a2b6c2e686b3c308;hb=fcc5ca0c8572f10915d5dbff1338ac17fec86775;hp=dea4b45755fcfa595b91fc2c5164f91c7ae83448;hpb=62483525bb81a62b72539a3bda9d1a9b425b482c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspircd.cpp b/src/inspircd.cpp index dea4b4575..956fb1155 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -36,7 +36,6 @@ #ifndef _WIN32 #include #include - #include #include #include // setuid #include // setgid @@ -136,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 = newtime - oldtime; + + 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 . void DropRoot() { @@ -668,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;