diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp index f9a86c314..8afb7d94b 100644 --- a/src/mangosd/Master.cpp +++ b/src/mangosd/Master.cpp @@ -199,9 +199,9 @@ int Master::Run() //server loaded successfully => enable async DB requests //this is done to forbid any async transactions during server startup! - CharacterDatabase.InitDelayThread(); - WorldDatabase.InitDelayThread(); - LoginDatabase.InitDelayThread(); + CharacterDatabase.AllowAsyncTransactions(); + WorldDatabase.AllowAsyncTransactions(); + LoginDatabase.AllowAsyncTransactions(); ///- Catch termination signals _HookSignals(); diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index 1936e48d7..136599260 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -288,7 +288,7 @@ extern int main(int argc, char **argv) #endif //server has started up successfully => enable async DB requests - LoginDatabase.InitDelayThread(); + LoginDatabase.AllowAsyncTransactions(); // maximum counter for next ping uint32 numLoops = (sConfig.GetIntDefault( "MaxPingTime", 30 ) * (MINUTE * 1000000 / 100000)); diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index e7046a8dc..d545e6db4 100644 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -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 diff --git a/src/shared/Database/Database.h b/src/shared/Database/Database.h index b1d3a715a..011cce923 100644 --- a/src/shared/Database/Database.h +++ b/src/shared/Database/Database.h @@ -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; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index fb4f4e315..783ec7f3a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11058" + #define REVISION_NR "11059" #endif // __REVISION_NR_H__