#ifndef _WIN32
#include <unistd.h>
#include <sys/resource.h>
- #include <dlfcn.h>
#include <getopt.h>
#include <pwd.h> // setuid
#include <grp.h> // setgid
#endif
}
- // Deletes a pointer and then zeroes it.
- template<typename T>
- void DeleteZero(T*& pr)
+ // Checks whether the server clock has skipped too much and warn about it if it has.
+ void CheckTimeSkip(time_t oldtime, time_t newtime)
{
- T* p = pr;
- pr = NULL;
- delete p;
+ 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 <security:runas{user,group}>.
delete FakeClient->server;
FakeClient->cull();
}
- DeleteZero(this->FakeClient);
- DeleteZero(this->XLines);
- DeleteZero(this->Config);
+ stdalgo::delete_zero(this->FakeClient);
+ stdalgo::delete_zero(this->XLines);
+ stdalgo::delete_zero(this->Config);
SocketEngine::Deinit();
Logs->CloseLogs();
}
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;