mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
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.
This commit is contained in:
@@ -138,7 +138,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
|
||||
private static uint nextXferID = 5000;
|
||||
private static Random randomClass = new Random();
|
||||
private static Random randomClass = new ThreadSafeRandom();
|
||||
|
||||
// Get a list of invalid file characters (OS dependent)
|
||||
private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]";
|
||||
|
||||
Reference in New Issue
Block a user