* Minor fix to previous threading patch, every nTH request would previously have been delayed for 1000ms. This has been fixed.
parent
0a5280edb5
commit
b63922dcfe
|
@ -72,18 +72,26 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
public MySQLSuperManager GetLockedConnection()
|
public MySQLSuperManager GetLockedConnection()
|
||||||
{
|
{
|
||||||
|
int lockedCons = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
m_lastConnect++;
|
m_lastConnect++;
|
||||||
|
|
||||||
|
// Overflow protection
|
||||||
|
if(m_lastConnect == int.MaxValue)
|
||||||
|
m_lastConnect = 0;
|
||||||
|
|
||||||
MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections];
|
MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections];
|
||||||
if (!x.Locked)
|
if (!x.Locked)
|
||||||
{
|
{
|
||||||
x.GetLock();
|
x.GetLock();
|
||||||
return x;
|
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.
|
System.Threading.Thread.Sleep(1000); // Wait some time before searching them again.
|
||||||
m_log.Debug(
|
m_log.Debug(
|
||||||
"WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound.");
|
"WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound.");
|
||||||
|
|
Loading…
Reference in New Issue