]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
rgw: fix lock scope in ObjectCache::get() 44747/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 18 Oct 2021 15:23:49 +0000 (11:23 -0400)
committerYuma Ogami <yuma-ogami@cybozu.co.jp>
Mon, 24 Jan 2022 05:06:42 +0000 (05:06 +0000)
commit079a9cb3e610ed7ab26f7bbcd8219a0111e851d3
tree60ffb6225e1d175033e6f8d42c5203b19ad19028
parent68920f895d7ffc82fc4156894d76b0211ec1fd74
rgw: fix lock scope in ObjectCache::get()

in the touch_lru() case, we promote the shared_lock to a unique_lock.
but because the unique_lock is in a nested scope, the lock drops with
its scope and we continue accessing the map without any protection

this moves the unique_lock up to function scope, where it's
constructed as unlocked with std::defer_lock. after promotion, this
lock will be held until the function returns

Fixes: https://tracker.ceph.com/issues/52800
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1aee987ec8f817541aab9cd21480b5351df38f69)
src/rgw/rgw_cache.cc