aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-10-31 10:55:29 +0100
committerMachiavelli <none@none>2010-10-31 10:55:29 +0100
commit05a292633cdfdb9383d0a914d5b95c838837e1eb (patch)
tree79c98f61a2f10b43a72548306b7854718667ce64
parentc9bbe85e48c3456db21859b6fd9951a6c1c7ccf3 (diff)
Core/DBLayer:
- Fix a race condition in KeepAlive() when connections are using mysql context when ping is called. - Don“t wait for locks to be released on a connection when pinging, this means the connection is not idle and locking is redundant. Patch by admin@****.net Fixes issue #4599 --HG-- branch : trunk
-rwxr-xr-xsrc/server/shared/Database/DatabaseWorkerPool.h26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h
index 899c0f8f63d..9f7bf6d72dc 100755
--- a/src/server/shared/Database/DatabaseWorkerPool.h
+++ b/src/server/shared/Database/DatabaseWorkerPool.h
@@ -37,13 +37,12 @@ class PingOperation : public SQLOperation
/// Operation for idle delaythreads
bool Execute()
{
- for (;;)
- if (m_conn->LockIfReady())
- {
- m_conn->Ping();
- m_conn->Unlock();
- return true;
- }
+ if (m_conn->LockIfReady())
+ {
+ m_conn->Ping();
+ m_conn->Unlock();
+ return true;
+ }
return false;
}
@@ -305,10 +304,17 @@ class DatabaseWorkerPool
void KeepAlive()
{
- /// Ping syncrhonous connections
+ /// Ping synchronous connections
for (uint8 i = 0; i < m_connections[IDX_SYNCH].size(); ++i)
- m_connections[IDX_SYNCH][i]->Ping();
-
+ {
+ T* t = m_connections[IDX_SYNCH][i];
+ if (t->LockIfReady())
+ {
+ t->Ping();
+ t->Unlock();
+ }
+ }
+
/// Assuming all worker threads are free, every worker thread will receive 1 ping operation request
/// If one or more worker threads are busy, the ping operations will not be split evenly, but this doesn't matter
/// as the sole purpose is to prevent connections from idling.