diff options
author | Justin Clark-Casey (justincc) | 2014-07-14 20:08:11 +0100 |
---|---|---|
committer | Justin Clark-Casey | 2014-08-02 00:54:42 +0100 |
commit | 539ffb776919e0285b052f7268893a37d387deac (patch) | |
tree | 82ccfb5207c380a7310469b822139094a02ff130 /OpenSim/Framework/Util.cs | |
parent | Call RemoveScriptInstance when removing from inventory (diff) | |
download | opensim-SC_OLD-539ffb776919e0285b052f7268893a37d387deac.zip opensim-SC_OLD-539ffb776919e0285b052f7268893a37d387deac.tar.gz opensim-SC_OLD-539ffb776919e0285b052f7268893a37d387deac.tar.bz2 opensim-SC_OLD-539ffb776919e0285b052f7268893a37d387deac.tar.xz |
Use thread-safe version of .NET Random as the SDK class is not thread-safe.
As per http://msdn.microsoft.com/en-us/library/system.random%28v=vs.100%29.aspx, the .NET Random class is not thread-safe.
If called by multiple threads at once, methods may return 0.
Except for llRand(), other OpenSimulator code did not lock before calling a shared Random instance.
This commit adds a ThreadSafeRandom class that extends Random but does internal locking so that it is thread-safe.
This change is invisible to existing callers and the explicit locking in the llFrand() implementation is now redundant.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 729281c..9d7de97 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -138,7 +138,7 @@ namespace OpenSim.Framework | |||
138 | } | 138 | } |
139 | 139 | ||
140 | private static uint nextXferID = 5000; | 140 | private static uint nextXferID = 5000; |
141 | private static Random randomClass = new Random(); | 141 | private static Random randomClass = new ThreadSafeRandom(); |
142 | 142 | ||
143 | // Get a list of invalid file characters (OS dependent) | 143 | // Get a list of invalid file characters (OS dependent) |
144 | private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; | 144 | private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; |