From cd41617e2df7ef813cbf760225e21947854f9d6f Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 6 Sep 2018 11:10:45 +0200 Subject: [PATCH] Prevent race conditions when getting elements for the first time or after flushing the cache (cherry picked from commit b99066f4e11f9b698ef376d751826b8288f502f6) (cherry picked from commit e50033d1732f9b5c1a56eacaf1edce9cc0d7471e) --- src/pool/PoolSQLCache.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/pool/PoolSQLCache.cc b/src/pool/PoolSQLCache.cc index a91d986bc3..5520fc095a 100644 --- a/src/pool/PoolSQLCache.cc +++ b/src/pool/PoolSQLCache.cc @@ -41,18 +41,12 @@ void PoolSQLCache::lock_line(int oid) { cl = new CacheLine(0); - cl->active++; - cache.insert(make_pair(oid, cl)); - - unlock(); - - cl->lock(); - - return; } - - cl = it->second; + else + { + cl = it->second; + } cl->active++; @@ -65,9 +59,9 @@ void PoolSQLCache::lock_line(int oid) cl->object->lock(); delete cl->object; - } - cl->object = 0; + cl->object = 0; + } return; }