mirror of
https://github.com/mangosfour/server.git
synced 2025-12-23 16:37:03 +00:00
[11059] Fix crash in [11054]. As it turned out - we use not only async transactions but async queries too during server startup =/
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
24164ef020
commit
d67219e327
5 changed files with 17 additions and 10 deletions
|
|
@ -75,6 +75,8 @@ bool Database::Initialize(const char * infoString, int nConns /*= 1*/)
|
|||
return false;
|
||||
|
||||
m_pResultQueue = new SqlResultQueue;
|
||||
|
||||
InitDelayThread();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +279,7 @@ bool Database::Execute(const char *sql)
|
|||
else
|
||||
{
|
||||
//if async execution is not available
|
||||
if(!m_threadBody)
|
||||
if(!m_bAllowAsyncTransactions)
|
||||
return DirectExecute(sql);
|
||||
|
||||
// Simple sql statement
|
||||
|
|
@ -363,7 +365,7 @@ bool Database::CommitTransaction()
|
|||
return false;
|
||||
|
||||
//if async execution is not available
|
||||
if(!m_delayThread)
|
||||
if(!m_bAllowAsyncTransactions)
|
||||
return CommitTransactionDirect();
|
||||
|
||||
//add SqlTransaction to the async queue
|
||||
|
|
|
|||
|
|
@ -82,8 +82,6 @@ class MANGOS_DLL_SPEC Database
|
|||
|
||||
virtual bool Initialize(const char *infoString, int nConns = 1);
|
||||
//start worker thread for async DB request execution
|
||||
//you should call it explicitly after your server successfully started up
|
||||
//NO ASYNC TRANSACTIONS DURING SERVER STARTUP - ONLY DURING RUNTIME!!!
|
||||
virtual void InitDelayThread();
|
||||
//stop worker thread
|
||||
virtual void HaltDelayThread();
|
||||
|
|
@ -178,9 +176,14 @@ class MANGOS_DLL_SPEC Database
|
|||
//function to ping database connections
|
||||
void Ping();
|
||||
|
||||
//set this to allow async transactions
|
||||
//you should call it explicitly after your server successfully started up
|
||||
//NO ASYNC TRANSACTIONS DURING SERVER STARTUP - ONLY DURING RUNTIME!!!
|
||||
void AllowAsyncTransactions() { m_bAllowAsyncTransactions = true; }
|
||||
|
||||
protected:
|
||||
Database() : m_pAsyncConn(NULL), m_pResultQueue(NULL), m_threadBody(NULL), m_delayThread(NULL),
|
||||
m_logSQL(false), m_pingIntervallms(0), m_nQueryConnPoolSize(1)
|
||||
m_logSQL(false), m_pingIntervallms(0), m_nQueryConnPoolSize(1), m_bAllowAsyncTransactions(false)
|
||||
{
|
||||
m_nQueryCounter = -1;
|
||||
}
|
||||
|
|
@ -239,6 +242,8 @@ class MANGOS_DLL_SPEC Database
|
|||
SqlDelayThread * m_threadBody; ///< Pointer to delay sql executer (owned by m_delayThread)
|
||||
ACE_Based::Thread * m_delayThread; ///< Pointer to executer thread
|
||||
|
||||
bool m_bAllowAsyncTransactions; ///< flag which specifies if async transactions are enabled
|
||||
|
||||
private:
|
||||
|
||||
bool m_logSQL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue