]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
replace in_method_t with a counter 425/head
authorLoic Dachary <loic@dachary.org>
Wed, 24 Jul 2013 16:35:03 +0000 (09:35 -0700)
committerLoic Dachary <loic@dachary.org>
Sat, 27 Jul 2013 15:11:11 +0000 (08:11 -0700)
commit2ec480b1ba00ff02f99a43963a321efc8edf247e
treedee0064b2bd3a363922e435f238bd338958c7fe7
parent6b16cd1aaaf818db0a6063f3a3ebb02eeefa3056
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>
src/common/sharedptr_registry.hpp
src/test/common/test_sharedptr_registry.cc