we can't allow abort to change only one dic

0.9.0-post-fixes
UbitUmarov 2017-05-13 16:34:29 +01:00
parent 9ea49d107d
commit 16f02cb6fd
1 changed files with 34 additions and 30 deletions

View File

@ -74,8 +74,6 @@ namespace OpenSim.Framework
{ {
rwLock.EnterWriteLock(); rwLock.EnterWriteLock();
gotLock = true; gotLock = true;
}
if (Dictionary1.ContainsKey(key1)) if (Dictionary1.ContainsKey(key1))
{ {
if (!Dictionary2.ContainsKey(key2)) if (!Dictionary2.ContainsKey(key2))
@ -86,10 +84,10 @@ namespace OpenSim.Framework
if (!Dictionary1.ContainsKey(key1)) if (!Dictionary1.ContainsKey(key1))
throw new ArgumentException("key2 exists in the dictionary but not key1"); throw new ArgumentException("key2 exists in the dictionary but not key1");
} }
Dictionary1[key1] = value; Dictionary1[key1] = value;
Dictionary2[key2] = value; Dictionary2[key2] = value;
} }
}
finally finally
{ {
if (gotLock) if (gotLock)
@ -112,11 +110,10 @@ namespace OpenSim.Framework
{ {
rwLock.EnterWriteLock(); rwLock.EnterWriteLock();
gotLock = true; gotLock = true;
}
Dictionary1.Remove(key1); Dictionary1.Remove(key1);
success = Dictionary2.Remove(key2); success = Dictionary2.Remove(key2);
} }
}
finally finally
{ {
if (gotLock) if (gotLock)
@ -150,9 +147,13 @@ namespace OpenSim.Framework
foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2) foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2)
{ {
if (kvp.Value.Equals(value)) if (kvp.Value.Equals(value))
{
try { }
finally
{ {
Dictionary1.Remove(key1); Dictionary1.Remove(key1);
Dictionary2.Remove(kvp.Key); Dictionary2.Remove(kvp.Key);
}
found = true; found = true;
break; break;
} }
@ -192,9 +193,13 @@ namespace OpenSim.Framework
foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1) foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1)
{ {
if (kvp.Value.Equals(value)) if (kvp.Value.Equals(value))
{
try { }
finally
{ {
Dictionary2.Remove(key2); Dictionary2.Remove(key2);
Dictionary1.Remove(kvp.Key); Dictionary1.Remove(kvp.Key);
}
found = true; found = true;
break; break;
} }
@ -224,11 +229,10 @@ namespace OpenSim.Framework
{ {
rwLock.EnterWriteLock(); rwLock.EnterWriteLock();
gotLock = true; gotLock = true;
}
Dictionary1.Clear(); Dictionary1.Clear();
Dictionary2.Clear(); Dictionary2.Clear();
} }
}
finally finally
{ {
if (gotLock) if (gotLock)
@ -487,7 +491,6 @@ namespace OpenSim.Framework
{ {
rwLock.EnterWriteLock(); rwLock.EnterWriteLock();
gotWriteLock = true; gotWriteLock = true;
}
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
Dictionary1.Remove(list[i]); Dictionary1.Remove(list[i]);
@ -495,6 +498,7 @@ namespace OpenSim.Framework
for (int i = 0; i < list2.Count; i++) for (int i = 0; i < list2.Count; i++)
Dictionary2.Remove(list2[i]); Dictionary2.Remove(list2[i]);
} }
}
finally finally
{ {
if (gotWriteLock) if (gotWriteLock)