[11053] Process all SQL requests upon SqlDelayThread object destroying which might have been added while thread was stopping.

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
Ambal 2011-01-20 23:06:31 +02:00
parent 241712305d
commit e6e7bf8573
3 changed files with 18 additions and 12 deletions

View file

@ -26,10 +26,8 @@ SqlDelayThread::SqlDelayThread(Database* db, SqlConnection* conn) : m_dbEngine(d
SqlDelayThread::~SqlDelayThread()
{
//empty SQL queue before exiting
SqlOperation* s = NULL;
while (m_sqlQueue.next(s))
delete s;
//process all requests which might have been queued while thread was stopping
ProcessRequests();
}
void SqlDelayThread::run()
@ -49,12 +47,7 @@ void SqlDelayThread::run()
// empty the queue before exiting
ACE_Based::Thread::Sleep(loopSleepms);
SqlOperation* s = NULL;
while (m_sqlQueue.next(s))
{
s->Execute(m_dbConnection);
delete s;
}
ProcessRequests();
if((loopCounter++) >= pingEveryLoop)
{
@ -72,3 +65,13 @@ void SqlDelayThread::Stop()
{
m_running = false;
}
void SqlDelayThread::ProcessRequests()
{
SqlOperation* s = NULL;
while (m_sqlQueue.next(s))
{
s->Execute(m_dbConnection);
delete s;
}
}