Esempio n. 1
0
        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);
                }

                lockedCons++;

                if (lockedCons > m_maxConnections)
                {
                    lockedCons = 0;
                    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.");
                }
            }
        }
Esempio n. 2
0
        public MySQLSuperManager GetLockedConnection(string why)
        {
            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();
                    x.Running = why;
                    return(x);
                }

                lockedCons++;

                if (lockedCons > m_maxConnections)
                {
                    lockedCons = 0;
                    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.");
                    m_log.Debug("Current connections-in-use dump:");

                    foreach (KeyValuePair <int, MySQLSuperManager> kvp in m_dbconnections)
                    {
                        m_log.Debug(kvp.Value.Running);
                    }
                }
            }
        }