+ ConfigThread->join();
+ delete ConfigThread;
+ ConfigThread = NULL;
+ }
+
+ UpdateTime();
+
+ /* Run background module timers every few seconds
+ * (the docs say modules shouldnt rely on accurate
+ * timing using this event, so we dont have to
+ * time this exactly).
+ */
+ if (TIME.tv_sec != OLDTIME)
+ {
+#ifndef _WIN32
+ getrusage(RUSAGE_SELF, &ru);
+ stats->LastSampled = TIME;
+ stats->LastCPU = ru.ru_utime;
+#else
+ if(QueryPerformanceCounter(&stats->LastSampled))
+ {
+ FILETIME CreationTime;
+ FILETIME ExitTime;
+ FILETIME KernelTime;
+ FILETIME UserTime;
+ GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime);
+ stats->LastCPU.dwHighDateTime = KernelTime.dwHighDateTime + UserTime.dwHighDateTime;
+ stats->LastCPU.dwLowDateTime = KernelTime.dwLowDateTime + UserTime.dwLowDateTime;
+ }
+#endif
+
+ /* Allow a buffer of two seconds drift on this so that ntpdate etc dont harass admins */
+ if (TIME.tv_sec < OLDTIME - 2)
+ {
+ SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)OLDTIME-TIME.tv_sec);
+ }
+ else if (TIME.tv_sec > OLDTIME + 2)
+ {
+ SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)TIME.tv_sec - OLDTIME);
+ }
+\r
+ OLDTIME = TIME.tv_sec;
+
+ if ((TIME.tv_sec % 3600) == 0)
+ {
+ this->RehashUsersAndChans();
+ FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+ }
+
+ Timers->TickTimers(TIME.tv_sec);
+ this->DoBackgroundUserStuff();
+
+ if ((TIME.tv_sec % 5) == 0)
+ {
+ FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME.tv_sec));
+ SNO->FlushSnotices();
+ }
+ }
+
+ /* Call the socket engine to wait on the active
+ * file descriptors. The socket engine has everything's
+ * descriptors in its list... dns, modules, users,
+ * servers... so its nice and easy, just one call.
+ * This will cause any read or write events to be
+ * dispatched to their handlers.
+ */
+ this->SE->DispatchTrialWrites();
+ this->SE->DispatchEvents();
+
+ /* if any users were quit, take them out */
+ GlobalCulls.Apply();
+ AtomicActions.Run();
+
+ if (s_signal)