mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[10865] Make DB code thread-safe. Original patch by Machiavelli and Kero99.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
9b3535f803
commit
af66b470a8
8 changed files with 53 additions and 26 deletions
|
|
@ -31,8 +31,10 @@ void SqlStatement::Execute(Database *db)
|
|||
|
||||
void SqlTransaction::Execute(Database *db)
|
||||
{
|
||||
ACE_Guard<ACE_Thread_Mutex> _lock(m_Mutex);
|
||||
if(m_queue.empty())
|
||||
return;
|
||||
|
||||
db->DirectExecute("START TRANSACTION");
|
||||
while(!m_queue.empty())
|
||||
{
|
||||
|
|
@ -42,17 +44,20 @@ void SqlTransaction::Execute(Database *db)
|
|||
if(!db->DirectExecute(sql))
|
||||
{
|
||||
delete [] sql;
|
||||
|
||||
db->DirectExecute("ROLLBACK");
|
||||
while(!m_queue.empty())
|
||||
{
|
||||
delete [] (const_cast<char*>(m_queue.front()));
|
||||
m_queue.pop();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
delete [] sql;
|
||||
}
|
||||
|
||||
db->DirectExecute("COMMIT");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue