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

View file

@ -38,6 +38,9 @@ class SqlDelayThread : public ACE_Based::Runnable
SqlConnection * m_dbConnection; ///< Pointer to DB connection SqlConnection * m_dbConnection; ///< Pointer to DB connection
volatile bool m_running; volatile bool m_running;
//process all enqueued requests
void ProcessRequests();
public: public:
SqlDelayThread(Database* db, SqlConnection* conn); SqlDelayThread(Database* db, SqlConnection* conn);
~SqlDelayThread(); ~SqlDelayThread();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11052" #define REVISION_NR "11053"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__