From fa57ce4cd12082e92f4da59c93b2f711f7e36ecd Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Sat, 15 May 2010 14:58:16 +0200 Subject: Reimplement ACE_Based::LockedQueue as SQL holder for the SqlTransaction class, since std::queue is not safe when multiple threads are reading/writing to it at the same time (SqlDelayThread and a MapUpdate Thread). Original patch by thenecromancer, was removed for ungrounded reasons. Thanks to Zor for the insight. Please give feedback on how this affects mtmaps usage. --HG-- branch : trunk --- src/shared/Database/SqlOperations.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/shared/Database/SqlOperations.cpp') diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index 09f3e30466e..c766d6ca21d 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -33,23 +33,18 @@ void SqlStatement::Execute(Database *db) void SqlTransaction::Execute(Database *db) { - if (m_queue.empty()) - return; + const char* sql; db->DirectExecute("START TRANSACTION"); - while (!m_queue.empty()) + while (m_queue.next(sql)) { - char const *sql = m_queue.front(); - m_queue.pop(); - if (!db->DirectExecute(sql)) { free((void*)const_cast(sql)); db->DirectExecute("ROLLBACK"); - while (!m_queue.empty()) + while (m_queue.next(sql)) { - free((void*)const_cast(m_queue.front())); - m_queue.pop(); + free((void*)const_cast(sql)); } return; } -- cgit v1.2.3