aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLUserData.cs12
1 files changed, 10 insertions, 2 deletions
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
72 72
73 public MySQLSuperManager GetLockedConnection() 73 public MySQLSuperManager GetLockedConnection()
74 { 74 {
75 int lockedCons = 0;
75 while (true) 76 while (true)
76 { 77 {
77 m_lastConnect++; 78 m_lastConnect++;
79
80 // Overflow protection
81 if(m_lastConnect == int.MaxValue)
82 m_lastConnect = 0;
83
78 MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; 84 MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections];
79 if (!x.Locked) 85 if (!x.Locked)
80 { 86 {
81 x.GetLock(); 87 x.GetLock();
82 return x; 88 return x;
83 } 89 }
84 if (m_lastConnect > m_maxConnections) 90
91 lockedCons++;
92 if (lockedCons > m_maxConnections)
85 { 93 {
86 m_lastConnect = 0; 94 lockedCons = 0;
87 System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. 95 System.Threading.Thread.Sleep(1000); // Wait some time before searching them again.
88 m_log.Debug( 96 m_log.Debug(
89 "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); 97 "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound.");