]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
replace in_method_t with a counter
authorLoic Dachary <loic@dachary.org>
Wed, 24 Jul 2013 16:35:03 +0000 (09:35 -0700)
committerSamuel Just <sam.just@inktank.com>
Fri, 19 Sep 2014 22:58:02 +0000 (15:58 -0700)
commite0f4162ef07a520a53ad70b6376cf93c94d6e673
treed081134c8513b4d9ba59ccb34d955b561ca9818a
parentd236a93b5f0283012134b8cc100741162c548cb0
replace in_method_t with a counter

A single counter ( waiting ) accurately reflects the number of
waiters, regardless of the method waiting. It is enough to allow
unit tests to synthetise all situations, including:

T1: x = lookup_or_create(0)
T1: release x part 1 (weak_ptrs now fail to lock)
T2: y = lookup_or_create(0)
T2: block in lookup_or_create (waiting == 1)
T1: z = lookup_or_create(1) (does not block because the key is different)
    while holding the lock it waiting++ and waiting == 2
    and before returning it waiting-- and waiting is back to == 1
T1: complete release x
T2: complete lookup_or_create(0) (waiting == 0)

The unit tests are modified to add a lookup on an unrelated key to
demonstrate that it does not reset waiting counter.

http://tracker.ceph.com/issues/5527 refs #5527

Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 2ec480b1ba00ff02f99a43963a321efc8edf247e)
src/common/sharedptr_registry.hpp
src/test/common/test_sharedptr_registry.cc