diff options
author | Justin Clark-Casey (justincc) | 2011-07-29 23:21:57 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-07-29 23:21:57 +0100 |
commit | 9a5e0ede7c86b1fc213948332ae09a14a2d4729e (patch) | |
tree | 90372a965f4c5bb0c038bbee033a913c93a6bde8 /OpenSim/Framework | |
parent | When we start the appearance saving thread, make sure we set the culture to E... (diff) | |
download | opensim-SC-9a5e0ede7c86b1fc213948332ae09a14a2d4729e.zip opensim-SC-9a5e0ede7c86b1fc213948332ae09a14a2d4729e.tar.gz opensim-SC-9a5e0ede7c86b1fc213948332ae09a14a2d4729e.tar.bz2 opensim-SC-9a5e0ede7c86b1fc213948332ae09a14a2d4729e.tar.xz |
For all Util.FireAndForget invocations, set thread to en_US before continuing wtih the invocation.
This is to avoid bugs where the locale is not manually set on the thread and bad data values get sent to the database or over the wire.
Lots of code does this manually but as we've seen, a subtle change can hit code which has forgotton to do this.
Since en_US show be used throughout the server at present, setting it at FireAndForget seems reasonable.
Arguably, it would be better to do this where data is sent, but doing it here is much easier.
All the manual BeginInvokes() remaining in the code should probably call FireAndForget instead.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index fce8999..984a7a8 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1499,25 +1499,30 @@ namespace OpenSim.Framework | |||
1499 | 1499 | ||
1500 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) | 1500 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) |
1501 | { | 1501 | { |
1502 | // When OpenSim interacts with a database or sends data over the wire, it must send this in en_US culture | ||
1503 | // so that we don't encounter problems where, for instance, data is saved with a culture that uses commas | ||
1504 | // for decimals places but is read by a culture that treats commas as number seperators. | ||
1505 | WaitCallback realCallback = delegate(object o) { Culture.SetCurrentCulture(); callback(o); }; | ||
1506 | |||
1502 | switch (FireAndForgetMethod) | 1507 | switch (FireAndForgetMethod) |
1503 | { | 1508 | { |
1504 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: | 1509 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: |
1505 | ThreadPool.UnsafeQueueUserWorkItem(callback, obj); | 1510 | ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj); |
1506 | break; | 1511 | break; |
1507 | case FireAndForgetMethod.QueueUserWorkItem: | 1512 | case FireAndForgetMethod.QueueUserWorkItem: |
1508 | ThreadPool.QueueUserWorkItem(callback, obj); | 1513 | ThreadPool.QueueUserWorkItem(realCallback, obj); |
1509 | break; | 1514 | break; |
1510 | case FireAndForgetMethod.BeginInvoke: | 1515 | case FireAndForgetMethod.BeginInvoke: |
1511 | FireAndForgetWrapper wrapper = FireAndForgetWrapper.Instance; | 1516 | FireAndForgetWrapper wrapper = FireAndForgetWrapper.Instance; |
1512 | wrapper.FireAndForget(callback, obj); | 1517 | wrapper.FireAndForget(realCallback, obj); |
1513 | break; | 1518 | break; |
1514 | case FireAndForgetMethod.SmartThreadPool: | 1519 | case FireAndForgetMethod.SmartThreadPool: |
1515 | if (m_ThreadPool == null) | 1520 | if (m_ThreadPool == null) |
1516 | m_ThreadPool = new SmartThreadPool(2000, 15, 2); | 1521 | m_ThreadPool = new SmartThreadPool(2000, 15, 2); |
1517 | m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { callback, obj }); | 1522 | m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { realCallback, obj }); |
1518 | break; | 1523 | break; |
1519 | case FireAndForgetMethod.Thread: | 1524 | case FireAndForgetMethod.Thread: |
1520 | Thread thread = new Thread(delegate(object o) { callback(o); }); | 1525 | Thread thread = new Thread(delegate(object o) { realCallback(o); }); |
1521 | thread.Start(obj); | 1526 | thread.Start(obj); |
1522 | break; | 1527 | break; |
1523 | default: | 1528 | default: |