mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +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()
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
|
@ -48,4 +51,4 @@ class SqlDelayThread : public ACE_Based::Runnable
|
||||||
virtual void Stop(); ///< Stop event
|
virtual void Stop(); ///< Stop event
|
||||||
virtual void run(); ///< Main Thread loop
|
virtual void run(); ///< Main Thread loop
|
||||||
};
|
};
|
||||||
#endif //__SQLDELAYTHREAD_H
|
#endif //__SQLDELAYTHREAD_H
|
||||||
|
|
@ -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__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue