From: Samuel Just Date: Wed, 14 Jan 2015 16:29:58 +0000 (-0800) Subject: common/shared_cache.hpp: restructure clear() X-Git-Tag: v0.93~163^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0172069d0fe3a73e3a89330689368e193f72040c;p=ceph.git common/shared_cache.hpp: restructure clear() Signed-off-by: Samuel Just --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index 8c24780439f..c4e65e467cb 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -128,17 +128,14 @@ public: //clear all strong reference from the lru. void clear() { - VPtr val; // release any ref we have after we drop the lock - while (size > 0) { + while (true) { + VPtr val; // release any ref we have after we drop the lock Mutex::Locker l(lock); - if (size == 0) //check size again with lock + if (size == 0) break; - K key = lru.back().first; - if (weak_refs.count(key)) { - val = weak_refs[key].first.lock(); - } - lru_remove(key); + val = lru.back().second; + lru_remove(lru.back().first); } }