From dd80380df5e47c0d67466f7d509898a71e19abd0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 7 Oct 2009 19:45:57 -0700 Subject: Another go at the deadlock: not locking TryGetValue, and just catch/ignore exceptions. --- .../ClientStack/LindenUDP/LLUDPClientCollection.cs | 46 +++++++++++++++------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs index 9be9480..36e1f49 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs @@ -215,33 +215,49 @@ namespace OpenSim.Region.ClientStack.LindenUDP public bool TryGetValue(UUID key, out LLUDPClient value) { - //bool success; - //bool doLock = !rwLock.IsUpgradeableReadLockHeld; - //if (doLock) rwLock.EnterReadLock(); + ////bool success; + ////bool doLock = !rwLock.IsUpgradeableReadLockHeld; + ////if (doLock) rwLock.EnterReadLock(); - //try { success = Dictionary1.TryGetValue(key, out value); } - //finally { if (doLock) rwLock.ExitReadLock(); } + ////try { success = Dictionary1.TryGetValue(key, out value); } + ////finally { if (doLock) rwLock.ExitReadLock(); } - //return success; + ////return success; - lock (m_sync) - return Dictionary1.TryGetValue(key, out value); + //lock (m_sync) + // return Dictionary1.TryGetValue(key, out value); + try + { + return Dictionary1.TryGetValue(key, out value); + } + catch { } + value = null; + return false; } public bool TryGetValue(IPEndPoint key, out LLUDPClient value) { - //bool success; - //bool doLock = !rwLock.IsUpgradeableReadLockHeld; - //if (doLock) rwLock.EnterReadLock(); + ////bool success; + ////bool doLock = !rwLock.IsUpgradeableReadLockHeld; + ////if (doLock) rwLock.EnterReadLock(); - //try { success = Dictionary2.TryGetValue(key, out value); } - //finally { if (doLock) rwLock.ExitReadLock(); } + ////try { success = Dictionary2.TryGetValue(key, out value); } + ////finally { if (doLock) rwLock.ExitReadLock(); } - //return success; + ////return success; - lock (m_sync) + //lock (m_sync) + // return Dictionary2.TryGetValue(key, out value); + + try + { return Dictionary2.TryGetValue(key, out value); + } + catch { } + value = null; + return false; + } public void ForEach(Action action) -- cgit v1.1