* Minor fix to previous threading patch, every nTH request would previously have been delayed for 1000ms. This has been fixed.

0.6.0-stable
Adam Frisby 2008-08-30 13:46:04 +00:00
parent 0a5280edb5
commit b63922dcfe
1 changed files with 10 additions and 2 deletions

View File

@ -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.");