diff options
author | Machiavelli <none@none> | 2010-05-15 14:58:16 +0200 |
---|---|---|
committer | Machiavelli <none@none> | 2010-05-15 14:58:16 +0200 |
commit | fa57ce4cd12082e92f4da59c93b2f711f7e36ecd (patch) | |
tree | 153606182e293a997c40f45b94a59e83bcc53560 /src/shared/Database/SqlOperations.cpp | |
parent | 7ff9e82f1a237b80ea42f0f6055e408634db841a (diff) |
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
Diffstat (limited to 'src/shared/Database/SqlOperations.cpp')
-rw-r--r-- | src/shared/Database/SqlOperations.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
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<char*>(sql)); db->DirectExecute("ROLLBACK"); - while (!m_queue.empty()) + while (m_queue.next(sql)) { - free((void*)const_cast<char*>(m_queue.front())); - m_queue.pop(); + free((void*)const_cast<char*>(sql)); } return; } |