From b63922dcfed1aa4198eed47a01fb5999c4d6a339 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 13:46:04 +0000 Subject: * Minor fix to previous threading patch, every nTH request would previously have been delayed for 1000ms. This has been fixed. --- OpenSim/Data/MySQL/MySQLUserData.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 664203a..78d1092 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -72,18 +72,26 @@ namespace OpenSim.Data.MySQL public MySQLSuperManager GetLockedConnection() { + int lockedCons = 0; while (true) { m_lastConnect++; + + // Overflow protection + if(m_lastConnect == int.MaxValue) + m_lastConnect = 0; + MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; if (!x.Locked) { x.GetLock(); return x; } - if (m_lastConnect > m_maxConnections) + + lockedCons++; + if (lockedCons > m_maxConnections) { - m_lastConnect = 0; + lockedCons = 0; System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. m_log.Debug( "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); -- cgit v1.1