From 16f02cb6fd57c5ad015b1c9e5edd17a4dbed37ef Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 13 May 2017 16:34:29 +0100 Subject: we can't allow abort to change only one dic --- .../Framework/DoubleDictionaryThreadAbortSafe.cs | 62 ++++++++++++---------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs index fe20767..816523b 100644 --- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs @@ -74,21 +74,19 @@ namespace OpenSim.Framework { rwLock.EnterWriteLock(); gotLock = true; + if (Dictionary1.ContainsKey(key1)) + { + if (!Dictionary2.ContainsKey(key2)) + throw new ArgumentException("key1 exists in the dictionary but not key2"); + } + else if (Dictionary2.ContainsKey(key2)) + { + if (!Dictionary1.ContainsKey(key1)) + throw new ArgumentException("key2 exists in the dictionary but not key1"); + } + Dictionary1[key1] = value; + Dictionary2[key2] = value; } - - if (Dictionary1.ContainsKey(key1)) - { - if (!Dictionary2.ContainsKey(key2)) - throw new ArgumentException("key1 exists in the dictionary but not key2"); - } - else if (Dictionary2.ContainsKey(key2)) - { - if (!Dictionary1.ContainsKey(key1)) - throw new ArgumentException("key2 exists in the dictionary but not key1"); - } - - Dictionary1[key1] = value; - Dictionary2[key2] = value; } finally { @@ -112,10 +110,9 @@ namespace OpenSim.Framework { rwLock.EnterWriteLock(); gotLock = true; + Dictionary1.Remove(key1); + success = Dictionary2.Remove(key2); } - - Dictionary1.Remove(key1); - success = Dictionary2.Remove(key2); } finally { @@ -151,8 +148,12 @@ namespace OpenSim.Framework { if (kvp.Value.Equals(value)) { - Dictionary1.Remove(key1); - Dictionary2.Remove(kvp.Key); + try { } + finally + { + Dictionary1.Remove(key1); + Dictionary2.Remove(kvp.Key); + } found = true; break; } @@ -193,8 +194,12 @@ namespace OpenSim.Framework { if (kvp.Value.Equals(value)) { - Dictionary2.Remove(key2); - Dictionary1.Remove(kvp.Key); + try { } + finally + { + Dictionary2.Remove(key2); + Dictionary1.Remove(kvp.Key); + } found = true; break; } @@ -224,10 +229,9 @@ namespace OpenSim.Framework { rwLock.EnterWriteLock(); gotLock = true; + Dictionary1.Clear(); + Dictionary2.Clear(); } - - Dictionary1.Clear(); - Dictionary2.Clear(); } finally { @@ -487,13 +491,13 @@ namespace OpenSim.Framework { rwLock.EnterWriteLock(); gotWriteLock = true; - } - for (int i = 0; i < list.Count; i++) - Dictionary1.Remove(list[i]); + for (int i = 0; i < list.Count; i++) + Dictionary1.Remove(list[i]); - for (int i = 0; i < list2.Count; i++) - Dictionary2.Remove(list2[i]); + for (int i = 0; i < list2.Count; i++) + Dictionary2.Remove(list2[i]); + } } finally { -- cgit v1.1