mirror of
https://github.com/mangosfour/server.git
synced 2025-12-23 07:37:01 +00:00
[9517] rewrote RA console using ACE
- moved SQL pinging to SqlDelayThread - use sAccountMgr instead of explict sql queries
This commit is contained in:
parent
bc5092686e
commit
39559fc73a
8 changed files with 307 additions and 179 deletions
|
|
@ -40,6 +40,7 @@ bool Database::Initialize(const char *)
|
|||
m_logsDir.append("/");
|
||||
}
|
||||
|
||||
m_pingIntervallms = sConfig.GetIntDefault ("MaxPingTime", 30) * (MINUTE * 1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -228,4 +229,4 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
sLog.outErrorDb("Table `%s` fields list query fail but expected have `%s`! No records in `%s`?",table_name,required_name,table_name);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,8 +130,11 @@ class MANGOS_DLL_SPEC Database
|
|||
void SetResultQueue(SqlResultQueue * queue);
|
||||
|
||||
bool CheckRequiredField(char const* table_name, char const* required_name);
|
||||
uint32 GetPingIntervall() { return m_pingIntervallms;}
|
||||
|
||||
private:
|
||||
bool m_logSQL;
|
||||
std::string m_logsDir;
|
||||
uint32 m_pingIntervallms;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,17 +30,28 @@ void SqlDelayThread::run()
|
|||
mysql_thread_init();
|
||||
#endif
|
||||
|
||||
const uint32 loopSleepms = 10;
|
||||
|
||||
const uint32 pingEveryLoop = m_dbEngine->GetPingIntervall()/loopSleepms;
|
||||
|
||||
uint32 loopCounter = 0;
|
||||
while (m_running)
|
||||
{
|
||||
// if the running state gets turned off while sleeping
|
||||
// empty the queue before exiting
|
||||
ACE_Based::Thread::Sleep(10);
|
||||
|
||||
ACE_Based::Thread::Sleep(loopSleepms);
|
||||
SqlOperation* s;
|
||||
while (m_sqlQueue.next(s))
|
||||
{
|
||||
s->Execute(m_dbEngine);
|
||||
delete s;
|
||||
}
|
||||
if((loopCounter++) >= pingEveryLoop)
|
||||
{
|
||||
loopCounter = 0;
|
||||
delete m_dbEngine->Query("SELECT 1");
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DO_POSTGRESQL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue