]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
rgw: fix lock scope in ObjectCache::get()
authorCasey Bodley <cbodley@redhat.com>
Mon, 18 Oct 2021 15:23:49 +0000 (11:23 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 18 Oct 2021 16:04:26 +0000 (12:04 -0400)
commit1aee987ec8f817541aab9cd21480b5351df38f69
tree6df17772023d87c5c97d7b5a4ce0ed5a07c5edf2
parent19535b1d0edd25340883b96d805c9555414a633b
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>
src/rgw/rgw_cache.cc