From 887ca5d3419c6d98edbf64215e0b9e33da801a20 Mon Sep 17 00:00:00 2001 From: Vorspire Date: Sun, 23 Aug 2015 01:40:09 +0100 Subject: [PATCH] + Don't allow processing of the Timer changed queue while the world is loading or saving. * Removes the risk of inconsistency [warnings] generated by timers that tick with handlers that modify World.Items and World.Mobiles during I/O. + Update description of Core.TickCount. --- RunUO.exe.config | 20 +++++++++++--------- Server/Main.cs | 16 +++++----------- Server/Timer.cs | 6 ++++++ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/RunUO.exe.config b/RunUO.exe.config index 5106eb6a4..3fe506032 100644 --- a/RunUO.exe.config +++ b/RunUO.exe.config @@ -1,10 +1,12 @@ - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/Server/Main.cs b/Server/Main.cs index 1bf17cc35..14f029207 100644 --- a/Server/Main.cs +++ b/Server/Main.cs @@ -107,23 +107,17 @@ namespace Server public static Thread Thread { get { return m_Thread; } } public static MultiTextWriter MultiConsoleOut { get { return m_MultiConOut; } } - /* DateTime.Now and DateTime.UtcNow are based on actual system clock time. + /* + * DateTime.Now and DateTime.UtcNow are based on actual system clock time. * The resolution is acceptable but large clock jumps are possible and cause issues. * GetTickCount and GetTickCount64 have poor resolution. * GetTickCount64 is unavailable on Windows XP and Windows Server 2003. * Stopwatch.GetTimestamp() (QueryPerformanceCounter) is high resolution, but - * somewhat expensive to call and unreliable with certain system configurations. + * somewhat expensive to call because of its defference to DateTime.Now, + * which is why Stopwatch has been used to verify HRT before calling GetTimestamp(), + * enabling the usage of DateTime.UtcNow instead. */ - /* The following implementation contains an effective substitute for GetTickCount64 that - * is reliable as long as it is retrieved once every 2^32 ms (~49 days). - */ - - /* We don't really need this, but it may be useful in the future. - private static ThreadLocal _HighOrder = new ThreadLocal(); - private static ThreadLocal _LastTickCount = new ThreadLocal(); - */ - private static readonly bool _HighRes = Stopwatch.IsHighResolution; private static readonly double _HighFrequency = 1000.0 / Stopwatch.Frequency; diff --git a/Server/Timer.cs b/Server/Timer.cs index 6c1170eb6..f3aa7a21e 100644 --- a/Server/Timer.cs +++ b/Server/Timer.cs @@ -313,6 +313,12 @@ namespace Server while ( !Core.Closing ) { + if (World.Loading || World.Saving) + { + m_Signal.WaitOne(1, false); + continue; + } + ProcessChanged(); loaded = false;