[10865] Make DB code thread-safe. Original patch by Machiavelli and Kero99.

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
Ambal 2010-12-12 11:34:26 +02:00
parent 9b3535f803
commit af66b470a8
8 changed files with 53 additions and 26 deletions

View file

@ -55,9 +55,18 @@ class SqlTransaction : public SqlOperation
{
private:
std::queue<const char *> m_queue;
ACE_Thread_Mutex m_Mutex;
public:
SqlTransaction() {}
void DelayExecute(const char *sql) { m_queue.push(mangos_strdup(sql)); }
void DelayExecute(const char *sql)
{
char* _sql = mangos_strdup(sql);
if (_sql)
{
ACE_Guard<ACE_Thread_Mutex> _lock(m_Mutex);
m_queue.push(_sql);
}
}
void Execute(Database *db);
};