aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2008-08-30 13:46:04 +0000
committerAdam Frisby2008-08-30 13:46:04 +0000
commitb63922dcfed1aa4198eed47a01fb5999c4d6a339 (patch)
treebe0c1de722c348e0516add75a4503e026fd5c3da /OpenSim
parent* Added new "SuperManager" class for MySQL connections, for allowing multiple... (diff)
downloadopensim-SC_OLD-b63922dcfed1aa4198eed47a01fb5999c4d6a339.zip
opensim-SC_OLD-b63922dcfed1aa4198eed47a01fb5999c4d6a339.tar.gz
opensim-SC_OLD-b63922dcfed1aa4198eed47a01fb5999c4d6a339.tar.bz2
opensim-SC_OLD-b63922dcfed1aa4198eed47a01fb5999c4d6a339.tar.xz
* Minor fix to previous threading patch, every nTH request would previously have been delayed for 1000ms. This has been fixed.
Diffstat (limited to 'OpenSim')
-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.");