mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[10865] Make DB code thread-safe. Original patch by Machiavelli and Kero99.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
9b3535f803
commit
af66b470a8
8 changed files with 53 additions and 26 deletions
|
|
@ -24,6 +24,14 @@ SqlDelayThread::SqlDelayThread(Database* db) : m_dbEngine(db), m_running(true)
|
|||
{
|
||||
}
|
||||
|
||||
SqlDelayThread::~SqlDelayThread()
|
||||
{
|
||||
//empty SQL queue before exiting
|
||||
SqlOperation* s = NULL;
|
||||
while (m_sqlQueue.next(s))
|
||||
delete s;
|
||||
}
|
||||
|
||||
void SqlDelayThread::run()
|
||||
{
|
||||
#ifndef DO_POSTGRESQL
|
||||
|
|
@ -39,14 +47,15 @@ void SqlDelayThread::run()
|
|||
{
|
||||
// if the running state gets turned off while sleeping
|
||||
// empty the queue before exiting
|
||||
|
||||
ACE_Based::Thread::Sleep(loopSleepms);
|
||||
|
||||
SqlOperation* s = NULL;
|
||||
while (m_sqlQueue.next(s))
|
||||
{
|
||||
s->Execute(m_dbEngine);
|
||||
delete s;
|
||||
}
|
||||
|
||||
if((loopCounter++) >= pingEveryLoop)
|
||||
{
|
||||
loopCounter = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue