mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[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:
parent
241712305d
commit
e6e7bf8573
3 changed files with 18 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,9 @@ class SqlDelayThread : public ACE_Based::Runnable
|
|||
SqlConnection * m_dbConnection; ///< Pointer to DB connection
|
||||
volatile bool m_running;
|
||||
|
||||
//process all enqueued requests
|
||||
void ProcessRequests();
|
||||
|
||||
public:
|
||||
SqlDelayThread(Database* db, SqlConnection* conn);
|
||||
~SqlDelayThread();
|
||||
|
|
@ -48,4 +51,4 @@ class SqlDelayThread : public ACE_Based::Runnable
|
|||
virtual void Stop(); ///< Stop event
|
||||
virtual void run(); ///< Main Thread loop
|
||||
};
|
||||
#endif //__SQLDELAYTHREAD_H
|
||||
#endif //__SQLDELAYTHREAD_H
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11052"
|
||||
#define REVISION_NR "11053"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue